babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. /**
  95. * User defined information that will be sent to observers
  96. */
  97. userInfo?: any;
  98. }
  99. /**
  100. * Represent an Observer registered to a given Observable object.
  101. */
  102. export class Observer<T> {
  103. /**
  104. * Defines the callback to call when the observer is notified
  105. */
  106. callback: (eventData: T, eventState: EventState) => void;
  107. /**
  108. * Defines the mask of the observer (used to filter notifications)
  109. */
  110. mask: number;
  111. /**
  112. * Defines the current scope used to restore the JS context
  113. */
  114. scope: any;
  115. /** @hidden */
  116. _willBeUnregistered: boolean;
  117. /**
  118. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  119. */
  120. unregisterOnNextCall: boolean;
  121. /**
  122. * Creates a new observer
  123. * @param callback defines the callback to call when the observer is notified
  124. * @param mask defines the mask of the observer (used to filter notifications)
  125. * @param scope defines the current scope used to restore the JS context
  126. */
  127. constructor(
  128. /**
  129. * Defines the callback to call when the observer is notified
  130. */
  131. callback: (eventData: T, eventState: EventState) => void,
  132. /**
  133. * Defines the mask of the observer (used to filter notifications)
  134. */
  135. mask: number,
  136. /**
  137. * Defines the current scope used to restore the JS context
  138. */
  139. scope?: any);
  140. }
  141. /**
  142. * Represent a list of observers registered to multiple Observables object.
  143. */
  144. export class MultiObserver<T> {
  145. private _observers;
  146. private _observables;
  147. /**
  148. * Release associated resources
  149. */
  150. dispose(): void;
  151. /**
  152. * Raise a callback when one of the observable will notify
  153. * @param observables defines a list of observables to watch
  154. * @param callback defines the callback to call on notification
  155. * @param mask defines the mask used to filter notifications
  156. * @param scope defines the current scope used to restore the JS context
  157. * @returns the new MultiObserver
  158. */
  159. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  160. }
  161. /**
  162. * The Observable class is a simple implementation of the Observable pattern.
  163. *
  164. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  165. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  166. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  167. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  168. */
  169. export class Observable<T> {
  170. private _observers;
  171. private _eventState;
  172. private _onObserverAdded;
  173. /**
  174. * Gets the list of observers
  175. */
  176. get observers(): Array<Observer<T>>;
  177. /**
  178. * Creates a new observable
  179. * @param onObserverAdded defines a callback to call when a new observer is added
  180. */
  181. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  182. /**
  183. * Create a new Observer with the specified callback
  184. * @param callback the callback that will be executed for that Observer
  185. * @param mask the mask used to filter observers
  186. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  187. * @param scope optional scope for the callback to be called from
  188. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  189. * @returns the new observer created for the callback
  190. */
  191. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  192. /**
  193. * Create a new Observer with the specified callback and unregisters after the next notification
  194. * @param callback the callback that will be executed for that Observer
  195. * @returns the new observer created for the callback
  196. */
  197. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  198. /**
  199. * Remove an Observer from the Observable object
  200. * @param observer the instance of the Observer to remove
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. remove(observer: Nullable<Observer<T>>): boolean;
  204. /**
  205. * Remove a callback from the Observable object
  206. * @param callback the callback to remove
  207. * @param scope optional scope. If used only the callbacks with this scope will be removed
  208. * @returns false if it doesn't belong to this Observable
  209. */
  210. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  211. private _deferUnregister;
  212. private _remove;
  213. /**
  214. * Moves the observable to the top of the observer list making it get called first when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverTopPriority(observer: Observer<T>): void;
  218. /**
  219. * Moves the observable to the bottom of the observer list making it get called last when notified
  220. * @param observer the observer to move
  221. */
  222. makeObserverBottomPriority(observer: Observer<T>): void;
  223. /**
  224. * Notify all Observers by calling their respective callback with the given data
  225. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  226. * @param eventData defines the data to send to all observers
  227. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  228. * @param target defines the original target of the state
  229. * @param currentTarget defines the current target of the state
  230. * @param userInfo defines any user info to send to observers
  231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  232. */
  233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  234. /**
  235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  238. * and it is crucial that all callbacks will be executed.
  239. * The order of the callbacks is kept, callbacks are not executed parallel.
  240. *
  241. * @param eventData The data to be sent to each callback
  242. * @param mask is used to filter observers defaults to -1
  243. * @param target defines the callback target (see EventState)
  244. * @param currentTarget defines he current object in the bubbling phase
  245. * @param userInfo defines any user info to send to observers
  246. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  247. */
  248. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  249. /**
  250. * Notify a specific observer
  251. * @param observer defines the observer to notify
  252. * @param eventData defines the data to be sent to each callback
  253. * @param mask is used to filter observers defaults to -1
  254. */
  255. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  256. /**
  257. * Gets a boolean indicating if the observable has at least one observer
  258. * @returns true is the Observable has at least one Observer registered
  259. */
  260. hasObservers(): boolean;
  261. /**
  262. * Clear the list of observers
  263. */
  264. clear(): void;
  265. /**
  266. * Clone the current observable
  267. * @returns a new observable
  268. */
  269. clone(): Observable<T>;
  270. /**
  271. * Does this observable handles observer registered with a given mask
  272. * @param mask defines the mask to be tested
  273. * @return whether or not one observer registered with the given mask is handeled
  274. **/
  275. hasSpecificMask(mask?: number): boolean;
  276. }
  277. }
  278. declare module "babylonjs/Misc/domManagement" {
  279. /**
  280. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  281. * Babylon.js
  282. */
  283. export class DomManagement {
  284. /**
  285. * Checks if the window object exists
  286. * @returns true if the window object exists
  287. */
  288. static IsWindowObjectExist(): boolean;
  289. /**
  290. * Checks if the navigator object exists
  291. * @returns true if the navigator object exists
  292. */
  293. static IsNavigatorAvailable(): boolean;
  294. /**
  295. * Check if the document object exists
  296. * @returns true if the document object exists
  297. */
  298. static IsDocumentAvailable(): boolean;
  299. /**
  300. * Extracts text content from a DOM element hierarchy
  301. * @param element defines the root element
  302. * @returns a string
  303. */
  304. static GetDOMTextContent(element: HTMLElement): string;
  305. }
  306. }
  307. declare module "babylonjs/Misc/logger" {
  308. /**
  309. * Logger used througouht the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. private static _LogCache;
  334. /**
  335. * Gets a value indicating the number of loading errors
  336. * @ignorenaming
  337. */
  338. static errorsCount: number;
  339. /**
  340. * Callback called when a new log is added
  341. */
  342. static OnNewCacheEntry: (entry: string) => void;
  343. private static _AddLogEntry;
  344. private static _FormatMessage;
  345. private static _LogDisabled;
  346. private static _LogEnabled;
  347. private static _WarnDisabled;
  348. private static _WarnEnabled;
  349. private static _ErrorDisabled;
  350. private static _ErrorEnabled;
  351. /**
  352. * Log a message to the console
  353. */
  354. static Log: (message: string) => void;
  355. /**
  356. * Write a warning message to the console
  357. */
  358. static Warn: (message: string) => void;
  359. /**
  360. * Write an error message to the console
  361. */
  362. static Error: (message: string) => void;
  363. /**
  364. * Gets current log cache (list of logs)
  365. */
  366. static get LogCache(): string;
  367. /**
  368. * Clears the log cache
  369. */
  370. static ClearLogCache(): void;
  371. /**
  372. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  373. */
  374. static set LogLevels(level: number);
  375. }
  376. }
  377. declare module "babylonjs/Misc/typeStore" {
  378. /** @hidden */
  379. export class _TypeStore {
  380. /** @hidden */
  381. static RegisteredTypes: {
  382. [key: string]: Object;
  383. };
  384. /** @hidden */
  385. static GetClass(fqdn: string): any;
  386. }
  387. }
  388. declare module "babylonjs/Misc/stringTools" {
  389. /**
  390. * Helper to manipulate strings
  391. */
  392. export class StringTools {
  393. /**
  394. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static EndsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static StartsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Decodes a buffer into a string
  409. * @param buffer The buffer to decode
  410. * @returns The decoded string
  411. */
  412. static Decode(buffer: Uint8Array | Uint16Array): string;
  413. /**
  414. * Encode a buffer to a base64 string
  415. * @param buffer defines the buffer to encode
  416. * @returns the encoded string
  417. */
  418. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  419. /**
  420. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  421. * @param num the number to convert and pad
  422. * @param length the expected length of the string
  423. * @returns the padded string
  424. */
  425. static PadNumber(num: number, length: number): string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/deepCopier" {
  429. /**
  430. * Class containing a set of static utilities functions for deep copy.
  431. */
  432. export class DeepCopier {
  433. /**
  434. * Tries to copy an object by duplicating every property
  435. * @param source defines the source object
  436. * @param destination defines the target object
  437. * @param doNotCopyList defines a list of properties to avoid
  438. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  439. */
  440. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  441. }
  442. }
  443. declare module "babylonjs/Misc/precisionDate" {
  444. /**
  445. * Class containing a set of static utilities functions for precision date
  446. */
  447. export class PrecisionDate {
  448. /**
  449. * Gets either window.performance.now() if supported or Date.now() else
  450. */
  451. static get Now(): number;
  452. }
  453. }
  454. declare module "babylonjs/Misc/devTools" {
  455. /** @hidden */
  456. export class _DevTools {
  457. static WarnImport(name: string): string;
  458. }
  459. }
  460. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  461. /**
  462. * Interface used to define the mechanism to get data from the network
  463. */
  464. export interface IWebRequest {
  465. /**
  466. * Returns client's response url
  467. */
  468. responseURL: string;
  469. /**
  470. * Returns client's status
  471. */
  472. status: number;
  473. /**
  474. * Returns client's status as a text
  475. */
  476. statusText: string;
  477. }
  478. }
  479. declare module "babylonjs/Misc/webRequest" {
  480. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  481. import { Nullable } from "babylonjs/types";
  482. /**
  483. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  484. */
  485. export class WebRequest implements IWebRequest {
  486. private _xhr;
  487. /**
  488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  489. * i.e. when loading files, where the server/service expects an Authorization header
  490. */
  491. static CustomRequestHeaders: {
  492. [key: string]: string;
  493. };
  494. /**
  495. * Add callback functions in this array to update all the requests before they get sent to the network
  496. */
  497. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  498. private _injectCustomRequestHeaders;
  499. /**
  500. * Gets or sets a function to be called when loading progress changes
  501. */
  502. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  503. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  504. /**
  505. * Returns client's state
  506. */
  507. get readyState(): number;
  508. /**
  509. * Returns client's status
  510. */
  511. get status(): number;
  512. /**
  513. * Returns client's status as a text
  514. */
  515. get statusText(): string;
  516. /**
  517. * Returns client's response
  518. */
  519. get response(): any;
  520. /**
  521. * Returns client's response url
  522. */
  523. get responseURL(): string;
  524. /**
  525. * Returns client's response as text
  526. */
  527. get responseText(): string;
  528. /**
  529. * Gets or sets the expected response type
  530. */
  531. get responseType(): XMLHttpRequestResponseType;
  532. set responseType(value: XMLHttpRequestResponseType);
  533. /** @hidden */
  534. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  535. /** @hidden */
  536. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  537. /**
  538. * Cancels any network activity
  539. */
  540. abort(): void;
  541. /**
  542. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  543. * @param body defines an optional request body
  544. */
  545. send(body?: Document | BodyInit | null): void;
  546. /**
  547. * Sets the request method, request URL
  548. * @param method defines the method to use (GET, POST, etc..)
  549. * @param url defines the url to connect with
  550. */
  551. open(method: string, url: string): void;
  552. /**
  553. * Sets the value of a request header.
  554. * @param name The name of the header whose value is to be set
  555. * @param value The value to set as the body of the header
  556. */
  557. setRequestHeader(name: string, value: string): void;
  558. /**
  559. * Get the string containing the text of a particular header's value.
  560. * @param name The name of the header
  561. * @returns The string containing the text of the given header name
  562. */
  563. getResponseHeader(name: string): Nullable<string>;
  564. }
  565. }
  566. declare module "babylonjs/Misc/fileRequest" {
  567. import { Observable } from "babylonjs/Misc/observable";
  568. /**
  569. * File request interface
  570. */
  571. export interface IFileRequest {
  572. /**
  573. * Raised when the request is complete (success or error).
  574. */
  575. onCompleteObservable: Observable<IFileRequest>;
  576. /**
  577. * Aborts the request for a file.
  578. */
  579. abort: () => void;
  580. }
  581. }
  582. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  583. /**
  584. * Define options used to create a render target texture
  585. */
  586. export class RenderTargetCreationOptions {
  587. /**
  588. * Specifies is mipmaps must be generated
  589. */
  590. generateMipMaps?: boolean;
  591. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  592. generateDepthBuffer?: boolean;
  593. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  594. generateStencilBuffer?: boolean;
  595. /** Defines texture type (int by default) */
  596. type?: number;
  597. /** Defines sampling mode (trilinear by default) */
  598. samplingMode?: number;
  599. /** Defines format (RGBA by default) */
  600. format?: number;
  601. }
  602. }
  603. declare module "babylonjs/Engines/constants" {
  604. /** Defines the cross module used constants to avoid circular dependncies */
  605. export class Constants {
  606. /** Defines that alpha blending is disabled */
  607. static readonly ALPHA_DISABLE: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  609. static readonly ALPHA_ADD: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_COMBINE: number;
  612. /** Defines that alpha blending is DEST - SRC * DEST */
  613. static readonly ALPHA_SUBTRACT: number;
  614. /** Defines that alpha blending is SRC * DEST */
  615. static readonly ALPHA_MULTIPLY: number;
  616. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  617. static readonly ALPHA_MAXIMIZED: number;
  618. /** Defines that alpha blending is SRC + DEST */
  619. static readonly ALPHA_ONEONE: number;
  620. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  621. static readonly ALPHA_PREMULTIPLIED: number;
  622. /**
  623. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  624. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  625. */
  626. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  627. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  628. static readonly ALPHA_INTERPOLATE: number;
  629. /**
  630. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  631. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  632. */
  633. static readonly ALPHA_SCREENMODE: number;
  634. /**
  635. * Defines that alpha blending is SRC + DST
  636. * Alpha will be set to SRC ALPHA + DST ALPHA
  637. */
  638. static readonly ALPHA_ONEONE_ONEONE: number;
  639. /**
  640. * Defines that alpha blending is SRC * DST ALPHA + DST
  641. * Alpha will be set to 0
  642. */
  643. static readonly ALPHA_ALPHATOCOLOR: number;
  644. /**
  645. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  646. */
  647. static readonly ALPHA_REVERSEONEMINUS: number;
  648. /**
  649. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  650. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  651. */
  652. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  653. /**
  654. * Defines that alpha blending is SRC + DST
  655. * Alpha will be set to SRC ALPHA
  656. */
  657. static readonly ALPHA_ONEONE_ONEZERO: number;
  658. /**
  659. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  660. * Alpha will be set to DST ALPHA
  661. */
  662. static readonly ALPHA_EXCLUSION: number;
  663. /** Defines that alpha blending equation a SUM */
  664. static readonly ALPHA_EQUATION_ADD: number;
  665. /** Defines that alpha blending equation a SUBSTRACTION */
  666. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  667. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  668. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  669. /** Defines that alpha blending equation a MAX operation */
  670. static readonly ALPHA_EQUATION_MAX: number;
  671. /** Defines that alpha blending equation a MIN operation */
  672. static readonly ALPHA_EQUATION_MIN: number;
  673. /**
  674. * Defines that alpha blending equation a DARKEN operation:
  675. * It takes the min of the src and sums the alpha channels.
  676. */
  677. static readonly ALPHA_EQUATION_DARKEN: number;
  678. /** Defines that the ressource is not delayed*/
  679. static readonly DELAYLOADSTATE_NONE: number;
  680. /** Defines that the ressource was successfully delay loaded */
  681. static readonly DELAYLOADSTATE_LOADED: number;
  682. /** Defines that the ressource is currently delay loading */
  683. static readonly DELAYLOADSTATE_LOADING: number;
  684. /** Defines that the ressource is delayed and has not started loading */
  685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  687. static readonly NEVER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  689. static readonly ALWAYS: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  691. static readonly LESS: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  693. static readonly EQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  695. static readonly LEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  697. static readonly GREATER: number;
  698. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  699. static readonly GEQUAL: number;
  700. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  701. static readonly NOTEQUAL: number;
  702. /** Passed to stencilOperation to specify that stencil value must be kept */
  703. static readonly KEEP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  705. static readonly REPLACE: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  707. static readonly INCR: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  709. static readonly DECR: number;
  710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  711. static readonly INVERT: number;
  712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  713. static readonly INCR_WRAP: number;
  714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  715. static readonly DECR_WRAP: number;
  716. /** Texture is not repeating outside of 0..1 UVs */
  717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  718. /** Texture is repeating outside of 0..1 UVs */
  719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  720. /** Texture is repeating and mirrored */
  721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  722. /** ALPHA */
  723. static readonly TEXTUREFORMAT_ALPHA: number;
  724. /** LUMINANCE */
  725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  726. /** LUMINANCE_ALPHA */
  727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  728. /** RGB */
  729. static readonly TEXTUREFORMAT_RGB: number;
  730. /** RGBA */
  731. static readonly TEXTUREFORMAT_RGBA: number;
  732. /** RED */
  733. static readonly TEXTUREFORMAT_RED: number;
  734. /** RED (2nd reference) */
  735. static readonly TEXTUREFORMAT_R: number;
  736. /** RG */
  737. static readonly TEXTUREFORMAT_RG: number;
  738. /** RED_INTEGER */
  739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  740. /** RED_INTEGER (2nd reference) */
  741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  742. /** RG_INTEGER */
  743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  744. /** RGB_INTEGER */
  745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  746. /** RGBA_INTEGER */
  747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  748. /** UNSIGNED_BYTE */
  749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  750. /** UNSIGNED_BYTE (2nd reference) */
  751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  752. /** FLOAT */
  753. static readonly TEXTURETYPE_FLOAT: number;
  754. /** HALF_FLOAT */
  755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  756. /** BYTE */
  757. static readonly TEXTURETYPE_BYTE: number;
  758. /** SHORT */
  759. static readonly TEXTURETYPE_SHORT: number;
  760. /** UNSIGNED_SHORT */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  762. /** INT */
  763. static readonly TEXTURETYPE_INT: number;
  764. /** UNSIGNED_INT */
  765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  766. /** UNSIGNED_SHORT_4_4_4_4 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  768. /** UNSIGNED_SHORT_5_5_5_1 */
  769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  770. /** UNSIGNED_SHORT_5_6_5 */
  771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  772. /** UNSIGNED_INT_2_10_10_10_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  774. /** UNSIGNED_INT_24_8 */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  776. /** UNSIGNED_INT_10F_11F_11F_REV */
  777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  778. /** UNSIGNED_INT_5_9_9_9_REV */
  779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  782. /** nearest is mag = nearest and min = nearest and no mip */
  783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** Bilinear is mag = linear and min = linear and no mip */
  787. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  788. /** mag = linear and min = linear and mip = none */
  789. static readonly TEXTURE_LINEAR_LINEAR: number;
  790. /** Trilinear is mag = linear and min = linear and mip = linear */
  791. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  792. /** Trilinear is mag = linear and min = linear and mip = linear */
  793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = nearest and mip = nearest */
  795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  796. /** mag = nearest and min = linear and mip = nearest */
  797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  798. /** mag = nearest and min = linear and mip = linear */
  799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  800. /** mag = nearest and min = linear and mip = none */
  801. static readonly TEXTURE_NEAREST_LINEAR: number;
  802. /** nearest is mag = nearest and min = nearest and mip = linear */
  803. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  804. /** mag = linear and min = nearest and mip = nearest */
  805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = linear */
  807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  810. /** mag = linear and min = nearest and mip = none */
  811. static readonly TEXTURE_LINEAR_NEAREST: number;
  812. /** Explicit coordinates mode */
  813. static readonly TEXTURE_EXPLICIT_MODE: number;
  814. /** Spherical coordinates mode */
  815. static readonly TEXTURE_SPHERICAL_MODE: number;
  816. /** Planar coordinates mode */
  817. static readonly TEXTURE_PLANAR_MODE: number;
  818. /** Cubic coordinates mode */
  819. static readonly TEXTURE_CUBIC_MODE: number;
  820. /** Projection coordinates mode */
  821. static readonly TEXTURE_PROJECTION_MODE: number;
  822. /** Skybox coordinates mode */
  823. static readonly TEXTURE_SKYBOX_MODE: number;
  824. /** Inverse Cubic coordinates mode */
  825. static readonly TEXTURE_INVCUBIC_MODE: number;
  826. /** Equirectangular coordinates mode */
  827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  828. /** Equirectangular Fixed coordinates mode */
  829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  830. /** Equirectangular Fixed Mirrored coordinates mode */
  831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  832. /** Offline (baking) quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  834. /** High quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  836. /** Medium quality for texture filtering */
  837. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  838. /** Low quality for texture filtering */
  839. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  840. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  841. static readonly SCALEMODE_FLOOR: number;
  842. /** Defines that texture rescaling will look for the nearest power of 2 size */
  843. static readonly SCALEMODE_NEAREST: number;
  844. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  845. static readonly SCALEMODE_CEILING: number;
  846. /**
  847. * The dirty texture flag value
  848. */
  849. static readonly MATERIAL_TextureDirtyFlag: number;
  850. /**
  851. * The dirty light flag value
  852. */
  853. static readonly MATERIAL_LightDirtyFlag: number;
  854. /**
  855. * The dirty fresnel flag value
  856. */
  857. static readonly MATERIAL_FresnelDirtyFlag: number;
  858. /**
  859. * The dirty attribute flag value
  860. */
  861. static readonly MATERIAL_AttributesDirtyFlag: number;
  862. /**
  863. * The dirty misc flag value
  864. */
  865. static readonly MATERIAL_MiscDirtyFlag: number;
  866. /**
  867. * The dirty prepass flag value
  868. */
  869. static readonly MATERIAL_PrePassDirtyFlag: number;
  870. /**
  871. * The all dirty flag value
  872. */
  873. static readonly MATERIAL_AllDirtyFlag: number;
  874. /**
  875. * Returns the triangle fill mode
  876. */
  877. static readonly MATERIAL_TriangleFillMode: number;
  878. /**
  879. * Returns the wireframe mode
  880. */
  881. static readonly MATERIAL_WireFrameFillMode: number;
  882. /**
  883. * Returns the point fill mode
  884. */
  885. static readonly MATERIAL_PointFillMode: number;
  886. /**
  887. * Returns the point list draw mode
  888. */
  889. static readonly MATERIAL_PointListDrawMode: number;
  890. /**
  891. * Returns the line list draw mode
  892. */
  893. static readonly MATERIAL_LineListDrawMode: number;
  894. /**
  895. * Returns the line loop draw mode
  896. */
  897. static readonly MATERIAL_LineLoopDrawMode: number;
  898. /**
  899. * Returns the line strip draw mode
  900. */
  901. static readonly MATERIAL_LineStripDrawMode: number;
  902. /**
  903. * Returns the triangle strip draw mode
  904. */
  905. static readonly MATERIAL_TriangleStripDrawMode: number;
  906. /**
  907. * Returns the triangle fan draw mode
  908. */
  909. static readonly MATERIAL_TriangleFanDrawMode: number;
  910. /**
  911. * Stores the clock-wise side orientation
  912. */
  913. static readonly MATERIAL_ClockWiseSideOrientation: number;
  914. /**
  915. * Stores the counter clock-wise side orientation
  916. */
  917. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  918. /**
  919. * Nothing
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_NothingTrigger: number;
  923. /**
  924. * On pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickTrigger: number;
  928. /**
  929. * On left pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnLeftPickTrigger: number;
  933. /**
  934. * On right pick
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnRightPickTrigger: number;
  938. /**
  939. * On center pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnCenterPickTrigger: number;
  943. /**
  944. * On pick down
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickDownTrigger: number;
  948. /**
  949. * On double pick
  950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  951. */
  952. static readonly ACTION_OnDoublePickTrigger: number;
  953. /**
  954. * On pick up
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickUpTrigger: number;
  958. /**
  959. * On pick out.
  960. * This trigger will only be raised if you also declared a OnPickDown
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPickOutTrigger: number;
  964. /**
  965. * On long press
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnLongPressTrigger: number;
  969. /**
  970. * On pointer over
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnPointerOverTrigger: number;
  974. /**
  975. * On pointer out
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnPointerOutTrigger: number;
  979. /**
  980. * On every frame
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnEveryFrameTrigger: number;
  984. /**
  985. * On intersection enter
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnIntersectionEnterTrigger: number;
  989. /**
  990. * On intersection exit
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnIntersectionExitTrigger: number;
  994. /**
  995. * On key down
  996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  997. */
  998. static readonly ACTION_OnKeyDownTrigger: number;
  999. /**
  1000. * On key up
  1001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1002. */
  1003. static readonly ACTION_OnKeyUpTrigger: number;
  1004. /**
  1005. * Billboard mode will only apply to Y axis
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1008. /**
  1009. * Billboard mode will apply to all axes
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1012. /**
  1013. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1014. */
  1015. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1017. * Test order :
  1018. * Is the bounding sphere outside the frustum ?
  1019. * If not, are the bounding box vertices outside the frustum ?
  1020. * It not, then the cullable object is in the frustum.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1023. /** Culling strategy : Bounding Sphere Only.
  1024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1025. * It's also less accurate than the standard because some not visible objects can still be selected.
  1026. * Test : is the bounding sphere outside the frustum ?
  1027. * If not, then the cullable object is in the frustum.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1030. /** Culling strategy : Optimistic Inclusion.
  1031. * This in an inclusion test first, then the standard exclusion test.
  1032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1034. * Anyway, it's as accurate as the standard strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the default culling strategy.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1043. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1045. * Test :
  1046. * Is the cullable object bounding sphere center in the frustum ?
  1047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1048. */
  1049. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1050. /**
  1051. * No logging while loading
  1052. */
  1053. static readonly SCENELOADER_NO_LOGGING: number;
  1054. /**
  1055. * Minimal logging while loading
  1056. */
  1057. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1058. /**
  1059. * Summary logging while loading
  1060. */
  1061. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1062. /**
  1063. * Detailled logging while loading
  1064. */
  1065. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1066. /**
  1067. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1069. */
  1070. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the position texture index in the textures array in the prepass
  1073. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1074. */
  1075. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1078. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1079. */
  1080. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1091. /**
  1092. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1093. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1094. */
  1095. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1096. /**
  1097. * Constant used to retrieve albedo index in the textures array in the prepass
  1098. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1099. */
  1100. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1101. }
  1102. }
  1103. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1104. import { Nullable } from "babylonjs/types";
  1105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1106. /**
  1107. * This represents the required contract to create a new type of texture loader.
  1108. */
  1109. export interface IInternalTextureLoader {
  1110. /**
  1111. * Defines wether the loader supports cascade loading the different faces.
  1112. */
  1113. supportCascades: boolean;
  1114. /**
  1115. * This returns if the loader support the current file information.
  1116. * @param extension defines the file extension of the file being loaded
  1117. * @param mimeType defines the optional mime type of the file being loaded
  1118. * @returns true if the loader can load the specified file
  1119. */
  1120. canLoad(extension: string, mimeType?: string): boolean;
  1121. /**
  1122. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1123. * @param data contains the texture data
  1124. * @param texture defines the BabylonJS internal texture
  1125. * @param createPolynomials will be true if polynomials have been requested
  1126. * @param onLoad defines the callback to trigger once the texture is ready
  1127. * @param onError defines the callback to trigger in case of error
  1128. */
  1129. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1130. /**
  1131. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1132. * @param data contains the texture data
  1133. * @param texture defines the BabylonJS internal texture
  1134. * @param callback defines the method to call once ready to upload
  1135. */
  1136. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1137. }
  1138. }
  1139. declare module "babylonjs/Engines/IPipelineContext" {
  1140. /**
  1141. * Class used to store and describe the pipeline context associated with an effect
  1142. */
  1143. export interface IPipelineContext {
  1144. /**
  1145. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1146. */
  1147. isAsync: boolean;
  1148. /**
  1149. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1150. */
  1151. isReady: boolean;
  1152. /** @hidden */
  1153. _getVertexShaderCode(): string | null;
  1154. /** @hidden */
  1155. _getFragmentShaderCode(): string | null;
  1156. /** @hidden */
  1157. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1158. }
  1159. }
  1160. declare module "babylonjs/Meshes/dataBuffer" {
  1161. /**
  1162. * Class used to store gfx data (like WebGLBuffer)
  1163. */
  1164. export class DataBuffer {
  1165. /**
  1166. * Gets or sets the number of objects referencing this buffer
  1167. */
  1168. references: number;
  1169. /** Gets or sets the size of the underlying buffer */
  1170. capacity: number;
  1171. /**
  1172. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1173. */
  1174. is32Bits: boolean;
  1175. /**
  1176. * Gets the underlying buffer
  1177. */
  1178. get underlyingResource(): any;
  1179. }
  1180. }
  1181. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1182. /** @hidden */
  1183. export interface IShaderProcessor {
  1184. attributeProcessor?: (attribute: string) => string;
  1185. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1186. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1187. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1188. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1189. lineProcessor?: (line: string, isFragment: boolean) => string;
  1190. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1191. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1192. }
  1193. }
  1194. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1195. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1196. /** @hidden */
  1197. export interface ProcessingOptions {
  1198. defines: string[];
  1199. indexParameters: any;
  1200. isFragment: boolean;
  1201. shouldUseHighPrecisionShader: boolean;
  1202. supportsUniformBuffers: boolean;
  1203. shadersRepository: string;
  1204. includesShadersStore: {
  1205. [key: string]: string;
  1206. };
  1207. processor?: IShaderProcessor;
  1208. version: string;
  1209. platformName: string;
  1210. lookForClosingBracketForUniformBuffer?: boolean;
  1211. }
  1212. }
  1213. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1214. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1215. /** @hidden */
  1216. export class ShaderCodeNode {
  1217. line: string;
  1218. children: ShaderCodeNode[];
  1219. additionalDefineKey?: string;
  1220. additionalDefineValue?: string;
  1221. isValid(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. process(preprocessors: {
  1225. [key: string]: string;
  1226. }, options: ProcessingOptions): string;
  1227. }
  1228. }
  1229. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1230. /** @hidden */
  1231. export class ShaderCodeCursor {
  1232. private _lines;
  1233. lineIndex: number;
  1234. get currentLine(): string;
  1235. get canRead(): boolean;
  1236. set lines(value: string[]);
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1240. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1241. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1242. /** @hidden */
  1243. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1244. process(preprocessors: {
  1245. [key: string]: string;
  1246. }, options: ProcessingOptions): string;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1250. /** @hidden */
  1251. export class ShaderDefineExpression {
  1252. isTrue(preprocessors: {
  1253. [key: string]: string;
  1254. }): boolean;
  1255. private static _OperatorPriority;
  1256. private static _Stack;
  1257. static postfixToInfix(postfix: string[]): string;
  1258. static infixToPostfix(infix: string): string[];
  1259. }
  1260. }
  1261. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1262. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderCodeTestNode extends ShaderCodeNode {
  1266. testExpression: ShaderDefineExpression;
  1267. isValid(preprocessors: {
  1268. [key: string]: string;
  1269. }): boolean;
  1270. }
  1271. }
  1272. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1273. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1274. /** @hidden */
  1275. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1276. define: string;
  1277. not: boolean;
  1278. constructor(define: string, not?: boolean);
  1279. isTrue(preprocessors: {
  1280. [key: string]: string;
  1281. }): boolean;
  1282. }
  1283. }
  1284. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1285. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1286. /** @hidden */
  1287. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1288. leftOperand: ShaderDefineExpression;
  1289. rightOperand: ShaderDefineExpression;
  1290. isTrue(preprocessors: {
  1291. [key: string]: string;
  1292. }): boolean;
  1293. }
  1294. }
  1295. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1296. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1297. /** @hidden */
  1298. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1299. leftOperand: ShaderDefineExpression;
  1300. rightOperand: ShaderDefineExpression;
  1301. isTrue(preprocessors: {
  1302. [key: string]: string;
  1303. }): boolean;
  1304. }
  1305. }
  1306. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1307. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1308. /** @hidden */
  1309. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1310. define: string;
  1311. operand: string;
  1312. testValue: string;
  1313. constructor(define: string, operand: string, testValue: string);
  1314. isTrue(preprocessors: {
  1315. [key: string]: string;
  1316. }): boolean;
  1317. }
  1318. }
  1319. declare module "babylonjs/Offline/IOfflineProvider" {
  1320. /**
  1321. * Class used to enable access to offline support
  1322. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1323. */
  1324. export interface IOfflineProvider {
  1325. /**
  1326. * Gets a boolean indicating if scene must be saved in the database
  1327. */
  1328. enableSceneOffline: boolean;
  1329. /**
  1330. * Gets a boolean indicating if textures must be saved in the database
  1331. */
  1332. enableTexturesOffline: boolean;
  1333. /**
  1334. * Open the offline support and make it available
  1335. * @param successCallback defines the callback to call on success
  1336. * @param errorCallback defines the callback to call on error
  1337. */
  1338. open(successCallback: () => void, errorCallback: () => void): void;
  1339. /**
  1340. * Loads an image from the offline support
  1341. * @param url defines the url to load from
  1342. * @param image defines the target DOM image
  1343. */
  1344. loadImage(url: string, image: HTMLImageElement): void;
  1345. /**
  1346. * Loads a file from offline support
  1347. * @param url defines the URL to load from
  1348. * @param sceneLoaded defines a callback to call on success
  1349. * @param progressCallBack defines a callback to call when progress changed
  1350. * @param errorCallback defines a callback to call on error
  1351. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1352. */
  1353. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/filesInputStore" {
  1357. /**
  1358. * Class used to help managing file picking and drag'n'drop
  1359. * File Storage
  1360. */
  1361. export class FilesInputStore {
  1362. /**
  1363. * List of files ready to be loaded
  1364. */
  1365. static FilesToLoad: {
  1366. [key: string]: File;
  1367. };
  1368. }
  1369. }
  1370. declare module "babylonjs/Misc/retryStrategy" {
  1371. import { WebRequest } from "babylonjs/Misc/webRequest";
  1372. /**
  1373. * Class used to define a retry strategy when error happens while loading assets
  1374. */
  1375. export class RetryStrategy {
  1376. /**
  1377. * Function used to defines an exponential back off strategy
  1378. * @param maxRetries defines the maximum number of retries (3 by default)
  1379. * @param baseInterval defines the interval between retries
  1380. * @returns the strategy function to use
  1381. */
  1382. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1383. }
  1384. }
  1385. declare module "babylonjs/Misc/baseError" {
  1386. /**
  1387. * @ignore
  1388. * Application error to support additional information when loading a file
  1389. */
  1390. export abstract class BaseError extends Error {
  1391. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1392. }
  1393. }
  1394. declare module "babylonjs/Misc/fileTools" {
  1395. import { WebRequest } from "babylonjs/Misc/webRequest";
  1396. import { Nullable } from "babylonjs/types";
  1397. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1398. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1399. import { BaseError } from "babylonjs/Misc/baseError";
  1400. /** @ignore */
  1401. export class LoadFileError extends BaseError {
  1402. request?: WebRequest;
  1403. file?: File;
  1404. /**
  1405. * Creates a new LoadFileError
  1406. * @param message defines the message of the error
  1407. * @param request defines the optional web request
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, object?: WebRequest | File);
  1411. }
  1412. /** @ignore */
  1413. export class RequestFileError extends BaseError {
  1414. request: WebRequest;
  1415. /**
  1416. * Creates a new LoadFileError
  1417. * @param message defines the message of the error
  1418. * @param request defines the optional web request
  1419. */
  1420. constructor(message: string, request: WebRequest);
  1421. }
  1422. /** @ignore */
  1423. export class ReadFileError extends BaseError {
  1424. file: File;
  1425. /**
  1426. * Creates a new ReadFileError
  1427. * @param message defines the message of the error
  1428. * @param file defines the optional file
  1429. */
  1430. constructor(message: string, file: File);
  1431. }
  1432. /**
  1433. * @hidden
  1434. */
  1435. export class FileTools {
  1436. /**
  1437. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1438. */
  1439. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1440. /**
  1441. * Gets or sets the base URL to use to load assets
  1442. */
  1443. static BaseUrl: string;
  1444. /**
  1445. * Default behaviour for cors in the application.
  1446. * It can be a string if the expected behavior is identical in the entire app.
  1447. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1448. */
  1449. static CorsBehavior: string | ((url: string | string[]) => string);
  1450. /**
  1451. * Gets or sets a function used to pre-process url before using them to load assets
  1452. */
  1453. static PreprocessUrl: (url: string) => string;
  1454. /**
  1455. * Removes unwanted characters from an url
  1456. * @param url defines the url to clean
  1457. * @returns the cleaned url
  1458. */
  1459. private static _CleanUrl;
  1460. /**
  1461. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1462. * @param url define the url we are trying
  1463. * @param element define the dom element where to configure the cors policy
  1464. */
  1465. static SetCorsBehavior(url: string | string[], element: {
  1466. crossOrigin: string | null;
  1467. }): void;
  1468. /**
  1469. * Loads an image as an HTMLImageElement.
  1470. * @param input url string, ArrayBuffer, or Blob to load
  1471. * @param onLoad callback called when the image successfully loads
  1472. * @param onError callback called when the image fails to load
  1473. * @param offlineProvider offline provider for caching
  1474. * @param mimeType optional mime type
  1475. * @returns the HTMLImageElement of the loaded image
  1476. */
  1477. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1478. /**
  1479. * Reads a file from a File object
  1480. * @param file defines the file to load
  1481. * @param onSuccess defines the callback to call when data is loaded
  1482. * @param onProgress defines the callback to call during loading process
  1483. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1484. * @param onError defines the callback to call when an error occurs
  1485. * @returns a file request object
  1486. */
  1487. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1488. /**
  1489. * Loads a file from a url
  1490. * @param url url to load
  1491. * @param onSuccess callback called when the file successfully loads
  1492. * @param onProgress callback called while file is loading (if the server supports this mode)
  1493. * @param offlineProvider defines the offline provider for caching
  1494. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1495. * @param onError callback called when the file fails to load
  1496. * @returns a file request object
  1497. */
  1498. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1499. /**
  1500. * Loads a file
  1501. * @param url url to load
  1502. * @param onSuccess callback called when the file successfully loads
  1503. * @param onProgress callback called while file is loading (if the server supports this mode)
  1504. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1505. * @param onError callback called when the file fails to load
  1506. * @param onOpened callback called when the web request is opened
  1507. * @returns a file request object
  1508. */
  1509. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1510. /**
  1511. * Checks if the loaded document was accessed via `file:`-Protocol.
  1512. * @returns boolean
  1513. */
  1514. static IsFileURL(): boolean;
  1515. }
  1516. }
  1517. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1518. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1519. import { WebRequest } from "babylonjs/Misc/webRequest";
  1520. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1521. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1522. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1523. /** @hidden */
  1524. export class ShaderProcessor {
  1525. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1526. private static _ProcessPrecision;
  1527. private static _ExtractOperation;
  1528. private static _BuildSubExpression;
  1529. private static _BuildExpression;
  1530. private static _MoveCursorWithinIf;
  1531. private static _MoveCursor;
  1532. private static _EvaluatePreProcessors;
  1533. private static _PreparePreProcessors;
  1534. private static _ProcessShaderConversion;
  1535. private static _ProcessIncludes;
  1536. /**
  1537. * Loads a file from a url
  1538. * @param url url to load
  1539. * @param onSuccess callback called when the file successfully loads
  1540. * @param onProgress callback called while file is loading (if the server supports this mode)
  1541. * @param offlineProvider defines the offline provider for caching
  1542. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1543. * @param onError callback called when the file fails to load
  1544. * @returns a file request object
  1545. * @hidden
  1546. */
  1547. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1548. }
  1549. }
  1550. declare module "babylonjs/Maths/math.like" {
  1551. import { float, int, DeepImmutable } from "babylonjs/types";
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IColor4Like {
  1556. r: float;
  1557. g: float;
  1558. b: float;
  1559. a: float;
  1560. }
  1561. /**
  1562. * @hidden
  1563. */
  1564. export interface IColor3Like {
  1565. r: float;
  1566. g: float;
  1567. b: float;
  1568. }
  1569. /**
  1570. * @hidden
  1571. */
  1572. export interface IVector4Like {
  1573. x: float;
  1574. y: float;
  1575. z: float;
  1576. w: float;
  1577. }
  1578. /**
  1579. * @hidden
  1580. */
  1581. export interface IVector3Like {
  1582. x: float;
  1583. y: float;
  1584. z: float;
  1585. }
  1586. /**
  1587. * @hidden
  1588. */
  1589. export interface IVector2Like {
  1590. x: float;
  1591. y: float;
  1592. }
  1593. /**
  1594. * @hidden
  1595. */
  1596. export interface IMatrixLike {
  1597. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1598. updateFlag: int;
  1599. }
  1600. /**
  1601. * @hidden
  1602. */
  1603. export interface IViewportLike {
  1604. x: float;
  1605. y: float;
  1606. width: float;
  1607. height: float;
  1608. }
  1609. /**
  1610. * @hidden
  1611. */
  1612. export interface IPlaneLike {
  1613. normal: IVector3Like;
  1614. d: float;
  1615. normalize(): void;
  1616. }
  1617. }
  1618. declare module "babylonjs/Materials/iEffectFallbacks" {
  1619. import { Effect } from "babylonjs/Materials/effect";
  1620. /**
  1621. * Interface used to define common properties for effect fallbacks
  1622. */
  1623. export interface IEffectFallbacks {
  1624. /**
  1625. * Removes the defines that should be removed when falling back.
  1626. * @param currentDefines defines the current define statements for the shader.
  1627. * @param effect defines the current effect we try to compile
  1628. * @returns The resulting defines with defines of the current rank removed.
  1629. */
  1630. reduce(currentDefines: string, effect: Effect): string;
  1631. /**
  1632. * Removes the fallback from the bound mesh.
  1633. */
  1634. unBindMesh(): void;
  1635. /**
  1636. * Checks to see if more fallbacks are still availible.
  1637. */
  1638. hasMoreFallbacks: boolean;
  1639. }
  1640. }
  1641. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1642. /**
  1643. * Class used to evalaute queries containing `and` and `or` operators
  1644. */
  1645. export class AndOrNotEvaluator {
  1646. /**
  1647. * Evaluate a query
  1648. * @param query defines the query to evaluate
  1649. * @param evaluateCallback defines the callback used to filter result
  1650. * @returns true if the query matches
  1651. */
  1652. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1653. private static _HandleParenthesisContent;
  1654. private static _SimplifyNegation;
  1655. }
  1656. }
  1657. declare module "babylonjs/Misc/tags" {
  1658. /**
  1659. * Class used to store custom tags
  1660. */
  1661. export class Tags {
  1662. /**
  1663. * Adds support for tags on the given object
  1664. * @param obj defines the object to use
  1665. */
  1666. static EnableFor(obj: any): void;
  1667. /**
  1668. * Removes tags support
  1669. * @param obj defines the object to use
  1670. */
  1671. static DisableFor(obj: any): void;
  1672. /**
  1673. * Gets a boolean indicating if the given object has tags
  1674. * @param obj defines the object to use
  1675. * @returns a boolean
  1676. */
  1677. static HasTags(obj: any): boolean;
  1678. /**
  1679. * Gets the tags available on a given object
  1680. * @param obj defines the object to use
  1681. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1682. * @returns the tags
  1683. */
  1684. static GetTags(obj: any, asString?: boolean): any;
  1685. /**
  1686. * Adds tags to an object
  1687. * @param obj defines the object to use
  1688. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1689. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1690. */
  1691. static AddTagsTo(obj: any, tagsString: string): void;
  1692. /**
  1693. * @hidden
  1694. */
  1695. static _AddTagTo(obj: any, tag: string): void;
  1696. /**
  1697. * Removes specific tags from a specific object
  1698. * @param obj defines the object to use
  1699. * @param tagsString defines the tags to remove
  1700. */
  1701. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1702. /**
  1703. * @hidden
  1704. */
  1705. static _RemoveTagFrom(obj: any, tag: string): void;
  1706. /**
  1707. * Defines if tags hosted on an object match a given query
  1708. * @param obj defines the object to use
  1709. * @param tagsQuery defines the tag query
  1710. * @returns a boolean
  1711. */
  1712. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1713. }
  1714. }
  1715. declare module "babylonjs/Maths/math.scalar" {
  1716. /**
  1717. * Scalar computation library
  1718. */
  1719. export class Scalar {
  1720. /**
  1721. * Two pi constants convenient for computation.
  1722. */
  1723. static TwoPi: number;
  1724. /**
  1725. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1726. * @param a number
  1727. * @param b number
  1728. * @param epsilon (default = 1.401298E-45)
  1729. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1730. */
  1731. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1732. /**
  1733. * Returns a string : the upper case translation of the number i to hexadecimal.
  1734. * @param i number
  1735. * @returns the upper case translation of the number i to hexadecimal.
  1736. */
  1737. static ToHex(i: number): string;
  1738. /**
  1739. * Returns -1 if value is negative and +1 is value is positive.
  1740. * @param value the value
  1741. * @returns the value itself if it's equal to zero.
  1742. */
  1743. static Sign(value: number): number;
  1744. /**
  1745. * Returns the value itself if it's between min and max.
  1746. * Returns min if the value is lower than min.
  1747. * Returns max if the value is greater than max.
  1748. * @param value the value to clmap
  1749. * @param min the min value to clamp to (default: 0)
  1750. * @param max the max value to clamp to (default: 1)
  1751. * @returns the clamped value
  1752. */
  1753. static Clamp(value: number, min?: number, max?: number): number;
  1754. /**
  1755. * the log2 of value.
  1756. * @param value the value to compute log2 of
  1757. * @returns the log2 of value.
  1758. */
  1759. static Log2(value: number): number;
  1760. /**
  1761. * Loops the value, so that it is never larger than length and never smaller than 0.
  1762. *
  1763. * This is similar to the modulo operator but it works with floating point numbers.
  1764. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1765. * With t = 5 and length = 2.5, the result would be 0.0.
  1766. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1767. * @param value the value
  1768. * @param length the length
  1769. * @returns the looped value
  1770. */
  1771. static Repeat(value: number, length: number): number;
  1772. /**
  1773. * Normalize the value between 0.0 and 1.0 using min and max values
  1774. * @param value value to normalize
  1775. * @param min max to normalize between
  1776. * @param max min to normalize between
  1777. * @returns the normalized value
  1778. */
  1779. static Normalize(value: number, min: number, max: number): number;
  1780. /**
  1781. * Denormalize the value from 0.0 and 1.0 using min and max values
  1782. * @param normalized value to denormalize
  1783. * @param min max to denormalize between
  1784. * @param max min to denormalize between
  1785. * @returns the denormalized value
  1786. */
  1787. static Denormalize(normalized: number, min: number, max: number): number;
  1788. /**
  1789. * Calculates the shortest difference between two given angles given in degrees.
  1790. * @param current current angle in degrees
  1791. * @param target target angle in degrees
  1792. * @returns the delta
  1793. */
  1794. static DeltaAngle(current: number, target: number): number;
  1795. /**
  1796. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1797. * @param tx value
  1798. * @param length length
  1799. * @returns The returned value will move back and forth between 0 and length
  1800. */
  1801. static PingPong(tx: number, length: number): number;
  1802. /**
  1803. * Interpolates between min and max with smoothing at the limits.
  1804. *
  1805. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1806. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1807. * @param from from
  1808. * @param to to
  1809. * @param tx value
  1810. * @returns the smooth stepped value
  1811. */
  1812. static SmoothStep(from: number, to: number, tx: number): number;
  1813. /**
  1814. * Moves a value current towards target.
  1815. *
  1816. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1817. * Negative values of maxDelta pushes the value away from target.
  1818. * @param current current value
  1819. * @param target target value
  1820. * @param maxDelta max distance to move
  1821. * @returns resulting value
  1822. */
  1823. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1824. /**
  1825. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1826. *
  1827. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1828. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1829. * @param current current value
  1830. * @param target target value
  1831. * @param maxDelta max distance to move
  1832. * @returns resulting angle
  1833. */
  1834. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1835. /**
  1836. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1837. * @param start start value
  1838. * @param end target value
  1839. * @param amount amount to lerp between
  1840. * @returns the lerped value
  1841. */
  1842. static Lerp(start: number, end: number, amount: number): number;
  1843. /**
  1844. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1845. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1846. * @param start start value
  1847. * @param end target value
  1848. * @param amount amount to lerp between
  1849. * @returns the lerped value
  1850. */
  1851. static LerpAngle(start: number, end: number, amount: number): number;
  1852. /**
  1853. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1854. * @param a start value
  1855. * @param b target value
  1856. * @param value value between a and b
  1857. * @returns the inverseLerp value
  1858. */
  1859. static InverseLerp(a: number, b: number, value: number): number;
  1860. /**
  1861. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1862. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1863. * @param value1 spline value
  1864. * @param tangent1 spline value
  1865. * @param value2 spline value
  1866. * @param tangent2 spline value
  1867. * @param amount input value
  1868. * @returns hermite result
  1869. */
  1870. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1871. /**
  1872. * Returns a random float number between and min and max values
  1873. * @param min min value of random
  1874. * @param max max value of random
  1875. * @returns random value
  1876. */
  1877. static RandomRange(min: number, max: number): number;
  1878. /**
  1879. * This function returns percentage of a number in a given range.
  1880. *
  1881. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1882. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1883. * @param number to convert to percentage
  1884. * @param min min range
  1885. * @param max max range
  1886. * @returns the percentage
  1887. */
  1888. static RangeToPercent(number: number, min: number, max: number): number;
  1889. /**
  1890. * This function returns number that corresponds to the percentage in a given range.
  1891. *
  1892. * PercentToRange(0.34,0,100) will return 34.
  1893. * @param percent to convert to number
  1894. * @param min min range
  1895. * @param max max range
  1896. * @returns the number
  1897. */
  1898. static PercentToRange(percent: number, min: number, max: number): number;
  1899. /**
  1900. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1901. * @param angle The angle to normalize in radian.
  1902. * @return The converted angle.
  1903. */
  1904. static NormalizeRadians(angle: number): number;
  1905. }
  1906. }
  1907. declare module "babylonjs/Maths/math.constants" {
  1908. /**
  1909. * Constant used to convert a value to gamma space
  1910. * @ignorenaming
  1911. */
  1912. export const ToGammaSpace: number;
  1913. /**
  1914. * Constant used to convert a value to linear space
  1915. * @ignorenaming
  1916. */
  1917. export const ToLinearSpace = 2.2;
  1918. /**
  1919. * Constant used to define the minimal number value in Babylon.js
  1920. * @ignorenaming
  1921. */
  1922. let Epsilon: number;
  1923. export { Epsilon };
  1924. }
  1925. declare module "babylonjs/Maths/math.viewport" {
  1926. /**
  1927. * Class used to represent a viewport on screen
  1928. */
  1929. export class Viewport {
  1930. /** viewport left coordinate */
  1931. x: number;
  1932. /** viewport top coordinate */
  1933. y: number;
  1934. /**viewport width */
  1935. width: number;
  1936. /** viewport height */
  1937. height: number;
  1938. /**
  1939. * Creates a Viewport object located at (x, y) and sized (width, height)
  1940. * @param x defines viewport left coordinate
  1941. * @param y defines viewport top coordinate
  1942. * @param width defines the viewport width
  1943. * @param height defines the viewport height
  1944. */
  1945. constructor(
  1946. /** viewport left coordinate */
  1947. x: number,
  1948. /** viewport top coordinate */
  1949. y: number,
  1950. /**viewport width */
  1951. width: number,
  1952. /** viewport height */
  1953. height: number);
  1954. /**
  1955. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1956. * @param renderWidth defines the rendering width
  1957. * @param renderHeight defines the rendering height
  1958. * @returns a new Viewport
  1959. */
  1960. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1961. /**
  1962. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1963. * @param renderWidth defines the rendering width
  1964. * @param renderHeight defines the rendering height
  1965. * @param ref defines the target viewport
  1966. * @returns the current viewport
  1967. */
  1968. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1969. /**
  1970. * Returns a new Viewport copied from the current one
  1971. * @returns a new Viewport
  1972. */
  1973. clone(): Viewport;
  1974. }
  1975. }
  1976. declare module "babylonjs/Misc/arrayTools" {
  1977. /**
  1978. * Class containing a set of static utilities functions for arrays.
  1979. */
  1980. export class ArrayTools {
  1981. /**
  1982. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1983. * @param size the number of element to construct and put in the array
  1984. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1985. * @returns a new array filled with new objects
  1986. */
  1987. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1988. }
  1989. }
  1990. declare module "babylonjs/Maths/math.plane" {
  1991. import { DeepImmutable } from "babylonjs/types";
  1992. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1993. /**
  1994. * Represents a plane by the equation ax + by + cz + d = 0
  1995. */
  1996. export class Plane {
  1997. private static _TmpMatrix;
  1998. /**
  1999. * Normal of the plane (a,b,c)
  2000. */
  2001. normal: Vector3;
  2002. /**
  2003. * d component of the plane
  2004. */
  2005. d: number;
  2006. /**
  2007. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2008. * @param a a component of the plane
  2009. * @param b b component of the plane
  2010. * @param c c component of the plane
  2011. * @param d d component of the plane
  2012. */
  2013. constructor(a: number, b: number, c: number, d: number);
  2014. /**
  2015. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2016. */
  2017. asArray(): number[];
  2018. /**
  2019. * @returns a new plane copied from the current Plane.
  2020. */
  2021. clone(): Plane;
  2022. /**
  2023. * @returns the string "Plane".
  2024. */
  2025. getClassName(): string;
  2026. /**
  2027. * @returns the Plane hash code.
  2028. */
  2029. getHashCode(): number;
  2030. /**
  2031. * Normalize the current Plane in place.
  2032. * @returns the updated Plane.
  2033. */
  2034. normalize(): Plane;
  2035. /**
  2036. * Applies a transformation the plane and returns the result
  2037. * @param transformation the transformation matrix to be applied to the plane
  2038. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2039. */
  2040. transform(transformation: DeepImmutable<Matrix>): Plane;
  2041. /**
  2042. * Compute the dot product between the point and the plane normal
  2043. * @param point point to calculate the dot product with
  2044. * @returns the dot product (float) of the point coordinates and the plane normal.
  2045. */
  2046. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2047. /**
  2048. * Updates the current Plane from the plane defined by the three given points.
  2049. * @param point1 one of the points used to contruct the plane
  2050. * @param point2 one of the points used to contruct the plane
  2051. * @param point3 one of the points used to contruct the plane
  2052. * @returns the updated Plane.
  2053. */
  2054. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2055. /**
  2056. * Checks if the plane is facing a given direction
  2057. * @param direction the direction to check if the plane is facing
  2058. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2059. * @returns True is the vector "direction" is the same side than the plane normal.
  2060. */
  2061. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2062. /**
  2063. * Calculates the distance to a point
  2064. * @param point point to calculate distance to
  2065. * @returns the signed distance (float) from the given point to the Plane.
  2066. */
  2067. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2068. /**
  2069. * Creates a plane from an array
  2070. * @param array the array to create a plane from
  2071. * @returns a new Plane from the given array.
  2072. */
  2073. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2074. /**
  2075. * Creates a plane from three points
  2076. * @param point1 point used to create the plane
  2077. * @param point2 point used to create the plane
  2078. * @param point3 point used to create the plane
  2079. * @returns a new Plane defined by the three given points.
  2080. */
  2081. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2082. /**
  2083. * Creates a plane from an origin point and a normal
  2084. * @param origin origin of the plane to be constructed
  2085. * @param normal normal of the plane to be constructed
  2086. * @returns a new Plane the normal vector to this plane at the given origin point.
  2087. * Note : the vector "normal" is updated because normalized.
  2088. */
  2089. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2090. /**
  2091. * Calculates the distance from a plane and a point
  2092. * @param origin origin of the plane to be constructed
  2093. * @param normal normal of the plane to be constructed
  2094. * @param point point to calculate distance to
  2095. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2096. */
  2097. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2098. }
  2099. }
  2100. declare module "babylonjs/Engines/performanceConfigurator" {
  2101. /** @hidden */
  2102. export class PerformanceConfigurator {
  2103. /** @hidden */
  2104. static MatrixUse64Bits: boolean;
  2105. /** @hidden */
  2106. static MatrixTrackPrecisionChange: boolean;
  2107. /** @hidden */
  2108. static MatrixCurrentType: any;
  2109. /** @hidden */
  2110. static MatrixTrackedMatrices: Array<any> | null;
  2111. /** @hidden */
  2112. static SetMatrixPrecision(use64bits: boolean): void;
  2113. }
  2114. }
  2115. declare module "babylonjs/Maths/math.vector" {
  2116. import { Viewport } from "babylonjs/Maths/math.viewport";
  2117. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2118. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2119. import { Plane } from "babylonjs/Maths/math.plane";
  2120. /**
  2121. * Class representing a vector containing 2 coordinates
  2122. */
  2123. export class Vector2 {
  2124. /** defines the first coordinate */
  2125. x: number;
  2126. /** defines the second coordinate */
  2127. y: number;
  2128. /**
  2129. * Creates a new Vector2 from the given x and y coordinates
  2130. * @param x defines the first coordinate
  2131. * @param y defines the second coordinate
  2132. */
  2133. constructor(
  2134. /** defines the first coordinate */
  2135. x?: number,
  2136. /** defines the second coordinate */
  2137. y?: number);
  2138. /**
  2139. * Gets a string with the Vector2 coordinates
  2140. * @returns a string with the Vector2 coordinates
  2141. */
  2142. toString(): string;
  2143. /**
  2144. * Gets class name
  2145. * @returns the string "Vector2"
  2146. */
  2147. getClassName(): string;
  2148. /**
  2149. * Gets current vector hash code
  2150. * @returns the Vector2 hash code as a number
  2151. */
  2152. getHashCode(): number;
  2153. /**
  2154. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2155. * @param array defines the source array
  2156. * @param index defines the offset in source array
  2157. * @returns the current Vector2
  2158. */
  2159. toArray(array: FloatArray, index?: number): Vector2;
  2160. /**
  2161. * Update the current vector from an array
  2162. * @param array defines the destination array
  2163. * @param index defines the offset in the destination array
  2164. * @returns the current Vector3
  2165. */
  2166. fromArray(array: FloatArray, index?: number): Vector2;
  2167. /**
  2168. * Copy the current vector to an array
  2169. * @returns a new array with 2 elements: the Vector2 coordinates.
  2170. */
  2171. asArray(): number[];
  2172. /**
  2173. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2174. * @param source defines the source Vector2
  2175. * @returns the current updated Vector2
  2176. */
  2177. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2178. /**
  2179. * Sets the Vector2 coordinates with the given floats
  2180. * @param x defines the first coordinate
  2181. * @param y defines the second coordinate
  2182. * @returns the current updated Vector2
  2183. */
  2184. copyFromFloats(x: number, y: number): Vector2;
  2185. /**
  2186. * Sets the Vector2 coordinates with the given floats
  2187. * @param x defines the first coordinate
  2188. * @param y defines the second coordinate
  2189. * @returns the current updated Vector2
  2190. */
  2191. set(x: number, y: number): Vector2;
  2192. /**
  2193. * Add another vector with the current one
  2194. * @param otherVector defines the other vector
  2195. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2196. */
  2197. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2198. /**
  2199. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2200. * @param otherVector defines the other vector
  2201. * @param result defines the target vector
  2202. * @returns the unmodified current Vector2
  2203. */
  2204. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2205. /**
  2206. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2207. * @param otherVector defines the other vector
  2208. * @returns the current updated Vector2
  2209. */
  2210. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2211. /**
  2212. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2213. * @param otherVector defines the other vector
  2214. * @returns a new Vector2
  2215. */
  2216. addVector3(otherVector: Vector3): Vector2;
  2217. /**
  2218. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2219. * @param otherVector defines the other vector
  2220. * @returns a new Vector2
  2221. */
  2222. subtract(otherVector: Vector2): Vector2;
  2223. /**
  2224. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2225. * @param otherVector defines the other vector
  2226. * @param result defines the target vector
  2227. * @returns the unmodified current Vector2
  2228. */
  2229. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2230. /**
  2231. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2232. * @param otherVector defines the other vector
  2233. * @returns the current updated Vector2
  2234. */
  2235. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2236. /**
  2237. * Multiplies in place the current Vector2 coordinates by the given ones
  2238. * @param otherVector defines the other vector
  2239. * @returns the current updated Vector2
  2240. */
  2241. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2242. /**
  2243. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2244. * @param otherVector defines the other vector
  2245. * @returns a new Vector2
  2246. */
  2247. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2248. /**
  2249. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2250. * @param otherVector defines the other vector
  2251. * @param result defines the target vector
  2252. * @returns the unmodified current Vector2
  2253. */
  2254. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2255. /**
  2256. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2257. * @param x defines the first coordinate
  2258. * @param y defines the second coordinate
  2259. * @returns a new Vector2
  2260. */
  2261. multiplyByFloats(x: number, y: number): Vector2;
  2262. /**
  2263. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2264. * @param otherVector defines the other vector
  2265. * @returns a new Vector2
  2266. */
  2267. divide(otherVector: Vector2): Vector2;
  2268. /**
  2269. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2270. * @param otherVector defines the other vector
  2271. * @param result defines the target vector
  2272. * @returns the unmodified current Vector2
  2273. */
  2274. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2275. /**
  2276. * Divides the current Vector2 coordinates by the given ones
  2277. * @param otherVector defines the other vector
  2278. * @returns the current updated Vector2
  2279. */
  2280. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2281. /**
  2282. * Gets a new Vector2 with current Vector2 negated coordinates
  2283. * @returns a new Vector2
  2284. */
  2285. negate(): Vector2;
  2286. /**
  2287. * Negate this vector in place
  2288. * @returns this
  2289. */
  2290. negateInPlace(): Vector2;
  2291. /**
  2292. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2293. * @param result defines the Vector3 object where to store the result
  2294. * @returns the current Vector2
  2295. */
  2296. negateToRef(result: Vector2): Vector2;
  2297. /**
  2298. * Multiply the Vector2 coordinates by scale
  2299. * @param scale defines the scaling factor
  2300. * @returns the current updated Vector2
  2301. */
  2302. scaleInPlace(scale: number): Vector2;
  2303. /**
  2304. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2305. * @param scale defines the scaling factor
  2306. * @returns a new Vector2
  2307. */
  2308. scale(scale: number): Vector2;
  2309. /**
  2310. * Scale the current Vector2 values by a factor to a given Vector2
  2311. * @param scale defines the scale factor
  2312. * @param result defines the Vector2 object where to store the result
  2313. * @returns the unmodified current Vector2
  2314. */
  2315. scaleToRef(scale: number, result: Vector2): Vector2;
  2316. /**
  2317. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2318. * @param scale defines the scale factor
  2319. * @param result defines the Vector2 object where to store the result
  2320. * @returns the unmodified current Vector2
  2321. */
  2322. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2323. /**
  2324. * Gets a boolean if two vectors are equals
  2325. * @param otherVector defines the other vector
  2326. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2327. */
  2328. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2329. /**
  2330. * Gets a boolean if two vectors are equals (using an epsilon value)
  2331. * @param otherVector defines the other vector
  2332. * @param epsilon defines the minimal distance to consider equality
  2333. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2334. */
  2335. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2336. /**
  2337. * Gets a new Vector2 from current Vector2 floored values
  2338. * @returns a new Vector2
  2339. */
  2340. floor(): Vector2;
  2341. /**
  2342. * Gets a new Vector2 from current Vector2 floored values
  2343. * @returns a new Vector2
  2344. */
  2345. fract(): Vector2;
  2346. /**
  2347. * Gets the length of the vector
  2348. * @returns the vector length (float)
  2349. */
  2350. length(): number;
  2351. /**
  2352. * Gets the vector squared length
  2353. * @returns the vector squared length (float)
  2354. */
  2355. lengthSquared(): number;
  2356. /**
  2357. * Normalize the vector
  2358. * @returns the current updated Vector2
  2359. */
  2360. normalize(): Vector2;
  2361. /**
  2362. * Gets a new Vector2 copied from the Vector2
  2363. * @returns a new Vector2
  2364. */
  2365. clone(): Vector2;
  2366. /**
  2367. * Gets a new Vector2(0, 0)
  2368. * @returns a new Vector2
  2369. */
  2370. static Zero(): Vector2;
  2371. /**
  2372. * Gets a new Vector2(1, 1)
  2373. * @returns a new Vector2
  2374. */
  2375. static One(): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set from the given index element of the given array
  2378. * @param array defines the data source
  2379. * @param offset defines the offset in the data source
  2380. * @returns a new Vector2
  2381. */
  2382. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2383. /**
  2384. * Sets "result" from the given index element of the given array
  2385. * @param array defines the data source
  2386. * @param offset defines the offset in the data source
  2387. * @param result defines the target vector
  2388. */
  2389. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2390. /**
  2391. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2392. * @param value1 defines 1st point of control
  2393. * @param value2 defines 2nd point of control
  2394. * @param value3 defines 3rd point of control
  2395. * @param value4 defines 4th point of control
  2396. * @param amount defines the interpolation factor
  2397. * @returns a new Vector2
  2398. */
  2399. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2400. /**
  2401. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2402. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2403. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2404. * @param value defines the value to clamp
  2405. * @param min defines the lower limit
  2406. * @param max defines the upper limit
  2407. * @returns a new Vector2
  2408. */
  2409. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2410. /**
  2411. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2412. * @param value1 defines the 1st control point
  2413. * @param tangent1 defines the outgoing tangent
  2414. * @param value2 defines the 2nd control point
  2415. * @param tangent2 defines the incoming tangent
  2416. * @param amount defines the interpolation factor
  2417. * @returns a new Vector2
  2418. */
  2419. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2420. /**
  2421. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2422. * @param start defines the start vector
  2423. * @param end defines the end vector
  2424. * @param amount defines the interpolation factor
  2425. * @returns a new Vector2
  2426. */
  2427. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2428. /**
  2429. * Gets the dot product of the vector "left" and the vector "right"
  2430. * @param left defines first vector
  2431. * @param right defines second vector
  2432. * @returns the dot product (float)
  2433. */
  2434. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2435. /**
  2436. * Returns a new Vector2 equal to the normalized given vector
  2437. * @param vector defines the vector to normalize
  2438. * @returns a new Vector2
  2439. */
  2440. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2441. /**
  2442. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2443. * @param left defines 1st vector
  2444. * @param right defines 2nd vector
  2445. * @returns a new Vector2
  2446. */
  2447. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2448. /**
  2449. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2450. * @param left defines 1st vector
  2451. * @param right defines 2nd vector
  2452. * @returns a new Vector2
  2453. */
  2454. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2455. /**
  2456. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2457. * @param vector defines the vector to transform
  2458. * @param transformation defines the matrix to apply
  2459. * @returns a new Vector2
  2460. */
  2461. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2462. /**
  2463. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2464. * @param vector defines the vector to transform
  2465. * @param transformation defines the matrix to apply
  2466. * @param result defines the target vector
  2467. */
  2468. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2469. /**
  2470. * Determines if a given vector is included in a triangle
  2471. * @param p defines the vector to test
  2472. * @param p0 defines 1st triangle point
  2473. * @param p1 defines 2nd triangle point
  2474. * @param p2 defines 3rd triangle point
  2475. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2476. */
  2477. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2478. /**
  2479. * Gets the distance between the vectors "value1" and "value2"
  2480. * @param value1 defines first vector
  2481. * @param value2 defines second vector
  2482. * @returns the distance between vectors
  2483. */
  2484. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2485. /**
  2486. * Returns the squared distance between the vectors "value1" and "value2"
  2487. * @param value1 defines first vector
  2488. * @param value2 defines second vector
  2489. * @returns the squared distance between vectors
  2490. */
  2491. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2492. /**
  2493. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2494. * @param value1 defines first vector
  2495. * @param value2 defines second vector
  2496. * @returns a new Vector2
  2497. */
  2498. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2499. /**
  2500. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2501. * @param p defines the middle point
  2502. * @param segA defines one point of the segment
  2503. * @param segB defines the other point of the segment
  2504. * @returns the shortest distance
  2505. */
  2506. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2507. }
  2508. /**
  2509. * Class used to store (x,y,z) vector representation
  2510. * A Vector3 is the main object used in 3D geometry
  2511. * It can represent etiher the coordinates of a point the space, either a direction
  2512. * Reminder: js uses a left handed forward facing system
  2513. */
  2514. export class Vector3 {
  2515. private static _UpReadOnly;
  2516. private static _ZeroReadOnly;
  2517. /** @hidden */
  2518. _x: number;
  2519. /** @hidden */
  2520. _y: number;
  2521. /** @hidden */
  2522. _z: number;
  2523. /** @hidden */
  2524. _isDirty: boolean;
  2525. /** Gets or sets the x coordinate */
  2526. get x(): number;
  2527. set x(value: number);
  2528. /** Gets or sets the y coordinate */
  2529. get y(): number;
  2530. set y(value: number);
  2531. /** Gets or sets the z coordinate */
  2532. get z(): number;
  2533. set z(value: number);
  2534. /**
  2535. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2536. * @param x defines the first coordinates (on X axis)
  2537. * @param y defines the second coordinates (on Y axis)
  2538. * @param z defines the third coordinates (on Z axis)
  2539. */
  2540. constructor(x?: number, y?: number, z?: number);
  2541. /**
  2542. * Creates a string representation of the Vector3
  2543. * @returns a string with the Vector3 coordinates.
  2544. */
  2545. toString(): string;
  2546. /**
  2547. * Gets the class name
  2548. * @returns the string "Vector3"
  2549. */
  2550. getClassName(): string;
  2551. /**
  2552. * Creates the Vector3 hash code
  2553. * @returns a number which tends to be unique between Vector3 instances
  2554. */
  2555. getHashCode(): number;
  2556. /**
  2557. * Creates an array containing three elements : the coordinates of the Vector3
  2558. * @returns a new array of numbers
  2559. */
  2560. asArray(): number[];
  2561. /**
  2562. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2563. * @param array defines the destination array
  2564. * @param index defines the offset in the destination array
  2565. * @returns the current Vector3
  2566. */
  2567. toArray(array: FloatArray, index?: number): Vector3;
  2568. /**
  2569. * Update the current vector from an array
  2570. * @param array defines the destination array
  2571. * @param index defines the offset in the destination array
  2572. * @returns the current Vector3
  2573. */
  2574. fromArray(array: FloatArray, index?: number): Vector3;
  2575. /**
  2576. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2577. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2578. */
  2579. toQuaternion(): Quaternion;
  2580. /**
  2581. * Adds the given vector to the current Vector3
  2582. * @param otherVector defines the second operand
  2583. * @returns the current updated Vector3
  2584. */
  2585. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2586. /**
  2587. * Adds the given coordinates to the current Vector3
  2588. * @param x defines the x coordinate of the operand
  2589. * @param y defines the y coordinate of the operand
  2590. * @param z defines the z coordinate of the operand
  2591. * @returns the current updated Vector3
  2592. */
  2593. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2594. /**
  2595. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2596. * @param otherVector defines the second operand
  2597. * @returns the resulting Vector3
  2598. */
  2599. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2600. /**
  2601. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2602. * @param otherVector defines the second operand
  2603. * @param result defines the Vector3 object where to store the result
  2604. * @returns the current Vector3
  2605. */
  2606. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2607. /**
  2608. * Subtract the given vector from the current Vector3
  2609. * @param otherVector defines the second operand
  2610. * @returns the current updated Vector3
  2611. */
  2612. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2613. /**
  2614. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2615. * @param otherVector defines the second operand
  2616. * @returns the resulting Vector3
  2617. */
  2618. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2619. /**
  2620. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2621. * @param otherVector defines the second operand
  2622. * @param result defines the Vector3 object where to store the result
  2623. * @returns the current Vector3
  2624. */
  2625. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2626. /**
  2627. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2628. * @param x defines the x coordinate of the operand
  2629. * @param y defines the y coordinate of the operand
  2630. * @param z defines the z coordinate of the operand
  2631. * @returns the resulting Vector3
  2632. */
  2633. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2634. /**
  2635. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2636. * @param x defines the x coordinate of the operand
  2637. * @param y defines the y coordinate of the operand
  2638. * @param z defines the z coordinate of the operand
  2639. * @param result defines the Vector3 object where to store the result
  2640. * @returns the current Vector3
  2641. */
  2642. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2643. /**
  2644. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2645. * @returns a new Vector3
  2646. */
  2647. negate(): Vector3;
  2648. /**
  2649. * Negate this vector in place
  2650. * @returns this
  2651. */
  2652. negateInPlace(): Vector3;
  2653. /**
  2654. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2655. * @param result defines the Vector3 object where to store the result
  2656. * @returns the current Vector3
  2657. */
  2658. negateToRef(result: Vector3): Vector3;
  2659. /**
  2660. * Multiplies the Vector3 coordinates by the float "scale"
  2661. * @param scale defines the multiplier factor
  2662. * @returns the current updated Vector3
  2663. */
  2664. scaleInPlace(scale: number): Vector3;
  2665. /**
  2666. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2667. * @param scale defines the multiplier factor
  2668. * @returns a new Vector3
  2669. */
  2670. scale(scale: number): Vector3;
  2671. /**
  2672. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2673. * @param scale defines the multiplier factor
  2674. * @param result defines the Vector3 object where to store the result
  2675. * @returns the current Vector3
  2676. */
  2677. scaleToRef(scale: number, result: Vector3): Vector3;
  2678. /**
  2679. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2680. * @param scale defines the scale factor
  2681. * @param result defines the Vector3 object where to store the result
  2682. * @returns the unmodified current Vector3
  2683. */
  2684. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2685. /**
  2686. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2687. * @param origin defines the origin of the projection ray
  2688. * @param plane defines the plane to project to
  2689. * @returns the projected vector3
  2690. */
  2691. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2692. /**
  2693. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2694. * @param origin defines the origin of the projection ray
  2695. * @param plane defines the plane to project to
  2696. * @param result defines the Vector3 where to store the result
  2697. */
  2698. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2699. /**
  2700. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2701. * @param otherVector defines the second operand
  2702. * @returns true if both vectors are equals
  2703. */
  2704. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2705. /**
  2706. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2707. * @param otherVector defines the second operand
  2708. * @param epsilon defines the minimal distance to define values as equals
  2709. * @returns true if both vectors are distant less than epsilon
  2710. */
  2711. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2712. /**
  2713. * Returns true if the current Vector3 coordinates equals the given floats
  2714. * @param x defines the x coordinate of the operand
  2715. * @param y defines the y coordinate of the operand
  2716. * @param z defines the z coordinate of the operand
  2717. * @returns true if both vectors are equals
  2718. */
  2719. equalsToFloats(x: number, y: number, z: number): boolean;
  2720. /**
  2721. * Multiplies the current Vector3 coordinates by the given ones
  2722. * @param otherVector defines the second operand
  2723. * @returns the current updated Vector3
  2724. */
  2725. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2726. /**
  2727. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2728. * @param otherVector defines the second operand
  2729. * @returns the new Vector3
  2730. */
  2731. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2732. /**
  2733. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2734. * @param otherVector defines the second operand
  2735. * @param result defines the Vector3 object where to store the result
  2736. * @returns the current Vector3
  2737. */
  2738. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2741. * @param x defines the x coordinate of the operand
  2742. * @param y defines the y coordinate of the operand
  2743. * @param z defines the z coordinate of the operand
  2744. * @returns the new Vector3
  2745. */
  2746. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2749. * @param otherVector defines the second operand
  2750. * @returns the new Vector3
  2751. */
  2752. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2753. /**
  2754. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2755. * @param otherVector defines the second operand
  2756. * @param result defines the Vector3 object where to store the result
  2757. * @returns the current Vector3
  2758. */
  2759. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2760. /**
  2761. * Divides the current Vector3 coordinates by the given ones.
  2762. * @param otherVector defines the second operand
  2763. * @returns the current updated Vector3
  2764. */
  2765. divideInPlace(otherVector: Vector3): Vector3;
  2766. /**
  2767. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2768. * @param other defines the second operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2772. /**
  2773. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2774. * @param other defines the second operand
  2775. * @returns the current updated Vector3
  2776. */
  2777. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2778. /**
  2779. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2780. * @param x defines the x coordinate of the operand
  2781. * @param y defines the y coordinate of the operand
  2782. * @param z defines the z coordinate of the operand
  2783. * @returns the current updated Vector3
  2784. */
  2785. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2786. /**
  2787. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2788. * @param x defines the x coordinate of the operand
  2789. * @param y defines the y coordinate of the operand
  2790. * @param z defines the z coordinate of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2794. /**
  2795. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2796. * Check if is non uniform within a certain amount of decimal places to account for this
  2797. * @param epsilon the amount the values can differ
  2798. * @returns if the the vector is non uniform to a certain number of decimal places
  2799. */
  2800. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2801. /**
  2802. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2803. */
  2804. get isNonUniform(): boolean;
  2805. /**
  2806. * Gets a new Vector3 from current Vector3 floored values
  2807. * @returns a new Vector3
  2808. */
  2809. floor(): Vector3;
  2810. /**
  2811. * Gets a new Vector3 from current Vector3 floored values
  2812. * @returns a new Vector3
  2813. */
  2814. fract(): Vector3;
  2815. /**
  2816. * Gets the length of the Vector3
  2817. * @returns the length of the Vector3
  2818. */
  2819. length(): number;
  2820. /**
  2821. * Gets the squared length of the Vector3
  2822. * @returns squared length of the Vector3
  2823. */
  2824. lengthSquared(): number;
  2825. /**
  2826. * Normalize the current Vector3.
  2827. * Please note that this is an in place operation.
  2828. * @returns the current updated Vector3
  2829. */
  2830. normalize(): Vector3;
  2831. /**
  2832. * Reorders the x y z properties of the vector in place
  2833. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2834. * @returns the current updated vector
  2835. */
  2836. reorderInPlace(order: string): this;
  2837. /**
  2838. * Rotates the vector around 0,0,0 by a quaternion
  2839. * @param quaternion the rotation quaternion
  2840. * @param result vector to store the result
  2841. * @returns the resulting vector
  2842. */
  2843. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2844. /**
  2845. * Rotates a vector around a given point
  2846. * @param quaternion the rotation quaternion
  2847. * @param point the point to rotate around
  2848. * @param result vector to store the result
  2849. * @returns the resulting vector
  2850. */
  2851. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2852. /**
  2853. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2854. * The cross product is then orthogonal to both current and "other"
  2855. * @param other defines the right operand
  2856. * @returns the cross product
  2857. */
  2858. cross(other: Vector3): Vector3;
  2859. /**
  2860. * Normalize the current Vector3 with the given input length.
  2861. * Please note that this is an in place operation.
  2862. * @param len the length of the vector
  2863. * @returns the current updated Vector3
  2864. */
  2865. normalizeFromLength(len: number): Vector3;
  2866. /**
  2867. * Normalize the current Vector3 to a new vector
  2868. * @returns the new Vector3
  2869. */
  2870. normalizeToNew(): Vector3;
  2871. /**
  2872. * Normalize the current Vector3 to the reference
  2873. * @param reference define the Vector3 to update
  2874. * @returns the updated Vector3
  2875. */
  2876. normalizeToRef(reference: Vector3): Vector3;
  2877. /**
  2878. * Creates a new Vector3 copied from the current Vector3
  2879. * @returns the new Vector3
  2880. */
  2881. clone(): Vector3;
  2882. /**
  2883. * Copies the given vector coordinates to the current Vector3 ones
  2884. * @param source defines the source Vector3
  2885. * @returns the current updated Vector3
  2886. */
  2887. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2888. /**
  2889. * Copies the given floats to the current Vector3 coordinates
  2890. * @param x defines the x coordinate of the operand
  2891. * @param y defines the y coordinate of the operand
  2892. * @param z defines the z coordinate of the operand
  2893. * @returns the current updated Vector3
  2894. */
  2895. copyFromFloats(x: number, y: number, z: number): Vector3;
  2896. /**
  2897. * Copies the given floats to the current Vector3 coordinates
  2898. * @param x defines the x coordinate of the operand
  2899. * @param y defines the y coordinate of the operand
  2900. * @param z defines the z coordinate of the operand
  2901. * @returns the current updated Vector3
  2902. */
  2903. set(x: number, y: number, z: number): Vector3;
  2904. /**
  2905. * Copies the given float to the current Vector3 coordinates
  2906. * @param v defines the x, y and z coordinates of the operand
  2907. * @returns the current updated Vector3
  2908. */
  2909. setAll(v: number): Vector3;
  2910. /**
  2911. * Get the clip factor between two vectors
  2912. * @param vector0 defines the first operand
  2913. * @param vector1 defines the second operand
  2914. * @param axis defines the axis to use
  2915. * @param size defines the size along the axis
  2916. * @returns the clip factor
  2917. */
  2918. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2919. /**
  2920. * Get angle between two vectors
  2921. * @param vector0 angle between vector0 and vector1
  2922. * @param vector1 angle between vector0 and vector1
  2923. * @param normal direction of the normal
  2924. * @return the angle between vector0 and vector1
  2925. */
  2926. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2927. /**
  2928. * Returns a new Vector3 set from the index "offset" of the given array
  2929. * @param array defines the source array
  2930. * @param offset defines the offset in the source array
  2931. * @returns the new Vector3
  2932. */
  2933. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2936. * @param array defines the source array
  2937. * @param offset defines the offset in the source array
  2938. * @returns the new Vector3
  2939. * @deprecated Please use FromArray instead.
  2940. */
  2941. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2942. /**
  2943. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2944. * @param array defines the source array
  2945. * @param offset defines the offset in the source array
  2946. * @param result defines the Vector3 where to store the result
  2947. */
  2948. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2949. /**
  2950. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2951. * @param array defines the source array
  2952. * @param offset defines the offset in the source array
  2953. * @param result defines the Vector3 where to store the result
  2954. * @deprecated Please use FromArrayToRef instead.
  2955. */
  2956. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2957. /**
  2958. * Sets the given vector "result" with the given floats.
  2959. * @param x defines the x coordinate of the source
  2960. * @param y defines the y coordinate of the source
  2961. * @param z defines the z coordinate of the source
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2967. * @returns a new empty Vector3
  2968. */
  2969. static Zero(): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2972. * @returns a new unit Vector3
  2973. */
  2974. static One(): Vector3;
  2975. /**
  2976. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2977. * @returns a new up Vector3
  2978. */
  2979. static Up(): Vector3;
  2980. /**
  2981. * Gets a up Vector3 that must not be updated
  2982. */
  2983. static get UpReadOnly(): DeepImmutable<Vector3>;
  2984. /**
  2985. * Gets a zero Vector3 that must not be updated
  2986. */
  2987. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2988. /**
  2989. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2990. * @returns a new down Vector3
  2991. */
  2992. static Down(): Vector3;
  2993. /**
  2994. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2995. * @param rightHandedSystem is the scene right-handed (negative z)
  2996. * @returns a new forward Vector3
  2997. */
  2998. static Forward(rightHandedSystem?: boolean): Vector3;
  2999. /**
  3000. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3001. * @param rightHandedSystem is the scene right-handed (negative-z)
  3002. * @returns a new forward Vector3
  3003. */
  3004. static Backward(rightHandedSystem?: boolean): Vector3;
  3005. /**
  3006. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3007. * @returns a new right Vector3
  3008. */
  3009. static Right(): Vector3;
  3010. /**
  3011. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3012. * @returns a new left Vector3
  3013. */
  3014. static Left(): Vector3;
  3015. /**
  3016. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3017. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3018. * @param vector defines the Vector3 to transform
  3019. * @param transformation defines the transformation matrix
  3020. * @returns the transformed Vector3
  3021. */
  3022. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3023. /**
  3024. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3025. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3026. * @param vector defines the Vector3 to transform
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3033. * This method computes tranformed coordinates only, not transformed direction vectors
  3034. * @param x define the x coordinate of the source vector
  3035. * @param y define the y coordinate of the source vector
  3036. * @param z define the z coordinate of the source vector
  3037. * @param transformation defines the transformation matrix
  3038. * @param result defines the Vector3 where to store the result
  3039. */
  3040. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3041. /**
  3042. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3043. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3044. * @param vector defines the Vector3 to transform
  3045. * @param transformation defines the transformation matrix
  3046. * @returns the new Vector3
  3047. */
  3048. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3049. /**
  3050. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3051. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3052. * @param vector defines the Vector3 to transform
  3053. * @param transformation defines the transformation matrix
  3054. * @param result defines the Vector3 where to store the result
  3055. */
  3056. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3057. /**
  3058. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3059. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3060. * @param x define the x coordinate of the source vector
  3061. * @param y define the y coordinate of the source vector
  3062. * @param z define the z coordinate of the source vector
  3063. * @param transformation defines the transformation matrix
  3064. * @param result defines the Vector3 where to store the result
  3065. */
  3066. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3067. /**
  3068. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3069. * @param value1 defines the first control point
  3070. * @param value2 defines the second control point
  3071. * @param value3 defines the third control point
  3072. * @param value4 defines the fourth control point
  3073. * @param amount defines the amount on the spline to use
  3074. * @returns the new Vector3
  3075. */
  3076. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3077. /**
  3078. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3079. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3080. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3081. * @param value defines the current value
  3082. * @param min defines the lower range value
  3083. * @param max defines the upper range value
  3084. * @returns the new Vector3
  3085. */
  3086. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3087. /**
  3088. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3089. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3090. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3091. * @param value defines the current value
  3092. * @param min defines the lower range value
  3093. * @param max defines the upper range value
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3097. /**
  3098. * Checks if a given vector is inside a specific range
  3099. * @param v defines the vector to test
  3100. * @param min defines the minimum range
  3101. * @param max defines the maximum range
  3102. */
  3103. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3104. /**
  3105. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3106. * @param value1 defines the first control point
  3107. * @param tangent1 defines the first tangent vector
  3108. * @param value2 defines the second control point
  3109. * @param tangent2 defines the second tangent vector
  3110. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3111. * @returns the new Vector3
  3112. */
  3113. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3114. /**
  3115. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3116. * @param start defines the start value
  3117. * @param end defines the end value
  3118. * @param amount max defines amount between both (between 0 and 1)
  3119. * @returns the new Vector3
  3120. */
  3121. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3122. /**
  3123. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3124. * @param start defines the start value
  3125. * @param end defines the end value
  3126. * @param amount max defines amount between both (between 0 and 1)
  3127. * @param result defines the Vector3 where to store the result
  3128. */
  3129. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3130. /**
  3131. * Returns the dot product (float) between the vectors "left" and "right"
  3132. * @param left defines the left operand
  3133. * @param right defines the right operand
  3134. * @returns the dot product
  3135. */
  3136. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3137. /**
  3138. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3139. * The cross product is then orthogonal to both "left" and "right"
  3140. * @param left defines the left operand
  3141. * @param right defines the right operand
  3142. * @returns the cross product
  3143. */
  3144. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3145. /**
  3146. * Sets the given vector "result" with the cross product of "left" and "right"
  3147. * The cross product is then orthogonal to both "left" and "right"
  3148. * @param left defines the left operand
  3149. * @param right defines the right operand
  3150. * @param result defines the Vector3 where to store the result
  3151. */
  3152. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3153. /**
  3154. * Returns a new Vector3 as the normalization of the given vector
  3155. * @param vector defines the Vector3 to normalize
  3156. * @returns the new Vector3
  3157. */
  3158. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3159. /**
  3160. * Sets the given vector "result" with the normalization of the given first vector
  3161. * @param vector defines the Vector3 to normalize
  3162. * @param result defines the Vector3 where to store the result
  3163. */
  3164. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3165. /**
  3166. * Project a Vector3 onto screen space
  3167. * @param vector defines the Vector3 to project
  3168. * @param world defines the world matrix to use
  3169. * @param transform defines the transform (view x projection) matrix to use
  3170. * @param viewport defines the screen viewport to use
  3171. * @returns the new Vector3
  3172. */
  3173. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3174. /** @hidden */
  3175. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3176. /**
  3177. * Unproject from screen space to object space
  3178. * @param source defines the screen space Vector3 to use
  3179. * @param viewportWidth defines the current width of the viewport
  3180. * @param viewportHeight defines the current height of the viewport
  3181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3182. * @param transform defines the transform (view x projection) matrix to use
  3183. * @returns the new Vector3
  3184. */
  3185. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3186. /**
  3187. * Unproject from screen space to object space
  3188. * @param source defines the screen space Vector3 to use
  3189. * @param viewportWidth defines the current width of the viewport
  3190. * @param viewportHeight defines the current height of the viewport
  3191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3192. * @param view defines the view matrix to use
  3193. * @param projection defines the projection matrix to use
  3194. * @returns the new Vector3
  3195. */
  3196. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3197. /**
  3198. * Unproject from screen space to object space
  3199. * @param source defines the screen space Vector3 to use
  3200. * @param viewportWidth defines the current width of the viewport
  3201. * @param viewportHeight defines the current height of the viewport
  3202. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3203. * @param view defines the view matrix to use
  3204. * @param projection defines the projection matrix to use
  3205. * @param result defines the Vector3 where to store the result
  3206. */
  3207. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3208. /**
  3209. * Unproject from screen space to object space
  3210. * @param sourceX defines the screen space x coordinate to use
  3211. * @param sourceY defines the screen space y coordinate to use
  3212. * @param sourceZ defines the screen space z coordinate to use
  3213. * @param viewportWidth defines the current width of the viewport
  3214. * @param viewportHeight defines the current height of the viewport
  3215. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3216. * @param view defines the view matrix to use
  3217. * @param projection defines the projection matrix to use
  3218. * @param result defines the Vector3 where to store the result
  3219. */
  3220. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3221. /**
  3222. * Gets the minimal coordinate values between two Vector3
  3223. * @param left defines the first operand
  3224. * @param right defines the second operand
  3225. * @returns the new Vector3
  3226. */
  3227. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3228. /**
  3229. * Gets the maximal coordinate values between two Vector3
  3230. * @param left defines the first operand
  3231. * @param right defines the second operand
  3232. * @returns the new Vector3
  3233. */
  3234. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3235. /**
  3236. * Returns the distance between the vectors "value1" and "value2"
  3237. * @param value1 defines the first operand
  3238. * @param value2 defines the second operand
  3239. * @returns the distance
  3240. */
  3241. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3242. /**
  3243. * Returns the squared distance between the vectors "value1" and "value2"
  3244. * @param value1 defines the first operand
  3245. * @param value2 defines the second operand
  3246. * @returns the squared distance
  3247. */
  3248. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3249. /**
  3250. * Returns a new Vector3 located at the center between "value1" and "value2"
  3251. * @param value1 defines the first operand
  3252. * @param value2 defines the second operand
  3253. * @returns the new Vector3
  3254. */
  3255. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3256. /**
  3257. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3258. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3259. * to something in order to rotate it from its local system to the given target system
  3260. * Note: axis1, axis2 and axis3 are normalized during this operation
  3261. * @param axis1 defines the first axis
  3262. * @param axis2 defines the second axis
  3263. * @param axis3 defines the third axis
  3264. * @returns a new Vector3
  3265. */
  3266. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3267. /**
  3268. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3269. * @param axis1 defines the first axis
  3270. * @param axis2 defines the second axis
  3271. * @param axis3 defines the third axis
  3272. * @param ref defines the Vector3 where to store the result
  3273. */
  3274. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3275. }
  3276. /**
  3277. * Vector4 class created for EulerAngle class conversion to Quaternion
  3278. */
  3279. export class Vector4 {
  3280. /** x value of the vector */
  3281. x: number;
  3282. /** y value of the vector */
  3283. y: number;
  3284. /** z value of the vector */
  3285. z: number;
  3286. /** w value of the vector */
  3287. w: number;
  3288. /**
  3289. * Creates a Vector4 object from the given floats.
  3290. * @param x x value of the vector
  3291. * @param y y value of the vector
  3292. * @param z z value of the vector
  3293. * @param w w value of the vector
  3294. */
  3295. constructor(
  3296. /** x value of the vector */
  3297. x: number,
  3298. /** y value of the vector */
  3299. y: number,
  3300. /** z value of the vector */
  3301. z: number,
  3302. /** w value of the vector */
  3303. w: number);
  3304. /**
  3305. * Returns the string with the Vector4 coordinates.
  3306. * @returns a string containing all the vector values
  3307. */
  3308. toString(): string;
  3309. /**
  3310. * Returns the string "Vector4".
  3311. * @returns "Vector4"
  3312. */
  3313. getClassName(): string;
  3314. /**
  3315. * Returns the Vector4 hash code.
  3316. * @returns a unique hash code
  3317. */
  3318. getHashCode(): number;
  3319. /**
  3320. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3321. * @returns the resulting array
  3322. */
  3323. asArray(): number[];
  3324. /**
  3325. * Populates the given array from the given index with the Vector4 coordinates.
  3326. * @param array array to populate
  3327. * @param index index of the array to start at (default: 0)
  3328. * @returns the Vector4.
  3329. */
  3330. toArray(array: FloatArray, index?: number): Vector4;
  3331. /**
  3332. * Update the current vector from an array
  3333. * @param array defines the destination array
  3334. * @param index defines the offset in the destination array
  3335. * @returns the current Vector3
  3336. */
  3337. fromArray(array: FloatArray, index?: number): Vector4;
  3338. /**
  3339. * Adds the given vector to the current Vector4.
  3340. * @param otherVector the vector to add
  3341. * @returns the updated Vector4.
  3342. */
  3343. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3344. /**
  3345. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3346. * @param otherVector the vector to add
  3347. * @returns the resulting vector
  3348. */
  3349. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3350. /**
  3351. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3352. * @param otherVector the vector to add
  3353. * @param result the vector to store the result
  3354. * @returns the current Vector4.
  3355. */
  3356. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3357. /**
  3358. * Subtract in place the given vector from the current Vector4.
  3359. * @param otherVector the vector to subtract
  3360. * @returns the updated Vector4.
  3361. */
  3362. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3365. * @param otherVector the vector to add
  3366. * @returns the new vector with the result
  3367. */
  3368. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3369. /**
  3370. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3371. * @param otherVector the vector to subtract
  3372. * @param result the vector to store the result
  3373. * @returns the current Vector4.
  3374. */
  3375. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3376. /**
  3377. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3378. */
  3379. /**
  3380. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3381. * @param x value to subtract
  3382. * @param y value to subtract
  3383. * @param z value to subtract
  3384. * @param w value to subtract
  3385. * @returns new vector containing the result
  3386. */
  3387. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3388. /**
  3389. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3390. * @param x value to subtract
  3391. * @param y value to subtract
  3392. * @param z value to subtract
  3393. * @param w value to subtract
  3394. * @param result the vector to store the result in
  3395. * @returns the current Vector4.
  3396. */
  3397. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3398. /**
  3399. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3400. * @returns a new vector with the negated values
  3401. */
  3402. negate(): Vector4;
  3403. /**
  3404. * Negate this vector in place
  3405. * @returns this
  3406. */
  3407. negateInPlace(): Vector4;
  3408. /**
  3409. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3410. * @param result defines the Vector3 object where to store the result
  3411. * @returns the current Vector4
  3412. */
  3413. negateToRef(result: Vector4): Vector4;
  3414. /**
  3415. * Multiplies the current Vector4 coordinates by scale (float).
  3416. * @param scale the number to scale with
  3417. * @returns the updated Vector4.
  3418. */
  3419. scaleInPlace(scale: number): Vector4;
  3420. /**
  3421. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3422. * @param scale the number to scale with
  3423. * @returns a new vector with the result
  3424. */
  3425. scale(scale: number): Vector4;
  3426. /**
  3427. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3428. * @param scale the number to scale with
  3429. * @param result a vector to store the result in
  3430. * @returns the current Vector4.
  3431. */
  3432. scaleToRef(scale: number, result: Vector4): Vector4;
  3433. /**
  3434. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3435. * @param scale defines the scale factor
  3436. * @param result defines the Vector4 object where to store the result
  3437. * @returns the unmodified current Vector4
  3438. */
  3439. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3440. /**
  3441. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3442. * @param otherVector the vector to compare against
  3443. * @returns true if they are equal
  3444. */
  3445. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3446. /**
  3447. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3448. * @param otherVector vector to compare against
  3449. * @param epsilon (Default: very small number)
  3450. * @returns true if they are equal
  3451. */
  3452. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3453. /**
  3454. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3455. * @param x x value to compare against
  3456. * @param y y value to compare against
  3457. * @param z z value to compare against
  3458. * @param w w value to compare against
  3459. * @returns true if equal
  3460. */
  3461. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3462. /**
  3463. * Multiplies in place the current Vector4 by the given one.
  3464. * @param otherVector vector to multiple with
  3465. * @returns the updated Vector4.
  3466. */
  3467. multiplyInPlace(otherVector: Vector4): Vector4;
  3468. /**
  3469. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3470. * @param otherVector vector to multiple with
  3471. * @returns resulting new vector
  3472. */
  3473. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3474. /**
  3475. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3476. * @param otherVector vector to multiple with
  3477. * @param result vector to store the result
  3478. * @returns the current Vector4.
  3479. */
  3480. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3481. /**
  3482. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3483. * @param x x value multiply with
  3484. * @param y y value multiply with
  3485. * @param z z value multiply with
  3486. * @param w w value multiply with
  3487. * @returns resulting new vector
  3488. */
  3489. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3490. /**
  3491. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3492. * @param otherVector vector to devide with
  3493. * @returns resulting new vector
  3494. */
  3495. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3496. /**
  3497. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3498. * @param otherVector vector to devide with
  3499. * @param result vector to store the result
  3500. * @returns the current Vector4.
  3501. */
  3502. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3503. /**
  3504. * Divides the current Vector3 coordinates by the given ones.
  3505. * @param otherVector vector to devide with
  3506. * @returns the updated Vector3.
  3507. */
  3508. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3509. /**
  3510. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3511. * @param other defines the second operand
  3512. * @returns the current updated Vector4
  3513. */
  3514. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3515. /**
  3516. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3517. * @param other defines the second operand
  3518. * @returns the current updated Vector4
  3519. */
  3520. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3521. /**
  3522. * Gets a new Vector4 from current Vector4 floored values
  3523. * @returns a new Vector4
  3524. */
  3525. floor(): Vector4;
  3526. /**
  3527. * Gets a new Vector4 from current Vector3 floored values
  3528. * @returns a new Vector4
  3529. */
  3530. fract(): Vector4;
  3531. /**
  3532. * Returns the Vector4 length (float).
  3533. * @returns the length
  3534. */
  3535. length(): number;
  3536. /**
  3537. * Returns the Vector4 squared length (float).
  3538. * @returns the length squared
  3539. */
  3540. lengthSquared(): number;
  3541. /**
  3542. * Normalizes in place the Vector4.
  3543. * @returns the updated Vector4.
  3544. */
  3545. normalize(): Vector4;
  3546. /**
  3547. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3548. * @returns this converted to a new vector3
  3549. */
  3550. toVector3(): Vector3;
  3551. /**
  3552. * Returns a new Vector4 copied from the current one.
  3553. * @returns the new cloned vector
  3554. */
  3555. clone(): Vector4;
  3556. /**
  3557. * Updates the current Vector4 with the given one coordinates.
  3558. * @param source the source vector to copy from
  3559. * @returns the updated Vector4.
  3560. */
  3561. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Updates the current Vector4 coordinates with the given floats.
  3564. * @param x float to copy from
  3565. * @param y float to copy from
  3566. * @param z float to copy from
  3567. * @param w float to copy from
  3568. * @returns the updated Vector4.
  3569. */
  3570. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3571. /**
  3572. * Updates the current Vector4 coordinates with the given floats.
  3573. * @param x float to set from
  3574. * @param y float to set from
  3575. * @param z float to set from
  3576. * @param w float to set from
  3577. * @returns the updated Vector4.
  3578. */
  3579. set(x: number, y: number, z: number, w: number): Vector4;
  3580. /**
  3581. * Copies the given float to the current Vector3 coordinates
  3582. * @param v defines the x, y, z and w coordinates of the operand
  3583. * @returns the current updated Vector3
  3584. */
  3585. setAll(v: number): Vector4;
  3586. /**
  3587. * Returns a new Vector4 set from the starting index of the given array.
  3588. * @param array the array to pull values from
  3589. * @param offset the offset into the array to start at
  3590. * @returns the new vector
  3591. */
  3592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3593. /**
  3594. * Updates the given vector "result" from the starting index of the given array.
  3595. * @param array the array to pull values from
  3596. * @param offset the offset into the array to start at
  3597. * @param result the vector to store the result in
  3598. */
  3599. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3600. /**
  3601. * Updates the given vector "result" from the starting index of the given Float32Array.
  3602. * @param array the array to pull values from
  3603. * @param offset the offset into the array to start at
  3604. * @param result the vector to store the result in
  3605. */
  3606. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3607. /**
  3608. * Updates the given vector "result" coordinates from the given floats.
  3609. * @param x float to set from
  3610. * @param y float to set from
  3611. * @param z float to set from
  3612. * @param w float to set from
  3613. * @param result the vector to the floats in
  3614. */
  3615. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3616. /**
  3617. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3618. * @returns the new vector
  3619. */
  3620. static Zero(): Vector4;
  3621. /**
  3622. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3623. * @returns the new vector
  3624. */
  3625. static One(): Vector4;
  3626. /**
  3627. * Returns a new normalized Vector4 from the given one.
  3628. * @param vector the vector to normalize
  3629. * @returns the vector
  3630. */
  3631. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3632. /**
  3633. * Updates the given vector "result" from the normalization of the given one.
  3634. * @param vector the vector to normalize
  3635. * @param result the vector to store the result in
  3636. */
  3637. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3638. /**
  3639. * Returns a vector with the minimum values from the left and right vectors
  3640. * @param left left vector to minimize
  3641. * @param right right vector to minimize
  3642. * @returns a new vector with the minimum of the left and right vector values
  3643. */
  3644. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3645. /**
  3646. * Returns a vector with the maximum values from the left and right vectors
  3647. * @param left left vector to maximize
  3648. * @param right right vector to maximize
  3649. * @returns a new vector with the maximum of the left and right vector values
  3650. */
  3651. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3652. /**
  3653. * Returns the distance (float) between the vectors "value1" and "value2".
  3654. * @param value1 value to calulate the distance between
  3655. * @param value2 value to calulate the distance between
  3656. * @return the distance between the two vectors
  3657. */
  3658. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3659. /**
  3660. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3661. * @param value1 value to calulate the distance between
  3662. * @param value2 value to calulate the distance between
  3663. * @return the distance between the two vectors squared
  3664. */
  3665. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3666. /**
  3667. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3668. * @param value1 value to calulate the center between
  3669. * @param value2 value to calulate the center between
  3670. * @return the center between the two vectors
  3671. */
  3672. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3673. /**
  3674. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3675. * This methods computes transformed normalized direction vectors only.
  3676. * @param vector the vector to transform
  3677. * @param transformation the transformation matrix to apply
  3678. * @returns the new vector
  3679. */
  3680. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3681. /**
  3682. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3683. * This methods computes transformed normalized direction vectors only.
  3684. * @param vector the vector to transform
  3685. * @param transformation the transformation matrix to apply
  3686. * @param result the vector to store the result in
  3687. */
  3688. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3689. /**
  3690. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3691. * This methods computes transformed normalized direction vectors only.
  3692. * @param x value to transform
  3693. * @param y value to transform
  3694. * @param z value to transform
  3695. * @param w value to transform
  3696. * @param transformation the transformation matrix to apply
  3697. * @param result the vector to store the results in
  3698. */
  3699. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3700. /**
  3701. * Creates a new Vector4 from a Vector3
  3702. * @param source defines the source data
  3703. * @param w defines the 4th component (default is 0)
  3704. * @returns a new Vector4
  3705. */
  3706. static FromVector3(source: Vector3, w?: number): Vector4;
  3707. }
  3708. /**
  3709. * Class used to store quaternion data
  3710. * @see https://en.wikipedia.org/wiki/Quaternion
  3711. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3712. */
  3713. export class Quaternion {
  3714. /** @hidden */
  3715. _x: number;
  3716. /** @hidden */
  3717. _y: number;
  3718. /** @hidden */
  3719. _z: number;
  3720. /** @hidden */
  3721. _w: number;
  3722. /** @hidden */
  3723. _isDirty: boolean;
  3724. /** Gets or sets the x coordinate */
  3725. get x(): number;
  3726. set x(value: number);
  3727. /** Gets or sets the y coordinate */
  3728. get y(): number;
  3729. set y(value: number);
  3730. /** Gets or sets the z coordinate */
  3731. get z(): number;
  3732. set z(value: number);
  3733. /** Gets or sets the w coordinate */
  3734. get w(): number;
  3735. set w(value: number);
  3736. /**
  3737. * Creates a new Quaternion from the given floats
  3738. * @param x defines the first component (0 by default)
  3739. * @param y defines the second component (0 by default)
  3740. * @param z defines the third component (0 by default)
  3741. * @param w defines the fourth component (1.0 by default)
  3742. */
  3743. constructor(x?: number, y?: number, z?: number, w?: number);
  3744. /**
  3745. * Gets a string representation for the current quaternion
  3746. * @returns a string with the Quaternion coordinates
  3747. */
  3748. toString(): string;
  3749. /**
  3750. * Gets the class name of the quaternion
  3751. * @returns the string "Quaternion"
  3752. */
  3753. getClassName(): string;
  3754. /**
  3755. * Gets a hash code for this quaternion
  3756. * @returns the quaternion hash code
  3757. */
  3758. getHashCode(): number;
  3759. /**
  3760. * Copy the quaternion to an array
  3761. * @returns a new array populated with 4 elements from the quaternion coordinates
  3762. */
  3763. asArray(): number[];
  3764. /**
  3765. * Check if two quaternions are equals
  3766. * @param otherQuaternion defines the second operand
  3767. * @return true if the current quaternion and the given one coordinates are strictly equals
  3768. */
  3769. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3770. /**
  3771. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3772. * @param otherQuaternion defines the other quaternion
  3773. * @param epsilon defines the minimal distance to consider equality
  3774. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3775. */
  3776. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3777. /**
  3778. * Clone the current quaternion
  3779. * @returns a new quaternion copied from the current one
  3780. */
  3781. clone(): Quaternion;
  3782. /**
  3783. * Copy a quaternion to the current one
  3784. * @param other defines the other quaternion
  3785. * @returns the updated current quaternion
  3786. */
  3787. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Updates the current quaternion with the given float coordinates
  3790. * @param x defines the x coordinate
  3791. * @param y defines the y coordinate
  3792. * @param z defines the z coordinate
  3793. * @param w defines the w coordinate
  3794. * @returns the updated current quaternion
  3795. */
  3796. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3797. /**
  3798. * Updates the current quaternion from the given float coordinates
  3799. * @param x defines the x coordinate
  3800. * @param y defines the y coordinate
  3801. * @param z defines the z coordinate
  3802. * @param w defines the w coordinate
  3803. * @returns the updated current quaternion
  3804. */
  3805. set(x: number, y: number, z: number, w: number): Quaternion;
  3806. /**
  3807. * Adds two quaternions
  3808. * @param other defines the second operand
  3809. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3810. */
  3811. add(other: DeepImmutable<Quaternion>): Quaternion;
  3812. /**
  3813. * Add a quaternion to the current one
  3814. * @param other defines the quaternion to add
  3815. * @returns the current quaternion
  3816. */
  3817. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3818. /**
  3819. * Subtract two quaternions
  3820. * @param other defines the second operand
  3821. * @returns a new quaternion as the subtraction result of the given one from the current one
  3822. */
  3823. subtract(other: Quaternion): Quaternion;
  3824. /**
  3825. * Multiplies the current quaternion by a scale factor
  3826. * @param value defines the scale factor
  3827. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3828. */
  3829. scale(value: number): Quaternion;
  3830. /**
  3831. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3832. * @param scale defines the scale factor
  3833. * @param result defines the Quaternion object where to store the result
  3834. * @returns the unmodified current quaternion
  3835. */
  3836. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3837. /**
  3838. * Multiplies in place the current quaternion by a scale factor
  3839. * @param value defines the scale factor
  3840. * @returns the current modified quaternion
  3841. */
  3842. scaleInPlace(value: number): Quaternion;
  3843. /**
  3844. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3845. * @param scale defines the scale factor
  3846. * @param result defines the Quaternion object where to store the result
  3847. * @returns the unmodified current quaternion
  3848. */
  3849. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3850. /**
  3851. * Multiplies two quaternions
  3852. * @param q1 defines the second operand
  3853. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3854. */
  3855. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3856. /**
  3857. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3858. * @param q1 defines the second operand
  3859. * @param result defines the target quaternion
  3860. * @returns the current quaternion
  3861. */
  3862. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3863. /**
  3864. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3865. * @param q1 defines the second operand
  3866. * @returns the currentupdated quaternion
  3867. */
  3868. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3869. /**
  3870. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3871. * @param ref defines the target quaternion
  3872. * @returns the current quaternion
  3873. */
  3874. conjugateToRef(ref: Quaternion): Quaternion;
  3875. /**
  3876. * Conjugates in place (1-q) the current quaternion
  3877. * @returns the current updated quaternion
  3878. */
  3879. conjugateInPlace(): Quaternion;
  3880. /**
  3881. * Conjugates in place (1-q) the current quaternion
  3882. * @returns a new quaternion
  3883. */
  3884. conjugate(): Quaternion;
  3885. /**
  3886. * Gets length of current quaternion
  3887. * @returns the quaternion length (float)
  3888. */
  3889. length(): number;
  3890. /**
  3891. * Normalize in place the current quaternion
  3892. * @returns the current updated quaternion
  3893. */
  3894. normalize(): Quaternion;
  3895. /**
  3896. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3897. * @param order is a reserved parameter and is ignored for now
  3898. * @returns a new Vector3 containing the Euler angles
  3899. */
  3900. toEulerAngles(order?: string): Vector3;
  3901. /**
  3902. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3903. * @param result defines the vector which will be filled with the Euler angles
  3904. * @returns the current unchanged quaternion
  3905. */
  3906. toEulerAnglesToRef(result: Vector3): Quaternion;
  3907. /**
  3908. * Updates the given rotation matrix with the current quaternion values
  3909. * @param result defines the target matrix
  3910. * @returns the current unchanged quaternion
  3911. */
  3912. toRotationMatrix(result: Matrix): Quaternion;
  3913. /**
  3914. * Updates the current quaternion from the given rotation matrix values
  3915. * @param matrix defines the source matrix
  3916. * @returns the current updated quaternion
  3917. */
  3918. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3919. /**
  3920. * Creates a new quaternion from a rotation matrix
  3921. * @param matrix defines the source matrix
  3922. * @returns a new quaternion created from the given rotation matrix values
  3923. */
  3924. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3925. /**
  3926. * Updates the given quaternion with the given rotation matrix values
  3927. * @param matrix defines the source matrix
  3928. * @param result defines the target quaternion
  3929. */
  3930. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3931. /**
  3932. * Returns the dot product (float) between the quaternions "left" and "right"
  3933. * @param left defines the left operand
  3934. * @param right defines the right operand
  3935. * @returns the dot product
  3936. */
  3937. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3938. /**
  3939. * Checks if the two quaternions are close to each other
  3940. * @param quat0 defines the first quaternion to check
  3941. * @param quat1 defines the second quaternion to check
  3942. * @returns true if the two quaternions are close to each other
  3943. */
  3944. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3945. /**
  3946. * Creates an empty quaternion
  3947. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3948. */
  3949. static Zero(): Quaternion;
  3950. /**
  3951. * Inverse a given quaternion
  3952. * @param q defines the source quaternion
  3953. * @returns a new quaternion as the inverted current quaternion
  3954. */
  3955. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3956. /**
  3957. * Inverse a given quaternion
  3958. * @param q defines the source quaternion
  3959. * @param result the quaternion the result will be stored in
  3960. * @returns the result quaternion
  3961. */
  3962. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3963. /**
  3964. * Creates an identity quaternion
  3965. * @returns the identity quaternion
  3966. */
  3967. static Identity(): Quaternion;
  3968. /**
  3969. * Gets a boolean indicating if the given quaternion is identity
  3970. * @param quaternion defines the quaternion to check
  3971. * @returns true if the quaternion is identity
  3972. */
  3973. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3974. /**
  3975. * Creates a quaternion from a rotation around an axis
  3976. * @param axis defines the axis to use
  3977. * @param angle defines the angle to use
  3978. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3979. */
  3980. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3981. /**
  3982. * Creates a rotation around an axis and stores it into the given quaternion
  3983. * @param axis defines the axis to use
  3984. * @param angle defines the angle to use
  3985. * @param result defines the target quaternion
  3986. * @returns the target quaternion
  3987. */
  3988. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3989. /**
  3990. * Creates a new quaternion from data stored into an array
  3991. * @param array defines the data source
  3992. * @param offset defines the offset in the source array where the data starts
  3993. * @returns a new quaternion
  3994. */
  3995. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3996. /**
  3997. * Updates the given quaternion "result" from the starting index of the given array.
  3998. * @param array the array to pull values from
  3999. * @param offset the offset into the array to start at
  4000. * @param result the quaternion to store the result in
  4001. */
  4002. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4003. /**
  4004. * Create a quaternion from Euler rotation angles
  4005. * @param x Pitch
  4006. * @param y Yaw
  4007. * @param z Roll
  4008. * @returns the new Quaternion
  4009. */
  4010. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4011. /**
  4012. * Updates a quaternion from Euler rotation angles
  4013. * @param x Pitch
  4014. * @param y Yaw
  4015. * @param z Roll
  4016. * @param result the quaternion to store the result
  4017. * @returns the updated quaternion
  4018. */
  4019. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4020. /**
  4021. * Create a quaternion from Euler rotation vector
  4022. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4023. * @returns the new Quaternion
  4024. */
  4025. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4026. /**
  4027. * Updates a quaternion from Euler rotation vector
  4028. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4029. * @param result the quaternion to store the result
  4030. * @returns the updated quaternion
  4031. */
  4032. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4033. /**
  4034. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4035. * @param yaw defines the rotation around Y axis
  4036. * @param pitch defines the rotation around X axis
  4037. * @param roll defines the rotation around Z axis
  4038. * @returns the new quaternion
  4039. */
  4040. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4041. /**
  4042. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4043. * @param yaw defines the rotation around Y axis
  4044. * @param pitch defines the rotation around X axis
  4045. * @param roll defines the rotation around Z axis
  4046. * @param result defines the target quaternion
  4047. */
  4048. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4049. /**
  4050. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4051. * @param alpha defines the rotation around first axis
  4052. * @param beta defines the rotation around second axis
  4053. * @param gamma defines the rotation around third axis
  4054. * @returns the new quaternion
  4055. */
  4056. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4057. /**
  4058. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4059. * @param alpha defines the rotation around first axis
  4060. * @param beta defines the rotation around second axis
  4061. * @param gamma defines the rotation around third axis
  4062. * @param result defines the target quaternion
  4063. */
  4064. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4065. /**
  4066. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4067. * @param axis1 defines the first axis
  4068. * @param axis2 defines the second axis
  4069. * @param axis3 defines the third axis
  4070. * @returns the new quaternion
  4071. */
  4072. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4073. /**
  4074. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4075. * @param axis1 defines the first axis
  4076. * @param axis2 defines the second axis
  4077. * @param axis3 defines the third axis
  4078. * @param ref defines the target quaternion
  4079. */
  4080. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4081. /**
  4082. * Interpolates between two quaternions
  4083. * @param left defines first quaternion
  4084. * @param right defines second quaternion
  4085. * @param amount defines the gradient to use
  4086. * @returns the new interpolated quaternion
  4087. */
  4088. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4089. /**
  4090. * Interpolates between two quaternions and stores it into a target quaternion
  4091. * @param left defines first quaternion
  4092. * @param right defines second quaternion
  4093. * @param amount defines the gradient to use
  4094. * @param result defines the target quaternion
  4095. */
  4096. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4097. /**
  4098. * Interpolate between two quaternions using Hermite interpolation
  4099. * @param value1 defines first quaternion
  4100. * @param tangent1 defines the incoming tangent
  4101. * @param value2 defines second quaternion
  4102. * @param tangent2 defines the outgoing tangent
  4103. * @param amount defines the target quaternion
  4104. * @returns the new interpolated quaternion
  4105. */
  4106. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4107. }
  4108. /**
  4109. * Class used to store matrix data (4x4)
  4110. */
  4111. export class Matrix {
  4112. /**
  4113. * Gets the precision of matrix computations
  4114. */
  4115. static get Use64Bits(): boolean;
  4116. private static _updateFlagSeed;
  4117. private static _identityReadOnly;
  4118. private _isIdentity;
  4119. private _isIdentityDirty;
  4120. private _isIdentity3x2;
  4121. private _isIdentity3x2Dirty;
  4122. /**
  4123. * Gets the update flag of the matrix which is an unique number for the matrix.
  4124. * It will be incremented every time the matrix data change.
  4125. * You can use it to speed the comparison between two versions of the same matrix.
  4126. */
  4127. updateFlag: number;
  4128. private readonly _m;
  4129. /**
  4130. * Gets the internal data of the matrix
  4131. */
  4132. get m(): DeepImmutable<Float32Array | Array<number>>;
  4133. /** @hidden */
  4134. _markAsUpdated(): void;
  4135. /** @hidden */
  4136. private _updateIdentityStatus;
  4137. /**
  4138. * Creates an empty matrix (filled with zeros)
  4139. */
  4140. constructor();
  4141. /**
  4142. * Check if the current matrix is identity
  4143. * @returns true is the matrix is the identity matrix
  4144. */
  4145. isIdentity(): boolean;
  4146. /**
  4147. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4148. * @returns true is the matrix is the identity matrix
  4149. */
  4150. isIdentityAs3x2(): boolean;
  4151. /**
  4152. * Gets the determinant of the matrix
  4153. * @returns the matrix determinant
  4154. */
  4155. determinant(): number;
  4156. /**
  4157. * Returns the matrix as a Float32Array or Array<number>
  4158. * @returns the matrix underlying array
  4159. */
  4160. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4161. /**
  4162. * Returns the matrix as a Float32Array or Array<number>
  4163. * @returns the matrix underlying array.
  4164. */
  4165. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4166. /**
  4167. * Inverts the current matrix in place
  4168. * @returns the current inverted matrix
  4169. */
  4170. invert(): Matrix;
  4171. /**
  4172. * Sets all the matrix elements to zero
  4173. * @returns the current matrix
  4174. */
  4175. reset(): Matrix;
  4176. /**
  4177. * Adds the current matrix with a second one
  4178. * @param other defines the matrix to add
  4179. * @returns a new matrix as the addition of the current matrix and the given one
  4180. */
  4181. add(other: DeepImmutable<Matrix>): Matrix;
  4182. /**
  4183. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4184. * @param other defines the matrix to add
  4185. * @param result defines the target matrix
  4186. * @returns the current matrix
  4187. */
  4188. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4189. /**
  4190. * Adds in place the given matrix to the current matrix
  4191. * @param other defines the second operand
  4192. * @returns the current updated matrix
  4193. */
  4194. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Sets the given matrix to the current inverted Matrix
  4197. * @param other defines the target matrix
  4198. * @returns the unmodified current matrix
  4199. */
  4200. invertToRef(other: Matrix): Matrix;
  4201. /**
  4202. * add a value at the specified position in the current Matrix
  4203. * @param index the index of the value within the matrix. between 0 and 15.
  4204. * @param value the value to be added
  4205. * @returns the current updated matrix
  4206. */
  4207. addAtIndex(index: number, value: number): Matrix;
  4208. /**
  4209. * mutiply the specified position in the current Matrix by a value
  4210. * @param index the index of the value within the matrix. between 0 and 15.
  4211. * @param value the value to be added
  4212. * @returns the current updated matrix
  4213. */
  4214. multiplyAtIndex(index: number, value: number): Matrix;
  4215. /**
  4216. * Inserts the translation vector (using 3 floats) in the current matrix
  4217. * @param x defines the 1st component of the translation
  4218. * @param y defines the 2nd component of the translation
  4219. * @param z defines the 3rd component of the translation
  4220. * @returns the current updated matrix
  4221. */
  4222. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4223. /**
  4224. * Adds the translation vector (using 3 floats) in the current matrix
  4225. * @param x defines the 1st component of the translation
  4226. * @param y defines the 2nd component of the translation
  4227. * @param z defines the 3rd component of the translation
  4228. * @returns the current updated matrix
  4229. */
  4230. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4231. /**
  4232. * Inserts the translation vector in the current matrix
  4233. * @param vector3 defines the translation to insert
  4234. * @returns the current updated matrix
  4235. */
  4236. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4237. /**
  4238. * Gets the translation value of the current matrix
  4239. * @returns a new Vector3 as the extracted translation from the matrix
  4240. */
  4241. getTranslation(): Vector3;
  4242. /**
  4243. * Fill a Vector3 with the extracted translation from the matrix
  4244. * @param result defines the Vector3 where to store the translation
  4245. * @returns the current matrix
  4246. */
  4247. getTranslationToRef(result: Vector3): Matrix;
  4248. /**
  4249. * Remove rotation and scaling part from the matrix
  4250. * @returns the updated matrix
  4251. */
  4252. removeRotationAndScaling(): Matrix;
  4253. /**
  4254. * Multiply two matrices
  4255. * @param other defines the second operand
  4256. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4257. */
  4258. multiply(other: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Copy the current matrix from the given one
  4261. * @param other defines the source matrix
  4262. * @returns the current updated matrix
  4263. */
  4264. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4265. /**
  4266. * Populates the given array from the starting index with the current matrix values
  4267. * @param array defines the target array
  4268. * @param offset defines the offset in the target array where to start storing values
  4269. * @returns the current matrix
  4270. */
  4271. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4272. /**
  4273. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4274. * @param other defines the second operand
  4275. * @param result defines the matrix where to store the multiplication
  4276. * @returns the current matrix
  4277. */
  4278. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4279. /**
  4280. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4281. * @param other defines the second operand
  4282. * @param result defines the array where to store the multiplication
  4283. * @param offset defines the offset in the target array where to start storing values
  4284. * @returns the current matrix
  4285. */
  4286. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4287. /**
  4288. * Check equality between this matrix and a second one
  4289. * @param value defines the second matrix to compare
  4290. * @returns true is the current matrix and the given one values are strictly equal
  4291. */
  4292. equals(value: DeepImmutable<Matrix>): boolean;
  4293. /**
  4294. * Clone the current matrix
  4295. * @returns a new matrix from the current matrix
  4296. */
  4297. clone(): Matrix;
  4298. /**
  4299. * Returns the name of the current matrix class
  4300. * @returns the string "Matrix"
  4301. */
  4302. getClassName(): string;
  4303. /**
  4304. * Gets the hash code of the current matrix
  4305. * @returns the hash code
  4306. */
  4307. getHashCode(): number;
  4308. /**
  4309. * Decomposes the current Matrix into a translation, rotation and scaling components
  4310. * @param scale defines the scale vector3 given as a reference to update
  4311. * @param rotation defines the rotation quaternion given as a reference to update
  4312. * @param translation defines the translation vector3 given as a reference to update
  4313. * @returns true if operation was successful
  4314. */
  4315. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4316. /**
  4317. * Gets specific row of the matrix
  4318. * @param index defines the number of the row to get
  4319. * @returns the index-th row of the current matrix as a new Vector4
  4320. */
  4321. getRow(index: number): Nullable<Vector4>;
  4322. /**
  4323. * Sets the index-th row of the current matrix to the vector4 values
  4324. * @param index defines the number of the row to set
  4325. * @param row defines the target vector4
  4326. * @returns the updated current matrix
  4327. */
  4328. setRow(index: number, row: Vector4): Matrix;
  4329. /**
  4330. * Compute the transpose of the matrix
  4331. * @returns the new transposed matrix
  4332. */
  4333. transpose(): Matrix;
  4334. /**
  4335. * Compute the transpose of the matrix and store it in a given matrix
  4336. * @param result defines the target matrix
  4337. * @returns the current matrix
  4338. */
  4339. transposeToRef(result: Matrix): Matrix;
  4340. /**
  4341. * Sets the index-th row of the current matrix with the given 4 x float values
  4342. * @param index defines the row index
  4343. * @param x defines the x component to set
  4344. * @param y defines the y component to set
  4345. * @param z defines the z component to set
  4346. * @param w defines the w component to set
  4347. * @returns the updated current matrix
  4348. */
  4349. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4350. /**
  4351. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4352. * @param scale defines the scale factor
  4353. * @returns a new matrix
  4354. */
  4355. scale(scale: number): Matrix;
  4356. /**
  4357. * Scale the current matrix values by a factor to a given result matrix
  4358. * @param scale defines the scale factor
  4359. * @param result defines the matrix to store the result
  4360. * @returns the current matrix
  4361. */
  4362. scaleToRef(scale: number, result: Matrix): Matrix;
  4363. /**
  4364. * Scale the current matrix values by a factor and add the result to a given matrix
  4365. * @param scale defines the scale factor
  4366. * @param result defines the Matrix to store the result
  4367. * @returns the current matrix
  4368. */
  4369. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4370. /**
  4371. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4372. * @param ref matrix to store the result
  4373. */
  4374. toNormalMatrix(ref: Matrix): void;
  4375. /**
  4376. * Gets only rotation part of the current matrix
  4377. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4378. */
  4379. getRotationMatrix(): Matrix;
  4380. /**
  4381. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4382. * @param result defines the target matrix to store data to
  4383. * @returns the current matrix
  4384. */
  4385. getRotationMatrixToRef(result: Matrix): Matrix;
  4386. /**
  4387. * Toggles model matrix from being right handed to left handed in place and vice versa
  4388. */
  4389. toggleModelMatrixHandInPlace(): void;
  4390. /**
  4391. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4392. */
  4393. toggleProjectionMatrixHandInPlace(): void;
  4394. /**
  4395. * Creates a matrix from an array
  4396. * @param array defines the source array
  4397. * @param offset defines an offset in the source array
  4398. * @returns a new Matrix set from the starting index of the given array
  4399. */
  4400. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4401. /**
  4402. * Copy the content of an array into a given matrix
  4403. * @param array defines the source array
  4404. * @param offset defines an offset in the source array
  4405. * @param result defines the target matrix
  4406. */
  4407. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4408. /**
  4409. * Stores an array into a matrix after having multiplied each component by a given factor
  4410. * @param array defines the source array
  4411. * @param offset defines the offset in the source array
  4412. * @param scale defines the scaling factor
  4413. * @param result defines the target matrix
  4414. */
  4415. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4416. /**
  4417. * Gets an identity matrix that must not be updated
  4418. */
  4419. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4420. /**
  4421. * Stores a list of values (16) inside a given matrix
  4422. * @param initialM11 defines 1st value of 1st row
  4423. * @param initialM12 defines 2nd value of 1st row
  4424. * @param initialM13 defines 3rd value of 1st row
  4425. * @param initialM14 defines 4th value of 1st row
  4426. * @param initialM21 defines 1st value of 2nd row
  4427. * @param initialM22 defines 2nd value of 2nd row
  4428. * @param initialM23 defines 3rd value of 2nd row
  4429. * @param initialM24 defines 4th value of 2nd row
  4430. * @param initialM31 defines 1st value of 3rd row
  4431. * @param initialM32 defines 2nd value of 3rd row
  4432. * @param initialM33 defines 3rd value of 3rd row
  4433. * @param initialM34 defines 4th value of 3rd row
  4434. * @param initialM41 defines 1st value of 4th row
  4435. * @param initialM42 defines 2nd value of 4th row
  4436. * @param initialM43 defines 3rd value of 4th row
  4437. * @param initialM44 defines 4th value of 4th row
  4438. * @param result defines the target matrix
  4439. */
  4440. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4441. /**
  4442. * Creates new matrix from a list of values (16)
  4443. * @param initialM11 defines 1st value of 1st row
  4444. * @param initialM12 defines 2nd value of 1st row
  4445. * @param initialM13 defines 3rd value of 1st row
  4446. * @param initialM14 defines 4th value of 1st row
  4447. * @param initialM21 defines 1st value of 2nd row
  4448. * @param initialM22 defines 2nd value of 2nd row
  4449. * @param initialM23 defines 3rd value of 2nd row
  4450. * @param initialM24 defines 4th value of 2nd row
  4451. * @param initialM31 defines 1st value of 3rd row
  4452. * @param initialM32 defines 2nd value of 3rd row
  4453. * @param initialM33 defines 3rd value of 3rd row
  4454. * @param initialM34 defines 4th value of 3rd row
  4455. * @param initialM41 defines 1st value of 4th row
  4456. * @param initialM42 defines 2nd value of 4th row
  4457. * @param initialM43 defines 3rd value of 4th row
  4458. * @param initialM44 defines 4th value of 4th row
  4459. * @returns the new matrix
  4460. */
  4461. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4462. /**
  4463. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4464. * @param scale defines the scale vector3
  4465. * @param rotation defines the rotation quaternion
  4466. * @param translation defines the translation vector3
  4467. * @returns a new matrix
  4468. */
  4469. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4470. /**
  4471. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4472. * @param scale defines the scale vector3
  4473. * @param rotation defines the rotation quaternion
  4474. * @param translation defines the translation vector3
  4475. * @param result defines the target matrix
  4476. */
  4477. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4478. /**
  4479. * Creates a new identity matrix
  4480. * @returns a new identity matrix
  4481. */
  4482. static Identity(): Matrix;
  4483. /**
  4484. * Creates a new identity matrix and stores the result in a given matrix
  4485. * @param result defines the target matrix
  4486. */
  4487. static IdentityToRef(result: Matrix): void;
  4488. /**
  4489. * Creates a new zero matrix
  4490. * @returns a new zero matrix
  4491. */
  4492. static Zero(): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the X axis
  4495. * @param angle defines the angle (in radians) to use
  4496. * @return the new matrix
  4497. */
  4498. static RotationX(angle: number): Matrix;
  4499. /**
  4500. * Creates a new matrix as the invert of a given matrix
  4501. * @param source defines the source matrix
  4502. * @returns the new matrix
  4503. */
  4504. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4507. * @param angle defines the angle (in radians) to use
  4508. * @param result defines the target matrix
  4509. */
  4510. static RotationXToRef(angle: number, result: Matrix): void;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the Y axis
  4513. * @param angle defines the angle (in radians) to use
  4514. * @return the new matrix
  4515. */
  4516. static RotationY(angle: number): Matrix;
  4517. /**
  4518. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4519. * @param angle defines the angle (in radians) to use
  4520. * @param result defines the target matrix
  4521. */
  4522. static RotationYToRef(angle: number, result: Matrix): void;
  4523. /**
  4524. * Creates a new rotation matrix for "angle" radians around the Z axis
  4525. * @param angle defines the angle (in radians) to use
  4526. * @return the new matrix
  4527. */
  4528. static RotationZ(angle: number): Matrix;
  4529. /**
  4530. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4531. * @param angle defines the angle (in radians) to use
  4532. * @param result defines the target matrix
  4533. */
  4534. static RotationZToRef(angle: number, result: Matrix): void;
  4535. /**
  4536. * Creates a new rotation matrix for "angle" radians around the given axis
  4537. * @param axis defines the axis to use
  4538. * @param angle defines the angle (in radians) to use
  4539. * @return the new matrix
  4540. */
  4541. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4542. /**
  4543. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4544. * @param axis defines the axis to use
  4545. * @param angle defines the angle (in radians) to use
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4549. /**
  4550. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4551. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4552. * @param from defines the vector to align
  4553. * @param to defines the vector to align to
  4554. * @param result defines the target matrix
  4555. */
  4556. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4557. /**
  4558. * Creates a rotation matrix
  4559. * @param yaw defines the yaw angle in radians (Y axis)
  4560. * @param pitch defines the pitch angle in radians (X axis)
  4561. * @param roll defines the roll angle in radians (Z axis)
  4562. * @returns the new rotation matrix
  4563. */
  4564. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4565. /**
  4566. * Creates a rotation matrix and stores it in a given matrix
  4567. * @param yaw defines the yaw angle in radians (Y axis)
  4568. * @param pitch defines the pitch angle in radians (X axis)
  4569. * @param roll defines the roll angle in radians (Z axis)
  4570. * @param result defines the target matrix
  4571. */
  4572. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4573. /**
  4574. * Creates a scaling matrix
  4575. * @param x defines the scale factor on X axis
  4576. * @param y defines the scale factor on Y axis
  4577. * @param z defines the scale factor on Z axis
  4578. * @returns the new matrix
  4579. */
  4580. static Scaling(x: number, y: number, z: number): Matrix;
  4581. /**
  4582. * Creates a scaling matrix and stores it in a given matrix
  4583. * @param x defines the scale factor on X axis
  4584. * @param y defines the scale factor on Y axis
  4585. * @param z defines the scale factor on Z axis
  4586. * @param result defines the target matrix
  4587. */
  4588. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4589. /**
  4590. * Creates a translation matrix
  4591. * @param x defines the translation on X axis
  4592. * @param y defines the translation on Y axis
  4593. * @param z defines the translationon Z axis
  4594. * @returns the new matrix
  4595. */
  4596. static Translation(x: number, y: number, z: number): Matrix;
  4597. /**
  4598. * Creates a translation matrix and stores it in a given matrix
  4599. * @param x defines the translation on X axis
  4600. * @param y defines the translation on Y axis
  4601. * @param z defines the translationon Z axis
  4602. * @param result defines the target matrix
  4603. */
  4604. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4605. /**
  4606. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4607. * @param startValue defines the start value
  4608. * @param endValue defines the end value
  4609. * @param gradient defines the gradient factor
  4610. * @returns the new matrix
  4611. */
  4612. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4613. /**
  4614. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4615. * @param startValue defines the start value
  4616. * @param endValue defines the end value
  4617. * @param gradient defines the gradient factor
  4618. * @param result defines the Matrix object where to store data
  4619. */
  4620. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4621. /**
  4622. * Builds a new matrix whose values are computed by:
  4623. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4624. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4625. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4626. * @param startValue defines the first matrix
  4627. * @param endValue defines the second matrix
  4628. * @param gradient defines the gradient between the two matrices
  4629. * @returns the new matrix
  4630. */
  4631. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4632. /**
  4633. * Update a matrix to values which are computed by:
  4634. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4635. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4636. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4637. * @param startValue defines the first matrix
  4638. * @param endValue defines the second matrix
  4639. * @param gradient defines the gradient between the two matrices
  4640. * @param result defines the target matrix
  4641. */
  4642. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4643. /**
  4644. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4645. * This function works in left handed mode
  4646. * @param eye defines the final position of the entity
  4647. * @param target defines where the entity should look at
  4648. * @param up defines the up vector for the entity
  4649. * @returns the new matrix
  4650. */
  4651. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4652. /**
  4653. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4654. * This function works in left handed mode
  4655. * @param eye defines the final position of the entity
  4656. * @param target defines where the entity should look at
  4657. * @param up defines the up vector for the entity
  4658. * @param result defines the target matrix
  4659. */
  4660. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4661. /**
  4662. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4663. * This function works in right handed mode
  4664. * @param eye defines the final position of the entity
  4665. * @param target defines where the entity should look at
  4666. * @param up defines the up vector for the entity
  4667. * @returns the new matrix
  4668. */
  4669. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4670. /**
  4671. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4672. * This function works in right handed mode
  4673. * @param eye defines the final position of the entity
  4674. * @param target defines where the entity should look at
  4675. * @param up defines the up vector for the entity
  4676. * @param result defines the target matrix
  4677. */
  4678. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4679. /**
  4680. * Create a left-handed orthographic projection matrix
  4681. * @param width defines the viewport width
  4682. * @param height defines the viewport height
  4683. * @param znear defines the near clip plane
  4684. * @param zfar defines the far clip plane
  4685. * @returns a new matrix as a left-handed orthographic projection matrix
  4686. */
  4687. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4688. /**
  4689. * Store a left-handed orthographic projection to a given matrix
  4690. * @param width defines the viewport width
  4691. * @param height defines the viewport height
  4692. * @param znear defines the near clip plane
  4693. * @param zfar defines the far clip plane
  4694. * @param result defines the target matrix
  4695. */
  4696. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4697. /**
  4698. * Create a left-handed orthographic projection matrix
  4699. * @param left defines the viewport left coordinate
  4700. * @param right defines the viewport right coordinate
  4701. * @param bottom defines the viewport bottom coordinate
  4702. * @param top defines the viewport top coordinate
  4703. * @param znear defines the near clip plane
  4704. * @param zfar defines the far clip plane
  4705. * @returns a new matrix as a left-handed orthographic projection matrix
  4706. */
  4707. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4708. /**
  4709. * Stores a left-handed orthographic projection into a given matrix
  4710. * @param left defines the viewport left coordinate
  4711. * @param right defines the viewport right coordinate
  4712. * @param bottom defines the viewport bottom coordinate
  4713. * @param top defines the viewport top coordinate
  4714. * @param znear defines the near clip plane
  4715. * @param zfar defines the far clip plane
  4716. * @param result defines the target matrix
  4717. */
  4718. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4719. /**
  4720. * Creates a right-handed orthographic projection matrix
  4721. * @param left defines the viewport left coordinate
  4722. * @param right defines the viewport right coordinate
  4723. * @param bottom defines the viewport bottom coordinate
  4724. * @param top defines the viewport top coordinate
  4725. * @param znear defines the near clip plane
  4726. * @param zfar defines the far clip plane
  4727. * @returns a new matrix as a right-handed orthographic projection matrix
  4728. */
  4729. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4730. /**
  4731. * Stores a right-handed orthographic projection into a given matrix
  4732. * @param left defines the viewport left coordinate
  4733. * @param right defines the viewport right coordinate
  4734. * @param bottom defines the viewport bottom coordinate
  4735. * @param top defines the viewport top coordinate
  4736. * @param znear defines the near clip plane
  4737. * @param zfar defines the far clip plane
  4738. * @param result defines the target matrix
  4739. */
  4740. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4741. /**
  4742. * Creates a left-handed perspective projection matrix
  4743. * @param width defines the viewport width
  4744. * @param height defines the viewport height
  4745. * @param znear defines the near clip plane
  4746. * @param zfar defines the far clip plane
  4747. * @returns a new matrix as a left-handed perspective projection matrix
  4748. */
  4749. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4750. /**
  4751. * Creates a left-handed perspective projection matrix
  4752. * @param fov defines the horizontal field of view
  4753. * @param aspect defines the aspect ratio
  4754. * @param znear defines the near clip plane
  4755. * @param zfar defines the far clip plane
  4756. * @returns a new matrix as a left-handed perspective projection matrix
  4757. */
  4758. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4759. /**
  4760. * Stores a left-handed perspective projection into a given matrix
  4761. * @param fov defines the horizontal field of view
  4762. * @param aspect defines the aspect ratio
  4763. * @param znear defines the near clip plane
  4764. * @param zfar defines the far clip plane
  4765. * @param result defines the target matrix
  4766. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4767. */
  4768. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4769. /**
  4770. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4771. * @param fov defines the horizontal field of view
  4772. * @param aspect defines the aspect ratio
  4773. * @param znear defines the near clip plane
  4774. * @param zfar not used as infinity is used as far clip
  4775. * @param result defines the target matrix
  4776. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4777. */
  4778. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4779. /**
  4780. * Creates a right-handed perspective projection matrix
  4781. * @param fov defines the horizontal field of view
  4782. * @param aspect defines the aspect ratio
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @returns a new matrix as a right-handed perspective projection matrix
  4786. */
  4787. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4788. /**
  4789. * Stores a right-handed perspective projection into a given matrix
  4790. * @param fov defines the horizontal field of view
  4791. * @param aspect defines the aspect ratio
  4792. * @param znear defines the near clip plane
  4793. * @param zfar defines the far clip plane
  4794. * @param result defines the target matrix
  4795. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4796. */
  4797. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4798. /**
  4799. * Stores a right-handed perspective projection into a given matrix
  4800. * @param fov defines the horizontal field of view
  4801. * @param aspect defines the aspect ratio
  4802. * @param znear defines the near clip plane
  4803. * @param zfar not used as infinity is used as far clip
  4804. * @param result defines the target matrix
  4805. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4806. */
  4807. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4808. /**
  4809. * Stores a perspective projection for WebVR info a given matrix
  4810. * @param fov defines the field of view
  4811. * @param znear defines the near clip plane
  4812. * @param zfar defines the far clip plane
  4813. * @param result defines the target matrix
  4814. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4815. */
  4816. static PerspectiveFovWebVRToRef(fov: {
  4817. upDegrees: number;
  4818. downDegrees: number;
  4819. leftDegrees: number;
  4820. rightDegrees: number;
  4821. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4822. /**
  4823. * Computes a complete transformation matrix
  4824. * @param viewport defines the viewport to use
  4825. * @param world defines the world matrix
  4826. * @param view defines the view matrix
  4827. * @param projection defines the projection matrix
  4828. * @param zmin defines the near clip plane
  4829. * @param zmax defines the far clip plane
  4830. * @returns the transformation matrix
  4831. */
  4832. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4833. /**
  4834. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4835. * @param matrix defines the matrix to use
  4836. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4837. */
  4838. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4839. /**
  4840. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4841. * @param matrix defines the matrix to use
  4842. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4843. */
  4844. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4845. /**
  4846. * Compute the transpose of a given matrix
  4847. * @param matrix defines the matrix to transpose
  4848. * @returns the new matrix
  4849. */
  4850. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4851. /**
  4852. * Compute the transpose of a matrix and store it in a target matrix
  4853. * @param matrix defines the matrix to transpose
  4854. * @param result defines the target matrix
  4855. */
  4856. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4857. /**
  4858. * Computes a reflection matrix from a plane
  4859. * @param plane defines the reflection plane
  4860. * @returns a new matrix
  4861. */
  4862. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4863. /**
  4864. * Computes a reflection matrix from a plane
  4865. * @param plane defines the reflection plane
  4866. * @param result defines the target matrix
  4867. */
  4868. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4869. /**
  4870. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4871. * @param xaxis defines the value of the 1st axis
  4872. * @param yaxis defines the value of the 2nd axis
  4873. * @param zaxis defines the value of the 3rd axis
  4874. * @param result defines the target matrix
  4875. */
  4876. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4877. /**
  4878. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4879. * @param quat defines the quaternion to use
  4880. * @param result defines the target matrix
  4881. */
  4882. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4883. }
  4884. /**
  4885. * @hidden
  4886. */
  4887. export class TmpVectors {
  4888. static Vector2: Vector2[];
  4889. static Vector3: Vector3[];
  4890. static Vector4: Vector4[];
  4891. static Quaternion: Quaternion[];
  4892. static Matrix: Matrix[];
  4893. }
  4894. }
  4895. declare module "babylonjs/Maths/math.path" {
  4896. import { DeepImmutable, Nullable } from "babylonjs/types";
  4897. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4898. /**
  4899. * Defines potential orientation for back face culling
  4900. */
  4901. export enum Orientation {
  4902. /**
  4903. * Clockwise
  4904. */
  4905. CW = 0,
  4906. /** Counter clockwise */
  4907. CCW = 1
  4908. }
  4909. /** Class used to represent a Bezier curve */
  4910. export class BezierCurve {
  4911. /**
  4912. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4913. * @param t defines the time
  4914. * @param x1 defines the left coordinate on X axis
  4915. * @param y1 defines the left coordinate on Y axis
  4916. * @param x2 defines the right coordinate on X axis
  4917. * @param y2 defines the right coordinate on Y axis
  4918. * @returns the interpolated value
  4919. */
  4920. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4921. }
  4922. /**
  4923. * Defines angle representation
  4924. */
  4925. export class Angle {
  4926. private _radians;
  4927. /**
  4928. * Creates an Angle object of "radians" radians (float).
  4929. * @param radians the angle in radians
  4930. */
  4931. constructor(radians: number);
  4932. /**
  4933. * Get value in degrees
  4934. * @returns the Angle value in degrees (float)
  4935. */
  4936. degrees(): number;
  4937. /**
  4938. * Get value in radians
  4939. * @returns the Angle value in radians (float)
  4940. */
  4941. radians(): number;
  4942. /**
  4943. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4944. * @param a defines first point as the origin
  4945. * @param b defines point
  4946. * @returns a new Angle
  4947. */
  4948. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4949. /**
  4950. * Gets a new Angle object from the given float in radians
  4951. * @param radians defines the angle value in radians
  4952. * @returns a new Angle
  4953. */
  4954. static FromRadians(radians: number): Angle;
  4955. /**
  4956. * Gets a new Angle object from the given float in degrees
  4957. * @param degrees defines the angle value in degrees
  4958. * @returns a new Angle
  4959. */
  4960. static FromDegrees(degrees: number): Angle;
  4961. }
  4962. /**
  4963. * This represents an arc in a 2d space.
  4964. */
  4965. export class Arc2 {
  4966. /** Defines the start point of the arc */
  4967. startPoint: Vector2;
  4968. /** Defines the mid point of the arc */
  4969. midPoint: Vector2;
  4970. /** Defines the end point of the arc */
  4971. endPoint: Vector2;
  4972. /**
  4973. * Defines the center point of the arc.
  4974. */
  4975. centerPoint: Vector2;
  4976. /**
  4977. * Defines the radius of the arc.
  4978. */
  4979. radius: number;
  4980. /**
  4981. * Defines the angle of the arc (from mid point to end point).
  4982. */
  4983. angle: Angle;
  4984. /**
  4985. * Defines the start angle of the arc (from start point to middle point).
  4986. */
  4987. startAngle: Angle;
  4988. /**
  4989. * Defines the orientation of the arc (clock wise/counter clock wise).
  4990. */
  4991. orientation: Orientation;
  4992. /**
  4993. * Creates an Arc object from the three given points : start, middle and end.
  4994. * @param startPoint Defines the start point of the arc
  4995. * @param midPoint Defines the midlle point of the arc
  4996. * @param endPoint Defines the end point of the arc
  4997. */
  4998. constructor(
  4999. /** Defines the start point of the arc */
  5000. startPoint: Vector2,
  5001. /** Defines the mid point of the arc */
  5002. midPoint: Vector2,
  5003. /** Defines the end point of the arc */
  5004. endPoint: Vector2);
  5005. }
  5006. /**
  5007. * Represents a 2D path made up of multiple 2D points
  5008. */
  5009. export class Path2 {
  5010. private _points;
  5011. private _length;
  5012. /**
  5013. * If the path start and end point are the same
  5014. */
  5015. closed: boolean;
  5016. /**
  5017. * Creates a Path2 object from the starting 2D coordinates x and y.
  5018. * @param x the starting points x value
  5019. * @param y the starting points y value
  5020. */
  5021. constructor(x: number, y: number);
  5022. /**
  5023. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5024. * @param x the added points x value
  5025. * @param y the added points y value
  5026. * @returns the updated Path2.
  5027. */
  5028. addLineTo(x: number, y: number): Path2;
  5029. /**
  5030. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5031. * @param midX middle point x value
  5032. * @param midY middle point y value
  5033. * @param endX end point x value
  5034. * @param endY end point y value
  5035. * @param numberOfSegments (default: 36)
  5036. * @returns the updated Path2.
  5037. */
  5038. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5039. /**
  5040. * Closes the Path2.
  5041. * @returns the Path2.
  5042. */
  5043. close(): Path2;
  5044. /**
  5045. * Gets the sum of the distance between each sequential point in the path
  5046. * @returns the Path2 total length (float).
  5047. */
  5048. length(): number;
  5049. /**
  5050. * Gets the points which construct the path
  5051. * @returns the Path2 internal array of points.
  5052. */
  5053. getPoints(): Vector2[];
  5054. /**
  5055. * Retreives the point at the distance aways from the starting point
  5056. * @param normalizedLengthPosition the length along the path to retreive the point from
  5057. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5058. */
  5059. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5060. /**
  5061. * Creates a new path starting from an x and y position
  5062. * @param x starting x value
  5063. * @param y starting y value
  5064. * @returns a new Path2 starting at the coordinates (x, y).
  5065. */
  5066. static StartingAt(x: number, y: number): Path2;
  5067. }
  5068. /**
  5069. * Represents a 3D path made up of multiple 3D points
  5070. */
  5071. export class Path3D {
  5072. /**
  5073. * an array of Vector3, the curve axis of the Path3D
  5074. */
  5075. path: Vector3[];
  5076. private _curve;
  5077. private _distances;
  5078. private _tangents;
  5079. private _normals;
  5080. private _binormals;
  5081. private _raw;
  5082. private _alignTangentsWithPath;
  5083. private readonly _pointAtData;
  5084. /**
  5085. * new Path3D(path, normal, raw)
  5086. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5087. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5088. * @param path an array of Vector3, the curve axis of the Path3D
  5089. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5090. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5091. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5092. */
  5093. constructor(
  5094. /**
  5095. * an array of Vector3, the curve axis of the Path3D
  5096. */
  5097. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5098. /**
  5099. * Returns the Path3D array of successive Vector3 designing its curve.
  5100. * @returns the Path3D array of successive Vector3 designing its curve.
  5101. */
  5102. getCurve(): Vector3[];
  5103. /**
  5104. * Returns the Path3D array of successive Vector3 designing its curve.
  5105. * @returns the Path3D array of successive Vector3 designing its curve.
  5106. */
  5107. getPoints(): Vector3[];
  5108. /**
  5109. * @returns the computed length (float) of the path.
  5110. */
  5111. length(): number;
  5112. /**
  5113. * Returns an array populated with tangent vectors on each Path3D curve point.
  5114. * @returns an array populated with tangent vectors on each Path3D curve point.
  5115. */
  5116. getTangents(): Vector3[];
  5117. /**
  5118. * Returns an array populated with normal vectors on each Path3D curve point.
  5119. * @returns an array populated with normal vectors on each Path3D curve point.
  5120. */
  5121. getNormals(): Vector3[];
  5122. /**
  5123. * Returns an array populated with binormal vectors on each Path3D curve point.
  5124. * @returns an array populated with binormal vectors on each Path3D curve point.
  5125. */
  5126. getBinormals(): Vector3[];
  5127. /**
  5128. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5129. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5130. */
  5131. getDistances(): number[];
  5132. /**
  5133. * Returns an interpolated point along this path
  5134. * @param position the position of the point along this path, from 0.0 to 1.0
  5135. * @returns a new Vector3 as the point
  5136. */
  5137. getPointAt(position: number): Vector3;
  5138. /**
  5139. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5140. * @param position the position of the point along this path, from 0.0 to 1.0
  5141. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5142. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5143. */
  5144. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5145. /**
  5146. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5147. * @param position the position of the point along this path, from 0.0 to 1.0
  5148. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5149. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5150. */
  5151. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5152. /**
  5153. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5154. * @param position the position of the point along this path, from 0.0 to 1.0
  5155. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5156. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5157. */
  5158. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5159. /**
  5160. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5161. * @param position the position of the point along this path, from 0.0 to 1.0
  5162. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5163. */
  5164. getDistanceAt(position: number): number;
  5165. /**
  5166. * Returns the array index of the previous point of an interpolated point along this path
  5167. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5168. * @returns the array index
  5169. */
  5170. getPreviousPointIndexAt(position: number): number;
  5171. /**
  5172. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5173. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5174. * @returns the sub position
  5175. */
  5176. getSubPositionAt(position: number): number;
  5177. /**
  5178. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5179. * @param target the vector of which to get the closest position to
  5180. * @returns the position of the closest virtual point on this path to the target vector
  5181. */
  5182. getClosestPositionTo(target: Vector3): number;
  5183. /**
  5184. * Returns a sub path (slice) of this path
  5185. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5186. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5187. * @returns a sub path (slice) of this path
  5188. */
  5189. slice(start?: number, end?: number): Path3D;
  5190. /**
  5191. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5192. * @param path path which all values are copied into the curves points
  5193. * @param firstNormal which should be projected onto the curve
  5194. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5195. * @returns the same object updated.
  5196. */
  5197. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5198. private _compute;
  5199. private _getFirstNonNullVector;
  5200. private _getLastNonNullVector;
  5201. private _normalVector;
  5202. /**
  5203. * Updates the point at data for an interpolated point along this curve
  5204. * @param position the position of the point along this curve, from 0.0 to 1.0
  5205. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5206. * @returns the (updated) point at data
  5207. */
  5208. private _updatePointAtData;
  5209. /**
  5210. * Updates the point at data from the specified parameters
  5211. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5212. * @param point the interpolated point
  5213. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5214. */
  5215. private _setPointAtData;
  5216. /**
  5217. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5218. */
  5219. private _updateInterpolationMatrix;
  5220. }
  5221. /**
  5222. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5223. * A Curve3 is designed from a series of successive Vector3.
  5224. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5225. */
  5226. export class Curve3 {
  5227. private _points;
  5228. private _length;
  5229. /**
  5230. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5231. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5232. * @param v1 (Vector3) the control point
  5233. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5234. * @param nbPoints (integer) the wanted number of points in the curve
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5238. /**
  5239. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5240. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5241. * @param v1 (Vector3) the first control point
  5242. * @param v2 (Vector3) the second control point
  5243. * @param v3 (Vector3) the end point of the Cubic Bezier
  5244. * @param nbPoints (integer) the wanted number of points in the curve
  5245. * @returns the created Curve3
  5246. */
  5247. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5248. /**
  5249. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5250. * @param p1 (Vector3) the origin point of the Hermite Spline
  5251. * @param t1 (Vector3) the tangent vector at the origin point
  5252. * @param p2 (Vector3) the end point of the Hermite Spline
  5253. * @param t2 (Vector3) the tangent vector at the end point
  5254. * @param nbPoints (integer) the wanted number of points in the curve
  5255. * @returns the created Curve3
  5256. */
  5257. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5258. /**
  5259. * Returns a Curve3 object along a CatmullRom Spline curve :
  5260. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5261. * @param nbPoints (integer) the wanted number of points between each curve control points
  5262. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5263. * @returns the created Curve3
  5264. */
  5265. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5266. /**
  5267. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5268. * A Curve3 is designed from a series of successive Vector3.
  5269. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5270. * @param points points which make up the curve
  5271. */
  5272. constructor(points: Vector3[]);
  5273. /**
  5274. * @returns the Curve3 stored array of successive Vector3
  5275. */
  5276. getPoints(): Vector3[];
  5277. /**
  5278. * @returns the computed length (float) of the curve.
  5279. */
  5280. length(): number;
  5281. /**
  5282. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5283. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5284. * curveA and curveB keep unchanged.
  5285. * @param curve the curve to continue from this curve
  5286. * @returns the newly constructed curve
  5287. */
  5288. continue(curve: DeepImmutable<Curve3>): Curve3;
  5289. private _computeLength;
  5290. }
  5291. }
  5292. declare module "babylonjs/Animations/easing" {
  5293. /**
  5294. * This represents the main contract an easing function should follow.
  5295. * Easing functions are used throughout the animation system.
  5296. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5297. */
  5298. export interface IEasingFunction {
  5299. /**
  5300. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5301. * of the easing function.
  5302. * The link below provides some of the most common examples of easing functions.
  5303. * @see https://easings.net/
  5304. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5305. * @returns the corresponding value on the curve defined by the easing function
  5306. */
  5307. ease(gradient: number): number;
  5308. }
  5309. /**
  5310. * Base class used for every default easing function.
  5311. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5312. */
  5313. export class EasingFunction implements IEasingFunction {
  5314. /**
  5315. * Interpolation follows the mathematical formula associated with the easing function.
  5316. */
  5317. static readonly EASINGMODE_EASEIN: number;
  5318. /**
  5319. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5320. */
  5321. static readonly EASINGMODE_EASEOUT: number;
  5322. /**
  5323. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5324. */
  5325. static readonly EASINGMODE_EASEINOUT: number;
  5326. private _easingMode;
  5327. /**
  5328. * Sets the easing mode of the current function.
  5329. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5330. */
  5331. setEasingMode(easingMode: number): void;
  5332. /**
  5333. * Gets the current easing mode.
  5334. * @returns the easing mode
  5335. */
  5336. getEasingMode(): number;
  5337. /**
  5338. * @hidden
  5339. */
  5340. easeInCore(gradient: number): number;
  5341. /**
  5342. * Given an input gradient between 0 and 1, this returns the corresponding value
  5343. * of the easing function.
  5344. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5345. * @returns the corresponding value on the curve defined by the easing function
  5346. */
  5347. ease(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a circle shape (see link below).
  5351. * @see https://easings.net/#easeInCirc
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class CircleEase extends EasingFunction implements IEasingFunction {
  5355. /** @hidden */
  5356. easeInCore(gradient: number): number;
  5357. }
  5358. /**
  5359. * Easing function with a ease back shape (see link below).
  5360. * @see https://easings.net/#easeInBack
  5361. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5362. */
  5363. export class BackEase extends EasingFunction implements IEasingFunction {
  5364. /** Defines the amplitude of the function */
  5365. amplitude: number;
  5366. /**
  5367. * Instantiates a back ease easing
  5368. * @see https://easings.net/#easeInBack
  5369. * @param amplitude Defines the amplitude of the function
  5370. */
  5371. constructor(
  5372. /** Defines the amplitude of the function */
  5373. amplitude?: number);
  5374. /** @hidden */
  5375. easeInCore(gradient: number): number;
  5376. }
  5377. /**
  5378. * Easing function with a bouncing shape (see link below).
  5379. * @see https://easings.net/#easeInBounce
  5380. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5381. */
  5382. export class BounceEase extends EasingFunction implements IEasingFunction {
  5383. /** Defines the number of bounces */
  5384. bounces: number;
  5385. /** Defines the amplitude of the bounce */
  5386. bounciness: number;
  5387. /**
  5388. * Instantiates a bounce easing
  5389. * @see https://easings.net/#easeInBounce
  5390. * @param bounces Defines the number of bounces
  5391. * @param bounciness Defines the amplitude of the bounce
  5392. */
  5393. constructor(
  5394. /** Defines the number of bounces */
  5395. bounces?: number,
  5396. /** Defines the amplitude of the bounce */
  5397. bounciness?: number);
  5398. /** @hidden */
  5399. easeInCore(gradient: number): number;
  5400. }
  5401. /**
  5402. * Easing function with a power of 3 shape (see link below).
  5403. * @see https://easings.net/#easeInCubic
  5404. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5405. */
  5406. export class CubicEase extends EasingFunction implements IEasingFunction {
  5407. /** @hidden */
  5408. easeInCore(gradient: number): number;
  5409. }
  5410. /**
  5411. * Easing function with an elastic shape (see link below).
  5412. * @see https://easings.net/#easeInElastic
  5413. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5414. */
  5415. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5416. /** Defines the number of oscillations*/
  5417. oscillations: number;
  5418. /** Defines the amplitude of the oscillations*/
  5419. springiness: number;
  5420. /**
  5421. * Instantiates an elastic easing function
  5422. * @see https://easings.net/#easeInElastic
  5423. * @param oscillations Defines the number of oscillations
  5424. * @param springiness Defines the amplitude of the oscillations
  5425. */
  5426. constructor(
  5427. /** Defines the number of oscillations*/
  5428. oscillations?: number,
  5429. /** Defines the amplitude of the oscillations*/
  5430. springiness?: number);
  5431. /** @hidden */
  5432. easeInCore(gradient: number): number;
  5433. }
  5434. /**
  5435. * Easing function with an exponential shape (see link below).
  5436. * @see https://easings.net/#easeInExpo
  5437. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5438. */
  5439. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5440. /** Defines the exponent of the function */
  5441. exponent: number;
  5442. /**
  5443. * Instantiates an exponential easing function
  5444. * @see https://easings.net/#easeInExpo
  5445. * @param exponent Defines the exponent of the function
  5446. */
  5447. constructor(
  5448. /** Defines the exponent of the function */
  5449. exponent?: number);
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power shape (see link below).
  5455. * @see https://easings.net/#easeInQuad
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class PowerEase extends EasingFunction implements IEasingFunction {
  5459. /** Defines the power of the function */
  5460. power: number;
  5461. /**
  5462. * Instantiates an power base easing function
  5463. * @see https://easings.net/#easeInQuad
  5464. * @param power Defines the power of the function
  5465. */
  5466. constructor(
  5467. /** Defines the power of the function */
  5468. power?: number);
  5469. /** @hidden */
  5470. easeInCore(gradient: number): number;
  5471. }
  5472. /**
  5473. * Easing function with a power of 2 shape (see link below).
  5474. * @see https://easings.net/#easeInQuad
  5475. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5476. */
  5477. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5478. /** @hidden */
  5479. easeInCore(gradient: number): number;
  5480. }
  5481. /**
  5482. * Easing function with a power of 4 shape (see link below).
  5483. * @see https://easings.net/#easeInQuart
  5484. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5485. */
  5486. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5487. /** @hidden */
  5488. easeInCore(gradient: number): number;
  5489. }
  5490. /**
  5491. * Easing function with a power of 5 shape (see link below).
  5492. * @see https://easings.net/#easeInQuint
  5493. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5494. */
  5495. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5496. /** @hidden */
  5497. easeInCore(gradient: number): number;
  5498. }
  5499. /**
  5500. * Easing function with a sin shape (see link below).
  5501. * @see https://easings.net/#easeInSine
  5502. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5503. */
  5504. export class SineEase extends EasingFunction implements IEasingFunction {
  5505. /** @hidden */
  5506. easeInCore(gradient: number): number;
  5507. }
  5508. /**
  5509. * Easing function with a bezier shape (see link below).
  5510. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5511. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5512. */
  5513. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5514. /** Defines the x component of the start tangent in the bezier curve */
  5515. x1: number;
  5516. /** Defines the y component of the start tangent in the bezier curve */
  5517. y1: number;
  5518. /** Defines the x component of the end tangent in the bezier curve */
  5519. x2: number;
  5520. /** Defines the y component of the end tangent in the bezier curve */
  5521. y2: number;
  5522. /**
  5523. * Instantiates a bezier function
  5524. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5525. * @param x1 Defines the x component of the start tangent in the bezier curve
  5526. * @param y1 Defines the y component of the start tangent in the bezier curve
  5527. * @param x2 Defines the x component of the end tangent in the bezier curve
  5528. * @param y2 Defines the y component of the end tangent in the bezier curve
  5529. */
  5530. constructor(
  5531. /** Defines the x component of the start tangent in the bezier curve */
  5532. x1?: number,
  5533. /** Defines the y component of the start tangent in the bezier curve */
  5534. y1?: number,
  5535. /** Defines the x component of the end tangent in the bezier curve */
  5536. x2?: number,
  5537. /** Defines the y component of the end tangent in the bezier curve */
  5538. y2?: number);
  5539. /** @hidden */
  5540. easeInCore(gradient: number): number;
  5541. }
  5542. }
  5543. declare module "babylonjs/Maths/math.color" {
  5544. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5545. /**
  5546. * Class used to hold a RBG color
  5547. */
  5548. export class Color3 {
  5549. /**
  5550. * Defines the red component (between 0 and 1, default is 0)
  5551. */
  5552. r: number;
  5553. /**
  5554. * Defines the green component (between 0 and 1, default is 0)
  5555. */
  5556. g: number;
  5557. /**
  5558. * Defines the blue component (between 0 and 1, default is 0)
  5559. */
  5560. b: number;
  5561. /**
  5562. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5563. * @param r defines the red component (between 0 and 1, default is 0)
  5564. * @param g defines the green component (between 0 and 1, default is 0)
  5565. * @param b defines the blue component (between 0 and 1, default is 0)
  5566. */
  5567. constructor(
  5568. /**
  5569. * Defines the red component (between 0 and 1, default is 0)
  5570. */
  5571. r?: number,
  5572. /**
  5573. * Defines the green component (between 0 and 1, default is 0)
  5574. */
  5575. g?: number,
  5576. /**
  5577. * Defines the blue component (between 0 and 1, default is 0)
  5578. */
  5579. b?: number);
  5580. /**
  5581. * Creates a string with the Color3 current values
  5582. * @returns the string representation of the Color3 object
  5583. */
  5584. toString(): string;
  5585. /**
  5586. * Returns the string "Color3"
  5587. * @returns "Color3"
  5588. */
  5589. getClassName(): string;
  5590. /**
  5591. * Compute the Color3 hash code
  5592. * @returns an unique number that can be used to hash Color3 objects
  5593. */
  5594. getHashCode(): number;
  5595. /**
  5596. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5597. * @param array defines the array where to store the r,g,b components
  5598. * @param index defines an optional index in the target array to define where to start storing values
  5599. * @returns the current Color3 object
  5600. */
  5601. toArray(array: FloatArray, index?: number): Color3;
  5602. /**
  5603. * Update the current color with values stored in an array from the starting index of the given array
  5604. * @param array defines the source array
  5605. * @param offset defines an offset in the source array
  5606. * @returns the current Color3 object
  5607. */
  5608. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5609. /**
  5610. * Returns a new Color4 object from the current Color3 and the given alpha
  5611. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5612. * @returns a new Color4 object
  5613. */
  5614. toColor4(alpha?: number): Color4;
  5615. /**
  5616. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5617. * @returns the new array
  5618. */
  5619. asArray(): number[];
  5620. /**
  5621. * Returns the luminance value
  5622. * @returns a float value
  5623. */
  5624. toLuminance(): number;
  5625. /**
  5626. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5627. * @param otherColor defines the second operand
  5628. * @returns the new Color3 object
  5629. */
  5630. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5631. /**
  5632. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5633. * @param otherColor defines the second operand
  5634. * @param result defines the Color3 object where to store the result
  5635. * @returns the current Color3
  5636. */
  5637. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5638. /**
  5639. * Determines equality between Color3 objects
  5640. * @param otherColor defines the second operand
  5641. * @returns true if the rgb values are equal to the given ones
  5642. */
  5643. equals(otherColor: DeepImmutable<Color3>): boolean;
  5644. /**
  5645. * Determines equality between the current Color3 object and a set of r,b,g values
  5646. * @param r defines the red component to check
  5647. * @param g defines the green component to check
  5648. * @param b defines the blue component to check
  5649. * @returns true if the rgb values are equal to the given ones
  5650. */
  5651. equalsFloats(r: number, g: number, b: number): boolean;
  5652. /**
  5653. * Multiplies in place each rgb value by scale
  5654. * @param scale defines the scaling factor
  5655. * @returns the updated Color3
  5656. */
  5657. scale(scale: number): Color3;
  5658. /**
  5659. * Multiplies the rgb values by scale and stores the result into "result"
  5660. * @param scale defines the scaling factor
  5661. * @param result defines the Color3 object where to store the result
  5662. * @returns the unmodified current Color3
  5663. */
  5664. scaleToRef(scale: number, result: Color3): Color3;
  5665. /**
  5666. * Scale the current Color3 values by a factor and add the result to a given Color3
  5667. * @param scale defines the scale factor
  5668. * @param result defines color to store the result into
  5669. * @returns the unmodified current Color3
  5670. */
  5671. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5672. /**
  5673. * Clamps the rgb values by the min and max values and stores the result into "result"
  5674. * @param min defines minimum clamping value (default is 0)
  5675. * @param max defines maximum clamping value (default is 1)
  5676. * @param result defines color to store the result into
  5677. * @returns the original Color3
  5678. */
  5679. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5680. /**
  5681. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5682. * @param otherColor defines the second operand
  5683. * @returns the new Color3
  5684. */
  5685. add(otherColor: DeepImmutable<Color3>): Color3;
  5686. /**
  5687. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5688. * @param otherColor defines the second operand
  5689. * @param result defines Color3 object to store the result into
  5690. * @returns the unmodified current Color3
  5691. */
  5692. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5693. /**
  5694. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5695. * @param otherColor defines the second operand
  5696. * @returns the new Color3
  5697. */
  5698. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5699. /**
  5700. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5701. * @param otherColor defines the second operand
  5702. * @param result defines Color3 object to store the result into
  5703. * @returns the unmodified current Color3
  5704. */
  5705. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5706. /**
  5707. * Copy the current object
  5708. * @returns a new Color3 copied the current one
  5709. */
  5710. clone(): Color3;
  5711. /**
  5712. * Copies the rgb values from the source in the current Color3
  5713. * @param source defines the source Color3 object
  5714. * @returns the updated Color3 object
  5715. */
  5716. copyFrom(source: DeepImmutable<Color3>): Color3;
  5717. /**
  5718. * Updates the Color3 rgb values from the given floats
  5719. * @param r defines the red component to read from
  5720. * @param g defines the green component to read from
  5721. * @param b defines the blue component to read from
  5722. * @returns the current Color3 object
  5723. */
  5724. copyFromFloats(r: number, g: number, b: number): Color3;
  5725. /**
  5726. * Updates the Color3 rgb values from the given floats
  5727. * @param r defines the red component to read from
  5728. * @param g defines the green component to read from
  5729. * @param b defines the blue component to read from
  5730. * @returns the current Color3 object
  5731. */
  5732. set(r: number, g: number, b: number): Color3;
  5733. /**
  5734. * Compute the Color3 hexadecimal code as a string
  5735. * @returns a string containing the hexadecimal representation of the Color3 object
  5736. */
  5737. toHexString(): string;
  5738. /**
  5739. * Computes a new Color3 converted from the current one to linear space
  5740. * @returns a new Color3 object
  5741. */
  5742. toLinearSpace(): Color3;
  5743. /**
  5744. * Converts current color in rgb space to HSV values
  5745. * @returns a new color3 representing the HSV values
  5746. */
  5747. toHSV(): Color3;
  5748. /**
  5749. * Converts current color in rgb space to HSV values
  5750. * @param result defines the Color3 where to store the HSV values
  5751. */
  5752. toHSVToRef(result: Color3): void;
  5753. /**
  5754. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5755. * @param convertedColor defines the Color3 object where to store the linear space version
  5756. * @returns the unmodified Color3
  5757. */
  5758. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5759. /**
  5760. * Computes a new Color3 converted from the current one to gamma space
  5761. * @returns a new Color3 object
  5762. */
  5763. toGammaSpace(): Color3;
  5764. /**
  5765. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5766. * @param convertedColor defines the Color3 object where to store the gamma space version
  5767. * @returns the unmodified Color3
  5768. */
  5769. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5770. private static _BlackReadOnly;
  5771. /**
  5772. * Convert Hue, saturation and value to a Color3 (RGB)
  5773. * @param hue defines the hue
  5774. * @param saturation defines the saturation
  5775. * @param value defines the value
  5776. * @param result defines the Color3 where to store the RGB values
  5777. */
  5778. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5779. /**
  5780. * Creates a new Color3 from the string containing valid hexadecimal values
  5781. * @param hex defines a string containing valid hexadecimal values
  5782. * @returns a new Color3 object
  5783. */
  5784. static FromHexString(hex: string): Color3;
  5785. /**
  5786. * Creates a new Color3 from the starting index of the given array
  5787. * @param array defines the source array
  5788. * @param offset defines an offset in the source array
  5789. * @returns a new Color3 object
  5790. */
  5791. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5792. /**
  5793. * Creates a new Color3 from the starting index element of the given array
  5794. * @param array defines the source array to read from
  5795. * @param offset defines the offset in the source array
  5796. * @param result defines the target Color3 object
  5797. */
  5798. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5799. /**
  5800. * Creates a new Color3 from integer values (< 256)
  5801. * @param r defines the red component to read from (value between 0 and 255)
  5802. * @param g defines the green component to read from (value between 0 and 255)
  5803. * @param b defines the blue component to read from (value between 0 and 255)
  5804. * @returns a new Color3 object
  5805. */
  5806. static FromInts(r: number, g: number, b: number): Color3;
  5807. /**
  5808. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5809. * @param start defines the start Color3 value
  5810. * @param end defines the end Color3 value
  5811. * @param amount defines the gradient value between start and end
  5812. * @returns a new Color3 object
  5813. */
  5814. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5815. /**
  5816. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5817. * @param left defines the start value
  5818. * @param right defines the end value
  5819. * @param amount defines the gradient factor
  5820. * @param result defines the Color3 object where to store the result
  5821. */
  5822. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5823. /**
  5824. * Returns a Color3 value containing a red color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Red(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a green color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Green(): Color3;
  5833. /**
  5834. * Returns a Color3 value containing a blue color
  5835. * @returns a new Color3 object
  5836. */
  5837. static Blue(): Color3;
  5838. /**
  5839. * Returns a Color3 value containing a black color
  5840. * @returns a new Color3 object
  5841. */
  5842. static Black(): Color3;
  5843. /**
  5844. * Gets a Color3 value containing a black color that must not be updated
  5845. */
  5846. static get BlackReadOnly(): DeepImmutable<Color3>;
  5847. /**
  5848. * Returns a Color3 value containing a white color
  5849. * @returns a new Color3 object
  5850. */
  5851. static White(): Color3;
  5852. /**
  5853. * Returns a Color3 value containing a purple color
  5854. * @returns a new Color3 object
  5855. */
  5856. static Purple(): Color3;
  5857. /**
  5858. * Returns a Color3 value containing a magenta color
  5859. * @returns a new Color3 object
  5860. */
  5861. static Magenta(): Color3;
  5862. /**
  5863. * Returns a Color3 value containing a yellow color
  5864. * @returns a new Color3 object
  5865. */
  5866. static Yellow(): Color3;
  5867. /**
  5868. * Returns a Color3 value containing a gray color
  5869. * @returns a new Color3 object
  5870. */
  5871. static Gray(): Color3;
  5872. /**
  5873. * Returns a Color3 value containing a teal color
  5874. * @returns a new Color3 object
  5875. */
  5876. static Teal(): Color3;
  5877. /**
  5878. * Returns a Color3 value containing a random color
  5879. * @returns a new Color3 object
  5880. */
  5881. static Random(): Color3;
  5882. }
  5883. /**
  5884. * Class used to hold a RBGA color
  5885. */
  5886. export class Color4 {
  5887. /**
  5888. * Defines the red component (between 0 and 1, default is 0)
  5889. */
  5890. r: number;
  5891. /**
  5892. * Defines the green component (between 0 and 1, default is 0)
  5893. */
  5894. g: number;
  5895. /**
  5896. * Defines the blue component (between 0 and 1, default is 0)
  5897. */
  5898. b: number;
  5899. /**
  5900. * Defines the alpha component (between 0 and 1, default is 1)
  5901. */
  5902. a: number;
  5903. /**
  5904. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5905. * @param r defines the red component (between 0 and 1, default is 0)
  5906. * @param g defines the green component (between 0 and 1, default is 0)
  5907. * @param b defines the blue component (between 0 and 1, default is 0)
  5908. * @param a defines the alpha component (between 0 and 1, default is 1)
  5909. */
  5910. constructor(
  5911. /**
  5912. * Defines the red component (between 0 and 1, default is 0)
  5913. */
  5914. r?: number,
  5915. /**
  5916. * Defines the green component (between 0 and 1, default is 0)
  5917. */
  5918. g?: number,
  5919. /**
  5920. * Defines the blue component (between 0 and 1, default is 0)
  5921. */
  5922. b?: number,
  5923. /**
  5924. * Defines the alpha component (between 0 and 1, default is 1)
  5925. */
  5926. a?: number);
  5927. /**
  5928. * Adds in place the given Color4 values to the current Color4 object
  5929. * @param right defines the second operand
  5930. * @returns the current updated Color4 object
  5931. */
  5932. addInPlace(right: DeepImmutable<Color4>): Color4;
  5933. /**
  5934. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5935. * @returns the new array
  5936. */
  5937. asArray(): number[];
  5938. /**
  5939. * Stores from the starting index in the given array the Color4 successive values
  5940. * @param array defines the array where to store the r,g,b components
  5941. * @param index defines an optional index in the target array to define where to start storing values
  5942. * @returns the current Color4 object
  5943. */
  5944. toArray(array: number[], index?: number): Color4;
  5945. /**
  5946. * Update the current color with values stored in an array from the starting index of the given array
  5947. * @param array defines the source array
  5948. * @param offset defines an offset in the source array
  5949. * @returns the current Color4 object
  5950. */
  5951. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5952. /**
  5953. * Determines equality between Color4 objects
  5954. * @param otherColor defines the second operand
  5955. * @returns true if the rgba values are equal to the given ones
  5956. */
  5957. equals(otherColor: DeepImmutable<Color4>): boolean;
  5958. /**
  5959. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5960. * @param right defines the second operand
  5961. * @returns a new Color4 object
  5962. */
  5963. add(right: DeepImmutable<Color4>): Color4;
  5964. /**
  5965. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5966. * @param right defines the second operand
  5967. * @returns a new Color4 object
  5968. */
  5969. subtract(right: DeepImmutable<Color4>): Color4;
  5970. /**
  5971. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5972. * @param right defines the second operand
  5973. * @param result defines the Color4 object where to store the result
  5974. * @returns the current Color4 object
  5975. */
  5976. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5977. /**
  5978. * Creates a new Color4 with the current Color4 values multiplied by scale
  5979. * @param scale defines the scaling factor to apply
  5980. * @returns a new Color4 object
  5981. */
  5982. scale(scale: number): Color4;
  5983. /**
  5984. * Multiplies the current Color4 values by scale and stores the result in "result"
  5985. * @param scale defines the scaling factor to apply
  5986. * @param result defines the Color4 object where to store the result
  5987. * @returns the current unmodified Color4
  5988. */
  5989. scaleToRef(scale: number, result: Color4): Color4;
  5990. /**
  5991. * Scale the current Color4 values by a factor and add the result to a given Color4
  5992. * @param scale defines the scale factor
  5993. * @param result defines the Color4 object where to store the result
  5994. * @returns the unmodified current Color4
  5995. */
  5996. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5997. /**
  5998. * Clamps the rgb values by the min and max values and stores the result into "result"
  5999. * @param min defines minimum clamping value (default is 0)
  6000. * @param max defines maximum clamping value (default is 1)
  6001. * @param result defines color to store the result into.
  6002. * @returns the cuurent Color4
  6003. */
  6004. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6005. /**
  6006. * Multipy an Color4 value by another and return a new Color4 object
  6007. * @param color defines the Color4 value to multiply by
  6008. * @returns a new Color4 object
  6009. */
  6010. multiply(color: Color4): Color4;
  6011. /**
  6012. * Multipy a Color4 value by another and push the result in a reference value
  6013. * @param color defines the Color4 value to multiply by
  6014. * @param result defines the Color4 to fill the result in
  6015. * @returns the result Color4
  6016. */
  6017. multiplyToRef(color: Color4, result: Color4): Color4;
  6018. /**
  6019. * Creates a string with the Color4 current values
  6020. * @returns the string representation of the Color4 object
  6021. */
  6022. toString(): string;
  6023. /**
  6024. * Returns the string "Color4"
  6025. * @returns "Color4"
  6026. */
  6027. getClassName(): string;
  6028. /**
  6029. * Compute the Color4 hash code
  6030. * @returns an unique number that can be used to hash Color4 objects
  6031. */
  6032. getHashCode(): number;
  6033. /**
  6034. * Creates a new Color4 copied from the current one
  6035. * @returns a new Color4 object
  6036. */
  6037. clone(): Color4;
  6038. /**
  6039. * Copies the given Color4 values into the current one
  6040. * @param source defines the source Color4 object
  6041. * @returns the current updated Color4 object
  6042. */
  6043. copyFrom(source: Color4): Color4;
  6044. /**
  6045. * Copies the given float values into the current one
  6046. * @param r defines the red component to read from
  6047. * @param g defines the green component to read from
  6048. * @param b defines the blue component to read from
  6049. * @param a defines the alpha component to read from
  6050. * @returns the current updated Color4 object
  6051. */
  6052. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6053. /**
  6054. * Copies the given float values into the current one
  6055. * @param r defines the red component to read from
  6056. * @param g defines the green component to read from
  6057. * @param b defines the blue component to read from
  6058. * @param a defines the alpha component to read from
  6059. * @returns the current updated Color4 object
  6060. */
  6061. set(r: number, g: number, b: number, a: number): Color4;
  6062. /**
  6063. * Compute the Color4 hexadecimal code as a string
  6064. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6065. * @returns a string containing the hexadecimal representation of the Color4 object
  6066. */
  6067. toHexString(returnAsColor3?: boolean): string;
  6068. /**
  6069. * Computes a new Color4 converted from the current one to linear space
  6070. * @returns a new Color4 object
  6071. */
  6072. toLinearSpace(): Color4;
  6073. /**
  6074. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6075. * @param convertedColor defines the Color4 object where to store the linear space version
  6076. * @returns the unmodified Color4
  6077. */
  6078. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6079. /**
  6080. * Computes a new Color4 converted from the current one to gamma space
  6081. * @returns a new Color4 object
  6082. */
  6083. toGammaSpace(): Color4;
  6084. /**
  6085. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6086. * @param convertedColor defines the Color4 object where to store the gamma space version
  6087. * @returns the unmodified Color4
  6088. */
  6089. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6090. /**
  6091. * Creates a new Color4 from the string containing valid hexadecimal values
  6092. * @param hex defines a string containing valid hexadecimal values
  6093. * @returns a new Color4 object
  6094. */
  6095. static FromHexString(hex: string): Color4;
  6096. /**
  6097. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6098. * @param left defines the start value
  6099. * @param right defines the end value
  6100. * @param amount defines the gradient factor
  6101. * @returns a new Color4 object
  6102. */
  6103. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6104. /**
  6105. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6106. * @param left defines the start value
  6107. * @param right defines the end value
  6108. * @param amount defines the gradient factor
  6109. * @param result defines the Color4 object where to store data
  6110. */
  6111. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6112. /**
  6113. * Creates a new Color4 from a Color3 and an alpha value
  6114. * @param color3 defines the source Color3 to read from
  6115. * @param alpha defines the alpha component (1.0 by default)
  6116. * @returns a new Color4 object
  6117. */
  6118. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6119. /**
  6120. * Creates a new Color4 from the starting index element of the given array
  6121. * @param array defines the source array to read from
  6122. * @param offset defines the offset in the source array
  6123. * @returns a new Color4 object
  6124. */
  6125. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6126. /**
  6127. * Creates a new Color4 from the starting index element of the given array
  6128. * @param array defines the source array to read from
  6129. * @param offset defines the offset in the source array
  6130. * @param result defines the target Color4 object
  6131. */
  6132. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6133. /**
  6134. * Creates a new Color3 from integer values (< 256)
  6135. * @param r defines the red component to read from (value between 0 and 255)
  6136. * @param g defines the green component to read from (value between 0 and 255)
  6137. * @param b defines the blue component to read from (value between 0 and 255)
  6138. * @param a defines the alpha component to read from (value between 0 and 255)
  6139. * @returns a new Color3 object
  6140. */
  6141. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6142. /**
  6143. * Check the content of a given array and convert it to an array containing RGBA data
  6144. * If the original array was already containing count * 4 values then it is returned directly
  6145. * @param colors defines the array to check
  6146. * @param count defines the number of RGBA data to expect
  6147. * @returns an array containing count * 4 values (RGBA)
  6148. */
  6149. static CheckColors4(colors: number[], count: number): number[];
  6150. }
  6151. /**
  6152. * @hidden
  6153. */
  6154. export class TmpColors {
  6155. static Color3: Color3[];
  6156. static Color4: Color4[];
  6157. }
  6158. }
  6159. declare module "babylonjs/Animations/animationKey" {
  6160. /**
  6161. * Defines an interface which represents an animation key frame
  6162. */
  6163. export interface IAnimationKey {
  6164. /**
  6165. * Frame of the key frame
  6166. */
  6167. frame: number;
  6168. /**
  6169. * Value at the specifies key frame
  6170. */
  6171. value: any;
  6172. /**
  6173. * The input tangent for the cubic hermite spline
  6174. */
  6175. inTangent?: any;
  6176. /**
  6177. * The output tangent for the cubic hermite spline
  6178. */
  6179. outTangent?: any;
  6180. /**
  6181. * The animation interpolation type
  6182. */
  6183. interpolation?: AnimationKeyInterpolation;
  6184. }
  6185. /**
  6186. * Enum for the animation key frame interpolation type
  6187. */
  6188. export enum AnimationKeyInterpolation {
  6189. /**
  6190. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6191. */
  6192. STEP = 1
  6193. }
  6194. }
  6195. declare module "babylonjs/Animations/animationRange" {
  6196. /**
  6197. * Represents the range of an animation
  6198. */
  6199. export class AnimationRange {
  6200. /**The name of the animation range**/
  6201. name: string;
  6202. /**The starting frame of the animation */
  6203. from: number;
  6204. /**The ending frame of the animation*/
  6205. to: number;
  6206. /**
  6207. * Initializes the range of an animation
  6208. * @param name The name of the animation range
  6209. * @param from The starting frame of the animation
  6210. * @param to The ending frame of the animation
  6211. */
  6212. constructor(
  6213. /**The name of the animation range**/
  6214. name: string,
  6215. /**The starting frame of the animation */
  6216. from: number,
  6217. /**The ending frame of the animation*/
  6218. to: number);
  6219. /**
  6220. * Makes a copy of the animation range
  6221. * @returns A copy of the animation range
  6222. */
  6223. clone(): AnimationRange;
  6224. }
  6225. }
  6226. declare module "babylonjs/Animations/animationEvent" {
  6227. /**
  6228. * Composed of a frame, and an action function
  6229. */
  6230. export class AnimationEvent {
  6231. /** The frame for which the event is triggered **/
  6232. frame: number;
  6233. /** The event to perform when triggered **/
  6234. action: (currentFrame: number) => void;
  6235. /** Specifies if the event should be triggered only once**/
  6236. onlyOnce?: boolean | undefined;
  6237. /**
  6238. * Specifies if the animation event is done
  6239. */
  6240. isDone: boolean;
  6241. /**
  6242. * Initializes the animation event
  6243. * @param frame The frame for which the event is triggered
  6244. * @param action The event to perform when triggered
  6245. * @param onlyOnce Specifies if the event should be triggered only once
  6246. */
  6247. constructor(
  6248. /** The frame for which the event is triggered **/
  6249. frame: number,
  6250. /** The event to perform when triggered **/
  6251. action: (currentFrame: number) => void,
  6252. /** Specifies if the event should be triggered only once**/
  6253. onlyOnce?: boolean | undefined);
  6254. /** @hidden */
  6255. _clone(): AnimationEvent;
  6256. }
  6257. }
  6258. declare module "babylonjs/Behaviors/behavior" {
  6259. import { Nullable } from "babylonjs/types";
  6260. /**
  6261. * Interface used to define a behavior
  6262. */
  6263. export interface Behavior<T> {
  6264. /** gets or sets behavior's name */
  6265. name: string;
  6266. /**
  6267. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6268. */
  6269. init(): void;
  6270. /**
  6271. * Called when the behavior is attached to a target
  6272. * @param target defines the target where the behavior is attached to
  6273. */
  6274. attach(target: T): void;
  6275. /**
  6276. * Called when the behavior is detached from its target
  6277. */
  6278. detach(): void;
  6279. }
  6280. /**
  6281. * Interface implemented by classes supporting behaviors
  6282. */
  6283. export interface IBehaviorAware<T> {
  6284. /**
  6285. * Attach a behavior
  6286. * @param behavior defines the behavior to attach
  6287. * @returns the current host
  6288. */
  6289. addBehavior(behavior: Behavior<T>): T;
  6290. /**
  6291. * Remove a behavior from the current object
  6292. * @param behavior defines the behavior to detach
  6293. * @returns the current host
  6294. */
  6295. removeBehavior(behavior: Behavior<T>): T;
  6296. /**
  6297. * Gets a behavior using its name to search
  6298. * @param name defines the name to search
  6299. * @returns the behavior or null if not found
  6300. */
  6301. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6302. }
  6303. }
  6304. declare module "babylonjs/Misc/smartArray" {
  6305. /**
  6306. * Defines an array and its length.
  6307. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6308. */
  6309. export interface ISmartArrayLike<T> {
  6310. /**
  6311. * The data of the array.
  6312. */
  6313. data: Array<T>;
  6314. /**
  6315. * The active length of the array.
  6316. */
  6317. length: number;
  6318. }
  6319. /**
  6320. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6321. */
  6322. export class SmartArray<T> implements ISmartArrayLike<T> {
  6323. /**
  6324. * The full set of data from the array.
  6325. */
  6326. data: Array<T>;
  6327. /**
  6328. * The active length of the array.
  6329. */
  6330. length: number;
  6331. protected _id: number;
  6332. /**
  6333. * Instantiates a Smart Array.
  6334. * @param capacity defines the default capacity of the array.
  6335. */
  6336. constructor(capacity: number);
  6337. /**
  6338. * Pushes a value at the end of the active data.
  6339. * @param value defines the object to push in the array.
  6340. */
  6341. push(value: T): void;
  6342. /**
  6343. * Iterates over the active data and apply the lambda to them.
  6344. * @param func defines the action to apply on each value.
  6345. */
  6346. forEach(func: (content: T) => void): void;
  6347. /**
  6348. * Sorts the full sets of data.
  6349. * @param compareFn defines the comparison function to apply.
  6350. */
  6351. sort(compareFn: (a: T, b: T) => number): void;
  6352. /**
  6353. * Resets the active data to an empty array.
  6354. */
  6355. reset(): void;
  6356. /**
  6357. * Releases all the data from the array as well as the array.
  6358. */
  6359. dispose(): void;
  6360. /**
  6361. * Concats the active data with a given array.
  6362. * @param array defines the data to concatenate with.
  6363. */
  6364. concat(array: any): void;
  6365. /**
  6366. * Returns the position of a value in the active data.
  6367. * @param value defines the value to find the index for
  6368. * @returns the index if found in the active data otherwise -1
  6369. */
  6370. indexOf(value: T): number;
  6371. /**
  6372. * Returns whether an element is part of the active data.
  6373. * @param value defines the value to look for
  6374. * @returns true if found in the active data otherwise false
  6375. */
  6376. contains(value: T): boolean;
  6377. private static _GlobalId;
  6378. }
  6379. /**
  6380. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6381. * The data in this array can only be present once
  6382. */
  6383. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6384. private _duplicateId;
  6385. /**
  6386. * Pushes a value at the end of the active data.
  6387. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6388. * @param value defines the object to push in the array.
  6389. */
  6390. push(value: T): void;
  6391. /**
  6392. * Pushes a value at the end of the active data.
  6393. * If the data is already present, it won t be added again
  6394. * @param value defines the object to push in the array.
  6395. * @returns true if added false if it was already present
  6396. */
  6397. pushNoDuplicate(value: T): boolean;
  6398. /**
  6399. * Resets the active data to an empty array.
  6400. */
  6401. reset(): void;
  6402. /**
  6403. * Concats the active data with a given array.
  6404. * This ensures no dupplicate will be present in the result.
  6405. * @param array defines the data to concatenate with.
  6406. */
  6407. concatWithNoDuplicate(array: any): void;
  6408. }
  6409. }
  6410. declare module "babylonjs/Cameras/cameraInputsManager" {
  6411. import { Nullable } from "babylonjs/types";
  6412. import { Camera } from "babylonjs/Cameras/camera";
  6413. /**
  6414. * @ignore
  6415. * This is a list of all the different input types that are available in the application.
  6416. * Fo instance: ArcRotateCameraGamepadInput...
  6417. */
  6418. export var CameraInputTypes: {};
  6419. /**
  6420. * This is the contract to implement in order to create a new input class.
  6421. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6422. */
  6423. export interface ICameraInput<TCamera extends Camera> {
  6424. /**
  6425. * Defines the camera the input is attached to.
  6426. */
  6427. camera: Nullable<TCamera>;
  6428. /**
  6429. * Gets the class name of the current intput.
  6430. * @returns the class name
  6431. */
  6432. getClassName(): string;
  6433. /**
  6434. * Get the friendly name associated with the input class.
  6435. * @returns the input friendly name
  6436. */
  6437. getSimpleName(): string;
  6438. /**
  6439. * Attach the input controls to a specific dom element to get the input from.
  6440. * @param element Defines the element the controls should be listened from
  6441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6442. */
  6443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6444. /**
  6445. * Detach the current controls from the specified dom element.
  6446. * @param element Defines the element to stop listening the inputs from
  6447. */
  6448. detachControl(element: Nullable<HTMLElement>): void;
  6449. /**
  6450. * Update the current camera state depending on the inputs that have been used this frame.
  6451. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6452. */
  6453. checkInputs?: () => void;
  6454. }
  6455. /**
  6456. * Represents a map of input types to input instance or input index to input instance.
  6457. */
  6458. export interface CameraInputsMap<TCamera extends Camera> {
  6459. /**
  6460. * Accessor to the input by input type.
  6461. */
  6462. [name: string]: ICameraInput<TCamera>;
  6463. /**
  6464. * Accessor to the input by input index.
  6465. */
  6466. [idx: number]: ICameraInput<TCamera>;
  6467. }
  6468. /**
  6469. * This represents the input manager used within a camera.
  6470. * It helps dealing with all the different kind of input attached to a camera.
  6471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6472. */
  6473. export class CameraInputsManager<TCamera extends Camera> {
  6474. /**
  6475. * Defines the list of inputs attahed to the camera.
  6476. */
  6477. attached: CameraInputsMap<TCamera>;
  6478. /**
  6479. * Defines the dom element the camera is collecting inputs from.
  6480. * This is null if the controls have not been attached.
  6481. */
  6482. attachedElement: Nullable<HTMLElement>;
  6483. /**
  6484. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6485. */
  6486. noPreventDefault: boolean;
  6487. /**
  6488. * Defined the camera the input manager belongs to.
  6489. */
  6490. camera: TCamera;
  6491. /**
  6492. * Update the current camera state depending on the inputs that have been used this frame.
  6493. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6494. */
  6495. checkInputs: () => void;
  6496. /**
  6497. * Instantiate a new Camera Input Manager.
  6498. * @param camera Defines the camera the input manager blongs to
  6499. */
  6500. constructor(camera: TCamera);
  6501. /**
  6502. * Add an input method to a camera
  6503. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6504. * @param input camera input method
  6505. */
  6506. add(input: ICameraInput<TCamera>): void;
  6507. /**
  6508. * Remove a specific input method from a camera
  6509. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6510. * @param inputToRemove camera input method
  6511. */
  6512. remove(inputToRemove: ICameraInput<TCamera>): void;
  6513. /**
  6514. * Remove a specific input type from a camera
  6515. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6516. * @param inputType the type of the input to remove
  6517. */
  6518. removeByType(inputType: string): void;
  6519. private _addCheckInputs;
  6520. /**
  6521. * Attach the input controls to the currently attached dom element to listen the events from.
  6522. * @param input Defines the input to attach
  6523. */
  6524. attachInput(input: ICameraInput<TCamera>): void;
  6525. /**
  6526. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6527. * @param element Defines the dom element to collect the events from
  6528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6529. */
  6530. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6531. /**
  6532. * Detach the current manager inputs controls from a specific dom element.
  6533. * @param element Defines the dom element to collect the events from
  6534. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6535. */
  6536. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6537. /**
  6538. * Rebuild the dynamic inputCheck function from the current list of
  6539. * defined inputs in the manager.
  6540. */
  6541. rebuildInputCheck(): void;
  6542. /**
  6543. * Remove all attached input methods from a camera
  6544. */
  6545. clear(): void;
  6546. /**
  6547. * Serialize the current input manager attached to a camera.
  6548. * This ensures than once parsed,
  6549. * the input associated to the camera will be identical to the current ones
  6550. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6551. */
  6552. serialize(serializedCamera: any): void;
  6553. /**
  6554. * Parses an input manager serialized JSON to restore the previous list of inputs
  6555. * and states associated to a camera.
  6556. * @param parsedCamera Defines the JSON to parse
  6557. */
  6558. parse(parsedCamera: any): void;
  6559. }
  6560. }
  6561. declare module "babylonjs/Meshes/buffer" {
  6562. import { Nullable, DataArray } from "babylonjs/types";
  6563. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6564. /**
  6565. * Class used to store data that will be store in GPU memory
  6566. */
  6567. export class Buffer {
  6568. private _engine;
  6569. private _buffer;
  6570. /** @hidden */
  6571. _data: Nullable<DataArray>;
  6572. private _updatable;
  6573. private _instanced;
  6574. private _divisor;
  6575. /**
  6576. * Gets the byte stride.
  6577. */
  6578. readonly byteStride: number;
  6579. /**
  6580. * Constructor
  6581. * @param engine the engine
  6582. * @param data the data to use for this buffer
  6583. * @param updatable whether the data is updatable
  6584. * @param stride the stride (optional)
  6585. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6586. * @param instanced whether the buffer is instanced (optional)
  6587. * @param useBytes set to true if the stride in in bytes (optional)
  6588. * @param divisor sets an optional divisor for instances (1 by default)
  6589. */
  6590. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6591. /**
  6592. * Create a new VertexBuffer based on the current buffer
  6593. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6594. * @param offset defines offset in the buffer (0 by default)
  6595. * @param size defines the size in floats of attributes (position is 3 for instance)
  6596. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6597. * @param instanced defines if the vertex buffer contains indexed data
  6598. * @param useBytes defines if the offset and stride are in bytes *
  6599. * @param divisor sets an optional divisor for instances (1 by default)
  6600. * @returns the new vertex buffer
  6601. */
  6602. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6603. /**
  6604. * Gets a boolean indicating if the Buffer is updatable?
  6605. * @returns true if the buffer is updatable
  6606. */
  6607. isUpdatable(): boolean;
  6608. /**
  6609. * Gets current buffer's data
  6610. * @returns a DataArray or null
  6611. */
  6612. getData(): Nullable<DataArray>;
  6613. /**
  6614. * Gets underlying native buffer
  6615. * @returns underlying native buffer
  6616. */
  6617. getBuffer(): Nullable<DataBuffer>;
  6618. /**
  6619. * Gets the stride in float32 units (i.e. byte stride / 4).
  6620. * May not be an integer if the byte stride is not divisible by 4.
  6621. * @returns the stride in float32 units
  6622. * @deprecated Please use byteStride instead.
  6623. */
  6624. getStrideSize(): number;
  6625. /**
  6626. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6627. * @param data defines the data to store
  6628. */
  6629. create(data?: Nullable<DataArray>): void;
  6630. /** @hidden */
  6631. _rebuild(): void;
  6632. /**
  6633. * Update current buffer data
  6634. * @param data defines the data to store
  6635. */
  6636. update(data: DataArray): void;
  6637. /**
  6638. * Updates the data directly.
  6639. * @param data the new data
  6640. * @param offset the new offset
  6641. * @param vertexCount the vertex count (optional)
  6642. * @param useBytes set to true if the offset is in bytes
  6643. */
  6644. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6645. /**
  6646. * Release all resources
  6647. */
  6648. dispose(): void;
  6649. }
  6650. /**
  6651. * Specialized buffer used to store vertex data
  6652. */
  6653. export class VertexBuffer {
  6654. /** @hidden */
  6655. _buffer: Buffer;
  6656. private _kind;
  6657. private _size;
  6658. private _ownsBuffer;
  6659. private _instanced;
  6660. private _instanceDivisor;
  6661. /**
  6662. * The byte type.
  6663. */
  6664. static readonly BYTE: number;
  6665. /**
  6666. * The unsigned byte type.
  6667. */
  6668. static readonly UNSIGNED_BYTE: number;
  6669. /**
  6670. * The short type.
  6671. */
  6672. static readonly SHORT: number;
  6673. /**
  6674. * The unsigned short type.
  6675. */
  6676. static readonly UNSIGNED_SHORT: number;
  6677. /**
  6678. * The integer type.
  6679. */
  6680. static readonly INT: number;
  6681. /**
  6682. * The unsigned integer type.
  6683. */
  6684. static readonly UNSIGNED_INT: number;
  6685. /**
  6686. * The float type.
  6687. */
  6688. static readonly FLOAT: number;
  6689. /**
  6690. * Gets or sets the instance divisor when in instanced mode
  6691. */
  6692. get instanceDivisor(): number;
  6693. set instanceDivisor(value: number);
  6694. /**
  6695. * Gets the byte stride.
  6696. */
  6697. readonly byteStride: number;
  6698. /**
  6699. * Gets the byte offset.
  6700. */
  6701. readonly byteOffset: number;
  6702. /**
  6703. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6704. */
  6705. readonly normalized: boolean;
  6706. /**
  6707. * Gets the data type of each component in the array.
  6708. */
  6709. readonly type: number;
  6710. /**
  6711. * Constructor
  6712. * @param engine the engine
  6713. * @param data the data to use for this vertex buffer
  6714. * @param kind the vertex buffer kind
  6715. * @param updatable whether the data is updatable
  6716. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6717. * @param stride the stride (optional)
  6718. * @param instanced whether the buffer is instanced (optional)
  6719. * @param offset the offset of the data (optional)
  6720. * @param size the number of components (optional)
  6721. * @param type the type of the component (optional)
  6722. * @param normalized whether the data contains normalized data (optional)
  6723. * @param useBytes set to true if stride and offset are in bytes (optional)
  6724. * @param divisor defines the instance divisor to use (1 by default)
  6725. */
  6726. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6727. /** @hidden */
  6728. _rebuild(): void;
  6729. /**
  6730. * Returns the kind of the VertexBuffer (string)
  6731. * @returns a string
  6732. */
  6733. getKind(): string;
  6734. /**
  6735. * Gets a boolean indicating if the VertexBuffer is updatable?
  6736. * @returns true if the buffer is updatable
  6737. */
  6738. isUpdatable(): boolean;
  6739. /**
  6740. * Gets current buffer's data
  6741. * @returns a DataArray or null
  6742. */
  6743. getData(): Nullable<DataArray>;
  6744. /**
  6745. * Gets underlying native buffer
  6746. * @returns underlying native buffer
  6747. */
  6748. getBuffer(): Nullable<DataBuffer>;
  6749. /**
  6750. * Gets the stride in float32 units (i.e. byte stride / 4).
  6751. * May not be an integer if the byte stride is not divisible by 4.
  6752. * @returns the stride in float32 units
  6753. * @deprecated Please use byteStride instead.
  6754. */
  6755. getStrideSize(): number;
  6756. /**
  6757. * Returns the offset as a multiple of the type byte length.
  6758. * @returns the offset in bytes
  6759. * @deprecated Please use byteOffset instead.
  6760. */
  6761. getOffset(): number;
  6762. /**
  6763. * Returns the number of components per vertex attribute (integer)
  6764. * @returns the size in float
  6765. */
  6766. getSize(): number;
  6767. /**
  6768. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6769. * @returns true if this buffer is instanced
  6770. */
  6771. getIsInstanced(): boolean;
  6772. /**
  6773. * Returns the instancing divisor, zero for non-instanced (integer).
  6774. * @returns a number
  6775. */
  6776. getInstanceDivisor(): number;
  6777. /**
  6778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6779. * @param data defines the data to store
  6780. */
  6781. create(data?: DataArray): void;
  6782. /**
  6783. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6784. * This function will create a new buffer if the current one is not updatable
  6785. * @param data defines the data to store
  6786. */
  6787. update(data: DataArray): void;
  6788. /**
  6789. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6790. * Returns the directly updated WebGLBuffer.
  6791. * @param data the new data
  6792. * @param offset the new offset
  6793. * @param useBytes set to true if the offset is in bytes
  6794. */
  6795. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6796. /**
  6797. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6798. */
  6799. dispose(): void;
  6800. /**
  6801. * Enumerates each value of this vertex buffer as numbers.
  6802. * @param count the number of values to enumerate
  6803. * @param callback the callback function called for each value
  6804. */
  6805. forEach(count: number, callback: (value: number, index: number) => void): void;
  6806. /**
  6807. * Positions
  6808. */
  6809. static readonly PositionKind: string;
  6810. /**
  6811. * Normals
  6812. */
  6813. static readonly NormalKind: string;
  6814. /**
  6815. * Tangents
  6816. */
  6817. static readonly TangentKind: string;
  6818. /**
  6819. * Texture coordinates
  6820. */
  6821. static readonly UVKind: string;
  6822. /**
  6823. * Texture coordinates 2
  6824. */
  6825. static readonly UV2Kind: string;
  6826. /**
  6827. * Texture coordinates 3
  6828. */
  6829. static readonly UV3Kind: string;
  6830. /**
  6831. * Texture coordinates 4
  6832. */
  6833. static readonly UV4Kind: string;
  6834. /**
  6835. * Texture coordinates 5
  6836. */
  6837. static readonly UV5Kind: string;
  6838. /**
  6839. * Texture coordinates 6
  6840. */
  6841. static readonly UV6Kind: string;
  6842. /**
  6843. * Colors
  6844. */
  6845. static readonly ColorKind: string;
  6846. /**
  6847. * Matrix indices (for bones)
  6848. */
  6849. static readonly MatricesIndicesKind: string;
  6850. /**
  6851. * Matrix weights (for bones)
  6852. */
  6853. static readonly MatricesWeightsKind: string;
  6854. /**
  6855. * Additional matrix indices (for bones)
  6856. */
  6857. static readonly MatricesIndicesExtraKind: string;
  6858. /**
  6859. * Additional matrix weights (for bones)
  6860. */
  6861. static readonly MatricesWeightsExtraKind: string;
  6862. /**
  6863. * Deduces the stride given a kind.
  6864. * @param kind The kind string to deduce
  6865. * @returns The deduced stride
  6866. */
  6867. static DeduceStride(kind: string): number;
  6868. /**
  6869. * Gets the byte length of the given type.
  6870. * @param type the type
  6871. * @returns the number of bytes
  6872. */
  6873. static GetTypeByteLength(type: number): number;
  6874. /**
  6875. * Enumerates each value of the given parameters as numbers.
  6876. * @param data the data to enumerate
  6877. * @param byteOffset the byte offset of the data
  6878. * @param byteStride the byte stride of the data
  6879. * @param componentCount the number of components per element
  6880. * @param componentType the type of the component
  6881. * @param count the number of values to enumerate
  6882. * @param normalized whether the data is normalized
  6883. * @param callback the callback function called for each value
  6884. */
  6885. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6886. private static _GetFloatValue;
  6887. }
  6888. }
  6889. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6890. import { Vector3 } from "babylonjs/Maths/math.vector";
  6891. import { Mesh } from "babylonjs/Meshes/mesh";
  6892. /**
  6893. * The options Interface for creating a Capsule Mesh
  6894. */
  6895. export interface ICreateCapsuleOptions {
  6896. /** The Orientation of the capsule. Default : Vector3.Up() */
  6897. orientation?: Vector3;
  6898. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6899. subdivisions: number;
  6900. /** Number of cylindrical segments on the capsule. */
  6901. tessellation: number;
  6902. /** Height or Length of the capsule. */
  6903. height: number;
  6904. /** Radius of the capsule. */
  6905. radius: number;
  6906. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6907. capSubdivisions: number;
  6908. /** Overwrite for the top radius. */
  6909. radiusTop?: number;
  6910. /** Overwrite for the bottom radius. */
  6911. radiusBottom?: number;
  6912. /** Overwrite for the top capSubdivisions. */
  6913. topCapSubdivisions?: number;
  6914. /** Overwrite for the bottom capSubdivisions. */
  6915. bottomCapSubdivisions?: number;
  6916. }
  6917. /**
  6918. * Class containing static functions to help procedurally build meshes
  6919. */
  6920. export class CapsuleBuilder {
  6921. /**
  6922. * Creates a capsule or a pill mesh
  6923. * @param name defines the name of the mesh
  6924. * @param options The constructors options.
  6925. * @param scene The scene the mesh is scoped to.
  6926. * @returns Capsule Mesh
  6927. */
  6928. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6929. }
  6930. }
  6931. declare module "babylonjs/Collisions/intersectionInfo" {
  6932. import { Nullable } from "babylonjs/types";
  6933. /**
  6934. * @hidden
  6935. */
  6936. export class IntersectionInfo {
  6937. bu: Nullable<number>;
  6938. bv: Nullable<number>;
  6939. distance: number;
  6940. faceId: number;
  6941. subMeshId: number;
  6942. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6943. }
  6944. }
  6945. declare module "babylonjs/Culling/boundingSphere" {
  6946. import { DeepImmutable } from "babylonjs/types";
  6947. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6948. import { Plane } from "babylonjs/Maths/math.plane";
  6949. /**
  6950. * Class used to store bounding sphere information
  6951. */
  6952. export class BoundingSphere {
  6953. /**
  6954. * Gets the center of the bounding sphere in local space
  6955. */
  6956. readonly center: Vector3;
  6957. /**
  6958. * Radius of the bounding sphere in local space
  6959. */
  6960. radius: number;
  6961. /**
  6962. * Gets the center of the bounding sphere in world space
  6963. */
  6964. readonly centerWorld: Vector3;
  6965. /**
  6966. * Radius of the bounding sphere in world space
  6967. */
  6968. radiusWorld: number;
  6969. /**
  6970. * Gets the minimum vector in local space
  6971. */
  6972. readonly minimum: Vector3;
  6973. /**
  6974. * Gets the maximum vector in local space
  6975. */
  6976. readonly maximum: Vector3;
  6977. private _worldMatrix;
  6978. private static readonly TmpVector3;
  6979. /**
  6980. * Creates a new bounding sphere
  6981. * @param min defines the minimum vector (in local space)
  6982. * @param max defines the maximum vector (in local space)
  6983. * @param worldMatrix defines the new world matrix
  6984. */
  6985. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6986. /**
  6987. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6988. * @param min defines the new minimum vector (in local space)
  6989. * @param max defines the new maximum vector (in local space)
  6990. * @param worldMatrix defines the new world matrix
  6991. */
  6992. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6993. /**
  6994. * Scale the current bounding sphere by applying a scale factor
  6995. * @param factor defines the scale factor to apply
  6996. * @returns the current bounding box
  6997. */
  6998. scale(factor: number): BoundingSphere;
  6999. /**
  7000. * Gets the world matrix of the bounding box
  7001. * @returns a matrix
  7002. */
  7003. getWorldMatrix(): DeepImmutable<Matrix>;
  7004. /** @hidden */
  7005. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7006. /**
  7007. * Tests if the bounding sphere is intersecting the frustum planes
  7008. * @param frustumPlanes defines the frustum planes to test
  7009. * @returns true if there is an intersection
  7010. */
  7011. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7012. /**
  7013. * Tests if the bounding sphere center is in between the frustum planes.
  7014. * Used for optimistic fast inclusion.
  7015. * @param frustumPlanes defines the frustum planes to test
  7016. * @returns true if the sphere center is in between the frustum planes
  7017. */
  7018. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7019. /**
  7020. * Tests if a point is inside the bounding sphere
  7021. * @param point defines the point to test
  7022. * @returns true if the point is inside the bounding sphere
  7023. */
  7024. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7025. /**
  7026. * Checks if two sphere intersct
  7027. * @param sphere0 sphere 0
  7028. * @param sphere1 sphere 1
  7029. * @returns true if the speres intersect
  7030. */
  7031. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7032. }
  7033. }
  7034. declare module "babylonjs/Culling/boundingBox" {
  7035. import { DeepImmutable } from "babylonjs/types";
  7036. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7037. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7038. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7039. import { Plane } from "babylonjs/Maths/math.plane";
  7040. /**
  7041. * Class used to store bounding box information
  7042. */
  7043. export class BoundingBox implements ICullable {
  7044. /**
  7045. * Gets the 8 vectors representing the bounding box in local space
  7046. */
  7047. readonly vectors: Vector3[];
  7048. /**
  7049. * Gets the center of the bounding box in local space
  7050. */
  7051. readonly center: Vector3;
  7052. /**
  7053. * Gets the center of the bounding box in world space
  7054. */
  7055. readonly centerWorld: Vector3;
  7056. /**
  7057. * Gets the extend size in local space
  7058. */
  7059. readonly extendSize: Vector3;
  7060. /**
  7061. * Gets the extend size in world space
  7062. */
  7063. readonly extendSizeWorld: Vector3;
  7064. /**
  7065. * Gets the OBB (object bounding box) directions
  7066. */
  7067. readonly directions: Vector3[];
  7068. /**
  7069. * Gets the 8 vectors representing the bounding box in world space
  7070. */
  7071. readonly vectorsWorld: Vector3[];
  7072. /**
  7073. * Gets the minimum vector in world space
  7074. */
  7075. readonly minimumWorld: Vector3;
  7076. /**
  7077. * Gets the maximum vector in world space
  7078. */
  7079. readonly maximumWorld: Vector3;
  7080. /**
  7081. * Gets the minimum vector in local space
  7082. */
  7083. readonly minimum: Vector3;
  7084. /**
  7085. * Gets the maximum vector in local space
  7086. */
  7087. readonly maximum: Vector3;
  7088. private _worldMatrix;
  7089. private static readonly TmpVector3;
  7090. /**
  7091. * @hidden
  7092. */
  7093. _tag: number;
  7094. /**
  7095. * Creates a new bounding box
  7096. * @param min defines the minimum vector (in local space)
  7097. * @param max defines the maximum vector (in local space)
  7098. * @param worldMatrix defines the new world matrix
  7099. */
  7100. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7101. /**
  7102. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7103. * @param min defines the new minimum vector (in local space)
  7104. * @param max defines the new maximum vector (in local space)
  7105. * @param worldMatrix defines the new world matrix
  7106. */
  7107. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7108. /**
  7109. * Scale the current bounding box by applying a scale factor
  7110. * @param factor defines the scale factor to apply
  7111. * @returns the current bounding box
  7112. */
  7113. scale(factor: number): BoundingBox;
  7114. /**
  7115. * Gets the world matrix of the bounding box
  7116. * @returns a matrix
  7117. */
  7118. getWorldMatrix(): DeepImmutable<Matrix>;
  7119. /** @hidden */
  7120. _update(world: DeepImmutable<Matrix>): void;
  7121. /**
  7122. * Tests if the bounding box is intersecting the frustum planes
  7123. * @param frustumPlanes defines the frustum planes to test
  7124. * @returns true if there is an intersection
  7125. */
  7126. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7127. /**
  7128. * Tests if the bounding box is entirely inside the frustum planes
  7129. * @param frustumPlanes defines the frustum planes to test
  7130. * @returns true if there is an inclusion
  7131. */
  7132. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7133. /**
  7134. * Tests if a point is inside the bounding box
  7135. * @param point defines the point to test
  7136. * @returns true if the point is inside the bounding box
  7137. */
  7138. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7139. /**
  7140. * Tests if the bounding box intersects with a bounding sphere
  7141. * @param sphere defines the sphere to test
  7142. * @returns true if there is an intersection
  7143. */
  7144. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7145. /**
  7146. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7147. * @param min defines the min vector to use
  7148. * @param max defines the max vector to use
  7149. * @returns true if there is an intersection
  7150. */
  7151. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7152. /**
  7153. * Tests if two bounding boxes are intersections
  7154. * @param box0 defines the first box to test
  7155. * @param box1 defines the second box to test
  7156. * @returns true if there is an intersection
  7157. */
  7158. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7159. /**
  7160. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7161. * @param minPoint defines the minimum vector of the bounding box
  7162. * @param maxPoint defines the maximum vector of the bounding box
  7163. * @param sphereCenter defines the sphere center
  7164. * @param sphereRadius defines the sphere radius
  7165. * @returns true if there is an intersection
  7166. */
  7167. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7168. /**
  7169. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7170. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7171. * @param frustumPlanes defines the frustum planes to test
  7172. * @return true if there is an inclusion
  7173. */
  7174. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7175. /**
  7176. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7177. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7178. * @param frustumPlanes defines the frustum planes to test
  7179. * @return true if there is an intersection
  7180. */
  7181. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7182. }
  7183. }
  7184. declare module "babylonjs/Collisions/collider" {
  7185. import { Nullable, IndicesArray } from "babylonjs/types";
  7186. import { Vector3 } from "babylonjs/Maths/math.vector";
  7187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7188. import { Plane } from "babylonjs/Maths/math.plane";
  7189. /** @hidden */
  7190. export class Collider {
  7191. /** Define if a collision was found */
  7192. collisionFound: boolean;
  7193. /**
  7194. * Define last intersection point in local space
  7195. */
  7196. intersectionPoint: Vector3;
  7197. /**
  7198. * Define last collided mesh
  7199. */
  7200. collidedMesh: Nullable<AbstractMesh>;
  7201. private _collisionPoint;
  7202. private _planeIntersectionPoint;
  7203. private _tempVector;
  7204. private _tempVector2;
  7205. private _tempVector3;
  7206. private _tempVector4;
  7207. private _edge;
  7208. private _baseToVertex;
  7209. private _destinationPoint;
  7210. private _slidePlaneNormal;
  7211. private _displacementVector;
  7212. /** @hidden */
  7213. _radius: Vector3;
  7214. /** @hidden */
  7215. _retry: number;
  7216. private _velocity;
  7217. private _basePoint;
  7218. private _epsilon;
  7219. /** @hidden */
  7220. _velocityWorldLength: number;
  7221. /** @hidden */
  7222. _basePointWorld: Vector3;
  7223. private _velocityWorld;
  7224. private _normalizedVelocity;
  7225. /** @hidden */
  7226. _initialVelocity: Vector3;
  7227. /** @hidden */
  7228. _initialPosition: Vector3;
  7229. private _nearestDistance;
  7230. private _collisionMask;
  7231. get collisionMask(): number;
  7232. set collisionMask(mask: number);
  7233. /**
  7234. * Gets the plane normal used to compute the sliding response (in local space)
  7235. */
  7236. get slidePlaneNormal(): Vector3;
  7237. /** @hidden */
  7238. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7239. /** @hidden */
  7240. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7241. /** @hidden */
  7242. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7243. /** @hidden */
  7244. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7245. /** @hidden */
  7246. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7247. /** @hidden */
  7248. _getResponse(pos: Vector3, vel: Vector3): void;
  7249. }
  7250. }
  7251. declare module "babylonjs/Culling/boundingInfo" {
  7252. import { DeepImmutable } from "babylonjs/types";
  7253. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7254. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7255. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7256. import { Plane } from "babylonjs/Maths/math.plane";
  7257. import { Collider } from "babylonjs/Collisions/collider";
  7258. /**
  7259. * Interface for cullable objects
  7260. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7261. */
  7262. export interface ICullable {
  7263. /**
  7264. * Checks if the object or part of the object is in the frustum
  7265. * @param frustumPlanes Camera near/planes
  7266. * @returns true if the object is in frustum otherwise false
  7267. */
  7268. isInFrustum(frustumPlanes: Plane[]): boolean;
  7269. /**
  7270. * Checks if a cullable object (mesh...) is in the camera frustum
  7271. * Unlike isInFrustum this cheks the full bounding box
  7272. * @param frustumPlanes Camera near/planes
  7273. * @returns true if the object is in frustum otherwise false
  7274. */
  7275. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7276. }
  7277. /**
  7278. * Info for a bounding data of a mesh
  7279. */
  7280. export class BoundingInfo implements ICullable {
  7281. /**
  7282. * Bounding box for the mesh
  7283. */
  7284. readonly boundingBox: BoundingBox;
  7285. /**
  7286. * Bounding sphere for the mesh
  7287. */
  7288. readonly boundingSphere: BoundingSphere;
  7289. private _isLocked;
  7290. private static readonly TmpVector3;
  7291. /**
  7292. * Constructs bounding info
  7293. * @param minimum min vector of the bounding box/sphere
  7294. * @param maximum max vector of the bounding box/sphere
  7295. * @param worldMatrix defines the new world matrix
  7296. */
  7297. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7298. /**
  7299. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7300. * @param min defines the new minimum vector (in local space)
  7301. * @param max defines the new maximum vector (in local space)
  7302. * @param worldMatrix defines the new world matrix
  7303. */
  7304. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7305. /**
  7306. * min vector of the bounding box/sphere
  7307. */
  7308. get minimum(): Vector3;
  7309. /**
  7310. * max vector of the bounding box/sphere
  7311. */
  7312. get maximum(): Vector3;
  7313. /**
  7314. * If the info is locked and won't be updated to avoid perf overhead
  7315. */
  7316. get isLocked(): boolean;
  7317. set isLocked(value: boolean);
  7318. /**
  7319. * Updates the bounding sphere and box
  7320. * @param world world matrix to be used to update
  7321. */
  7322. update(world: DeepImmutable<Matrix>): void;
  7323. /**
  7324. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7325. * @param center New center of the bounding info
  7326. * @param extend New extend of the bounding info
  7327. * @returns the current bounding info
  7328. */
  7329. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7330. /**
  7331. * Scale the current bounding info by applying a scale factor
  7332. * @param factor defines the scale factor to apply
  7333. * @returns the current bounding info
  7334. */
  7335. scale(factor: number): BoundingInfo;
  7336. /**
  7337. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7338. * @param frustumPlanes defines the frustum to test
  7339. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7340. * @returns true if the bounding info is in the frustum planes
  7341. */
  7342. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7343. /**
  7344. * Gets the world distance between the min and max points of the bounding box
  7345. */
  7346. get diagonalLength(): number;
  7347. /**
  7348. * Checks if a cullable object (mesh...) is in the camera frustum
  7349. * Unlike isInFrustum this cheks the full bounding box
  7350. * @param frustumPlanes Camera near/planes
  7351. * @returns true if the object is in frustum otherwise false
  7352. */
  7353. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7354. /** @hidden */
  7355. _checkCollision(collider: Collider): boolean;
  7356. /**
  7357. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7358. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7359. * @param point the point to check intersection with
  7360. * @returns if the point intersects
  7361. */
  7362. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7363. /**
  7364. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7365. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7366. * @param boundingInfo the bounding info to check intersection with
  7367. * @param precise if the intersection should be done using OBB
  7368. * @returns if the bounding info intersects
  7369. */
  7370. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7371. }
  7372. }
  7373. declare module "babylonjs/Maths/math.functions" {
  7374. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7375. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7376. /**
  7377. * Extracts minimum and maximum values from a list of indexed positions
  7378. * @param positions defines the positions to use
  7379. * @param indices defines the indices to the positions
  7380. * @param indexStart defines the start index
  7381. * @param indexCount defines the end index
  7382. * @param bias defines bias value to add to the result
  7383. * @return minimum and maximum values
  7384. */
  7385. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7386. minimum: Vector3;
  7387. maximum: Vector3;
  7388. };
  7389. /**
  7390. * Extracts minimum and maximum values from a list of positions
  7391. * @param positions defines the positions to use
  7392. * @param start defines the start index in the positions array
  7393. * @param count defines the number of positions to handle
  7394. * @param bias defines bias value to add to the result
  7395. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7396. * @return minimum and maximum values
  7397. */
  7398. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7399. minimum: Vector3;
  7400. maximum: Vector3;
  7401. };
  7402. }
  7403. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7404. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7405. /** @hidden */
  7406. export class WebGLDataBuffer extends DataBuffer {
  7407. private _buffer;
  7408. constructor(resource: WebGLBuffer);
  7409. get underlyingResource(): any;
  7410. }
  7411. }
  7412. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7413. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7414. import { Nullable } from "babylonjs/types";
  7415. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7416. /** @hidden */
  7417. export class WebGLPipelineContext implements IPipelineContext {
  7418. engine: ThinEngine;
  7419. program: Nullable<WebGLProgram>;
  7420. context?: WebGLRenderingContext;
  7421. vertexShader?: WebGLShader;
  7422. fragmentShader?: WebGLShader;
  7423. isParallelCompiled: boolean;
  7424. onCompiled?: () => void;
  7425. transformFeedback?: WebGLTransformFeedback | null;
  7426. vertexCompilationError: Nullable<string>;
  7427. fragmentCompilationError: Nullable<string>;
  7428. programLinkError: Nullable<string>;
  7429. programValidationError: Nullable<string>;
  7430. get isAsync(): boolean;
  7431. get isReady(): boolean;
  7432. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7433. _getVertexShaderCode(): string | null;
  7434. _getFragmentShaderCode(): string | null;
  7435. }
  7436. }
  7437. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7438. import { FloatArray, Nullable } from "babylonjs/types";
  7439. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7440. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7441. module "babylonjs/Engines/thinEngine" {
  7442. interface ThinEngine {
  7443. /**
  7444. * Create an uniform buffer
  7445. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7446. * @param elements defines the content of the uniform buffer
  7447. * @returns the webGL uniform buffer
  7448. */
  7449. createUniformBuffer(elements: FloatArray): DataBuffer;
  7450. /**
  7451. * Create a dynamic uniform buffer
  7452. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7453. * @param elements defines the content of the uniform buffer
  7454. * @returns the webGL uniform buffer
  7455. */
  7456. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7457. /**
  7458. * Update an existing uniform buffer
  7459. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7460. * @param uniformBuffer defines the target uniform buffer
  7461. * @param elements defines the content to update
  7462. * @param offset defines the offset in the uniform buffer where update should start
  7463. * @param count defines the size of the data to update
  7464. */
  7465. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7466. /**
  7467. * Bind an uniform buffer to the current webGL context
  7468. * @param buffer defines the buffer to bind
  7469. */
  7470. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7471. /**
  7472. * Bind a buffer to the current webGL context at a given location
  7473. * @param buffer defines the buffer to bind
  7474. * @param location defines the index where to bind the buffer
  7475. */
  7476. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7477. /**
  7478. * Bind a specific block at a given index in a specific shader program
  7479. * @param pipelineContext defines the pipeline context to use
  7480. * @param blockName defines the block name
  7481. * @param index defines the index where to bind the block
  7482. */
  7483. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7484. }
  7485. }
  7486. }
  7487. declare module "babylonjs/Materials/uniformBuffer" {
  7488. import { Nullable, FloatArray } from "babylonjs/types";
  7489. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7490. import { Engine } from "babylonjs/Engines/engine";
  7491. import { Effect } from "babylonjs/Materials/effect";
  7492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7493. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7494. import { Color3 } from "babylonjs/Maths/math.color";
  7495. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7496. /**
  7497. * Uniform buffer objects.
  7498. *
  7499. * Handles blocks of uniform on the GPU.
  7500. *
  7501. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7502. *
  7503. * For more information, please refer to :
  7504. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7505. */
  7506. export class UniformBuffer {
  7507. private _engine;
  7508. private _buffer;
  7509. private _data;
  7510. private _bufferData;
  7511. private _dynamic?;
  7512. private _uniformLocations;
  7513. private _uniformSizes;
  7514. private _uniformLocationPointer;
  7515. private _needSync;
  7516. private _noUBO;
  7517. private _currentEffect;
  7518. /** @hidden */
  7519. _alreadyBound: boolean;
  7520. private static _MAX_UNIFORM_SIZE;
  7521. private static _tempBuffer;
  7522. /**
  7523. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7524. * This is dynamic to allow compat with webgl 1 and 2.
  7525. * You will need to pass the name of the uniform as well as the value.
  7526. */
  7527. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7528. /**
  7529. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7530. * This is dynamic to allow compat with webgl 1 and 2.
  7531. * You will need to pass the name of the uniform as well as the value.
  7532. */
  7533. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7534. /**
  7535. * Lambda to Update a single float in a uniform buffer.
  7536. * This is dynamic to allow compat with webgl 1 and 2.
  7537. * You will need to pass the name of the uniform as well as the value.
  7538. */
  7539. updateFloat: (name: string, x: number) => void;
  7540. /**
  7541. * Lambda to Update a vec2 of float in a uniform buffer.
  7542. * This is dynamic to allow compat with webgl 1 and 2.
  7543. * You will need to pass the name of the uniform as well as the value.
  7544. */
  7545. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7546. /**
  7547. * Lambda to Update a vec3 of float in a uniform buffer.
  7548. * This is dynamic to allow compat with webgl 1 and 2.
  7549. * You will need to pass the name of the uniform as well as the value.
  7550. */
  7551. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7552. /**
  7553. * Lambda to Update a vec4 of float in a uniform buffer.
  7554. * This is dynamic to allow compat with webgl 1 and 2.
  7555. * You will need to pass the name of the uniform as well as the value.
  7556. */
  7557. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7558. /**
  7559. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7560. * This is dynamic to allow compat with webgl 1 and 2.
  7561. * You will need to pass the name of the uniform as well as the value.
  7562. */
  7563. updateMatrix: (name: string, mat: Matrix) => void;
  7564. /**
  7565. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7566. * This is dynamic to allow compat with webgl 1 and 2.
  7567. * You will need to pass the name of the uniform as well as the value.
  7568. */
  7569. updateVector3: (name: string, vector: Vector3) => void;
  7570. /**
  7571. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7572. * This is dynamic to allow compat with webgl 1 and 2.
  7573. * You will need to pass the name of the uniform as well as the value.
  7574. */
  7575. updateVector4: (name: string, vector: Vector4) => void;
  7576. /**
  7577. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7578. * This is dynamic to allow compat with webgl 1 and 2.
  7579. * You will need to pass the name of the uniform as well as the value.
  7580. */
  7581. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7582. /**
  7583. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7584. * This is dynamic to allow compat with webgl 1 and 2.
  7585. * You will need to pass the name of the uniform as well as the value.
  7586. */
  7587. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7588. /**
  7589. * Instantiates a new Uniform buffer objects.
  7590. *
  7591. * Handles blocks of uniform on the GPU.
  7592. *
  7593. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7594. *
  7595. * For more information, please refer to :
  7596. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7597. * @param engine Define the engine the buffer is associated with
  7598. * @param data Define the data contained in the buffer
  7599. * @param dynamic Define if the buffer is updatable
  7600. */
  7601. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7602. /**
  7603. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7604. * or just falling back on setUniformXXX calls.
  7605. */
  7606. get useUbo(): boolean;
  7607. /**
  7608. * Indicates if the WebGL underlying uniform buffer is in sync
  7609. * with the javascript cache data.
  7610. */
  7611. get isSync(): boolean;
  7612. /**
  7613. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7614. * Also, a dynamic UniformBuffer will disable cache verification and always
  7615. * update the underlying WebGL uniform buffer to the GPU.
  7616. * @returns if Dynamic, otherwise false
  7617. */
  7618. isDynamic(): boolean;
  7619. /**
  7620. * The data cache on JS side.
  7621. * @returns the underlying data as a float array
  7622. */
  7623. getData(): Float32Array;
  7624. /**
  7625. * The underlying WebGL Uniform buffer.
  7626. * @returns the webgl buffer
  7627. */
  7628. getBuffer(): Nullable<DataBuffer>;
  7629. /**
  7630. * std140 layout specifies how to align data within an UBO structure.
  7631. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7632. * for specs.
  7633. */
  7634. private _fillAlignment;
  7635. /**
  7636. * Adds an uniform in the buffer.
  7637. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7638. * for the layout to be correct !
  7639. * @param name Name of the uniform, as used in the uniform block in the shader.
  7640. * @param size Data size, or data directly.
  7641. */
  7642. addUniform(name: string, size: number | number[]): void;
  7643. /**
  7644. * Adds a Matrix 4x4 to the uniform buffer.
  7645. * @param name Name of the uniform, as used in the uniform block in the shader.
  7646. * @param mat A 4x4 matrix.
  7647. */
  7648. addMatrix(name: string, mat: Matrix): void;
  7649. /**
  7650. * Adds a vec2 to the uniform buffer.
  7651. * @param name Name of the uniform, as used in the uniform block in the shader.
  7652. * @param x Define the x component value of the vec2
  7653. * @param y Define the y component value of the vec2
  7654. */
  7655. addFloat2(name: string, x: number, y: number): void;
  7656. /**
  7657. * Adds a vec3 to the uniform buffer.
  7658. * @param name Name of the uniform, as used in the uniform block in the shader.
  7659. * @param x Define the x component value of the vec3
  7660. * @param y Define the y component value of the vec3
  7661. * @param z Define the z component value of the vec3
  7662. */
  7663. addFloat3(name: string, x: number, y: number, z: number): void;
  7664. /**
  7665. * Adds a vec3 to the uniform buffer.
  7666. * @param name Name of the uniform, as used in the uniform block in the shader.
  7667. * @param color Define the vec3 from a Color
  7668. */
  7669. addColor3(name: string, color: Color3): void;
  7670. /**
  7671. * Adds a vec4 to the uniform buffer.
  7672. * @param name Name of the uniform, as used in the uniform block in the shader.
  7673. * @param color Define the rgb components from a Color
  7674. * @param alpha Define the a component of the vec4
  7675. */
  7676. addColor4(name: string, color: Color3, alpha: number): void;
  7677. /**
  7678. * Adds a vec3 to the uniform buffer.
  7679. * @param name Name of the uniform, as used in the uniform block in the shader.
  7680. * @param vector Define the vec3 components from a Vector
  7681. */
  7682. addVector3(name: string, vector: Vector3): void;
  7683. /**
  7684. * Adds a Matrix 3x3 to the uniform buffer.
  7685. * @param name Name of the uniform, as used in the uniform block in the shader.
  7686. */
  7687. addMatrix3x3(name: string): void;
  7688. /**
  7689. * Adds a Matrix 2x2 to the uniform buffer.
  7690. * @param name Name of the uniform, as used in the uniform block in the shader.
  7691. */
  7692. addMatrix2x2(name: string): void;
  7693. /**
  7694. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7695. */
  7696. create(): void;
  7697. /** @hidden */
  7698. _rebuild(): void;
  7699. /**
  7700. * Updates the WebGL Uniform Buffer on the GPU.
  7701. * If the `dynamic` flag is set to true, no cache comparison is done.
  7702. * Otherwise, the buffer will be updated only if the cache differs.
  7703. */
  7704. update(): void;
  7705. /**
  7706. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7707. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7708. * @param data Define the flattened data
  7709. * @param size Define the size of the data.
  7710. */
  7711. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7712. private _valueCache;
  7713. private _cacheMatrix;
  7714. private _updateMatrix3x3ForUniform;
  7715. private _updateMatrix3x3ForEffect;
  7716. private _updateMatrix2x2ForEffect;
  7717. private _updateMatrix2x2ForUniform;
  7718. private _updateFloatForEffect;
  7719. private _updateFloatForUniform;
  7720. private _updateFloat2ForEffect;
  7721. private _updateFloat2ForUniform;
  7722. private _updateFloat3ForEffect;
  7723. private _updateFloat3ForUniform;
  7724. private _updateFloat4ForEffect;
  7725. private _updateFloat4ForUniform;
  7726. private _updateMatrixForEffect;
  7727. private _updateMatrixForUniform;
  7728. private _updateVector3ForEffect;
  7729. private _updateVector3ForUniform;
  7730. private _updateVector4ForEffect;
  7731. private _updateVector4ForUniform;
  7732. private _updateColor3ForEffect;
  7733. private _updateColor3ForUniform;
  7734. private _updateColor4ForEffect;
  7735. private _updateColor4ForUniform;
  7736. /**
  7737. * Sets a sampler uniform on the effect.
  7738. * @param name Define the name of the sampler.
  7739. * @param texture Define the texture to set in the sampler
  7740. */
  7741. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7742. /**
  7743. * Directly updates the value of the uniform in the cache AND on the GPU.
  7744. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7745. * @param data Define the flattened data
  7746. */
  7747. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7748. /**
  7749. * Binds this uniform buffer to an effect.
  7750. * @param effect Define the effect to bind the buffer to
  7751. * @param name Name of the uniform block in the shader.
  7752. */
  7753. bindToEffect(effect: Effect, name: string): void;
  7754. /**
  7755. * Disposes the uniform buffer.
  7756. */
  7757. dispose(): void;
  7758. }
  7759. }
  7760. declare module "babylonjs/Misc/iInspectable" {
  7761. /**
  7762. * Enum that determines the text-wrapping mode to use.
  7763. */
  7764. export enum InspectableType {
  7765. /**
  7766. * Checkbox for booleans
  7767. */
  7768. Checkbox = 0,
  7769. /**
  7770. * Sliders for numbers
  7771. */
  7772. Slider = 1,
  7773. /**
  7774. * Vector3
  7775. */
  7776. Vector3 = 2,
  7777. /**
  7778. * Quaternions
  7779. */
  7780. Quaternion = 3,
  7781. /**
  7782. * Color3
  7783. */
  7784. Color3 = 4,
  7785. /**
  7786. * String
  7787. */
  7788. String = 5
  7789. }
  7790. /**
  7791. * Interface used to define custom inspectable properties.
  7792. * This interface is used by the inspector to display custom property grids
  7793. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7794. */
  7795. export interface IInspectable {
  7796. /**
  7797. * Gets the label to display
  7798. */
  7799. label: string;
  7800. /**
  7801. * Gets the name of the property to edit
  7802. */
  7803. propertyName: string;
  7804. /**
  7805. * Gets the type of the editor to use
  7806. */
  7807. type: InspectableType;
  7808. /**
  7809. * Gets the minimum value of the property when using in "slider" mode
  7810. */
  7811. min?: number;
  7812. /**
  7813. * Gets the maximum value of the property when using in "slider" mode
  7814. */
  7815. max?: number;
  7816. /**
  7817. * Gets the setp to use when using in "slider" mode
  7818. */
  7819. step?: number;
  7820. }
  7821. }
  7822. declare module "babylonjs/Misc/timingTools" {
  7823. /**
  7824. * Class used to provide helper for timing
  7825. */
  7826. export class TimingTools {
  7827. /**
  7828. * Polyfill for setImmediate
  7829. * @param action defines the action to execute after the current execution block
  7830. */
  7831. static SetImmediate(action: () => void): void;
  7832. }
  7833. }
  7834. declare module "babylonjs/Misc/instantiationTools" {
  7835. /**
  7836. * Class used to enable instatition of objects by class name
  7837. */
  7838. export class InstantiationTools {
  7839. /**
  7840. * Use this object to register external classes like custom textures or material
  7841. * to allow the laoders to instantiate them
  7842. */
  7843. static RegisteredExternalClasses: {
  7844. [key: string]: Object;
  7845. };
  7846. /**
  7847. * Tries to instantiate a new object from a given class name
  7848. * @param className defines the class name to instantiate
  7849. * @returns the new object or null if the system was not able to do the instantiation
  7850. */
  7851. static Instantiate(className: string): any;
  7852. }
  7853. }
  7854. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7855. /**
  7856. * Define options used to create a depth texture
  7857. */
  7858. export class DepthTextureCreationOptions {
  7859. /** Specifies whether or not a stencil should be allocated in the texture */
  7860. generateStencil?: boolean;
  7861. /** Specifies whether or not bilinear filtering is enable on the texture */
  7862. bilinearFiltering?: boolean;
  7863. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7864. comparisonFunction?: number;
  7865. /** Specifies if the created texture is a cube texture */
  7866. isCube?: boolean;
  7867. }
  7868. }
  7869. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7871. import { Nullable } from "babylonjs/types";
  7872. import { Scene } from "babylonjs/scene";
  7873. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7874. module "babylonjs/Engines/thinEngine" {
  7875. interface ThinEngine {
  7876. /**
  7877. * Creates a depth stencil cube texture.
  7878. * This is only available in WebGL 2.
  7879. * @param size The size of face edge in the cube texture.
  7880. * @param options The options defining the cube texture.
  7881. * @returns The cube texture
  7882. */
  7883. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7884. /**
  7885. * Creates a cube texture
  7886. * @param rootUrl defines the url where the files to load is located
  7887. * @param scene defines the current scene
  7888. * @param files defines the list of files to load (1 per face)
  7889. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7890. * @param onLoad defines an optional callback raised when the texture is loaded
  7891. * @param onError defines an optional callback raised if there is an issue to load the texture
  7892. * @param format defines the format of the data
  7893. * @param forcedExtension defines the extension to use to pick the right loader
  7894. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7895. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7896. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7897. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7898. * @returns the cube texture as an InternalTexture
  7899. */
  7900. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7901. /**
  7902. * Creates a cube texture
  7903. * @param rootUrl defines the url where the files to load is located
  7904. * @param scene defines the current scene
  7905. * @param files defines the list of files to load (1 per face)
  7906. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7907. * @param onLoad defines an optional callback raised when the texture is loaded
  7908. * @param onError defines an optional callback raised if there is an issue to load the texture
  7909. * @param format defines the format of the data
  7910. * @param forcedExtension defines the extension to use to pick the right loader
  7911. * @returns the cube texture as an InternalTexture
  7912. */
  7913. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7914. /**
  7915. * Creates a cube texture
  7916. * @param rootUrl defines the url where the files to load is located
  7917. * @param scene defines the current scene
  7918. * @param files defines the list of files to load (1 per face)
  7919. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7920. * @param onLoad defines an optional callback raised when the texture is loaded
  7921. * @param onError defines an optional callback raised if there is an issue to load the texture
  7922. * @param format defines the format of the data
  7923. * @param forcedExtension defines the extension to use to pick the right loader
  7924. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7925. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7926. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7927. * @returns the cube texture as an InternalTexture
  7928. */
  7929. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7930. /** @hidden */
  7931. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7932. /** @hidden */
  7933. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7934. /** @hidden */
  7935. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7936. /** @hidden */
  7937. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7938. /**
  7939. * @hidden
  7940. */
  7941. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7942. }
  7943. }
  7944. }
  7945. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7946. import { Nullable } from "babylonjs/types";
  7947. import { Scene } from "babylonjs/scene";
  7948. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7950. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7951. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7952. import { Observable } from "babylonjs/Misc/observable";
  7953. /**
  7954. * Class for creating a cube texture
  7955. */
  7956. export class CubeTexture extends BaseTexture {
  7957. private _delayedOnLoad;
  7958. /**
  7959. * Observable triggered once the texture has been loaded.
  7960. */
  7961. onLoadObservable: Observable<CubeTexture>;
  7962. /**
  7963. * The url of the texture
  7964. */
  7965. url: string;
  7966. /**
  7967. * Gets or sets the center of the bounding box associated with the cube texture.
  7968. * It must define where the camera used to render the texture was set
  7969. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7970. */
  7971. boundingBoxPosition: Vector3;
  7972. private _boundingBoxSize;
  7973. /**
  7974. * Gets or sets the size of the bounding box associated with the cube texture
  7975. * When defined, the cubemap will switch to local mode
  7976. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7977. * @example https://www.babylonjs-playground.com/#RNASML
  7978. */
  7979. set boundingBoxSize(value: Vector3);
  7980. /**
  7981. * Returns the bounding box size
  7982. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7983. */
  7984. get boundingBoxSize(): Vector3;
  7985. protected _rotationY: number;
  7986. /**
  7987. * Sets texture matrix rotation angle around Y axis in radians.
  7988. */
  7989. set rotationY(value: number);
  7990. /**
  7991. * Gets texture matrix rotation angle around Y axis radians.
  7992. */
  7993. get rotationY(): number;
  7994. /**
  7995. * Are mip maps generated for this texture or not.
  7996. */
  7997. get noMipmap(): boolean;
  7998. private _noMipmap;
  7999. private _files;
  8000. protected _forcedExtension: Nullable<string>;
  8001. private _extensions;
  8002. private _textureMatrix;
  8003. private _format;
  8004. private _createPolynomials;
  8005. /**
  8006. * Creates a cube texture from an array of image urls
  8007. * @param files defines an array of image urls
  8008. * @param scene defines the hosting scene
  8009. * @param noMipmap specifies if mip maps are not used
  8010. * @returns a cube texture
  8011. */
  8012. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8013. /**
  8014. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8015. * @param url defines the url of the prefiltered texture
  8016. * @param scene defines the scene the texture is attached to
  8017. * @param forcedExtension defines the extension of the file if different from the url
  8018. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8019. * @return the prefiltered texture
  8020. */
  8021. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8022. /**
  8023. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8024. * as prefiltered data.
  8025. * @param rootUrl defines the url of the texture or the root name of the six images
  8026. * @param null defines the scene or engine the texture is attached to
  8027. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8028. * @param noMipmap defines if mipmaps should be created or not
  8029. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8030. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8031. * @param onError defines a callback triggered in case of error during load
  8032. * @param format defines the internal format to use for the texture once loaded
  8033. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8034. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8035. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8036. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8037. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8038. * @return the cube texture
  8039. */
  8040. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  8041. /**
  8042. * Get the current class name of the texture useful for serialization or dynamic coding.
  8043. * @returns "CubeTexture"
  8044. */
  8045. getClassName(): string;
  8046. /**
  8047. * Update the url (and optional buffer) of this texture if url was null during construction.
  8048. * @param url the url of the texture
  8049. * @param forcedExtension defines the extension to use
  8050. * @param onLoad callback called when the texture is loaded (defaults to null)
  8051. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8052. */
  8053. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8054. /**
  8055. * Delays loading of the cube texture
  8056. * @param forcedExtension defines the extension to use
  8057. */
  8058. delayLoad(forcedExtension?: string): void;
  8059. /**
  8060. * Returns the reflection texture matrix
  8061. * @returns the reflection texture matrix
  8062. */
  8063. getReflectionTextureMatrix(): Matrix;
  8064. /**
  8065. * Sets the reflection texture matrix
  8066. * @param value Reflection texture matrix
  8067. */
  8068. setReflectionTextureMatrix(value: Matrix): void;
  8069. /**
  8070. * Parses text to create a cube texture
  8071. * @param parsedTexture define the serialized text to read from
  8072. * @param scene defines the hosting scene
  8073. * @param rootUrl defines the root url of the cube texture
  8074. * @returns a cube texture
  8075. */
  8076. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8077. /**
  8078. * Makes a clone, or deep copy, of the cube texture
  8079. * @returns a new cube texture
  8080. */
  8081. clone(): CubeTexture;
  8082. }
  8083. }
  8084. declare module "babylonjs/Materials/materialDefines" {
  8085. /**
  8086. * Manages the defines for the Material
  8087. */
  8088. export class MaterialDefines {
  8089. /** @hidden */
  8090. protected _keys: string[];
  8091. private _isDirty;
  8092. /** @hidden */
  8093. _renderId: number;
  8094. /** @hidden */
  8095. _areLightsDirty: boolean;
  8096. /** @hidden */
  8097. _areLightsDisposed: boolean;
  8098. /** @hidden */
  8099. _areAttributesDirty: boolean;
  8100. /** @hidden */
  8101. _areTexturesDirty: boolean;
  8102. /** @hidden */
  8103. _areFresnelDirty: boolean;
  8104. /** @hidden */
  8105. _areMiscDirty: boolean;
  8106. /** @hidden */
  8107. _arePrePassDirty: boolean;
  8108. /** @hidden */
  8109. _areImageProcessingDirty: boolean;
  8110. /** @hidden */
  8111. _normals: boolean;
  8112. /** @hidden */
  8113. _uvs: boolean;
  8114. /** @hidden */
  8115. _needNormals: boolean;
  8116. /** @hidden */
  8117. _needUVs: boolean;
  8118. [id: string]: any;
  8119. /**
  8120. * Specifies if the material needs to be re-calculated
  8121. */
  8122. get isDirty(): boolean;
  8123. /**
  8124. * Marks the material to indicate that it has been re-calculated
  8125. */
  8126. markAsProcessed(): void;
  8127. /**
  8128. * Marks the material to indicate that it needs to be re-calculated
  8129. */
  8130. markAsUnprocessed(): void;
  8131. /**
  8132. * Marks the material to indicate all of its defines need to be re-calculated
  8133. */
  8134. markAllAsDirty(): void;
  8135. /**
  8136. * Marks the material to indicate that image processing needs to be re-calculated
  8137. */
  8138. markAsImageProcessingDirty(): void;
  8139. /**
  8140. * Marks the material to indicate the lights need to be re-calculated
  8141. * @param disposed Defines whether the light is dirty due to dispose or not
  8142. */
  8143. markAsLightDirty(disposed?: boolean): void;
  8144. /**
  8145. * Marks the attribute state as changed
  8146. */
  8147. markAsAttributesDirty(): void;
  8148. /**
  8149. * Marks the texture state as changed
  8150. */
  8151. markAsTexturesDirty(): void;
  8152. /**
  8153. * Marks the fresnel state as changed
  8154. */
  8155. markAsFresnelDirty(): void;
  8156. /**
  8157. * Marks the misc state as changed
  8158. */
  8159. markAsMiscDirty(): void;
  8160. /**
  8161. * Marks the prepass state as changed
  8162. */
  8163. markAsPrePassDirty(): void;
  8164. /**
  8165. * Rebuilds the material defines
  8166. */
  8167. rebuild(): void;
  8168. /**
  8169. * Specifies if two material defines are equal
  8170. * @param other - A material define instance to compare to
  8171. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8172. */
  8173. isEqual(other: MaterialDefines): boolean;
  8174. /**
  8175. * Clones this instance's defines to another instance
  8176. * @param other - material defines to clone values to
  8177. */
  8178. cloneTo(other: MaterialDefines): void;
  8179. /**
  8180. * Resets the material define values
  8181. */
  8182. reset(): void;
  8183. /**
  8184. * Converts the material define values to a string
  8185. * @returns - String of material define information
  8186. */
  8187. toString(): string;
  8188. }
  8189. }
  8190. declare module "babylonjs/Materials/colorCurves" {
  8191. import { Effect } from "babylonjs/Materials/effect";
  8192. /**
  8193. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8194. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8195. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8196. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8197. */
  8198. export class ColorCurves {
  8199. private _dirty;
  8200. private _tempColor;
  8201. private _globalCurve;
  8202. private _highlightsCurve;
  8203. private _midtonesCurve;
  8204. private _shadowsCurve;
  8205. private _positiveCurve;
  8206. private _negativeCurve;
  8207. private _globalHue;
  8208. private _globalDensity;
  8209. private _globalSaturation;
  8210. private _globalExposure;
  8211. /**
  8212. * Gets the global Hue value.
  8213. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8214. */
  8215. get globalHue(): number;
  8216. /**
  8217. * Sets the global Hue value.
  8218. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8219. */
  8220. set globalHue(value: number);
  8221. /**
  8222. * Gets the global Density value.
  8223. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8224. * Values less than zero provide a filter of opposite hue.
  8225. */
  8226. get globalDensity(): number;
  8227. /**
  8228. * Sets the global Density value.
  8229. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8230. * Values less than zero provide a filter of opposite hue.
  8231. */
  8232. set globalDensity(value: number);
  8233. /**
  8234. * Gets the global Saturation value.
  8235. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8236. */
  8237. get globalSaturation(): number;
  8238. /**
  8239. * Sets the global Saturation value.
  8240. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8241. */
  8242. set globalSaturation(value: number);
  8243. /**
  8244. * Gets the global Exposure value.
  8245. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8246. */
  8247. get globalExposure(): number;
  8248. /**
  8249. * Sets the global Exposure value.
  8250. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8251. */
  8252. set globalExposure(value: number);
  8253. private _highlightsHue;
  8254. private _highlightsDensity;
  8255. private _highlightsSaturation;
  8256. private _highlightsExposure;
  8257. /**
  8258. * Gets the highlights Hue value.
  8259. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8260. */
  8261. get highlightsHue(): number;
  8262. /**
  8263. * Sets the highlights Hue value.
  8264. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8265. */
  8266. set highlightsHue(value: number);
  8267. /**
  8268. * Gets the highlights Density value.
  8269. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8270. * Values less than zero provide a filter of opposite hue.
  8271. */
  8272. get highlightsDensity(): number;
  8273. /**
  8274. * Sets the highlights Density value.
  8275. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8276. * Values less than zero provide a filter of opposite hue.
  8277. */
  8278. set highlightsDensity(value: number);
  8279. /**
  8280. * Gets the highlights Saturation value.
  8281. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8282. */
  8283. get highlightsSaturation(): number;
  8284. /**
  8285. * Sets the highlights Saturation value.
  8286. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8287. */
  8288. set highlightsSaturation(value: number);
  8289. /**
  8290. * Gets the highlights Exposure value.
  8291. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8292. */
  8293. get highlightsExposure(): number;
  8294. /**
  8295. * Sets the highlights Exposure value.
  8296. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8297. */
  8298. set highlightsExposure(value: number);
  8299. private _midtonesHue;
  8300. private _midtonesDensity;
  8301. private _midtonesSaturation;
  8302. private _midtonesExposure;
  8303. /**
  8304. * Gets the midtones Hue value.
  8305. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8306. */
  8307. get midtonesHue(): number;
  8308. /**
  8309. * Sets the midtones Hue value.
  8310. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8311. */
  8312. set midtonesHue(value: number);
  8313. /**
  8314. * Gets the midtones Density value.
  8315. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8316. * Values less than zero provide a filter of opposite hue.
  8317. */
  8318. get midtonesDensity(): number;
  8319. /**
  8320. * Sets the midtones Density value.
  8321. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8322. * Values less than zero provide a filter of opposite hue.
  8323. */
  8324. set midtonesDensity(value: number);
  8325. /**
  8326. * Gets the midtones Saturation value.
  8327. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8328. */
  8329. get midtonesSaturation(): number;
  8330. /**
  8331. * Sets the midtones Saturation value.
  8332. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8333. */
  8334. set midtonesSaturation(value: number);
  8335. /**
  8336. * Gets the midtones Exposure value.
  8337. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8338. */
  8339. get midtonesExposure(): number;
  8340. /**
  8341. * Sets the midtones Exposure value.
  8342. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8343. */
  8344. set midtonesExposure(value: number);
  8345. private _shadowsHue;
  8346. private _shadowsDensity;
  8347. private _shadowsSaturation;
  8348. private _shadowsExposure;
  8349. /**
  8350. * Gets the shadows Hue value.
  8351. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8352. */
  8353. get shadowsHue(): number;
  8354. /**
  8355. * Sets the shadows Hue value.
  8356. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8357. */
  8358. set shadowsHue(value: number);
  8359. /**
  8360. * Gets the shadows Density value.
  8361. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8362. * Values less than zero provide a filter of opposite hue.
  8363. */
  8364. get shadowsDensity(): number;
  8365. /**
  8366. * Sets the shadows Density value.
  8367. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8368. * Values less than zero provide a filter of opposite hue.
  8369. */
  8370. set shadowsDensity(value: number);
  8371. /**
  8372. * Gets the shadows Saturation value.
  8373. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8374. */
  8375. get shadowsSaturation(): number;
  8376. /**
  8377. * Sets the shadows Saturation value.
  8378. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8379. */
  8380. set shadowsSaturation(value: number);
  8381. /**
  8382. * Gets the shadows Exposure value.
  8383. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8384. */
  8385. get shadowsExposure(): number;
  8386. /**
  8387. * Sets the shadows Exposure value.
  8388. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8389. */
  8390. set shadowsExposure(value: number);
  8391. /**
  8392. * Returns the class name
  8393. * @returns The class name
  8394. */
  8395. getClassName(): string;
  8396. /**
  8397. * Binds the color curves to the shader.
  8398. * @param colorCurves The color curve to bind
  8399. * @param effect The effect to bind to
  8400. * @param positiveUniform The positive uniform shader parameter
  8401. * @param neutralUniform The neutral uniform shader parameter
  8402. * @param negativeUniform The negative uniform shader parameter
  8403. */
  8404. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8405. /**
  8406. * Prepare the list of uniforms associated with the ColorCurves effects.
  8407. * @param uniformsList The list of uniforms used in the effect
  8408. */
  8409. static PrepareUniforms(uniformsList: string[]): void;
  8410. /**
  8411. * Returns color grading data based on a hue, density, saturation and exposure value.
  8412. * @param filterHue The hue of the color filter.
  8413. * @param filterDensity The density of the color filter.
  8414. * @param saturation The saturation.
  8415. * @param exposure The exposure.
  8416. * @param result The result data container.
  8417. */
  8418. private getColorGradingDataToRef;
  8419. /**
  8420. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8421. * @param value The input slider value in range [-100,100].
  8422. * @returns Adjusted value.
  8423. */
  8424. private static applyColorGradingSliderNonlinear;
  8425. /**
  8426. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8427. * @param hue The hue (H) input.
  8428. * @param saturation The saturation (S) input.
  8429. * @param brightness The brightness (B) input.
  8430. * @result An RGBA color represented as Vector4.
  8431. */
  8432. private static fromHSBToRef;
  8433. /**
  8434. * Returns a value clamped between min and max
  8435. * @param value The value to clamp
  8436. * @param min The minimum of value
  8437. * @param max The maximum of value
  8438. * @returns The clamped value.
  8439. */
  8440. private static clamp;
  8441. /**
  8442. * Clones the current color curve instance.
  8443. * @return The cloned curves
  8444. */
  8445. clone(): ColorCurves;
  8446. /**
  8447. * Serializes the current color curve instance to a json representation.
  8448. * @return a JSON representation
  8449. */
  8450. serialize(): any;
  8451. /**
  8452. * Parses the color curve from a json representation.
  8453. * @param source the JSON source to parse
  8454. * @return The parsed curves
  8455. */
  8456. static Parse(source: any): ColorCurves;
  8457. }
  8458. }
  8459. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8460. import { Observable } from "babylonjs/Misc/observable";
  8461. import { Nullable } from "babylonjs/types";
  8462. import { Color4 } from "babylonjs/Maths/math.color";
  8463. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8464. import { Effect } from "babylonjs/Materials/effect";
  8465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8466. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8467. /**
  8468. * Interface to follow in your material defines to integrate easily the
  8469. * Image proccessing functions.
  8470. * @hidden
  8471. */
  8472. export interface IImageProcessingConfigurationDefines {
  8473. IMAGEPROCESSING: boolean;
  8474. VIGNETTE: boolean;
  8475. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8476. VIGNETTEBLENDMODEOPAQUE: boolean;
  8477. TONEMAPPING: boolean;
  8478. TONEMAPPING_ACES: boolean;
  8479. CONTRAST: boolean;
  8480. EXPOSURE: boolean;
  8481. COLORCURVES: boolean;
  8482. COLORGRADING: boolean;
  8483. COLORGRADING3D: boolean;
  8484. SAMPLER3DGREENDEPTH: boolean;
  8485. SAMPLER3DBGRMAP: boolean;
  8486. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8487. }
  8488. /**
  8489. * @hidden
  8490. */
  8491. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8492. IMAGEPROCESSING: boolean;
  8493. VIGNETTE: boolean;
  8494. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8495. VIGNETTEBLENDMODEOPAQUE: boolean;
  8496. TONEMAPPING: boolean;
  8497. TONEMAPPING_ACES: boolean;
  8498. CONTRAST: boolean;
  8499. COLORCURVES: boolean;
  8500. COLORGRADING: boolean;
  8501. COLORGRADING3D: boolean;
  8502. SAMPLER3DGREENDEPTH: boolean;
  8503. SAMPLER3DBGRMAP: boolean;
  8504. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8505. EXPOSURE: boolean;
  8506. constructor();
  8507. }
  8508. /**
  8509. * This groups together the common properties used for image processing either in direct forward pass
  8510. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8511. * or not.
  8512. */
  8513. export class ImageProcessingConfiguration {
  8514. /**
  8515. * Default tone mapping applied in BabylonJS.
  8516. */
  8517. static readonly TONEMAPPING_STANDARD: number;
  8518. /**
  8519. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8520. * to other engines rendering to increase portability.
  8521. */
  8522. static readonly TONEMAPPING_ACES: number;
  8523. /**
  8524. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8525. */
  8526. colorCurves: Nullable<ColorCurves>;
  8527. private _colorCurvesEnabled;
  8528. /**
  8529. * Gets wether the color curves effect is enabled.
  8530. */
  8531. get colorCurvesEnabled(): boolean;
  8532. /**
  8533. * Sets wether the color curves effect is enabled.
  8534. */
  8535. set colorCurvesEnabled(value: boolean);
  8536. private _colorGradingTexture;
  8537. /**
  8538. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8539. */
  8540. get colorGradingTexture(): Nullable<BaseTexture>;
  8541. /**
  8542. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8543. */
  8544. set colorGradingTexture(value: Nullable<BaseTexture>);
  8545. private _colorGradingEnabled;
  8546. /**
  8547. * Gets wether the color grading effect is enabled.
  8548. */
  8549. get colorGradingEnabled(): boolean;
  8550. /**
  8551. * Sets wether the color grading effect is enabled.
  8552. */
  8553. set colorGradingEnabled(value: boolean);
  8554. private _colorGradingWithGreenDepth;
  8555. /**
  8556. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8557. */
  8558. get colorGradingWithGreenDepth(): boolean;
  8559. /**
  8560. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8561. */
  8562. set colorGradingWithGreenDepth(value: boolean);
  8563. private _colorGradingBGR;
  8564. /**
  8565. * Gets wether the color grading texture contains BGR values.
  8566. */
  8567. get colorGradingBGR(): boolean;
  8568. /**
  8569. * Sets wether the color grading texture contains BGR values.
  8570. */
  8571. set colorGradingBGR(value: boolean);
  8572. /** @hidden */
  8573. _exposure: number;
  8574. /**
  8575. * Gets the Exposure used in the effect.
  8576. */
  8577. get exposure(): number;
  8578. /**
  8579. * Sets the Exposure used in the effect.
  8580. */
  8581. set exposure(value: number);
  8582. private _toneMappingEnabled;
  8583. /**
  8584. * Gets wether the tone mapping effect is enabled.
  8585. */
  8586. get toneMappingEnabled(): boolean;
  8587. /**
  8588. * Sets wether the tone mapping effect is enabled.
  8589. */
  8590. set toneMappingEnabled(value: boolean);
  8591. private _toneMappingType;
  8592. /**
  8593. * Gets the type of tone mapping effect.
  8594. */
  8595. get toneMappingType(): number;
  8596. /**
  8597. * Sets the type of tone mapping effect used in BabylonJS.
  8598. */
  8599. set toneMappingType(value: number);
  8600. protected _contrast: number;
  8601. /**
  8602. * Gets the contrast used in the effect.
  8603. */
  8604. get contrast(): number;
  8605. /**
  8606. * Sets the contrast used in the effect.
  8607. */
  8608. set contrast(value: number);
  8609. /**
  8610. * Vignette stretch size.
  8611. */
  8612. vignetteStretch: number;
  8613. /**
  8614. * Vignette centre X Offset.
  8615. */
  8616. vignetteCentreX: number;
  8617. /**
  8618. * Vignette centre Y Offset.
  8619. */
  8620. vignetteCentreY: number;
  8621. /**
  8622. * Vignette weight or intensity of the vignette effect.
  8623. */
  8624. vignetteWeight: number;
  8625. /**
  8626. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8627. * if vignetteEnabled is set to true.
  8628. */
  8629. vignetteColor: Color4;
  8630. /**
  8631. * Camera field of view used by the Vignette effect.
  8632. */
  8633. vignetteCameraFov: number;
  8634. private _vignetteBlendMode;
  8635. /**
  8636. * Gets the vignette blend mode allowing different kind of effect.
  8637. */
  8638. get vignetteBlendMode(): number;
  8639. /**
  8640. * Sets the vignette blend mode allowing different kind of effect.
  8641. */
  8642. set vignetteBlendMode(value: number);
  8643. private _vignetteEnabled;
  8644. /**
  8645. * Gets wether the vignette effect is enabled.
  8646. */
  8647. get vignetteEnabled(): boolean;
  8648. /**
  8649. * Sets wether the vignette effect is enabled.
  8650. */
  8651. set vignetteEnabled(value: boolean);
  8652. private _applyByPostProcess;
  8653. /**
  8654. * Gets wether the image processing is applied through a post process or not.
  8655. */
  8656. get applyByPostProcess(): boolean;
  8657. /**
  8658. * Sets wether the image processing is applied through a post process or not.
  8659. */
  8660. set applyByPostProcess(value: boolean);
  8661. private _isEnabled;
  8662. /**
  8663. * Gets wether the image processing is enabled or not.
  8664. */
  8665. get isEnabled(): boolean;
  8666. /**
  8667. * Sets wether the image processing is enabled or not.
  8668. */
  8669. set isEnabled(value: boolean);
  8670. /**
  8671. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8672. */
  8673. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8674. /**
  8675. * Method called each time the image processing information changes requires to recompile the effect.
  8676. */
  8677. protected _updateParameters(): void;
  8678. /**
  8679. * Gets the current class name.
  8680. * @return "ImageProcessingConfiguration"
  8681. */
  8682. getClassName(): string;
  8683. /**
  8684. * Prepare the list of uniforms associated with the Image Processing effects.
  8685. * @param uniforms The list of uniforms used in the effect
  8686. * @param defines the list of defines currently in use
  8687. */
  8688. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8689. /**
  8690. * Prepare the list of samplers associated with the Image Processing effects.
  8691. * @param samplersList The list of uniforms used in the effect
  8692. * @param defines the list of defines currently in use
  8693. */
  8694. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8695. /**
  8696. * Prepare the list of defines associated to the shader.
  8697. * @param defines the list of defines to complete
  8698. * @param forPostProcess Define if we are currently in post process mode or not
  8699. */
  8700. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8701. /**
  8702. * Returns true if all the image processing information are ready.
  8703. * @returns True if ready, otherwise, false
  8704. */
  8705. isReady(): boolean;
  8706. /**
  8707. * Binds the image processing to the shader.
  8708. * @param effect The effect to bind to
  8709. * @param overrideAspectRatio Override the aspect ratio of the effect
  8710. */
  8711. bind(effect: Effect, overrideAspectRatio?: number): void;
  8712. /**
  8713. * Clones the current image processing instance.
  8714. * @return The cloned image processing
  8715. */
  8716. clone(): ImageProcessingConfiguration;
  8717. /**
  8718. * Serializes the current image processing instance to a json representation.
  8719. * @return a JSON representation
  8720. */
  8721. serialize(): any;
  8722. /**
  8723. * Parses the image processing from a json representation.
  8724. * @param source the JSON source to parse
  8725. * @return The parsed image processing
  8726. */
  8727. static Parse(source: any): ImageProcessingConfiguration;
  8728. private static _VIGNETTEMODE_MULTIPLY;
  8729. private static _VIGNETTEMODE_OPAQUE;
  8730. /**
  8731. * Used to apply the vignette as a mix with the pixel color.
  8732. */
  8733. static get VIGNETTEMODE_MULTIPLY(): number;
  8734. /**
  8735. * Used to apply the vignette as a replacement of the pixel color.
  8736. */
  8737. static get VIGNETTEMODE_OPAQUE(): number;
  8738. }
  8739. }
  8740. declare module "babylonjs/Shaders/postprocess.vertex" {
  8741. /** @hidden */
  8742. export var postprocessVertexShader: {
  8743. name: string;
  8744. shader: string;
  8745. };
  8746. }
  8747. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8748. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8749. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8750. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8751. /**
  8752. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8753. */
  8754. export type RenderTargetTextureSize = number | {
  8755. width: number;
  8756. height: number;
  8757. layers?: number;
  8758. };
  8759. module "babylonjs/Engines/thinEngine" {
  8760. interface ThinEngine {
  8761. /**
  8762. * Creates a new render target texture
  8763. * @param size defines the size of the texture
  8764. * @param options defines the options used to create the texture
  8765. * @returns a new render target texture stored in an InternalTexture
  8766. */
  8767. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8768. /**
  8769. * Creates a depth stencil texture.
  8770. * This is only available in WebGL 2 or with the depth texture extension available.
  8771. * @param size The size of face edge in the texture.
  8772. * @param options The options defining the texture.
  8773. * @returns The texture
  8774. */
  8775. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8776. /** @hidden */
  8777. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8778. }
  8779. }
  8780. }
  8781. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8782. /**
  8783. * Defines the kind of connection point for node based material
  8784. */
  8785. export enum NodeMaterialBlockConnectionPointTypes {
  8786. /** Float */
  8787. Float = 1,
  8788. /** Int */
  8789. Int = 2,
  8790. /** Vector2 */
  8791. Vector2 = 4,
  8792. /** Vector3 */
  8793. Vector3 = 8,
  8794. /** Vector4 */
  8795. Vector4 = 16,
  8796. /** Color3 */
  8797. Color3 = 32,
  8798. /** Color4 */
  8799. Color4 = 64,
  8800. /** Matrix */
  8801. Matrix = 128,
  8802. /** Custom object */
  8803. Object = 256,
  8804. /** Detect type based on connection */
  8805. AutoDetect = 1024,
  8806. /** Output type that will be defined by input type */
  8807. BasedOnInput = 2048
  8808. }
  8809. }
  8810. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8811. /**
  8812. * Enum used to define the target of a block
  8813. */
  8814. export enum NodeMaterialBlockTargets {
  8815. /** Vertex shader */
  8816. Vertex = 1,
  8817. /** Fragment shader */
  8818. Fragment = 2,
  8819. /** Neutral */
  8820. Neutral = 4,
  8821. /** Vertex and Fragment */
  8822. VertexAndFragment = 3
  8823. }
  8824. }
  8825. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8826. /**
  8827. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8828. */
  8829. export enum NodeMaterialBlockConnectionPointMode {
  8830. /** Value is an uniform */
  8831. Uniform = 0,
  8832. /** Value is a mesh attribute */
  8833. Attribute = 1,
  8834. /** Value is a varying between vertex and fragment shaders */
  8835. Varying = 2,
  8836. /** Mode is undefined */
  8837. Undefined = 3
  8838. }
  8839. }
  8840. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8841. /**
  8842. * Enum used to define system values e.g. values automatically provided by the system
  8843. */
  8844. export enum NodeMaterialSystemValues {
  8845. /** World */
  8846. World = 1,
  8847. /** View */
  8848. View = 2,
  8849. /** Projection */
  8850. Projection = 3,
  8851. /** ViewProjection */
  8852. ViewProjection = 4,
  8853. /** WorldView */
  8854. WorldView = 5,
  8855. /** WorldViewProjection */
  8856. WorldViewProjection = 6,
  8857. /** CameraPosition */
  8858. CameraPosition = 7,
  8859. /** Fog Color */
  8860. FogColor = 8,
  8861. /** Delta time */
  8862. DeltaTime = 9
  8863. }
  8864. }
  8865. declare module "babylonjs/Maths/math.axis" {
  8866. import { Vector3 } from "babylonjs/Maths/math.vector";
  8867. /** Defines supported spaces */
  8868. export enum Space {
  8869. /** Local (object) space */
  8870. LOCAL = 0,
  8871. /** World space */
  8872. WORLD = 1,
  8873. /** Bone space */
  8874. BONE = 2
  8875. }
  8876. /** Defines the 3 main axes */
  8877. export class Axis {
  8878. /** X axis */
  8879. static X: Vector3;
  8880. /** Y axis */
  8881. static Y: Vector3;
  8882. /** Z axis */
  8883. static Z: Vector3;
  8884. }
  8885. }
  8886. declare module "babylonjs/Maths/math.frustum" {
  8887. import { Matrix } from "babylonjs/Maths/math.vector";
  8888. import { DeepImmutable } from "babylonjs/types";
  8889. import { Plane } from "babylonjs/Maths/math.plane";
  8890. /**
  8891. * Represents a camera frustum
  8892. */
  8893. export class Frustum {
  8894. /**
  8895. * Gets the planes representing the frustum
  8896. * @param transform matrix to be applied to the returned planes
  8897. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8898. */
  8899. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8900. /**
  8901. * Gets the near frustum plane transformed by the transform matrix
  8902. * @param transform transformation matrix to be applied to the resulting frustum plane
  8903. * @param frustumPlane the resuling frustum plane
  8904. */
  8905. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8906. /**
  8907. * Gets the far frustum plane transformed by the transform matrix
  8908. * @param transform transformation matrix to be applied to the resulting frustum plane
  8909. * @param frustumPlane the resuling frustum plane
  8910. */
  8911. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8912. /**
  8913. * Gets the left frustum plane transformed by the transform matrix
  8914. * @param transform transformation matrix to be applied to the resulting frustum plane
  8915. * @param frustumPlane the resuling frustum plane
  8916. */
  8917. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8918. /**
  8919. * Gets the right frustum plane transformed by the transform matrix
  8920. * @param transform transformation matrix to be applied to the resulting frustum plane
  8921. * @param frustumPlane the resuling frustum plane
  8922. */
  8923. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8924. /**
  8925. * Gets the top frustum plane transformed by the transform matrix
  8926. * @param transform transformation matrix to be applied to the resulting frustum plane
  8927. * @param frustumPlane the resuling frustum plane
  8928. */
  8929. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8930. /**
  8931. * Gets the bottom frustum plane transformed by the transform matrix
  8932. * @param transform transformation matrix to be applied to the resulting frustum plane
  8933. * @param frustumPlane the resuling frustum plane
  8934. */
  8935. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8936. /**
  8937. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8938. * @param transform transformation matrix to be applied to the resulting frustum planes
  8939. * @param frustumPlanes the resuling frustum planes
  8940. */
  8941. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8942. }
  8943. }
  8944. declare module "babylonjs/Maths/math.size" {
  8945. /**
  8946. * Interface for the size containing width and height
  8947. */
  8948. export interface ISize {
  8949. /**
  8950. * Width
  8951. */
  8952. width: number;
  8953. /**
  8954. * Heighht
  8955. */
  8956. height: number;
  8957. }
  8958. /**
  8959. * Size containing widht and height
  8960. */
  8961. export class Size implements ISize {
  8962. /**
  8963. * Width
  8964. */
  8965. width: number;
  8966. /**
  8967. * Height
  8968. */
  8969. height: number;
  8970. /**
  8971. * Creates a Size object from the given width and height (floats).
  8972. * @param width width of the new size
  8973. * @param height height of the new size
  8974. */
  8975. constructor(width: number, height: number);
  8976. /**
  8977. * Returns a string with the Size width and height
  8978. * @returns a string with the Size width and height
  8979. */
  8980. toString(): string;
  8981. /**
  8982. * "Size"
  8983. * @returns the string "Size"
  8984. */
  8985. getClassName(): string;
  8986. /**
  8987. * Returns the Size hash code.
  8988. * @returns a hash code for a unique width and height
  8989. */
  8990. getHashCode(): number;
  8991. /**
  8992. * Updates the current size from the given one.
  8993. * @param src the given size
  8994. */
  8995. copyFrom(src: Size): void;
  8996. /**
  8997. * Updates in place the current Size from the given floats.
  8998. * @param width width of the new size
  8999. * @param height height of the new size
  9000. * @returns the updated Size.
  9001. */
  9002. copyFromFloats(width: number, height: number): Size;
  9003. /**
  9004. * Updates in place the current Size from the given floats.
  9005. * @param width width to set
  9006. * @param height height to set
  9007. * @returns the updated Size.
  9008. */
  9009. set(width: number, height: number): Size;
  9010. /**
  9011. * Multiplies the width and height by numbers
  9012. * @param w factor to multiple the width by
  9013. * @param h factor to multiple the height by
  9014. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9015. */
  9016. multiplyByFloats(w: number, h: number): Size;
  9017. /**
  9018. * Clones the size
  9019. * @returns a new Size copied from the given one.
  9020. */
  9021. clone(): Size;
  9022. /**
  9023. * True if the current Size and the given one width and height are strictly equal.
  9024. * @param other the other size to compare against
  9025. * @returns True if the current Size and the given one width and height are strictly equal.
  9026. */
  9027. equals(other: Size): boolean;
  9028. /**
  9029. * The surface of the Size : width * height (float).
  9030. */
  9031. get surface(): number;
  9032. /**
  9033. * Create a new size of zero
  9034. * @returns a new Size set to (0.0, 0.0)
  9035. */
  9036. static Zero(): Size;
  9037. /**
  9038. * Sums the width and height of two sizes
  9039. * @param otherSize size to add to this size
  9040. * @returns a new Size set as the addition result of the current Size and the given one.
  9041. */
  9042. add(otherSize: Size): Size;
  9043. /**
  9044. * Subtracts the width and height of two
  9045. * @param otherSize size to subtract to this size
  9046. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9047. */
  9048. subtract(otherSize: Size): Size;
  9049. /**
  9050. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9051. * @param start starting size to lerp between
  9052. * @param end end size to lerp between
  9053. * @param amount amount to lerp between the start and end values
  9054. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9055. */
  9056. static Lerp(start: Size, end: Size, amount: number): Size;
  9057. }
  9058. }
  9059. declare module "babylonjs/Maths/math.vertexFormat" {
  9060. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9061. /**
  9062. * Contains position and normal vectors for a vertex
  9063. */
  9064. export class PositionNormalVertex {
  9065. /** the position of the vertex (defaut: 0,0,0) */
  9066. position: Vector3;
  9067. /** the normal of the vertex (defaut: 0,1,0) */
  9068. normal: Vector3;
  9069. /**
  9070. * Creates a PositionNormalVertex
  9071. * @param position the position of the vertex (defaut: 0,0,0)
  9072. * @param normal the normal of the vertex (defaut: 0,1,0)
  9073. */
  9074. constructor(
  9075. /** the position of the vertex (defaut: 0,0,0) */
  9076. position?: Vector3,
  9077. /** the normal of the vertex (defaut: 0,1,0) */
  9078. normal?: Vector3);
  9079. /**
  9080. * Clones the PositionNormalVertex
  9081. * @returns the cloned PositionNormalVertex
  9082. */
  9083. clone(): PositionNormalVertex;
  9084. }
  9085. /**
  9086. * Contains position, normal and uv vectors for a vertex
  9087. */
  9088. export class PositionNormalTextureVertex {
  9089. /** the position of the vertex (defaut: 0,0,0) */
  9090. position: Vector3;
  9091. /** the normal of the vertex (defaut: 0,1,0) */
  9092. normal: Vector3;
  9093. /** the uv of the vertex (default: 0,0) */
  9094. uv: Vector2;
  9095. /**
  9096. * Creates a PositionNormalTextureVertex
  9097. * @param position the position of the vertex (defaut: 0,0,0)
  9098. * @param normal the normal of the vertex (defaut: 0,1,0)
  9099. * @param uv the uv of the vertex (default: 0,0)
  9100. */
  9101. constructor(
  9102. /** the position of the vertex (defaut: 0,0,0) */
  9103. position?: Vector3,
  9104. /** the normal of the vertex (defaut: 0,1,0) */
  9105. normal?: Vector3,
  9106. /** the uv of the vertex (default: 0,0) */
  9107. uv?: Vector2);
  9108. /**
  9109. * Clones the PositionNormalTextureVertex
  9110. * @returns the cloned PositionNormalTextureVertex
  9111. */
  9112. clone(): PositionNormalTextureVertex;
  9113. }
  9114. }
  9115. declare module "babylonjs/Maths/math" {
  9116. export * from "babylonjs/Maths/math.axis";
  9117. export * from "babylonjs/Maths/math.color";
  9118. export * from "babylonjs/Maths/math.constants";
  9119. export * from "babylonjs/Maths/math.frustum";
  9120. export * from "babylonjs/Maths/math.path";
  9121. export * from "babylonjs/Maths/math.plane";
  9122. export * from "babylonjs/Maths/math.size";
  9123. export * from "babylonjs/Maths/math.vector";
  9124. export * from "babylonjs/Maths/math.vertexFormat";
  9125. export * from "babylonjs/Maths/math.viewport";
  9126. }
  9127. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9128. /**
  9129. * Enum defining the type of animations supported by InputBlock
  9130. */
  9131. export enum AnimatedInputBlockTypes {
  9132. /** No animation */
  9133. None = 0,
  9134. /** Time based animation. Will only work for floats */
  9135. Time = 1
  9136. }
  9137. }
  9138. declare module "babylonjs/Lights/shadowLight" {
  9139. import { Camera } from "babylonjs/Cameras/camera";
  9140. import { Scene } from "babylonjs/scene";
  9141. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9143. import { Light } from "babylonjs/Lights/light";
  9144. /**
  9145. * Interface describing all the common properties and methods a shadow light needs to implement.
  9146. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9147. * as well as binding the different shadow properties to the effects.
  9148. */
  9149. export interface IShadowLight extends Light {
  9150. /**
  9151. * The light id in the scene (used in scene.findLighById for instance)
  9152. */
  9153. id: string;
  9154. /**
  9155. * The position the shdow will be casted from.
  9156. */
  9157. position: Vector3;
  9158. /**
  9159. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9160. */
  9161. direction: Vector3;
  9162. /**
  9163. * The transformed position. Position of the light in world space taking parenting in account.
  9164. */
  9165. transformedPosition: Vector3;
  9166. /**
  9167. * The transformed direction. Direction of the light in world space taking parenting in account.
  9168. */
  9169. transformedDirection: Vector3;
  9170. /**
  9171. * The friendly name of the light in the scene.
  9172. */
  9173. name: string;
  9174. /**
  9175. * Defines the shadow projection clipping minimum z value.
  9176. */
  9177. shadowMinZ: number;
  9178. /**
  9179. * Defines the shadow projection clipping maximum z value.
  9180. */
  9181. shadowMaxZ: number;
  9182. /**
  9183. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9184. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9185. */
  9186. computeTransformedInformation(): boolean;
  9187. /**
  9188. * Gets the scene the light belongs to.
  9189. * @returns The scene
  9190. */
  9191. getScene(): Scene;
  9192. /**
  9193. * Callback defining a custom Projection Matrix Builder.
  9194. * This can be used to override the default projection matrix computation.
  9195. */
  9196. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9197. /**
  9198. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9199. * @param matrix The materix to updated with the projection information
  9200. * @param viewMatrix The transform matrix of the light
  9201. * @param renderList The list of mesh to render in the map
  9202. * @returns The current light
  9203. */
  9204. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9205. /**
  9206. * Gets the current depth scale used in ESM.
  9207. * @returns The scale
  9208. */
  9209. getDepthScale(): number;
  9210. /**
  9211. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9212. * @returns true if a cube texture needs to be use
  9213. */
  9214. needCube(): boolean;
  9215. /**
  9216. * Detects if the projection matrix requires to be recomputed this frame.
  9217. * @returns true if it requires to be recomputed otherwise, false.
  9218. */
  9219. needProjectionMatrixCompute(): boolean;
  9220. /**
  9221. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9222. */
  9223. forceProjectionMatrixCompute(): void;
  9224. /**
  9225. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9226. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9227. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9228. */
  9229. getShadowDirection(faceIndex?: number): Vector3;
  9230. /**
  9231. * Gets the minZ used for shadow according to both the scene and the light.
  9232. * @param activeCamera The camera we are returning the min for
  9233. * @returns the depth min z
  9234. */
  9235. getDepthMinZ(activeCamera: Camera): number;
  9236. /**
  9237. * Gets the maxZ used for shadow according to both the scene and the light.
  9238. * @param activeCamera The camera we are returning the max for
  9239. * @returns the depth max z
  9240. */
  9241. getDepthMaxZ(activeCamera: Camera): number;
  9242. }
  9243. /**
  9244. * Base implementation IShadowLight
  9245. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9246. */
  9247. export abstract class ShadowLight extends Light implements IShadowLight {
  9248. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9249. protected _position: Vector3;
  9250. protected _setPosition(value: Vector3): void;
  9251. /**
  9252. * Sets the position the shadow will be casted from. Also use as the light position for both
  9253. * point and spot lights.
  9254. */
  9255. get position(): Vector3;
  9256. /**
  9257. * Sets the position the shadow will be casted from. Also use as the light position for both
  9258. * point and spot lights.
  9259. */
  9260. set position(value: Vector3);
  9261. protected _direction: Vector3;
  9262. protected _setDirection(value: Vector3): void;
  9263. /**
  9264. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9265. * Also use as the light direction on spot and directional lights.
  9266. */
  9267. get direction(): Vector3;
  9268. /**
  9269. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9270. * Also use as the light direction on spot and directional lights.
  9271. */
  9272. set direction(value: Vector3);
  9273. protected _shadowMinZ: number;
  9274. /**
  9275. * Gets the shadow projection clipping minimum z value.
  9276. */
  9277. get shadowMinZ(): number;
  9278. /**
  9279. * Sets the shadow projection clipping minimum z value.
  9280. */
  9281. set shadowMinZ(value: number);
  9282. protected _shadowMaxZ: number;
  9283. /**
  9284. * Sets the shadow projection clipping maximum z value.
  9285. */
  9286. get shadowMaxZ(): number;
  9287. /**
  9288. * Gets the shadow projection clipping maximum z value.
  9289. */
  9290. set shadowMaxZ(value: number);
  9291. /**
  9292. * Callback defining a custom Projection Matrix Builder.
  9293. * This can be used to override the default projection matrix computation.
  9294. */
  9295. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9296. /**
  9297. * The transformed position. Position of the light in world space taking parenting in account.
  9298. */
  9299. transformedPosition: Vector3;
  9300. /**
  9301. * The transformed direction. Direction of the light in world space taking parenting in account.
  9302. */
  9303. transformedDirection: Vector3;
  9304. private _needProjectionMatrixCompute;
  9305. /**
  9306. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9307. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9308. */
  9309. computeTransformedInformation(): boolean;
  9310. /**
  9311. * Return the depth scale used for the shadow map.
  9312. * @returns the depth scale.
  9313. */
  9314. getDepthScale(): number;
  9315. /**
  9316. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9317. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9318. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9319. */
  9320. getShadowDirection(faceIndex?: number): Vector3;
  9321. /**
  9322. * Returns the ShadowLight absolute position in the World.
  9323. * @returns the position vector in world space
  9324. */
  9325. getAbsolutePosition(): Vector3;
  9326. /**
  9327. * Sets the ShadowLight direction toward the passed target.
  9328. * @param target The point to target in local space
  9329. * @returns the updated ShadowLight direction
  9330. */
  9331. setDirectionToTarget(target: Vector3): Vector3;
  9332. /**
  9333. * Returns the light rotation in euler definition.
  9334. * @returns the x y z rotation in local space.
  9335. */
  9336. getRotation(): Vector3;
  9337. /**
  9338. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9339. * @returns true if a cube texture needs to be use
  9340. */
  9341. needCube(): boolean;
  9342. /**
  9343. * Detects if the projection matrix requires to be recomputed this frame.
  9344. * @returns true if it requires to be recomputed otherwise, false.
  9345. */
  9346. needProjectionMatrixCompute(): boolean;
  9347. /**
  9348. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9349. */
  9350. forceProjectionMatrixCompute(): void;
  9351. /** @hidden */
  9352. _initCache(): void;
  9353. /** @hidden */
  9354. _isSynchronized(): boolean;
  9355. /**
  9356. * Computes the world matrix of the node
  9357. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9358. * @returns the world matrix
  9359. */
  9360. computeWorldMatrix(force?: boolean): Matrix;
  9361. /**
  9362. * Gets the minZ used for shadow according to both the scene and the light.
  9363. * @param activeCamera The camera we are returning the min for
  9364. * @returns the depth min z
  9365. */
  9366. getDepthMinZ(activeCamera: Camera): number;
  9367. /**
  9368. * Gets the maxZ used for shadow according to both the scene and the light.
  9369. * @param activeCamera The camera we are returning the max for
  9370. * @returns the depth max z
  9371. */
  9372. getDepthMaxZ(activeCamera: Camera): number;
  9373. /**
  9374. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9375. * @param matrix The materix to updated with the projection information
  9376. * @param viewMatrix The transform matrix of the light
  9377. * @param renderList The list of mesh to render in the map
  9378. * @returns The current light
  9379. */
  9380. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9381. }
  9382. }
  9383. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9384. /** @hidden */
  9385. export var packingFunctions: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9391. /** @hidden */
  9392. export var bayerDitherFunctions: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9398. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9399. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9400. /** @hidden */
  9401. export var shadowMapFragmentDeclaration: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9407. /** @hidden */
  9408. export var clipPlaneFragmentDeclaration: {
  9409. name: string;
  9410. shader: string;
  9411. };
  9412. }
  9413. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9414. /** @hidden */
  9415. export var clipPlaneFragment: {
  9416. name: string;
  9417. shader: string;
  9418. };
  9419. }
  9420. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9421. /** @hidden */
  9422. export var shadowMapFragment: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9428. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9429. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9430. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9431. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9432. /** @hidden */
  9433. export var shadowMapPixelShader: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9439. /** @hidden */
  9440. export var bonesDeclaration: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9446. /** @hidden */
  9447. export var morphTargetsVertexGlobalDeclaration: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9453. /** @hidden */
  9454. export var morphTargetsVertexDeclaration: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9460. /** @hidden */
  9461. export var instancesDeclaration: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9467. /** @hidden */
  9468. export var helperFunctions: {
  9469. name: string;
  9470. shader: string;
  9471. };
  9472. }
  9473. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9474. /** @hidden */
  9475. export var shadowMapVertexDeclaration: {
  9476. name: string;
  9477. shader: string;
  9478. };
  9479. }
  9480. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9481. /** @hidden */
  9482. export var clipPlaneVertexDeclaration: {
  9483. name: string;
  9484. shader: string;
  9485. };
  9486. }
  9487. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9488. /** @hidden */
  9489. export var morphTargetsVertex: {
  9490. name: string;
  9491. shader: string;
  9492. };
  9493. }
  9494. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9495. /** @hidden */
  9496. export var instancesVertex: {
  9497. name: string;
  9498. shader: string;
  9499. };
  9500. }
  9501. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9502. /** @hidden */
  9503. export var bonesVertex: {
  9504. name: string;
  9505. shader: string;
  9506. };
  9507. }
  9508. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9509. /** @hidden */
  9510. export var shadowMapVertexNormalBias: {
  9511. name: string;
  9512. shader: string;
  9513. };
  9514. }
  9515. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9516. /** @hidden */
  9517. export var shadowMapVertexMetric: {
  9518. name: string;
  9519. shader: string;
  9520. };
  9521. }
  9522. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9523. /** @hidden */
  9524. export var clipPlaneVertex: {
  9525. name: string;
  9526. shader: string;
  9527. };
  9528. }
  9529. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9530. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9533. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9534. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9535. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9536. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9537. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9538. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9539. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9540. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9541. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9542. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9543. /** @hidden */
  9544. export var shadowMapVertexShader: {
  9545. name: string;
  9546. shader: string;
  9547. };
  9548. }
  9549. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9550. /** @hidden */
  9551. export var depthBoxBlurPixelShader: {
  9552. name: string;
  9553. shader: string;
  9554. };
  9555. }
  9556. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9557. /** @hidden */
  9558. export var shadowMapFragmentSoftTransparentShadow: {
  9559. name: string;
  9560. shader: string;
  9561. };
  9562. }
  9563. declare module "babylonjs/Materials/effectFallbacks" {
  9564. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9565. import { Effect } from "babylonjs/Materials/effect";
  9566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9567. /**
  9568. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9569. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9570. */
  9571. export class EffectFallbacks implements IEffectFallbacks {
  9572. private _defines;
  9573. private _currentRank;
  9574. private _maxRank;
  9575. private _mesh;
  9576. /**
  9577. * Removes the fallback from the bound mesh.
  9578. */
  9579. unBindMesh(): void;
  9580. /**
  9581. * Adds a fallback on the specified property.
  9582. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9583. * @param define The name of the define in the shader
  9584. */
  9585. addFallback(rank: number, define: string): void;
  9586. /**
  9587. * Sets the mesh to use CPU skinning when needing to fallback.
  9588. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9589. * @param mesh The mesh to use the fallbacks.
  9590. */
  9591. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9592. /**
  9593. * Checks to see if more fallbacks are still availible.
  9594. */
  9595. get hasMoreFallbacks(): boolean;
  9596. /**
  9597. * Removes the defines that should be removed when falling back.
  9598. * @param currentDefines defines the current define statements for the shader.
  9599. * @param effect defines the current effect we try to compile
  9600. * @returns The resulting defines with defines of the current rank removed.
  9601. */
  9602. reduce(currentDefines: string, effect: Effect): string;
  9603. }
  9604. }
  9605. declare module "babylonjs/Actions/action" {
  9606. import { Observable } from "babylonjs/Misc/observable";
  9607. import { Condition } from "babylonjs/Actions/condition";
  9608. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9609. import { Nullable } from "babylonjs/types";
  9610. import { Scene } from "babylonjs/scene";
  9611. import { ActionManager } from "babylonjs/Actions/actionManager";
  9612. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9613. import { Node } from "babylonjs/node";
  9614. /**
  9615. * Interface used to define Action
  9616. */
  9617. export interface IAction {
  9618. /**
  9619. * Trigger for the action
  9620. */
  9621. trigger: number;
  9622. /** Options of the trigger */
  9623. triggerOptions: any;
  9624. /**
  9625. * Gets the trigger parameters
  9626. * @returns the trigger parameters
  9627. */
  9628. getTriggerParameter(): any;
  9629. /**
  9630. * Internal only - executes current action event
  9631. * @hidden
  9632. */
  9633. _executeCurrent(evt?: ActionEvent): void;
  9634. /**
  9635. * Serialize placeholder for child classes
  9636. * @param parent of child
  9637. * @returns the serialized object
  9638. */
  9639. serialize(parent: any): any;
  9640. /**
  9641. * Internal only
  9642. * @hidden
  9643. */
  9644. _prepare(): void;
  9645. /**
  9646. * Internal only - manager for action
  9647. * @hidden
  9648. */
  9649. _actionManager: Nullable<AbstractActionManager>;
  9650. /**
  9651. * Adds action to chain of actions, may be a DoNothingAction
  9652. * @param action defines the next action to execute
  9653. * @returns The action passed in
  9654. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9655. */
  9656. then(action: IAction): IAction;
  9657. }
  9658. /**
  9659. * The action to be carried out following a trigger
  9660. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9661. */
  9662. export class Action implements IAction {
  9663. /** the trigger, with or without parameters, for the action */
  9664. triggerOptions: any;
  9665. /**
  9666. * Trigger for the action
  9667. */
  9668. trigger: number;
  9669. /**
  9670. * Internal only - manager for action
  9671. * @hidden
  9672. */
  9673. _actionManager: ActionManager;
  9674. private _nextActiveAction;
  9675. private _child;
  9676. private _condition?;
  9677. private _triggerParameter;
  9678. /**
  9679. * An event triggered prior to action being executed.
  9680. */
  9681. onBeforeExecuteObservable: Observable<Action>;
  9682. /**
  9683. * Creates a new Action
  9684. * @param triggerOptions the trigger, with or without parameters, for the action
  9685. * @param condition an optional determinant of action
  9686. */
  9687. constructor(
  9688. /** the trigger, with or without parameters, for the action */
  9689. triggerOptions: any, condition?: Condition);
  9690. /**
  9691. * Internal only
  9692. * @hidden
  9693. */
  9694. _prepare(): void;
  9695. /**
  9696. * Gets the trigger parameters
  9697. * @returns the trigger parameters
  9698. */
  9699. getTriggerParameter(): any;
  9700. /**
  9701. * Internal only - executes current action event
  9702. * @hidden
  9703. */
  9704. _executeCurrent(evt?: ActionEvent): void;
  9705. /**
  9706. * Execute placeholder for child classes
  9707. * @param evt optional action event
  9708. */
  9709. execute(evt?: ActionEvent): void;
  9710. /**
  9711. * Skips to next active action
  9712. */
  9713. skipToNextActiveAction(): void;
  9714. /**
  9715. * Adds action to chain of actions, may be a DoNothingAction
  9716. * @param action defines the next action to execute
  9717. * @returns The action passed in
  9718. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9719. */
  9720. then(action: Action): Action;
  9721. /**
  9722. * Internal only
  9723. * @hidden
  9724. */
  9725. _getProperty(propertyPath: string): string;
  9726. /**
  9727. * Internal only
  9728. * @hidden
  9729. */
  9730. _getEffectiveTarget(target: any, propertyPath: string): any;
  9731. /**
  9732. * Serialize placeholder for child classes
  9733. * @param parent of child
  9734. * @returns the serialized object
  9735. */
  9736. serialize(parent: any): any;
  9737. /**
  9738. * Internal only called by serialize
  9739. * @hidden
  9740. */
  9741. protected _serialize(serializedAction: any, parent?: any): any;
  9742. /**
  9743. * Internal only
  9744. * @hidden
  9745. */
  9746. static _SerializeValueAsString: (value: any) => string;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. static _GetTargetProperty: (target: Scene | Node) => {
  9752. name: string;
  9753. targetType: string;
  9754. value: string;
  9755. };
  9756. }
  9757. }
  9758. declare module "babylonjs/Actions/condition" {
  9759. import { ActionManager } from "babylonjs/Actions/actionManager";
  9760. /**
  9761. * A Condition applied to an Action
  9762. */
  9763. export class Condition {
  9764. /**
  9765. * Internal only - manager for action
  9766. * @hidden
  9767. */
  9768. _actionManager: ActionManager;
  9769. /**
  9770. * Internal only
  9771. * @hidden
  9772. */
  9773. _evaluationId: number;
  9774. /**
  9775. * Internal only
  9776. * @hidden
  9777. */
  9778. _currentResult: boolean;
  9779. /**
  9780. * Creates a new Condition
  9781. * @param actionManager the manager of the action the condition is applied to
  9782. */
  9783. constructor(actionManager: ActionManager);
  9784. /**
  9785. * Check if the current condition is valid
  9786. * @returns a boolean
  9787. */
  9788. isValid(): boolean;
  9789. /**
  9790. * Internal only
  9791. * @hidden
  9792. */
  9793. _getProperty(propertyPath: string): string;
  9794. /**
  9795. * Internal only
  9796. * @hidden
  9797. */
  9798. _getEffectiveTarget(target: any, propertyPath: string): any;
  9799. /**
  9800. * Serialize placeholder for child classes
  9801. * @returns the serialized object
  9802. */
  9803. serialize(): any;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. protected _serialize(serializedCondition: any): any;
  9809. }
  9810. /**
  9811. * Defines specific conditional operators as extensions of Condition
  9812. */
  9813. export class ValueCondition extends Condition {
  9814. /** path to specify the property of the target the conditional operator uses */
  9815. propertyPath: string;
  9816. /** the value compared by the conditional operator against the current value of the property */
  9817. value: any;
  9818. /** the conditional operator, default ValueCondition.IsEqual */
  9819. operator: number;
  9820. /**
  9821. * Internal only
  9822. * @hidden
  9823. */
  9824. private static _IsEqual;
  9825. /**
  9826. * Internal only
  9827. * @hidden
  9828. */
  9829. private static _IsDifferent;
  9830. /**
  9831. * Internal only
  9832. * @hidden
  9833. */
  9834. private static _IsGreater;
  9835. /**
  9836. * Internal only
  9837. * @hidden
  9838. */
  9839. private static _IsLesser;
  9840. /**
  9841. * returns the number for IsEqual
  9842. */
  9843. static get IsEqual(): number;
  9844. /**
  9845. * Returns the number for IsDifferent
  9846. */
  9847. static get IsDifferent(): number;
  9848. /**
  9849. * Returns the number for IsGreater
  9850. */
  9851. static get IsGreater(): number;
  9852. /**
  9853. * Returns the number for IsLesser
  9854. */
  9855. static get IsLesser(): number;
  9856. /**
  9857. * Internal only The action manager for the condition
  9858. * @hidden
  9859. */
  9860. _actionManager: ActionManager;
  9861. /**
  9862. * Internal only
  9863. * @hidden
  9864. */
  9865. private _target;
  9866. /**
  9867. * Internal only
  9868. * @hidden
  9869. */
  9870. private _effectiveTarget;
  9871. /**
  9872. * Internal only
  9873. * @hidden
  9874. */
  9875. private _property;
  9876. /**
  9877. * Creates a new ValueCondition
  9878. * @param actionManager manager for the action the condition applies to
  9879. * @param target for the action
  9880. * @param propertyPath path to specify the property of the target the conditional operator uses
  9881. * @param value the value compared by the conditional operator against the current value of the property
  9882. * @param operator the conditional operator, default ValueCondition.IsEqual
  9883. */
  9884. constructor(actionManager: ActionManager, target: any,
  9885. /** path to specify the property of the target the conditional operator uses */
  9886. propertyPath: string,
  9887. /** the value compared by the conditional operator against the current value of the property */
  9888. value: any,
  9889. /** the conditional operator, default ValueCondition.IsEqual */
  9890. operator?: number);
  9891. /**
  9892. * Compares the given value with the property value for the specified conditional operator
  9893. * @returns the result of the comparison
  9894. */
  9895. isValid(): boolean;
  9896. /**
  9897. * Serialize the ValueCondition into a JSON compatible object
  9898. * @returns serialization object
  9899. */
  9900. serialize(): any;
  9901. /**
  9902. * Gets the name of the conditional operator for the ValueCondition
  9903. * @param operator the conditional operator
  9904. * @returns the name
  9905. */
  9906. static GetOperatorName(operator: number): string;
  9907. }
  9908. /**
  9909. * Defines a predicate condition as an extension of Condition
  9910. */
  9911. export class PredicateCondition extends Condition {
  9912. /** defines the predicate function used to validate the condition */
  9913. predicate: () => boolean;
  9914. /**
  9915. * Internal only - manager for action
  9916. * @hidden
  9917. */
  9918. _actionManager: ActionManager;
  9919. /**
  9920. * Creates a new PredicateCondition
  9921. * @param actionManager manager for the action the condition applies to
  9922. * @param predicate defines the predicate function used to validate the condition
  9923. */
  9924. constructor(actionManager: ActionManager,
  9925. /** defines the predicate function used to validate the condition */
  9926. predicate: () => boolean);
  9927. /**
  9928. * @returns the validity of the predicate condition
  9929. */
  9930. isValid(): boolean;
  9931. }
  9932. /**
  9933. * Defines a state condition as an extension of Condition
  9934. */
  9935. export class StateCondition extends Condition {
  9936. /** Value to compare with target state */
  9937. value: string;
  9938. /**
  9939. * Internal only - manager for action
  9940. * @hidden
  9941. */
  9942. _actionManager: ActionManager;
  9943. /**
  9944. * Internal only
  9945. * @hidden
  9946. */
  9947. private _target;
  9948. /**
  9949. * Creates a new StateCondition
  9950. * @param actionManager manager for the action the condition applies to
  9951. * @param target of the condition
  9952. * @param value to compare with target state
  9953. */
  9954. constructor(actionManager: ActionManager, target: any,
  9955. /** Value to compare with target state */
  9956. value: string);
  9957. /**
  9958. * Gets a boolean indicating if the current condition is met
  9959. * @returns the validity of the state
  9960. */
  9961. isValid(): boolean;
  9962. /**
  9963. * Serialize the StateCondition into a JSON compatible object
  9964. * @returns serialization object
  9965. */
  9966. serialize(): any;
  9967. }
  9968. }
  9969. declare module "babylonjs/Actions/directActions" {
  9970. import { Action } from "babylonjs/Actions/action";
  9971. import { Condition } from "babylonjs/Actions/condition";
  9972. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9973. /**
  9974. * This defines an action responsible to toggle a boolean once triggered.
  9975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9976. */
  9977. export class SwitchBooleanAction extends Action {
  9978. /**
  9979. * The path to the boolean property in the target object
  9980. */
  9981. propertyPath: string;
  9982. private _target;
  9983. private _effectiveTarget;
  9984. private _property;
  9985. /**
  9986. * Instantiate the action
  9987. * @param triggerOptions defines the trigger options
  9988. * @param target defines the object containing the boolean
  9989. * @param propertyPath defines the path to the boolean property in the target object
  9990. * @param condition defines the trigger related conditions
  9991. */
  9992. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9993. /** @hidden */
  9994. _prepare(): void;
  9995. /**
  9996. * Execute the action toggle the boolean value.
  9997. */
  9998. execute(): void;
  9999. /**
  10000. * Serializes the actions and its related information.
  10001. * @param parent defines the object to serialize in
  10002. * @returns the serialized object
  10003. */
  10004. serialize(parent: any): any;
  10005. }
  10006. /**
  10007. * This defines an action responsible to set a the state field of the target
  10008. * to a desired value once triggered.
  10009. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10010. */
  10011. export class SetStateAction extends Action {
  10012. /**
  10013. * The value to store in the state field.
  10014. */
  10015. value: string;
  10016. private _target;
  10017. /**
  10018. * Instantiate the action
  10019. * @param triggerOptions defines the trigger options
  10020. * @param target defines the object containing the state property
  10021. * @param value defines the value to store in the state field
  10022. * @param condition defines the trigger related conditions
  10023. */
  10024. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10025. /**
  10026. * Execute the action and store the value on the target state property.
  10027. */
  10028. execute(): void;
  10029. /**
  10030. * Serializes the actions and its related information.
  10031. * @param parent defines the object to serialize in
  10032. * @returns the serialized object
  10033. */
  10034. serialize(parent: any): any;
  10035. }
  10036. /**
  10037. * This defines an action responsible to set a property of the target
  10038. * to a desired value once triggered.
  10039. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10040. */
  10041. export class SetValueAction extends Action {
  10042. /**
  10043. * The path of the property to set in the target.
  10044. */
  10045. propertyPath: string;
  10046. /**
  10047. * The value to set in the property
  10048. */
  10049. value: any;
  10050. private _target;
  10051. private _effectiveTarget;
  10052. private _property;
  10053. /**
  10054. * Instantiate the action
  10055. * @param triggerOptions defines the trigger options
  10056. * @param target defines the object containing the property
  10057. * @param propertyPath defines the path of the property to set in the target
  10058. * @param value defines the value to set in the property
  10059. * @param condition defines the trigger related conditions
  10060. */
  10061. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10062. /** @hidden */
  10063. _prepare(): void;
  10064. /**
  10065. * Execute the action and set the targetted property to the desired value.
  10066. */
  10067. execute(): void;
  10068. /**
  10069. * Serializes the actions and its related information.
  10070. * @param parent defines the object to serialize in
  10071. * @returns the serialized object
  10072. */
  10073. serialize(parent: any): any;
  10074. }
  10075. /**
  10076. * This defines an action responsible to increment the target value
  10077. * to a desired value once triggered.
  10078. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10079. */
  10080. export class IncrementValueAction extends Action {
  10081. /**
  10082. * The path of the property to increment in the target.
  10083. */
  10084. propertyPath: string;
  10085. /**
  10086. * The value we should increment the property by.
  10087. */
  10088. value: any;
  10089. private _target;
  10090. private _effectiveTarget;
  10091. private _property;
  10092. /**
  10093. * Instantiate the action
  10094. * @param triggerOptions defines the trigger options
  10095. * @param target defines the object containing the property
  10096. * @param propertyPath defines the path of the property to increment in the target
  10097. * @param value defines the value value we should increment the property by
  10098. * @param condition defines the trigger related conditions
  10099. */
  10100. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10101. /** @hidden */
  10102. _prepare(): void;
  10103. /**
  10104. * Execute the action and increment the target of the value amount.
  10105. */
  10106. execute(): void;
  10107. /**
  10108. * Serializes the actions and its related information.
  10109. * @param parent defines the object to serialize in
  10110. * @returns the serialized object
  10111. */
  10112. serialize(parent: any): any;
  10113. }
  10114. /**
  10115. * This defines an action responsible to start an animation once triggered.
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10117. */
  10118. export class PlayAnimationAction extends Action {
  10119. /**
  10120. * Where the animation should start (animation frame)
  10121. */
  10122. from: number;
  10123. /**
  10124. * Where the animation should stop (animation frame)
  10125. */
  10126. to: number;
  10127. /**
  10128. * Define if the animation should loop or stop after the first play.
  10129. */
  10130. loop?: boolean;
  10131. private _target;
  10132. /**
  10133. * Instantiate the action
  10134. * @param triggerOptions defines the trigger options
  10135. * @param target defines the target animation or animation name
  10136. * @param from defines from where the animation should start (animation frame)
  10137. * @param end defines where the animation should stop (animation frame)
  10138. * @param loop defines if the animation should loop or stop after the first play
  10139. * @param condition defines the trigger related conditions
  10140. */
  10141. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10142. /** @hidden */
  10143. _prepare(): void;
  10144. /**
  10145. * Execute the action and play the animation.
  10146. */
  10147. execute(): void;
  10148. /**
  10149. * Serializes the actions and its related information.
  10150. * @param parent defines the object to serialize in
  10151. * @returns the serialized object
  10152. */
  10153. serialize(parent: any): any;
  10154. }
  10155. /**
  10156. * This defines an action responsible to stop an animation once triggered.
  10157. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10158. */
  10159. export class StopAnimationAction extends Action {
  10160. private _target;
  10161. /**
  10162. * Instantiate the action
  10163. * @param triggerOptions defines the trigger options
  10164. * @param target defines the target animation or animation name
  10165. * @param condition defines the trigger related conditions
  10166. */
  10167. constructor(triggerOptions: any, target: any, condition?: Condition);
  10168. /** @hidden */
  10169. _prepare(): void;
  10170. /**
  10171. * Execute the action and stop the animation.
  10172. */
  10173. execute(): void;
  10174. /**
  10175. * Serializes the actions and its related information.
  10176. * @param parent defines the object to serialize in
  10177. * @returns the serialized object
  10178. */
  10179. serialize(parent: any): any;
  10180. }
  10181. /**
  10182. * This defines an action responsible that does nothing once triggered.
  10183. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10184. */
  10185. export class DoNothingAction extends Action {
  10186. /**
  10187. * Instantiate the action
  10188. * @param triggerOptions defines the trigger options
  10189. * @param condition defines the trigger related conditions
  10190. */
  10191. constructor(triggerOptions?: any, condition?: Condition);
  10192. /**
  10193. * Execute the action and do nothing.
  10194. */
  10195. execute(): void;
  10196. /**
  10197. * Serializes the actions and its related information.
  10198. * @param parent defines the object to serialize in
  10199. * @returns the serialized object
  10200. */
  10201. serialize(parent: any): any;
  10202. }
  10203. /**
  10204. * This defines an action responsible to trigger several actions once triggered.
  10205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10206. */
  10207. export class CombineAction extends Action {
  10208. /**
  10209. * The list of aggregated animations to run.
  10210. */
  10211. children: Action[];
  10212. /**
  10213. * Instantiate the action
  10214. * @param triggerOptions defines the trigger options
  10215. * @param children defines the list of aggregated animations to run
  10216. * @param condition defines the trigger related conditions
  10217. */
  10218. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10219. /** @hidden */
  10220. _prepare(): void;
  10221. /**
  10222. * Execute the action and executes all the aggregated actions.
  10223. */
  10224. execute(evt: ActionEvent): void;
  10225. /**
  10226. * Serializes the actions and its related information.
  10227. * @param parent defines the object to serialize in
  10228. * @returns the serialized object
  10229. */
  10230. serialize(parent: any): any;
  10231. }
  10232. /**
  10233. * This defines an action responsible to run code (external event) once triggered.
  10234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10235. */
  10236. export class ExecuteCodeAction extends Action {
  10237. /**
  10238. * The callback function to run.
  10239. */
  10240. func: (evt: ActionEvent) => void;
  10241. /**
  10242. * Instantiate the action
  10243. * @param triggerOptions defines the trigger options
  10244. * @param func defines the callback function to run
  10245. * @param condition defines the trigger related conditions
  10246. */
  10247. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10248. /**
  10249. * Execute the action and run the attached code.
  10250. */
  10251. execute(evt: ActionEvent): void;
  10252. }
  10253. /**
  10254. * This defines an action responsible to set the parent property of the target once triggered.
  10255. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10256. */
  10257. export class SetParentAction extends Action {
  10258. private _parent;
  10259. private _target;
  10260. /**
  10261. * Instantiate the action
  10262. * @param triggerOptions defines the trigger options
  10263. * @param target defines the target containing the parent property
  10264. * @param parent defines from where the animation should start (animation frame)
  10265. * @param condition defines the trigger related conditions
  10266. */
  10267. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10268. /** @hidden */
  10269. _prepare(): void;
  10270. /**
  10271. * Execute the action and set the parent property.
  10272. */
  10273. execute(): void;
  10274. /**
  10275. * Serializes the actions and its related information.
  10276. * @param parent defines the object to serialize in
  10277. * @returns the serialized object
  10278. */
  10279. serialize(parent: any): any;
  10280. }
  10281. }
  10282. declare module "babylonjs/Actions/actionManager" {
  10283. import { Nullable } from "babylonjs/types";
  10284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10285. import { Scene } from "babylonjs/scene";
  10286. import { IAction } from "babylonjs/Actions/action";
  10287. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10288. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10289. /**
  10290. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10291. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10293. */
  10294. export class ActionManager extends AbstractActionManager {
  10295. /**
  10296. * Nothing
  10297. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10298. */
  10299. static readonly NothingTrigger: number;
  10300. /**
  10301. * On pick
  10302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10303. */
  10304. static readonly OnPickTrigger: number;
  10305. /**
  10306. * On left pick
  10307. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10308. */
  10309. static readonly OnLeftPickTrigger: number;
  10310. /**
  10311. * On right pick
  10312. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10313. */
  10314. static readonly OnRightPickTrigger: number;
  10315. /**
  10316. * On center pick
  10317. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10318. */
  10319. static readonly OnCenterPickTrigger: number;
  10320. /**
  10321. * On pick down
  10322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10323. */
  10324. static readonly OnPickDownTrigger: number;
  10325. /**
  10326. * On double pick
  10327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10328. */
  10329. static readonly OnDoublePickTrigger: number;
  10330. /**
  10331. * On pick up
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPickUpTrigger: number;
  10335. /**
  10336. * On pick out.
  10337. * This trigger will only be raised if you also declared a OnPickDown
  10338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10339. */
  10340. static readonly OnPickOutTrigger: number;
  10341. /**
  10342. * On long press
  10343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10344. */
  10345. static readonly OnLongPressTrigger: number;
  10346. /**
  10347. * On pointer over
  10348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10349. */
  10350. static readonly OnPointerOverTrigger: number;
  10351. /**
  10352. * On pointer out
  10353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10354. */
  10355. static readonly OnPointerOutTrigger: number;
  10356. /**
  10357. * On every frame
  10358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10359. */
  10360. static readonly OnEveryFrameTrigger: number;
  10361. /**
  10362. * On intersection enter
  10363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10364. */
  10365. static readonly OnIntersectionEnterTrigger: number;
  10366. /**
  10367. * On intersection exit
  10368. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10369. */
  10370. static readonly OnIntersectionExitTrigger: number;
  10371. /**
  10372. * On key down
  10373. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10374. */
  10375. static readonly OnKeyDownTrigger: number;
  10376. /**
  10377. * On key up
  10378. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10379. */
  10380. static readonly OnKeyUpTrigger: number;
  10381. private _scene;
  10382. /**
  10383. * Creates a new action manager
  10384. * @param scene defines the hosting scene
  10385. */
  10386. constructor(scene: Scene);
  10387. /**
  10388. * Releases all associated resources
  10389. */
  10390. dispose(): void;
  10391. /**
  10392. * Gets hosting scene
  10393. * @returns the hosting scene
  10394. */
  10395. getScene(): Scene;
  10396. /**
  10397. * Does this action manager handles actions of any of the given triggers
  10398. * @param triggers defines the triggers to be tested
  10399. * @return a boolean indicating whether one (or more) of the triggers is handled
  10400. */
  10401. hasSpecificTriggers(triggers: number[]): boolean;
  10402. /**
  10403. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10404. * speed.
  10405. * @param triggerA defines the trigger to be tested
  10406. * @param triggerB defines the trigger to be tested
  10407. * @return a boolean indicating whether one (or more) of the triggers is handled
  10408. */
  10409. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10410. /**
  10411. * Does this action manager handles actions of a given trigger
  10412. * @param trigger defines the trigger to be tested
  10413. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10414. * @return whether the trigger is handled
  10415. */
  10416. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10417. /**
  10418. * Does this action manager has pointer triggers
  10419. */
  10420. get hasPointerTriggers(): boolean;
  10421. /**
  10422. * Does this action manager has pick triggers
  10423. */
  10424. get hasPickTriggers(): boolean;
  10425. /**
  10426. * Registers an action to this action manager
  10427. * @param action defines the action to be registered
  10428. * @return the action amended (prepared) after registration
  10429. */
  10430. registerAction(action: IAction): Nullable<IAction>;
  10431. /**
  10432. * Unregisters an action to this action manager
  10433. * @param action defines the action to be unregistered
  10434. * @return a boolean indicating whether the action has been unregistered
  10435. */
  10436. unregisterAction(action: IAction): Boolean;
  10437. /**
  10438. * Process a specific trigger
  10439. * @param trigger defines the trigger to process
  10440. * @param evt defines the event details to be processed
  10441. */
  10442. processTrigger(trigger: number, evt?: IActionEvent): void;
  10443. /** @hidden */
  10444. _getEffectiveTarget(target: any, propertyPath: string): any;
  10445. /** @hidden */
  10446. _getProperty(propertyPath: string): string;
  10447. /**
  10448. * Serialize this manager to a JSON object
  10449. * @param name defines the property name to store this manager
  10450. * @returns a JSON representation of this manager
  10451. */
  10452. serialize(name: string): any;
  10453. /**
  10454. * Creates a new ActionManager from a JSON data
  10455. * @param parsedActions defines the JSON data to read from
  10456. * @param object defines the hosting mesh
  10457. * @param scene defines the hosting scene
  10458. */
  10459. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10460. /**
  10461. * Get a trigger name by index
  10462. * @param trigger defines the trigger index
  10463. * @returns a trigger name
  10464. */
  10465. static GetTriggerName(trigger: number): string;
  10466. }
  10467. }
  10468. declare module "babylonjs/Sprites/sprite" {
  10469. import { Vector3 } from "babylonjs/Maths/math.vector";
  10470. import { Nullable } from "babylonjs/types";
  10471. import { ActionManager } from "babylonjs/Actions/actionManager";
  10472. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10473. import { Color4 } from "babylonjs/Maths/math.color";
  10474. import { Observable } from "babylonjs/Misc/observable";
  10475. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10476. import { Animation } from "babylonjs/Animations/animation";
  10477. /**
  10478. * Class used to represent a sprite
  10479. * @see https://doc.babylonjs.com/babylon101/sprites
  10480. */
  10481. export class Sprite implements IAnimatable {
  10482. /** defines the name */
  10483. name: string;
  10484. /** Gets or sets the current world position */
  10485. position: Vector3;
  10486. /** Gets or sets the main color */
  10487. color: Color4;
  10488. /** Gets or sets the width */
  10489. width: number;
  10490. /** Gets or sets the height */
  10491. height: number;
  10492. /** Gets or sets rotation angle */
  10493. angle: number;
  10494. /** Gets or sets the cell index in the sprite sheet */
  10495. cellIndex: number;
  10496. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10497. cellRef: string;
  10498. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10499. invertU: boolean;
  10500. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10501. invertV: boolean;
  10502. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10503. disposeWhenFinishedAnimating: boolean;
  10504. /** Gets the list of attached animations */
  10505. animations: Nullable<Array<Animation>>;
  10506. /** Gets or sets a boolean indicating if the sprite can be picked */
  10507. isPickable: boolean;
  10508. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10509. useAlphaForPicking: boolean;
  10510. /** @hidden */
  10511. _xOffset: number;
  10512. /** @hidden */
  10513. _yOffset: number;
  10514. /** @hidden */
  10515. _xSize: number;
  10516. /** @hidden */
  10517. _ySize: number;
  10518. /**
  10519. * Gets or sets the associated action manager
  10520. */
  10521. actionManager: Nullable<ActionManager>;
  10522. /**
  10523. * An event triggered when the control has been disposed
  10524. */
  10525. onDisposeObservable: Observable<Sprite>;
  10526. private _animationStarted;
  10527. private _loopAnimation;
  10528. private _fromIndex;
  10529. private _toIndex;
  10530. private _delay;
  10531. private _direction;
  10532. private _manager;
  10533. private _time;
  10534. private _onAnimationEnd;
  10535. /**
  10536. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10537. */
  10538. isVisible: boolean;
  10539. /**
  10540. * Gets or sets the sprite size
  10541. */
  10542. get size(): number;
  10543. set size(value: number);
  10544. /**
  10545. * Returns a boolean indicating if the animation is started
  10546. */
  10547. get animationStarted(): boolean;
  10548. /**
  10549. * Gets or sets the unique id of the sprite
  10550. */
  10551. uniqueId: number;
  10552. /**
  10553. * Gets the manager of this sprite
  10554. */
  10555. get manager(): ISpriteManager;
  10556. /**
  10557. * Creates a new Sprite
  10558. * @param name defines the name
  10559. * @param manager defines the manager
  10560. */
  10561. constructor(
  10562. /** defines the name */
  10563. name: string, manager: ISpriteManager);
  10564. /**
  10565. * Returns the string "Sprite"
  10566. * @returns "Sprite"
  10567. */
  10568. getClassName(): string;
  10569. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10570. get fromIndex(): number;
  10571. set fromIndex(value: number);
  10572. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10573. get toIndex(): number;
  10574. set toIndex(value: number);
  10575. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10576. get loopAnimation(): boolean;
  10577. set loopAnimation(value: boolean);
  10578. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10579. get delay(): number;
  10580. set delay(value: number);
  10581. /**
  10582. * Starts an animation
  10583. * @param from defines the initial key
  10584. * @param to defines the end key
  10585. * @param loop defines if the animation must loop
  10586. * @param delay defines the start delay (in ms)
  10587. * @param onAnimationEnd defines a callback to call when animation ends
  10588. */
  10589. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10590. /** Stops current animation (if any) */
  10591. stopAnimation(): void;
  10592. /** @hidden */
  10593. _animate(deltaTime: number): void;
  10594. /** Release associated resources */
  10595. dispose(): void;
  10596. /**
  10597. * Serializes the sprite to a JSON object
  10598. * @returns the JSON object
  10599. */
  10600. serialize(): any;
  10601. /**
  10602. * Parses a JSON object to create a new sprite
  10603. * @param parsedSprite The JSON object to parse
  10604. * @param manager defines the hosting manager
  10605. * @returns the new sprite
  10606. */
  10607. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10608. }
  10609. }
  10610. declare module "babylonjs/Collisions/pickingInfo" {
  10611. import { Nullable } from "babylonjs/types";
  10612. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10614. import { Sprite } from "babylonjs/Sprites/sprite";
  10615. import { Ray } from "babylonjs/Culling/ray";
  10616. /**
  10617. * Information about the result of picking within a scene
  10618. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10619. */
  10620. export class PickingInfo {
  10621. /** @hidden */
  10622. _pickingUnavailable: boolean;
  10623. /**
  10624. * If the pick collided with an object
  10625. */
  10626. hit: boolean;
  10627. /**
  10628. * Distance away where the pick collided
  10629. */
  10630. distance: number;
  10631. /**
  10632. * The location of pick collision
  10633. */
  10634. pickedPoint: Nullable<Vector3>;
  10635. /**
  10636. * The mesh corresponding the the pick collision
  10637. */
  10638. pickedMesh: Nullable<AbstractMesh>;
  10639. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10640. bu: number;
  10641. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10642. bv: number;
  10643. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10644. faceId: number;
  10645. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10646. subMeshFaceId: number;
  10647. /** Id of the the submesh that was picked */
  10648. subMeshId: number;
  10649. /** If a sprite was picked, this will be the sprite the pick collided with */
  10650. pickedSprite: Nullable<Sprite>;
  10651. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10652. thinInstanceIndex: number;
  10653. /**
  10654. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10655. */
  10656. originMesh: Nullable<AbstractMesh>;
  10657. /**
  10658. * The ray that was used to perform the picking.
  10659. */
  10660. ray: Nullable<Ray>;
  10661. /**
  10662. * Gets the normal correspodning to the face the pick collided with
  10663. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10664. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10665. * @returns The normal correspodning to the face the pick collided with
  10666. */
  10667. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10668. /**
  10669. * Gets the texture coordinates of where the pick occured
  10670. * @returns the vector containing the coordnates of the texture
  10671. */
  10672. getTextureCoordinates(): Nullable<Vector2>;
  10673. }
  10674. }
  10675. declare module "babylonjs/Culling/ray" {
  10676. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10677. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10679. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10680. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10681. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10682. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10683. import { Plane } from "babylonjs/Maths/math.plane";
  10684. /**
  10685. * Class representing a ray with position and direction
  10686. */
  10687. export class Ray {
  10688. /** origin point */
  10689. origin: Vector3;
  10690. /** direction */
  10691. direction: Vector3;
  10692. /** length of the ray */
  10693. length: number;
  10694. private static readonly _TmpVector3;
  10695. private _tmpRay;
  10696. /**
  10697. * Creates a new ray
  10698. * @param origin origin point
  10699. * @param direction direction
  10700. * @param length length of the ray
  10701. */
  10702. constructor(
  10703. /** origin point */
  10704. origin: Vector3,
  10705. /** direction */
  10706. direction: Vector3,
  10707. /** length of the ray */
  10708. length?: number);
  10709. /**
  10710. * Checks if the ray intersects a box
  10711. * This does not account for the ray lenght by design to improve perfs.
  10712. * @param minimum bound of the box
  10713. * @param maximum bound of the box
  10714. * @param intersectionTreshold extra extend to be added to the box in all direction
  10715. * @returns if the box was hit
  10716. */
  10717. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10718. /**
  10719. * Checks if the ray intersects a box
  10720. * This does not account for the ray lenght by design to improve perfs.
  10721. * @param box the bounding box to check
  10722. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10723. * @returns if the box was hit
  10724. */
  10725. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10726. /**
  10727. * If the ray hits a sphere
  10728. * @param sphere the bounding sphere to check
  10729. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10730. * @returns true if it hits the sphere
  10731. */
  10732. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10733. /**
  10734. * If the ray hits a triange
  10735. * @param vertex0 triangle vertex
  10736. * @param vertex1 triangle vertex
  10737. * @param vertex2 triangle vertex
  10738. * @returns intersection information if hit
  10739. */
  10740. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10741. /**
  10742. * Checks if ray intersects a plane
  10743. * @param plane the plane to check
  10744. * @returns the distance away it was hit
  10745. */
  10746. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10747. /**
  10748. * Calculate the intercept of a ray on a given axis
  10749. * @param axis to check 'x' | 'y' | 'z'
  10750. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10751. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10752. */
  10753. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10754. /**
  10755. * Checks if ray intersects a mesh
  10756. * @param mesh the mesh to check
  10757. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10758. * @returns picking info of the intersecton
  10759. */
  10760. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10761. /**
  10762. * Checks if ray intersects a mesh
  10763. * @param meshes the meshes to check
  10764. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10765. * @param results array to store result in
  10766. * @returns Array of picking infos
  10767. */
  10768. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10769. private _comparePickingInfo;
  10770. private static smallnum;
  10771. private static rayl;
  10772. /**
  10773. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10774. * @param sega the first point of the segment to test the intersection against
  10775. * @param segb the second point of the segment to test the intersection against
  10776. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10777. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10778. */
  10779. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10780. /**
  10781. * Update the ray from viewport position
  10782. * @param x position
  10783. * @param y y position
  10784. * @param viewportWidth viewport width
  10785. * @param viewportHeight viewport height
  10786. * @param world world matrix
  10787. * @param view view matrix
  10788. * @param projection projection matrix
  10789. * @returns this ray updated
  10790. */
  10791. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10792. /**
  10793. * Creates a ray with origin and direction of 0,0,0
  10794. * @returns the new ray
  10795. */
  10796. static Zero(): Ray;
  10797. /**
  10798. * Creates a new ray from screen space and viewport
  10799. * @param x position
  10800. * @param y y position
  10801. * @param viewportWidth viewport width
  10802. * @param viewportHeight viewport height
  10803. * @param world world matrix
  10804. * @param view view matrix
  10805. * @param projection projection matrix
  10806. * @returns new ray
  10807. */
  10808. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10809. /**
  10810. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10811. * transformed to the given world matrix.
  10812. * @param origin The origin point
  10813. * @param end The end point
  10814. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10815. * @returns the new ray
  10816. */
  10817. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10818. /**
  10819. * Transforms a ray by a matrix
  10820. * @param ray ray to transform
  10821. * @param matrix matrix to apply
  10822. * @returns the resulting new ray
  10823. */
  10824. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10825. /**
  10826. * Transforms a ray by a matrix
  10827. * @param ray ray to transform
  10828. * @param matrix matrix to apply
  10829. * @param result ray to store result in
  10830. */
  10831. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10832. /**
  10833. * Unproject a ray from screen space to object space
  10834. * @param sourceX defines the screen space x coordinate to use
  10835. * @param sourceY defines the screen space y coordinate to use
  10836. * @param viewportWidth defines the current width of the viewport
  10837. * @param viewportHeight defines the current height of the viewport
  10838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10839. * @param view defines the view matrix to use
  10840. * @param projection defines the projection matrix to use
  10841. */
  10842. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10843. }
  10844. /**
  10845. * Type used to define predicate used to select faces when a mesh intersection is detected
  10846. */
  10847. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10848. module "babylonjs/scene" {
  10849. interface Scene {
  10850. /** @hidden */
  10851. _tempPickingRay: Nullable<Ray>;
  10852. /** @hidden */
  10853. _cachedRayForTransform: Ray;
  10854. /** @hidden */
  10855. _pickWithRayInverseMatrix: Matrix;
  10856. /** @hidden */
  10857. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10858. /** @hidden */
  10859. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10860. /** @hidden */
  10861. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10862. }
  10863. }
  10864. }
  10865. declare module "babylonjs/sceneComponent" {
  10866. import { Scene } from "babylonjs/scene";
  10867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10868. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10869. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10870. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10871. import { Nullable } from "babylonjs/types";
  10872. import { Camera } from "babylonjs/Cameras/camera";
  10873. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10874. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10875. import { AbstractScene } from "babylonjs/abstractScene";
  10876. import { Mesh } from "babylonjs/Meshes/mesh";
  10877. /**
  10878. * Groups all the scene component constants in one place to ease maintenance.
  10879. * @hidden
  10880. */
  10881. export class SceneComponentConstants {
  10882. static readonly NAME_EFFECTLAYER: string;
  10883. static readonly NAME_LAYER: string;
  10884. static readonly NAME_LENSFLARESYSTEM: string;
  10885. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10886. static readonly NAME_PARTICLESYSTEM: string;
  10887. static readonly NAME_GAMEPAD: string;
  10888. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10889. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10890. static readonly NAME_PREPASSRENDERER: string;
  10891. static readonly NAME_DEPTHRENDERER: string;
  10892. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10893. static readonly NAME_SPRITE: string;
  10894. static readonly NAME_SUBSURFACE: string;
  10895. static readonly NAME_OUTLINERENDERER: string;
  10896. static readonly NAME_PROCEDURALTEXTURE: string;
  10897. static readonly NAME_SHADOWGENERATOR: string;
  10898. static readonly NAME_OCTREE: string;
  10899. static readonly NAME_PHYSICSENGINE: string;
  10900. static readonly NAME_AUDIO: string;
  10901. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10902. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10903. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10904. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10905. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10906. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10907. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10908. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10909. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10910. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10911. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10912. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10913. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10914. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10915. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10916. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10917. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10918. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10919. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10920. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10921. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10922. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10923. static readonly STEP_AFTERRENDER_AUDIO: number;
  10924. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10925. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10926. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10927. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10928. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10929. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10930. static readonly STEP_POINTERMOVE_SPRITE: number;
  10931. static readonly STEP_POINTERDOWN_SPRITE: number;
  10932. static readonly STEP_POINTERUP_SPRITE: number;
  10933. }
  10934. /**
  10935. * This represents a scene component.
  10936. *
  10937. * This is used to decouple the dependency the scene is having on the different workloads like
  10938. * layers, post processes...
  10939. */
  10940. export interface ISceneComponent {
  10941. /**
  10942. * The name of the component. Each component must have a unique name.
  10943. */
  10944. name: string;
  10945. /**
  10946. * The scene the component belongs to.
  10947. */
  10948. scene: Scene;
  10949. /**
  10950. * Register the component to one instance of a scene.
  10951. */
  10952. register(): void;
  10953. /**
  10954. * Rebuilds the elements related to this component in case of
  10955. * context lost for instance.
  10956. */
  10957. rebuild(): void;
  10958. /**
  10959. * Disposes the component and the associated ressources.
  10960. */
  10961. dispose(): void;
  10962. }
  10963. /**
  10964. * This represents a SERIALIZABLE scene component.
  10965. *
  10966. * This extends Scene Component to add Serialization methods on top.
  10967. */
  10968. export interface ISceneSerializableComponent extends ISceneComponent {
  10969. /**
  10970. * Adds all the elements from the container to the scene
  10971. * @param container the container holding the elements
  10972. */
  10973. addFromContainer(container: AbstractScene): void;
  10974. /**
  10975. * Removes all the elements in the container from the scene
  10976. * @param container contains the elements to remove
  10977. * @param dispose if the removed element should be disposed (default: false)
  10978. */
  10979. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10980. /**
  10981. * Serializes the component data to the specified json object
  10982. * @param serializationObject The object to serialize to
  10983. */
  10984. serialize(serializationObject: any): void;
  10985. }
  10986. /**
  10987. * Strong typing of a Mesh related stage step action
  10988. */
  10989. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10990. /**
  10991. * Strong typing of a Evaluate Sub Mesh related stage step action
  10992. */
  10993. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10994. /**
  10995. * Strong typing of a Active Mesh related stage step action
  10996. */
  10997. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10998. /**
  10999. * Strong typing of a Camera related stage step action
  11000. */
  11001. export type CameraStageAction = (camera: Camera) => void;
  11002. /**
  11003. * Strong typing of a Camera Frame buffer related stage step action
  11004. */
  11005. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11006. /**
  11007. * Strong typing of a Render Target related stage step action
  11008. */
  11009. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11010. /**
  11011. * Strong typing of a RenderingGroup related stage step action
  11012. */
  11013. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11014. /**
  11015. * Strong typing of a Mesh Render related stage step action
  11016. */
  11017. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11018. /**
  11019. * Strong typing of a simple stage step action
  11020. */
  11021. export type SimpleStageAction = () => void;
  11022. /**
  11023. * Strong typing of a render target action.
  11024. */
  11025. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11026. /**
  11027. * Strong typing of a pointer move action.
  11028. */
  11029. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11030. /**
  11031. * Strong typing of a pointer up/down action.
  11032. */
  11033. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11034. /**
  11035. * Representation of a stage in the scene (Basically a list of ordered steps)
  11036. * @hidden
  11037. */
  11038. export class Stage<T extends Function> extends Array<{
  11039. index: number;
  11040. component: ISceneComponent;
  11041. action: T;
  11042. }> {
  11043. /**
  11044. * Hide ctor from the rest of the world.
  11045. * @param items The items to add.
  11046. */
  11047. private constructor();
  11048. /**
  11049. * Creates a new Stage.
  11050. * @returns A new instance of a Stage
  11051. */
  11052. static Create<T extends Function>(): Stage<T>;
  11053. /**
  11054. * Registers a step in an ordered way in the targeted stage.
  11055. * @param index Defines the position to register the step in
  11056. * @param component Defines the component attached to the step
  11057. * @param action Defines the action to launch during the step
  11058. */
  11059. registerStep(index: number, component: ISceneComponent, action: T): void;
  11060. /**
  11061. * Clears all the steps from the stage.
  11062. */
  11063. clear(): void;
  11064. }
  11065. }
  11066. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11067. import { Nullable } from "babylonjs/types";
  11068. import { Observable } from "babylonjs/Misc/observable";
  11069. import { Scene } from "babylonjs/scene";
  11070. import { Sprite } from "babylonjs/Sprites/sprite";
  11071. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11072. import { Ray } from "babylonjs/Culling/ray";
  11073. import { Camera } from "babylonjs/Cameras/camera";
  11074. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11075. import { ISceneComponent } from "babylonjs/sceneComponent";
  11076. module "babylonjs/scene" {
  11077. interface Scene {
  11078. /** @hidden */
  11079. _pointerOverSprite: Nullable<Sprite>;
  11080. /** @hidden */
  11081. _pickedDownSprite: Nullable<Sprite>;
  11082. /** @hidden */
  11083. _tempSpritePickingRay: Nullable<Ray>;
  11084. /**
  11085. * All of the sprite managers added to this scene
  11086. * @see https://doc.babylonjs.com/babylon101/sprites
  11087. */
  11088. spriteManagers: Array<ISpriteManager>;
  11089. /**
  11090. * An event triggered when sprites rendering is about to start
  11091. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11092. */
  11093. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11094. /**
  11095. * An event triggered when sprites rendering is done
  11096. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11097. */
  11098. onAfterSpritesRenderingObservable: Observable<Scene>;
  11099. /** @hidden */
  11100. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11101. /** Launch a ray to try to pick a sprite in the scene
  11102. * @param x position on screen
  11103. * @param y position on screen
  11104. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11105. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11106. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11107. * @returns a PickingInfo
  11108. */
  11109. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11110. /** Use the given ray to pick a sprite in the scene
  11111. * @param ray The ray (in world space) to use to pick meshes
  11112. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11113. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11114. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11115. * @returns a PickingInfo
  11116. */
  11117. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11118. /** @hidden */
  11119. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11120. /** Launch a ray to try to pick sprites in the scene
  11121. * @param x position on screen
  11122. * @param y position on screen
  11123. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11124. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11125. * @returns a PickingInfo array
  11126. */
  11127. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11128. /** Use the given ray to pick sprites in the scene
  11129. * @param ray The ray (in world space) to use to pick meshes
  11130. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11131. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11132. * @returns a PickingInfo array
  11133. */
  11134. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11135. /**
  11136. * Force the sprite under the pointer
  11137. * @param sprite defines the sprite to use
  11138. */
  11139. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11140. /**
  11141. * Gets the sprite under the pointer
  11142. * @returns a Sprite or null if no sprite is under the pointer
  11143. */
  11144. getPointerOverSprite(): Nullable<Sprite>;
  11145. }
  11146. }
  11147. /**
  11148. * Defines the sprite scene component responsible to manage sprites
  11149. * in a given scene.
  11150. */
  11151. export class SpriteSceneComponent implements ISceneComponent {
  11152. /**
  11153. * The component name helpfull to identify the component in the list of scene components.
  11154. */
  11155. readonly name: string;
  11156. /**
  11157. * The scene the component belongs to.
  11158. */
  11159. scene: Scene;
  11160. /** @hidden */
  11161. private _spritePredicate;
  11162. /**
  11163. * Creates a new instance of the component for the given scene
  11164. * @param scene Defines the scene to register the component in
  11165. */
  11166. constructor(scene: Scene);
  11167. /**
  11168. * Registers the component in a given scene
  11169. */
  11170. register(): void;
  11171. /**
  11172. * Rebuilds the elements related to this component in case of
  11173. * context lost for instance.
  11174. */
  11175. rebuild(): void;
  11176. /**
  11177. * Disposes the component and the associated ressources.
  11178. */
  11179. dispose(): void;
  11180. private _pickSpriteButKeepRay;
  11181. private _pointerMove;
  11182. private _pointerDown;
  11183. private _pointerUp;
  11184. }
  11185. }
  11186. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11187. /** @hidden */
  11188. export var fogFragmentDeclaration: {
  11189. name: string;
  11190. shader: string;
  11191. };
  11192. }
  11193. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11194. /** @hidden */
  11195. export var fogFragment: {
  11196. name: string;
  11197. shader: string;
  11198. };
  11199. }
  11200. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  11201. /** @hidden */
  11202. export var imageProcessingCompatibility: {
  11203. name: string;
  11204. shader: string;
  11205. };
  11206. }
  11207. declare module "babylonjs/Shaders/sprites.fragment" {
  11208. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11209. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11210. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  11211. /** @hidden */
  11212. export var spritesPixelShader: {
  11213. name: string;
  11214. shader: string;
  11215. };
  11216. }
  11217. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11218. /** @hidden */
  11219. export var fogVertexDeclaration: {
  11220. name: string;
  11221. shader: string;
  11222. };
  11223. }
  11224. declare module "babylonjs/Shaders/sprites.vertex" {
  11225. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11226. /** @hidden */
  11227. export var spritesVertexShader: {
  11228. name: string;
  11229. shader: string;
  11230. };
  11231. }
  11232. declare module "babylonjs/Sprites/spriteManager" {
  11233. import { IDisposable, Scene } from "babylonjs/scene";
  11234. import { Nullable } from "babylonjs/types";
  11235. import { Observable } from "babylonjs/Misc/observable";
  11236. import { Sprite } from "babylonjs/Sprites/sprite";
  11237. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11238. import { Camera } from "babylonjs/Cameras/camera";
  11239. import { Texture } from "babylonjs/Materials/Textures/texture";
  11240. import "babylonjs/Shaders/sprites.fragment";
  11241. import "babylonjs/Shaders/sprites.vertex";
  11242. import { Ray } from "babylonjs/Culling/ray";
  11243. /**
  11244. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11245. */
  11246. export interface ISpriteManager extends IDisposable {
  11247. /**
  11248. * Gets manager's name
  11249. */
  11250. name: string;
  11251. /**
  11252. * Restricts the camera to viewing objects with the same layerMask.
  11253. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11254. */
  11255. layerMask: number;
  11256. /**
  11257. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11258. */
  11259. isPickable: boolean;
  11260. /**
  11261. * Gets the hosting scene
  11262. */
  11263. scene: Scene;
  11264. /**
  11265. * Specifies the rendering group id for this mesh (0 by default)
  11266. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11267. */
  11268. renderingGroupId: number;
  11269. /**
  11270. * Defines the list of sprites managed by the manager.
  11271. */
  11272. sprites: Array<Sprite>;
  11273. /**
  11274. * Gets or sets the spritesheet texture
  11275. */
  11276. texture: Texture;
  11277. /** Defines the default width of a cell in the spritesheet */
  11278. cellWidth: number;
  11279. /** Defines the default height of a cell in the spritesheet */
  11280. cellHeight: number;
  11281. /**
  11282. * Tests the intersection of a sprite with a specific ray.
  11283. * @param ray The ray we are sending to test the collision
  11284. * @param camera The camera space we are sending rays in
  11285. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11286. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11287. * @returns picking info or null.
  11288. */
  11289. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11290. /**
  11291. * Intersects the sprites with a ray
  11292. * @param ray defines the ray to intersect with
  11293. * @param camera defines the current active camera
  11294. * @param predicate defines a predicate used to select candidate sprites
  11295. * @returns null if no hit or a PickingInfo array
  11296. */
  11297. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11298. /**
  11299. * Renders the list of sprites on screen.
  11300. */
  11301. render(): void;
  11302. }
  11303. /**
  11304. * Class used to manage multiple sprites on the same spritesheet
  11305. * @see https://doc.babylonjs.com/babylon101/sprites
  11306. */
  11307. export class SpriteManager implements ISpriteManager {
  11308. /** defines the manager's name */
  11309. name: string;
  11310. /** Define the Url to load snippets */
  11311. static SnippetUrl: string;
  11312. /** Snippet ID if the manager was created from the snippet server */
  11313. snippetId: string;
  11314. /** Gets the list of sprites */
  11315. sprites: Sprite[];
  11316. /** Gets or sets the rendering group id (0 by default) */
  11317. renderingGroupId: number;
  11318. /** Gets or sets camera layer mask */
  11319. layerMask: number;
  11320. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11321. fogEnabled: boolean;
  11322. /** Gets or sets a boolean indicating if the sprites are pickable */
  11323. isPickable: boolean;
  11324. /** Defines the default width of a cell in the spritesheet */
  11325. cellWidth: number;
  11326. /** Defines the default height of a cell in the spritesheet */
  11327. cellHeight: number;
  11328. /** Associative array from JSON sprite data file */
  11329. private _cellData;
  11330. /** Array of sprite names from JSON sprite data file */
  11331. private _spriteMap;
  11332. /** True when packed cell data from JSON file is ready*/
  11333. private _packedAndReady;
  11334. private _textureContent;
  11335. private _useInstancing;
  11336. /**
  11337. * An event triggered when the manager is disposed.
  11338. */
  11339. onDisposeObservable: Observable<SpriteManager>;
  11340. private _onDisposeObserver;
  11341. /**
  11342. * Callback called when the manager is disposed
  11343. */
  11344. set onDispose(callback: () => void);
  11345. private _capacity;
  11346. private _fromPacked;
  11347. private _spriteTexture;
  11348. private _epsilon;
  11349. private _scene;
  11350. private _vertexData;
  11351. private _buffer;
  11352. private _vertexBuffers;
  11353. private _spriteBuffer;
  11354. private _indexBuffer;
  11355. private _effectBase;
  11356. private _effectFog;
  11357. private _vertexBufferSize;
  11358. /**
  11359. * Gets or sets the unique id of the sprite
  11360. */
  11361. uniqueId: number;
  11362. /**
  11363. * Gets the array of sprites
  11364. */
  11365. get children(): Sprite[];
  11366. /**
  11367. * Gets the hosting scene
  11368. */
  11369. get scene(): Scene;
  11370. /**
  11371. * Gets the capacity of the manager
  11372. */
  11373. get capacity(): number;
  11374. /**
  11375. * Gets or sets the spritesheet texture
  11376. */
  11377. get texture(): Texture;
  11378. set texture(value: Texture);
  11379. private _blendMode;
  11380. /**
  11381. * Blend mode use to render the particle, it can be any of
  11382. * the static Constants.ALPHA_x properties provided in this class.
  11383. * Default value is Constants.ALPHA_COMBINE
  11384. */
  11385. get blendMode(): number;
  11386. set blendMode(blendMode: number);
  11387. /** Disables writing to the depth buffer when rendering the sprites.
  11388. * It can be handy to disable depth writing when using textures without alpha channel
  11389. * and setting some specific blend modes.
  11390. */
  11391. disableDepthWrite: boolean;
  11392. /**
  11393. * Creates a new sprite manager
  11394. * @param name defines the manager's name
  11395. * @param imgUrl defines the sprite sheet url
  11396. * @param capacity defines the maximum allowed number of sprites
  11397. * @param cellSize defines the size of a sprite cell
  11398. * @param scene defines the hosting scene
  11399. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11400. * @param samplingMode defines the smapling mode to use with spritesheet
  11401. * @param fromPacked set to false; do not alter
  11402. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11403. */
  11404. constructor(
  11405. /** defines the manager's name */
  11406. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11407. /**
  11408. * Returns the string "SpriteManager"
  11409. * @returns "SpriteManager"
  11410. */
  11411. getClassName(): string;
  11412. private _makePacked;
  11413. private _appendSpriteVertex;
  11414. private _checkTextureAlpha;
  11415. /**
  11416. * Intersects the sprites with a ray
  11417. * @param ray defines the ray to intersect with
  11418. * @param camera defines the current active camera
  11419. * @param predicate defines a predicate used to select candidate sprites
  11420. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11421. * @returns null if no hit or a PickingInfo
  11422. */
  11423. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11424. /**
  11425. * Intersects the sprites with a ray
  11426. * @param ray defines the ray to intersect with
  11427. * @param camera defines the current active camera
  11428. * @param predicate defines a predicate used to select candidate sprites
  11429. * @returns null if no hit or a PickingInfo array
  11430. */
  11431. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11432. /**
  11433. * Render all child sprites
  11434. */
  11435. render(): void;
  11436. /**
  11437. * Release associated resources
  11438. */
  11439. dispose(): void;
  11440. /**
  11441. * Serializes the sprite manager to a JSON object
  11442. * @param serializeTexture defines if the texture must be serialized as well
  11443. * @returns the JSON object
  11444. */
  11445. serialize(serializeTexture?: boolean): any;
  11446. /**
  11447. * Parses a JSON object to create a new sprite manager.
  11448. * @param parsedManager The JSON object to parse
  11449. * @param scene The scene to create the sprite managerin
  11450. * @param rootUrl The root url to use to load external dependencies like texture
  11451. * @returns the new sprite manager
  11452. */
  11453. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11454. /**
  11455. * Creates a sprite manager from a snippet saved in a remote file
  11456. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11457. * @param url defines the url to load from
  11458. * @param scene defines the hosting scene
  11459. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11460. * @returns a promise that will resolve to the new sprite manager
  11461. */
  11462. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11463. /**
  11464. * Creates a sprite manager from a snippet saved by the sprite editor
  11465. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11466. * @param scene defines the hosting scene
  11467. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11468. * @returns a promise that will resolve to the new sprite manager
  11469. */
  11470. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11471. }
  11472. }
  11473. declare module "babylonjs/Misc/gradients" {
  11474. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11475. /** Interface used by value gradients (color, factor, ...) */
  11476. export interface IValueGradient {
  11477. /**
  11478. * Gets or sets the gradient value (between 0 and 1)
  11479. */
  11480. gradient: number;
  11481. }
  11482. /** Class used to store color4 gradient */
  11483. export class ColorGradient implements IValueGradient {
  11484. /**
  11485. * Gets or sets the gradient value (between 0 and 1)
  11486. */
  11487. gradient: number;
  11488. /**
  11489. * Gets or sets first associated color
  11490. */
  11491. color1: Color4;
  11492. /**
  11493. * Gets or sets second associated color
  11494. */
  11495. color2?: Color4 | undefined;
  11496. /**
  11497. * Creates a new color4 gradient
  11498. * @param gradient gets or sets the gradient value (between 0 and 1)
  11499. * @param color1 gets or sets first associated color
  11500. * @param color2 gets or sets first second color
  11501. */
  11502. constructor(
  11503. /**
  11504. * Gets or sets the gradient value (between 0 and 1)
  11505. */
  11506. gradient: number,
  11507. /**
  11508. * Gets or sets first associated color
  11509. */
  11510. color1: Color4,
  11511. /**
  11512. * Gets or sets second associated color
  11513. */
  11514. color2?: Color4 | undefined);
  11515. /**
  11516. * Will get a color picked randomly between color1 and color2.
  11517. * If color2 is undefined then color1 will be used
  11518. * @param result defines the target Color4 to store the result in
  11519. */
  11520. getColorToRef(result: Color4): void;
  11521. }
  11522. /** Class used to store color 3 gradient */
  11523. export class Color3Gradient implements IValueGradient {
  11524. /**
  11525. * Gets or sets the gradient value (between 0 and 1)
  11526. */
  11527. gradient: number;
  11528. /**
  11529. * Gets or sets the associated color
  11530. */
  11531. color: Color3;
  11532. /**
  11533. * Creates a new color3 gradient
  11534. * @param gradient gets or sets the gradient value (between 0 and 1)
  11535. * @param color gets or sets associated color
  11536. */
  11537. constructor(
  11538. /**
  11539. * Gets or sets the gradient value (between 0 and 1)
  11540. */
  11541. gradient: number,
  11542. /**
  11543. * Gets or sets the associated color
  11544. */
  11545. color: Color3);
  11546. }
  11547. /** Class used to store factor gradient */
  11548. export class FactorGradient implements IValueGradient {
  11549. /**
  11550. * Gets or sets the gradient value (between 0 and 1)
  11551. */
  11552. gradient: number;
  11553. /**
  11554. * Gets or sets first associated factor
  11555. */
  11556. factor1: number;
  11557. /**
  11558. * Gets or sets second associated factor
  11559. */
  11560. factor2?: number | undefined;
  11561. /**
  11562. * Creates a new factor gradient
  11563. * @param gradient gets or sets the gradient value (between 0 and 1)
  11564. * @param factor1 gets or sets first associated factor
  11565. * @param factor2 gets or sets second associated factor
  11566. */
  11567. constructor(
  11568. /**
  11569. * Gets or sets the gradient value (between 0 and 1)
  11570. */
  11571. gradient: number,
  11572. /**
  11573. * Gets or sets first associated factor
  11574. */
  11575. factor1: number,
  11576. /**
  11577. * Gets or sets second associated factor
  11578. */
  11579. factor2?: number | undefined);
  11580. /**
  11581. * Will get a number picked randomly between factor1 and factor2.
  11582. * If factor2 is undefined then factor1 will be used
  11583. * @returns the picked number
  11584. */
  11585. getFactor(): number;
  11586. }
  11587. /**
  11588. * Helper used to simplify some generic gradient tasks
  11589. */
  11590. export class GradientHelper {
  11591. /**
  11592. * Gets the current gradient from an array of IValueGradient
  11593. * @param ratio defines the current ratio to get
  11594. * @param gradients defines the array of IValueGradient
  11595. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11596. */
  11597. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11598. }
  11599. }
  11600. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11601. import { Nullable } from "babylonjs/types";
  11602. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11603. import { Scene } from "babylonjs/scene";
  11604. module "babylonjs/Engines/thinEngine" {
  11605. interface ThinEngine {
  11606. /**
  11607. * Creates a raw texture
  11608. * @param data defines the data to store in the texture
  11609. * @param width defines the width of the texture
  11610. * @param height defines the height of the texture
  11611. * @param format defines the format of the data
  11612. * @param generateMipMaps defines if the engine should generate the mip levels
  11613. * @param invertY defines if data must be stored with Y axis inverted
  11614. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11615. * @param compression defines the compression used (null by default)
  11616. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11617. * @returns the raw texture inside an InternalTexture
  11618. */
  11619. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11620. /**
  11621. * Update a raw texture
  11622. * @param texture defines the texture to update
  11623. * @param data defines the data to store in the texture
  11624. * @param format defines the format of the data
  11625. * @param invertY defines if data must be stored with Y axis inverted
  11626. */
  11627. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11628. /**
  11629. * Update a raw texture
  11630. * @param texture defines the texture to update
  11631. * @param data defines the data to store in the texture
  11632. * @param format defines the format of the data
  11633. * @param invertY defines if data must be stored with Y axis inverted
  11634. * @param compression defines the compression used (null by default)
  11635. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11636. */
  11637. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11638. /**
  11639. * Creates a new raw cube texture
  11640. * @param data defines the array of data to use to create each face
  11641. * @param size defines the size of the textures
  11642. * @param format defines the format of the data
  11643. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11644. * @param generateMipMaps defines if the engine should generate the mip levels
  11645. * @param invertY defines if data must be stored with Y axis inverted
  11646. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11647. * @param compression defines the compression used (null by default)
  11648. * @returns the cube texture as an InternalTexture
  11649. */
  11650. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11651. /**
  11652. * Update a raw cube texture
  11653. * @param texture defines the texture to udpdate
  11654. * @param data defines the data to store
  11655. * @param format defines the data format
  11656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11657. * @param invertY defines if data must be stored with Y axis inverted
  11658. */
  11659. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11660. /**
  11661. * Update a raw cube texture
  11662. * @param texture defines the texture to udpdate
  11663. * @param data defines the data to store
  11664. * @param format defines the data format
  11665. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11666. * @param invertY defines if data must be stored with Y axis inverted
  11667. * @param compression defines the compression used (null by default)
  11668. */
  11669. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11670. /**
  11671. * Update a raw cube texture
  11672. * @param texture defines the texture to udpdate
  11673. * @param data defines the data to store
  11674. * @param format defines the data format
  11675. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11676. * @param invertY defines if data must be stored with Y axis inverted
  11677. * @param compression defines the compression used (null by default)
  11678. * @param level defines which level of the texture to update
  11679. */
  11680. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11681. /**
  11682. * Creates a new raw cube texture from a specified url
  11683. * @param url defines the url where the data is located
  11684. * @param scene defines the current scene
  11685. * @param size defines the size of the textures
  11686. * @param format defines the format of the data
  11687. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11688. * @param noMipmap defines if the engine should avoid generating the mip levels
  11689. * @param callback defines a callback used to extract texture data from loaded data
  11690. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11691. * @param onLoad defines a callback called when texture is loaded
  11692. * @param onError defines a callback called if there is an error
  11693. * @returns the cube texture as an InternalTexture
  11694. */
  11695. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11696. /**
  11697. * Creates a new raw cube texture from a specified url
  11698. * @param url defines the url where the data is located
  11699. * @param scene defines the current scene
  11700. * @param size defines the size of the textures
  11701. * @param format defines the format of the data
  11702. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11703. * @param noMipmap defines if the engine should avoid generating the mip levels
  11704. * @param callback defines a callback used to extract texture data from loaded data
  11705. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11706. * @param onLoad defines a callback called when texture is loaded
  11707. * @param onError defines a callback called if there is an error
  11708. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. * @returns the cube texture as an InternalTexture
  11711. */
  11712. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11713. /**
  11714. * Creates a new raw 3D texture
  11715. * @param data defines the data used to create the texture
  11716. * @param width defines the width of the texture
  11717. * @param height defines the height of the texture
  11718. * @param depth defines the depth of the texture
  11719. * @param format defines the format of the texture
  11720. * @param generateMipMaps defines if the engine must generate mip levels
  11721. * @param invertY defines if data must be stored with Y axis inverted
  11722. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11723. * @param compression defines the compressed used (can be null)
  11724. * @param textureType defines the compressed used (can be null)
  11725. * @returns a new raw 3D texture (stored in an InternalTexture)
  11726. */
  11727. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11728. /**
  11729. * Update a raw 3D texture
  11730. * @param texture defines the texture to update
  11731. * @param data defines the data to store
  11732. * @param format defines the data format
  11733. * @param invertY defines if data must be stored with Y axis inverted
  11734. */
  11735. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11736. /**
  11737. * Update a raw 3D texture
  11738. * @param texture defines the texture to update
  11739. * @param data defines the data to store
  11740. * @param format defines the data format
  11741. * @param invertY defines if data must be stored with Y axis inverted
  11742. * @param compression defines the used compression (can be null)
  11743. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11744. */
  11745. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11746. /**
  11747. * Creates a new raw 2D array texture
  11748. * @param data defines the data used to create the texture
  11749. * @param width defines the width of the texture
  11750. * @param height defines the height of the texture
  11751. * @param depth defines the number of layers of the texture
  11752. * @param format defines the format of the texture
  11753. * @param generateMipMaps defines if the engine must generate mip levels
  11754. * @param invertY defines if data must be stored with Y axis inverted
  11755. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11756. * @param compression defines the compressed used (can be null)
  11757. * @param textureType defines the compressed used (can be null)
  11758. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11759. */
  11760. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11761. /**
  11762. * Update a raw 2D array texture
  11763. * @param texture defines the texture to update
  11764. * @param data defines the data to store
  11765. * @param format defines the data format
  11766. * @param invertY defines if data must be stored with Y axis inverted
  11767. */
  11768. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11769. /**
  11770. * Update a raw 2D array texture
  11771. * @param texture defines the texture to update
  11772. * @param data defines the data to store
  11773. * @param format defines the data format
  11774. * @param invertY defines if data must be stored with Y axis inverted
  11775. * @param compression defines the used compression (can be null)
  11776. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11777. */
  11778. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11779. }
  11780. }
  11781. }
  11782. declare module "babylonjs/Materials/Textures/rawTexture" {
  11783. import { Texture } from "babylonjs/Materials/Textures/texture";
  11784. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11785. import { Nullable } from "babylonjs/types";
  11786. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11787. import { Scene } from "babylonjs/scene";
  11788. /**
  11789. * Raw texture can help creating a texture directly from an array of data.
  11790. * This can be super useful if you either get the data from an uncompressed source or
  11791. * if you wish to create your texture pixel by pixel.
  11792. */
  11793. export class RawTexture extends Texture {
  11794. /**
  11795. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11796. */
  11797. format: number;
  11798. /**
  11799. * Instantiates a new RawTexture.
  11800. * Raw texture can help creating a texture directly from an array of data.
  11801. * This can be super useful if you either get the data from an uncompressed source or
  11802. * if you wish to create your texture pixel by pixel.
  11803. * @param data define the array of data to use to create the texture
  11804. * @param width define the width of the texture
  11805. * @param height define the height of the texture
  11806. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11807. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11808. * @param generateMipMaps define whether mip maps should be generated or not
  11809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11811. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11812. */
  11813. constructor(data: ArrayBufferView, width: number, height: number,
  11814. /**
  11815. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11816. */
  11817. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11818. /**
  11819. * Updates the texture underlying data.
  11820. * @param data Define the new data of the texture
  11821. */
  11822. update(data: ArrayBufferView): void;
  11823. /**
  11824. * Creates a luminance texture from some data.
  11825. * @param data Define the texture data
  11826. * @param width Define the width of the texture
  11827. * @param height Define the height of the texture
  11828. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11832. * @returns the luminance texture
  11833. */
  11834. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11835. /**
  11836. * Creates a luminance alpha texture from some data.
  11837. * @param data Define the texture data
  11838. * @param width Define the width of the texture
  11839. * @param height Define the height of the texture
  11840. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11841. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11842. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11843. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11844. * @returns the luminance alpha texture
  11845. */
  11846. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11847. /**
  11848. * Creates an alpha texture from some data.
  11849. * @param data Define the texture data
  11850. * @param width Define the width of the texture
  11851. * @param height Define the height of the texture
  11852. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11853. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11854. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11855. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11856. * @returns the alpha texture
  11857. */
  11858. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11859. /**
  11860. * Creates a RGB texture from some data.
  11861. * @param data Define the texture data
  11862. * @param width Define the width of the texture
  11863. * @param height Define the height of the texture
  11864. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11865. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11866. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11867. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11868. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11869. * @returns the RGB alpha texture
  11870. */
  11871. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11872. /**
  11873. * Creates a RGBA texture from some data.
  11874. * @param data Define the texture data
  11875. * @param width Define the width of the texture
  11876. * @param height Define the height of the texture
  11877. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11878. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11879. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11880. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11881. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11882. * @returns the RGBA texture
  11883. */
  11884. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11885. /**
  11886. * Creates a R texture from some data.
  11887. * @param data Define the texture data
  11888. * @param width Define the width of the texture
  11889. * @param height Define the height of the texture
  11890. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11891. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11892. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11893. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11894. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11895. * @returns the R texture
  11896. */
  11897. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11898. }
  11899. }
  11900. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11901. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11902. import { IndicesArray, DataArray } from "babylonjs/types";
  11903. module "babylonjs/Engines/thinEngine" {
  11904. interface ThinEngine {
  11905. /**
  11906. * Update a dynamic index buffer
  11907. * @param indexBuffer defines the target index buffer
  11908. * @param indices defines the data to update
  11909. * @param offset defines the offset in the target index buffer where update should start
  11910. */
  11911. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11912. /**
  11913. * Updates a dynamic vertex buffer.
  11914. * @param vertexBuffer the vertex buffer to update
  11915. * @param data the data used to update the vertex buffer
  11916. * @param byteOffset the byte offset of the data
  11917. * @param byteLength the byte length of the data
  11918. */
  11919. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11920. }
  11921. }
  11922. }
  11923. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11924. import { Scene } from "babylonjs/scene";
  11925. import { ISceneComponent } from "babylonjs/sceneComponent";
  11926. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11927. module "babylonjs/abstractScene" {
  11928. interface AbstractScene {
  11929. /**
  11930. * The list of procedural textures added to the scene
  11931. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11932. */
  11933. proceduralTextures: Array<ProceduralTexture>;
  11934. }
  11935. }
  11936. /**
  11937. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11938. * in a given scene.
  11939. */
  11940. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11941. /**
  11942. * The component name helpfull to identify the component in the list of scene components.
  11943. */
  11944. readonly name: string;
  11945. /**
  11946. * The scene the component belongs to.
  11947. */
  11948. scene: Scene;
  11949. /**
  11950. * Creates a new instance of the component for the given scene
  11951. * @param scene Defines the scene to register the component in
  11952. */
  11953. constructor(scene: Scene);
  11954. /**
  11955. * Registers the component in a given scene
  11956. */
  11957. register(): void;
  11958. /**
  11959. * Rebuilds the elements related to this component in case of
  11960. * context lost for instance.
  11961. */
  11962. rebuild(): void;
  11963. /**
  11964. * Disposes the component and the associated ressources.
  11965. */
  11966. dispose(): void;
  11967. private _beforeClear;
  11968. }
  11969. }
  11970. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11971. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11972. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11973. module "babylonjs/Engines/thinEngine" {
  11974. interface ThinEngine {
  11975. /**
  11976. * Creates a new render target cube texture
  11977. * @param size defines the size of the texture
  11978. * @param options defines the options used to create the texture
  11979. * @returns a new render target cube texture stored in an InternalTexture
  11980. */
  11981. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11982. }
  11983. }
  11984. }
  11985. declare module "babylonjs/Shaders/procedural.vertex" {
  11986. /** @hidden */
  11987. export var proceduralVertexShader: {
  11988. name: string;
  11989. shader: string;
  11990. };
  11991. }
  11992. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11993. import { Observable } from "babylonjs/Misc/observable";
  11994. import { Nullable } from "babylonjs/types";
  11995. import { Scene } from "babylonjs/scene";
  11996. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11997. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11998. import { Effect } from "babylonjs/Materials/effect";
  11999. import { Texture } from "babylonjs/Materials/Textures/texture";
  12000. import "babylonjs/Engines/Extensions/engine.renderTarget";
  12001. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  12002. import "babylonjs/Shaders/procedural.vertex";
  12003. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12004. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  12005. /**
  12006. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  12007. * This is the base class of any Procedural texture and contains most of the shareable code.
  12008. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12009. */
  12010. export class ProceduralTexture extends Texture {
  12011. /**
  12012. * Define if the texture is enabled or not (disabled texture will not render)
  12013. */
  12014. isEnabled: boolean;
  12015. /**
  12016. * Define if the texture must be cleared before rendering (default is true)
  12017. */
  12018. autoClear: boolean;
  12019. /**
  12020. * Callback called when the texture is generated
  12021. */
  12022. onGenerated: () => void;
  12023. /**
  12024. * Event raised when the texture is generated
  12025. */
  12026. onGeneratedObservable: Observable<ProceduralTexture>;
  12027. /**
  12028. * Event raised before the texture is generated
  12029. */
  12030. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12031. /**
  12032. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12033. */
  12034. nodeMaterialSource: Nullable<NodeMaterial>;
  12035. /** @hidden */
  12036. _generateMipMaps: boolean;
  12037. /** @hidden **/
  12038. _effect: Effect;
  12039. /** @hidden */
  12040. _textures: {
  12041. [key: string]: Texture;
  12042. };
  12043. /** @hidden */
  12044. protected _fallbackTexture: Nullable<Texture>;
  12045. private _size;
  12046. private _currentRefreshId;
  12047. private _frameId;
  12048. private _refreshRate;
  12049. private _vertexBuffers;
  12050. private _indexBuffer;
  12051. private _uniforms;
  12052. private _samplers;
  12053. private _fragment;
  12054. private _floats;
  12055. private _ints;
  12056. private _floatsArrays;
  12057. private _colors3;
  12058. private _colors4;
  12059. private _vectors2;
  12060. private _vectors3;
  12061. private _matrices;
  12062. private _fallbackTextureUsed;
  12063. private _fullEngine;
  12064. private _cachedDefines;
  12065. private _contentUpdateId;
  12066. private _contentData;
  12067. /**
  12068. * Instantiates a new procedural texture.
  12069. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  12070. * This is the base class of any Procedural texture and contains most of the shareable code.
  12071. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12072. * @param name Define the name of the texture
  12073. * @param size Define the size of the texture to create
  12074. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12075. * @param scene Define the scene the texture belongs to
  12076. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12077. * @param generateMipMaps Define if the texture should creates mip maps or not
  12078. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12079. * @param textureType The FBO internal texture type
  12080. */
  12081. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12082. /**
  12083. * The effect that is created when initializing the post process.
  12084. * @returns The created effect corresponding the the postprocess.
  12085. */
  12086. getEffect(): Effect;
  12087. /**
  12088. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12089. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12090. */
  12091. getContent(): Nullable<ArrayBufferView>;
  12092. private _createIndexBuffer;
  12093. /** @hidden */
  12094. _rebuild(): void;
  12095. /**
  12096. * Resets the texture in order to recreate its associated resources.
  12097. * This can be called in case of context loss
  12098. */
  12099. reset(): void;
  12100. protected _getDefines(): string;
  12101. /**
  12102. * Is the texture ready to be used ? (rendered at least once)
  12103. * @returns true if ready, otherwise, false.
  12104. */
  12105. isReady(): boolean;
  12106. /**
  12107. * Resets the refresh counter of the texture and start bak from scratch.
  12108. * Could be useful to regenerate the texture if it is setup to render only once.
  12109. */
  12110. resetRefreshCounter(): void;
  12111. /**
  12112. * Set the fragment shader to use in order to render the texture.
  12113. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12114. */
  12115. setFragment(fragment: any): void;
  12116. /**
  12117. * Define the refresh rate of the texture or the rendering frequency.
  12118. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12119. */
  12120. get refreshRate(): number;
  12121. set refreshRate(value: number);
  12122. /** @hidden */
  12123. _shouldRender(): boolean;
  12124. /**
  12125. * Get the size the texture is rendering at.
  12126. * @returns the size (on cube texture it is always squared)
  12127. */
  12128. getRenderSize(): RenderTargetTextureSize;
  12129. /**
  12130. * Resize the texture to new value.
  12131. * @param size Define the new size the texture should have
  12132. * @param generateMipMaps Define whether the new texture should create mip maps
  12133. */
  12134. resize(size: number, generateMipMaps: boolean): void;
  12135. private _checkUniform;
  12136. /**
  12137. * Set a texture in the shader program used to render.
  12138. * @param name Define the name of the uniform samplers as defined in the shader
  12139. * @param texture Define the texture to bind to this sampler
  12140. * @return the texture itself allowing "fluent" like uniform updates
  12141. */
  12142. setTexture(name: string, texture: Texture): ProceduralTexture;
  12143. /**
  12144. * Set a float in the shader.
  12145. * @param name Define the name of the uniform as defined in the shader
  12146. * @param value Define the value to give to the uniform
  12147. * @return the texture itself allowing "fluent" like uniform updates
  12148. */
  12149. setFloat(name: string, value: number): ProceduralTexture;
  12150. /**
  12151. * Set a int in the shader.
  12152. * @param name Define the name of the uniform as defined in the shader
  12153. * @param value Define the value to give to the uniform
  12154. * @return the texture itself allowing "fluent" like uniform updates
  12155. */
  12156. setInt(name: string, value: number): ProceduralTexture;
  12157. /**
  12158. * Set an array of floats in the shader.
  12159. * @param name Define the name of the uniform as defined in the shader
  12160. * @param value Define the value to give to the uniform
  12161. * @return the texture itself allowing "fluent" like uniform updates
  12162. */
  12163. setFloats(name: string, value: number[]): ProceduralTexture;
  12164. /**
  12165. * Set a vec3 in the shader from a Color3.
  12166. * @param name Define the name of the uniform as defined in the shader
  12167. * @param value Define the value to give to the uniform
  12168. * @return the texture itself allowing "fluent" like uniform updates
  12169. */
  12170. setColor3(name: string, value: Color3): ProceduralTexture;
  12171. /**
  12172. * Set a vec4 in the shader from a Color4.
  12173. * @param name Define the name of the uniform as defined in the shader
  12174. * @param value Define the value to give to the uniform
  12175. * @return the texture itself allowing "fluent" like uniform updates
  12176. */
  12177. setColor4(name: string, value: Color4): ProceduralTexture;
  12178. /**
  12179. * Set a vec2 in the shader from a Vector2.
  12180. * @param name Define the name of the uniform as defined in the shader
  12181. * @param value Define the value to give to the uniform
  12182. * @return the texture itself allowing "fluent" like uniform updates
  12183. */
  12184. setVector2(name: string, value: Vector2): ProceduralTexture;
  12185. /**
  12186. * Set a vec3 in the shader from a Vector3.
  12187. * @param name Define the name of the uniform as defined in the shader
  12188. * @param value Define the value to give to the uniform
  12189. * @return the texture itself allowing "fluent" like uniform updates
  12190. */
  12191. setVector3(name: string, value: Vector3): ProceduralTexture;
  12192. /**
  12193. * Set a mat4 in the shader from a MAtrix.
  12194. * @param name Define the name of the uniform as defined in the shader
  12195. * @param value Define the value to give to the uniform
  12196. * @return the texture itself allowing "fluent" like uniform updates
  12197. */
  12198. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12199. /**
  12200. * Render the texture to its associated render target.
  12201. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12202. */
  12203. render(useCameraPostProcess?: boolean): void;
  12204. /**
  12205. * Clone the texture.
  12206. * @returns the cloned texture
  12207. */
  12208. clone(): ProceduralTexture;
  12209. /**
  12210. * Dispose the texture and release its asoociated resources.
  12211. */
  12212. dispose(): void;
  12213. }
  12214. }
  12215. declare module "babylonjs/Particles/baseParticleSystem" {
  12216. import { Nullable } from "babylonjs/types";
  12217. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12219. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12220. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12221. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12222. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12223. import { Color4 } from "babylonjs/Maths/math.color";
  12224. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12225. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12226. import { Animation } from "babylonjs/Animations/animation";
  12227. import { Scene } from "babylonjs/scene";
  12228. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12229. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12230. /**
  12231. * This represents the base class for particle system in Babylon.
  12232. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12233. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12234. * @example https://doc.babylonjs.com/babylon101/particles
  12235. */
  12236. export class BaseParticleSystem {
  12237. /**
  12238. * Source color is added to the destination color without alpha affecting the result
  12239. */
  12240. static BLENDMODE_ONEONE: number;
  12241. /**
  12242. * Blend current color and particle color using particle’s alpha
  12243. */
  12244. static BLENDMODE_STANDARD: number;
  12245. /**
  12246. * Add current color and particle color multiplied by particle’s alpha
  12247. */
  12248. static BLENDMODE_ADD: number;
  12249. /**
  12250. * Multiply current color with particle color
  12251. */
  12252. static BLENDMODE_MULTIPLY: number;
  12253. /**
  12254. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12255. */
  12256. static BLENDMODE_MULTIPLYADD: number;
  12257. /**
  12258. * List of animations used by the particle system.
  12259. */
  12260. animations: Animation[];
  12261. /**
  12262. * Gets or sets the unique id of the particle system
  12263. */
  12264. uniqueId: number;
  12265. /**
  12266. * The id of the Particle system.
  12267. */
  12268. id: string;
  12269. /**
  12270. * The friendly name of the Particle system.
  12271. */
  12272. name: string;
  12273. /**
  12274. * Snippet ID if the particle system was created from the snippet server
  12275. */
  12276. snippetId: string;
  12277. /**
  12278. * The rendering group used by the Particle system to chose when to render.
  12279. */
  12280. renderingGroupId: number;
  12281. /**
  12282. * The emitter represents the Mesh or position we are attaching the particle system to.
  12283. */
  12284. emitter: Nullable<AbstractMesh | Vector3>;
  12285. /**
  12286. * The maximum number of particles to emit per frame
  12287. */
  12288. emitRate: number;
  12289. /**
  12290. * If you want to launch only a few particles at once, that can be done, as well.
  12291. */
  12292. manualEmitCount: number;
  12293. /**
  12294. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12295. */
  12296. updateSpeed: number;
  12297. /**
  12298. * The amount of time the particle system is running (depends of the overall update speed).
  12299. */
  12300. targetStopDuration: number;
  12301. /**
  12302. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12303. */
  12304. disposeOnStop: boolean;
  12305. /**
  12306. * Minimum power of emitting particles.
  12307. */
  12308. minEmitPower: number;
  12309. /**
  12310. * Maximum power of emitting particles.
  12311. */
  12312. maxEmitPower: number;
  12313. /**
  12314. * Minimum life time of emitting particles.
  12315. */
  12316. minLifeTime: number;
  12317. /**
  12318. * Maximum life time of emitting particles.
  12319. */
  12320. maxLifeTime: number;
  12321. /**
  12322. * Minimum Size of emitting particles.
  12323. */
  12324. minSize: number;
  12325. /**
  12326. * Maximum Size of emitting particles.
  12327. */
  12328. maxSize: number;
  12329. /**
  12330. * Minimum scale of emitting particles on X axis.
  12331. */
  12332. minScaleX: number;
  12333. /**
  12334. * Maximum scale of emitting particles on X axis.
  12335. */
  12336. maxScaleX: number;
  12337. /**
  12338. * Minimum scale of emitting particles on Y axis.
  12339. */
  12340. minScaleY: number;
  12341. /**
  12342. * Maximum scale of emitting particles on Y axis.
  12343. */
  12344. maxScaleY: number;
  12345. /**
  12346. * Gets or sets the minimal initial rotation in radians.
  12347. */
  12348. minInitialRotation: number;
  12349. /**
  12350. * Gets or sets the maximal initial rotation in radians.
  12351. */
  12352. maxInitialRotation: number;
  12353. /**
  12354. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12355. */
  12356. minAngularSpeed: number;
  12357. /**
  12358. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12359. */
  12360. maxAngularSpeed: number;
  12361. /**
  12362. * The texture used to render each particle. (this can be a spritesheet)
  12363. */
  12364. particleTexture: Nullable<BaseTexture>;
  12365. /**
  12366. * The layer mask we are rendering the particles through.
  12367. */
  12368. layerMask: number;
  12369. /**
  12370. * This can help using your own shader to render the particle system.
  12371. * The according effect will be created
  12372. */
  12373. customShader: any;
  12374. /**
  12375. * By default particle system starts as soon as they are created. This prevents the
  12376. * automatic start to happen and let you decide when to start emitting particles.
  12377. */
  12378. preventAutoStart: boolean;
  12379. private _noiseTexture;
  12380. /**
  12381. * Gets or sets a texture used to add random noise to particle positions
  12382. */
  12383. get noiseTexture(): Nullable<ProceduralTexture>;
  12384. set noiseTexture(value: Nullable<ProceduralTexture>);
  12385. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12386. noiseStrength: Vector3;
  12387. /**
  12388. * Callback triggered when the particle animation is ending.
  12389. */
  12390. onAnimationEnd: Nullable<() => void>;
  12391. /**
  12392. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12393. */
  12394. blendMode: number;
  12395. /**
  12396. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12397. * to override the particles.
  12398. */
  12399. forceDepthWrite: boolean;
  12400. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12401. preWarmCycles: number;
  12402. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12403. preWarmStepOffset: number;
  12404. /**
  12405. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12406. */
  12407. spriteCellChangeSpeed: number;
  12408. /**
  12409. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12410. */
  12411. startSpriteCellID: number;
  12412. /**
  12413. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12414. */
  12415. endSpriteCellID: number;
  12416. /**
  12417. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12418. */
  12419. spriteCellWidth: number;
  12420. /**
  12421. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12422. */
  12423. spriteCellHeight: number;
  12424. /**
  12425. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12426. */
  12427. spriteRandomStartCell: boolean;
  12428. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12429. translationPivot: Vector2;
  12430. /** @hidden */
  12431. protected _isAnimationSheetEnabled: boolean;
  12432. /**
  12433. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12434. */
  12435. beginAnimationOnStart: boolean;
  12436. /**
  12437. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12438. */
  12439. beginAnimationFrom: number;
  12440. /**
  12441. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12442. */
  12443. beginAnimationTo: number;
  12444. /**
  12445. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12446. */
  12447. beginAnimationLoop: boolean;
  12448. /**
  12449. * Gets or sets a world offset applied to all particles
  12450. */
  12451. worldOffset: Vector3;
  12452. /**
  12453. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12454. */
  12455. get isAnimationSheetEnabled(): boolean;
  12456. set isAnimationSheetEnabled(value: boolean);
  12457. /**
  12458. * Get hosting scene
  12459. * @returns the scene
  12460. */
  12461. getScene(): Nullable<Scene>;
  12462. /**
  12463. * You can use gravity if you want to give an orientation to your particles.
  12464. */
  12465. gravity: Vector3;
  12466. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12467. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12468. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12469. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12470. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12471. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12472. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12473. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12474. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12475. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12476. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12477. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12478. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12479. /**
  12480. * Defines the delay in milliseconds before starting the system (0 by default)
  12481. */
  12482. startDelay: number;
  12483. /**
  12484. * Gets the current list of drag gradients.
  12485. * You must use addDragGradient and removeDragGradient to udpate this list
  12486. * @returns the list of drag gradients
  12487. */
  12488. getDragGradients(): Nullable<Array<FactorGradient>>;
  12489. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12490. limitVelocityDamping: number;
  12491. /**
  12492. * Gets the current list of limit velocity gradients.
  12493. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12494. * @returns the list of limit velocity gradients
  12495. */
  12496. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12497. /**
  12498. * Gets the current list of color gradients.
  12499. * You must use addColorGradient and removeColorGradient to udpate this list
  12500. * @returns the list of color gradients
  12501. */
  12502. getColorGradients(): Nullable<Array<ColorGradient>>;
  12503. /**
  12504. * Gets the current list of size gradients.
  12505. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12506. * @returns the list of size gradients
  12507. */
  12508. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12509. /**
  12510. * Gets the current list of color remap gradients.
  12511. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12512. * @returns the list of color remap gradients
  12513. */
  12514. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12515. /**
  12516. * Gets the current list of alpha remap gradients.
  12517. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12518. * @returns the list of alpha remap gradients
  12519. */
  12520. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12521. /**
  12522. * Gets the current list of life time gradients.
  12523. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12524. * @returns the list of life time gradients
  12525. */
  12526. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12527. /**
  12528. * Gets the current list of angular speed gradients.
  12529. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12530. * @returns the list of angular speed gradients
  12531. */
  12532. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12533. /**
  12534. * Gets the current list of velocity gradients.
  12535. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12536. * @returns the list of velocity gradients
  12537. */
  12538. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12539. /**
  12540. * Gets the current list of start size gradients.
  12541. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12542. * @returns the list of start size gradients
  12543. */
  12544. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12545. /**
  12546. * Gets the current list of emit rate gradients.
  12547. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12548. * @returns the list of emit rate gradients
  12549. */
  12550. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12551. /**
  12552. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12553. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12554. */
  12555. get direction1(): Vector3;
  12556. set direction1(value: Vector3);
  12557. /**
  12558. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12559. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12560. */
  12561. get direction2(): Vector3;
  12562. set direction2(value: Vector3);
  12563. /**
  12564. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12565. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12566. */
  12567. get minEmitBox(): Vector3;
  12568. set minEmitBox(value: Vector3);
  12569. /**
  12570. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12571. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12572. */
  12573. get maxEmitBox(): Vector3;
  12574. set maxEmitBox(value: Vector3);
  12575. /**
  12576. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12577. */
  12578. color1: Color4;
  12579. /**
  12580. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12581. */
  12582. color2: Color4;
  12583. /**
  12584. * Color the particle will have at the end of its lifetime
  12585. */
  12586. colorDead: Color4;
  12587. /**
  12588. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12589. */
  12590. textureMask: Color4;
  12591. /**
  12592. * The particle emitter type defines the emitter used by the particle system.
  12593. * It can be for example box, sphere, or cone...
  12594. */
  12595. particleEmitterType: IParticleEmitterType;
  12596. /** @hidden */
  12597. _isSubEmitter: boolean;
  12598. /**
  12599. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12600. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12601. */
  12602. billboardMode: number;
  12603. protected _isBillboardBased: boolean;
  12604. /**
  12605. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12606. */
  12607. get isBillboardBased(): boolean;
  12608. set isBillboardBased(value: boolean);
  12609. /**
  12610. * The scene the particle system belongs to.
  12611. */
  12612. protected _scene: Nullable<Scene>;
  12613. /**
  12614. * The engine the particle system belongs to.
  12615. */
  12616. protected _engine: ThinEngine;
  12617. /**
  12618. * Local cache of defines for image processing.
  12619. */
  12620. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12621. /**
  12622. * Default configuration related to image processing available in the standard Material.
  12623. */
  12624. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12625. /**
  12626. * Gets the image processing configuration used either in this material.
  12627. */
  12628. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12629. /**
  12630. * Sets the Default image processing configuration used either in the this material.
  12631. *
  12632. * If sets to null, the scene one is in use.
  12633. */
  12634. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12635. /**
  12636. * Attaches a new image processing configuration to the Standard Material.
  12637. * @param configuration
  12638. */
  12639. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12640. /** @hidden */
  12641. protected _reset(): void;
  12642. /** @hidden */
  12643. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12644. /**
  12645. * Instantiates a particle system.
  12646. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12647. * @param name The name of the particle system
  12648. */
  12649. constructor(name: string);
  12650. /**
  12651. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12654. * @returns the emitter
  12655. */
  12656. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12657. /**
  12658. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12659. * @param radius The radius of the hemisphere to emit from
  12660. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12661. * @returns the emitter
  12662. */
  12663. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12664. /**
  12665. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12666. * @param radius The radius of the sphere to emit from
  12667. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12668. * @returns the emitter
  12669. */
  12670. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12671. /**
  12672. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12673. * @param radius The radius of the sphere to emit from
  12674. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12675. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12676. * @returns the emitter
  12677. */
  12678. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12679. /**
  12680. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12681. * @param radius The radius of the emission cylinder
  12682. * @param height The height of the emission cylinder
  12683. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12684. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12685. * @returns the emitter
  12686. */
  12687. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12688. /**
  12689. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12690. * @param radius The radius of the cylinder to emit from
  12691. * @param height The height of the emission cylinder
  12692. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12695. * @returns the emitter
  12696. */
  12697. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12698. /**
  12699. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12700. * @param radius The radius of the cone to emit from
  12701. * @param angle The base angle of the cone
  12702. * @returns the emitter
  12703. */
  12704. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12705. /**
  12706. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12707. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12708. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12709. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12710. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12711. * @returns the emitter
  12712. */
  12713. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12714. }
  12715. }
  12716. declare module "babylonjs/Particles/subEmitter" {
  12717. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12718. import { Scene } from "babylonjs/scene";
  12719. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12720. /**
  12721. * Type of sub emitter
  12722. */
  12723. export enum SubEmitterType {
  12724. /**
  12725. * Attached to the particle over it's lifetime
  12726. */
  12727. ATTACHED = 0,
  12728. /**
  12729. * Created when the particle dies
  12730. */
  12731. END = 1
  12732. }
  12733. /**
  12734. * Sub emitter class used to emit particles from an existing particle
  12735. */
  12736. export class SubEmitter {
  12737. /**
  12738. * the particle system to be used by the sub emitter
  12739. */
  12740. particleSystem: ParticleSystem;
  12741. /**
  12742. * Type of the submitter (Default: END)
  12743. */
  12744. type: SubEmitterType;
  12745. /**
  12746. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12747. * Note: This only is supported when using an emitter of type Mesh
  12748. */
  12749. inheritDirection: boolean;
  12750. /**
  12751. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12752. */
  12753. inheritedVelocityAmount: number;
  12754. /**
  12755. * Creates a sub emitter
  12756. * @param particleSystem the particle system to be used by the sub emitter
  12757. */
  12758. constructor(
  12759. /**
  12760. * the particle system to be used by the sub emitter
  12761. */
  12762. particleSystem: ParticleSystem);
  12763. /**
  12764. * Clones the sub emitter
  12765. * @returns the cloned sub emitter
  12766. */
  12767. clone(): SubEmitter;
  12768. /**
  12769. * Serialize current object to a JSON object
  12770. * @returns the serialized object
  12771. */
  12772. serialize(): any;
  12773. /** @hidden */
  12774. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12775. /**
  12776. * Creates a new SubEmitter from a serialized JSON version
  12777. * @param serializationObject defines the JSON object to read from
  12778. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12779. * @param rootUrl defines the rootUrl for data loading
  12780. * @returns a new SubEmitter
  12781. */
  12782. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12783. /** Release associated resources */
  12784. dispose(): void;
  12785. }
  12786. }
  12787. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12788. /** @hidden */
  12789. export var imageProcessingDeclaration: {
  12790. name: string;
  12791. shader: string;
  12792. };
  12793. }
  12794. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12795. /** @hidden */
  12796. export var imageProcessingFunctions: {
  12797. name: string;
  12798. shader: string;
  12799. };
  12800. }
  12801. declare module "babylonjs/Shaders/particles.fragment" {
  12802. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12803. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12804. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12805. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12806. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12807. /** @hidden */
  12808. export var particlesPixelShader: {
  12809. name: string;
  12810. shader: string;
  12811. };
  12812. }
  12813. declare module "babylonjs/Shaders/particles.vertex" {
  12814. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12815. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12816. /** @hidden */
  12817. export var particlesVertexShader: {
  12818. name: string;
  12819. shader: string;
  12820. };
  12821. }
  12822. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12823. import { Nullable } from "babylonjs/types";
  12824. import { Plane } from "babylonjs/Maths/math";
  12825. /**
  12826. * Interface used to define entities containing multiple clip planes
  12827. */
  12828. export interface IClipPlanesHolder {
  12829. /**
  12830. * Gets or sets the active clipplane 1
  12831. */
  12832. clipPlane: Nullable<Plane>;
  12833. /**
  12834. * Gets or sets the active clipplane 2
  12835. */
  12836. clipPlane2: Nullable<Plane>;
  12837. /**
  12838. * Gets or sets the active clipplane 3
  12839. */
  12840. clipPlane3: Nullable<Plane>;
  12841. /**
  12842. * Gets or sets the active clipplane 4
  12843. */
  12844. clipPlane4: Nullable<Plane>;
  12845. /**
  12846. * Gets or sets the active clipplane 5
  12847. */
  12848. clipPlane5: Nullable<Plane>;
  12849. /**
  12850. * Gets or sets the active clipplane 6
  12851. */
  12852. clipPlane6: Nullable<Plane>;
  12853. }
  12854. }
  12855. declare module "babylonjs/Materials/thinMaterialHelper" {
  12856. import { Effect } from "babylonjs/Materials/effect";
  12857. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12858. /**
  12859. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12860. *
  12861. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12862. *
  12863. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12864. */
  12865. export class ThinMaterialHelper {
  12866. /**
  12867. * Binds the clip plane information from the holder to the effect.
  12868. * @param effect The effect we are binding the data to
  12869. * @param holder The entity containing the clip plane information
  12870. */
  12871. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12872. }
  12873. }
  12874. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12875. module "babylonjs/Engines/thinEngine" {
  12876. interface ThinEngine {
  12877. /**
  12878. * Sets alpha constants used by some alpha blending modes
  12879. * @param r defines the red component
  12880. * @param g defines the green component
  12881. * @param b defines the blue component
  12882. * @param a defines the alpha component
  12883. */
  12884. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12885. /**
  12886. * Sets the current alpha mode
  12887. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12888. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12889. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12890. */
  12891. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12892. /**
  12893. * Gets the current alpha mode
  12894. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12895. * @returns the current alpha mode
  12896. */
  12897. getAlphaMode(): number;
  12898. /**
  12899. * Sets the current alpha equation
  12900. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12901. */
  12902. setAlphaEquation(equation: number): void;
  12903. /**
  12904. * Gets the current alpha equation.
  12905. * @returns the current alpha equation
  12906. */
  12907. getAlphaEquation(): number;
  12908. }
  12909. }
  12910. }
  12911. declare module "babylonjs/Particles/particleSystem" {
  12912. import { Nullable } from "babylonjs/types";
  12913. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12914. import { Observable } from "babylonjs/Misc/observable";
  12915. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12916. import { Effect } from "babylonjs/Materials/effect";
  12917. import { IDisposable } from "babylonjs/scene";
  12918. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12919. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12920. import { Particle } from "babylonjs/Particles/particle";
  12921. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12922. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12923. import "babylonjs/Shaders/particles.fragment";
  12924. import "babylonjs/Shaders/particles.vertex";
  12925. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12926. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12927. import "babylonjs/Engines/Extensions/engine.alpha";
  12928. import { Scene } from "babylonjs/scene";
  12929. /**
  12930. * This represents a particle system in Babylon.
  12931. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12932. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12933. * @example https://doc.babylonjs.com/babylon101/particles
  12934. */
  12935. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12936. /**
  12937. * Billboard mode will only apply to Y axis
  12938. */
  12939. static readonly BILLBOARDMODE_Y: number;
  12940. /**
  12941. * Billboard mode will apply to all axes
  12942. */
  12943. static readonly BILLBOARDMODE_ALL: number;
  12944. /**
  12945. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12946. */
  12947. static readonly BILLBOARDMODE_STRETCHED: number;
  12948. /**
  12949. * This function can be defined to provide custom update for active particles.
  12950. * This function will be called instead of regular update (age, position, color, etc.).
  12951. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12952. */
  12953. updateFunction: (particles: Particle[]) => void;
  12954. private _emitterWorldMatrix;
  12955. /**
  12956. * This function can be defined to specify initial direction for every new particle.
  12957. * It by default use the emitterType defined function
  12958. */
  12959. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12960. /**
  12961. * This function can be defined to specify initial position for every new particle.
  12962. * It by default use the emitterType defined function
  12963. */
  12964. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12965. /**
  12966. * @hidden
  12967. */
  12968. _inheritedVelocityOffset: Vector3;
  12969. /**
  12970. * An event triggered when the system is disposed
  12971. */
  12972. onDisposeObservable: Observable<IParticleSystem>;
  12973. /**
  12974. * An event triggered when the system is stopped
  12975. */
  12976. onStoppedObservable: Observable<IParticleSystem>;
  12977. private _onDisposeObserver;
  12978. /**
  12979. * Sets a callback that will be triggered when the system is disposed
  12980. */
  12981. set onDispose(callback: () => void);
  12982. private _particles;
  12983. private _epsilon;
  12984. private _capacity;
  12985. private _stockParticles;
  12986. private _newPartsExcess;
  12987. private _vertexData;
  12988. private _vertexBuffer;
  12989. private _vertexBuffers;
  12990. private _spriteBuffer;
  12991. private _indexBuffer;
  12992. private _effect;
  12993. private _customEffect;
  12994. private _cachedDefines;
  12995. private _scaledColorStep;
  12996. private _colorDiff;
  12997. private _scaledDirection;
  12998. private _scaledGravity;
  12999. private _currentRenderId;
  13000. private _alive;
  13001. private _useInstancing;
  13002. private _started;
  13003. private _stopped;
  13004. private _actualFrame;
  13005. private _scaledUpdateSpeed;
  13006. private _vertexBufferSize;
  13007. /** @hidden */
  13008. _currentEmitRateGradient: Nullable<FactorGradient>;
  13009. /** @hidden */
  13010. _currentEmitRate1: number;
  13011. /** @hidden */
  13012. _currentEmitRate2: number;
  13013. /** @hidden */
  13014. _currentStartSizeGradient: Nullable<FactorGradient>;
  13015. /** @hidden */
  13016. _currentStartSize1: number;
  13017. /** @hidden */
  13018. _currentStartSize2: number;
  13019. private readonly _rawTextureWidth;
  13020. private _rampGradientsTexture;
  13021. private _useRampGradients;
  13022. /** Gets or sets a matrix to use to compute projection */
  13023. defaultProjectionMatrix: Matrix;
  13024. /** Gets or sets a matrix to use to compute view */
  13025. defaultViewMatrix: Matrix;
  13026. /** Gets or sets a boolean indicating that ramp gradients must be used
  13027. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13028. */
  13029. get useRampGradients(): boolean;
  13030. set useRampGradients(value: boolean);
  13031. /**
  13032. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  13033. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  13034. */
  13035. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13036. private _subEmitters;
  13037. /**
  13038. * @hidden
  13039. * If the particle systems emitter should be disposed when the particle system is disposed
  13040. */
  13041. _disposeEmitterOnDispose: boolean;
  13042. /**
  13043. * The current active Sub-systems, this property is used by the root particle system only.
  13044. */
  13045. activeSubSystems: Array<ParticleSystem>;
  13046. /**
  13047. * Specifies if the particles are updated in emitter local space or world space
  13048. */
  13049. isLocal: boolean;
  13050. private _rootParticleSystem;
  13051. /**
  13052. * Gets the current list of active particles
  13053. */
  13054. get particles(): Particle[];
  13055. /**
  13056. * Gets the number of particles active at the same time.
  13057. * @returns The number of active particles.
  13058. */
  13059. getActiveCount(): number;
  13060. /**
  13061. * Returns the string "ParticleSystem"
  13062. * @returns a string containing the class name
  13063. */
  13064. getClassName(): string;
  13065. /**
  13066. * Gets a boolean indicating that the system is stopping
  13067. * @returns true if the system is currently stopping
  13068. */
  13069. isStopping(): boolean;
  13070. /**
  13071. * Gets the custom effect used to render the particles
  13072. * @param blendMode Blend mode for which the effect should be retrieved
  13073. * @returns The effect
  13074. */
  13075. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13076. /**
  13077. * Sets the custom effect used to render the particles
  13078. * @param effect The effect to set
  13079. * @param blendMode Blend mode for which the effect should be set
  13080. */
  13081. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13082. /** @hidden */
  13083. private _onBeforeDrawParticlesObservable;
  13084. /**
  13085. * Observable that will be called just before the particles are drawn
  13086. */
  13087. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13088. /**
  13089. * Gets the name of the particle vertex shader
  13090. */
  13091. get vertexShaderName(): string;
  13092. /**
  13093. * Instantiates a particle system.
  13094. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  13095. * @param name The name of the particle system
  13096. * @param capacity The max number of particles alive at the same time
  13097. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13098. * @param customEffect a custom effect used to change the way particles are rendered by default
  13099. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13100. * @param epsilon Offset used to render the particles
  13101. */
  13102. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13103. private _addFactorGradient;
  13104. private _removeFactorGradient;
  13105. /**
  13106. * Adds a new life time gradient
  13107. * @param gradient defines the gradient to use (between 0 and 1)
  13108. * @param factor defines the life time factor to affect to the specified gradient
  13109. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13110. * @returns the current particle system
  13111. */
  13112. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13113. /**
  13114. * Remove a specific life time gradient
  13115. * @param gradient defines the gradient to remove
  13116. * @returns the current particle system
  13117. */
  13118. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13119. /**
  13120. * Adds a new size gradient
  13121. * @param gradient defines the gradient to use (between 0 and 1)
  13122. * @param factor defines the size factor to affect to the specified gradient
  13123. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13124. * @returns the current particle system
  13125. */
  13126. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13127. /**
  13128. * Remove a specific size gradient
  13129. * @param gradient defines the gradient to remove
  13130. * @returns the current particle system
  13131. */
  13132. removeSizeGradient(gradient: number): IParticleSystem;
  13133. /**
  13134. * Adds a new color remap gradient
  13135. * @param gradient defines the gradient to use (between 0 and 1)
  13136. * @param min defines the color remap minimal range
  13137. * @param max defines the color remap maximal range
  13138. * @returns the current particle system
  13139. */
  13140. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13141. /**
  13142. * Remove a specific color remap gradient
  13143. * @param gradient defines the gradient to remove
  13144. * @returns the current particle system
  13145. */
  13146. removeColorRemapGradient(gradient: number): IParticleSystem;
  13147. /**
  13148. * Adds a new alpha remap gradient
  13149. * @param gradient defines the gradient to use (between 0 and 1)
  13150. * @param min defines the alpha remap minimal range
  13151. * @param max defines the alpha remap maximal range
  13152. * @returns the current particle system
  13153. */
  13154. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13155. /**
  13156. * Remove a specific alpha remap gradient
  13157. * @param gradient defines the gradient to remove
  13158. * @returns the current particle system
  13159. */
  13160. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13161. /**
  13162. * Adds a new angular speed gradient
  13163. * @param gradient defines the gradient to use (between 0 and 1)
  13164. * @param factor defines the angular speed to affect to the specified gradient
  13165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13166. * @returns the current particle system
  13167. */
  13168. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13169. /**
  13170. * Remove a specific angular speed gradient
  13171. * @param gradient defines the gradient to remove
  13172. * @returns the current particle system
  13173. */
  13174. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13175. /**
  13176. * Adds a new velocity gradient
  13177. * @param gradient defines the gradient to use (between 0 and 1)
  13178. * @param factor defines the velocity to affect to the specified gradient
  13179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13180. * @returns the current particle system
  13181. */
  13182. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13183. /**
  13184. * Remove a specific velocity gradient
  13185. * @param gradient defines the gradient to remove
  13186. * @returns the current particle system
  13187. */
  13188. removeVelocityGradient(gradient: number): IParticleSystem;
  13189. /**
  13190. * Adds a new limit velocity gradient
  13191. * @param gradient defines the gradient to use (between 0 and 1)
  13192. * @param factor defines the limit velocity value to affect to the specified gradient
  13193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13194. * @returns the current particle system
  13195. */
  13196. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13197. /**
  13198. * Remove a specific limit velocity gradient
  13199. * @param gradient defines the gradient to remove
  13200. * @returns the current particle system
  13201. */
  13202. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13203. /**
  13204. * Adds a new drag gradient
  13205. * @param gradient defines the gradient to use (between 0 and 1)
  13206. * @param factor defines the drag value to affect to the specified gradient
  13207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13208. * @returns the current particle system
  13209. */
  13210. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13211. /**
  13212. * Remove a specific drag gradient
  13213. * @param gradient defines the gradient to remove
  13214. * @returns the current particle system
  13215. */
  13216. removeDragGradient(gradient: number): IParticleSystem;
  13217. /**
  13218. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13219. * @param gradient defines the gradient to use (between 0 and 1)
  13220. * @param factor defines the emit rate value to affect to the specified gradient
  13221. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13222. * @returns the current particle system
  13223. */
  13224. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13225. /**
  13226. * Remove a specific emit rate gradient
  13227. * @param gradient defines the gradient to remove
  13228. * @returns the current particle system
  13229. */
  13230. removeEmitRateGradient(gradient: number): IParticleSystem;
  13231. /**
  13232. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13233. * @param gradient defines the gradient to use (between 0 and 1)
  13234. * @param factor defines the start size value to affect to the specified gradient
  13235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13236. * @returns the current particle system
  13237. */
  13238. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13239. /**
  13240. * Remove a specific start size gradient
  13241. * @param gradient defines the gradient to remove
  13242. * @returns the current particle system
  13243. */
  13244. removeStartSizeGradient(gradient: number): IParticleSystem;
  13245. private _createRampGradientTexture;
  13246. /**
  13247. * Gets the current list of ramp gradients.
  13248. * You must use addRampGradient and removeRampGradient to udpate this list
  13249. * @returns the list of ramp gradients
  13250. */
  13251. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13252. /** Force the system to rebuild all gradients that need to be resync */
  13253. forceRefreshGradients(): void;
  13254. private _syncRampGradientTexture;
  13255. /**
  13256. * Adds a new ramp gradient used to remap particle colors
  13257. * @param gradient defines the gradient to use (between 0 and 1)
  13258. * @param color defines the color to affect to the specified gradient
  13259. * @returns the current particle system
  13260. */
  13261. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13262. /**
  13263. * Remove a specific ramp gradient
  13264. * @param gradient defines the gradient to remove
  13265. * @returns the current particle system
  13266. */
  13267. removeRampGradient(gradient: number): ParticleSystem;
  13268. /**
  13269. * Adds a new color gradient
  13270. * @param gradient defines the gradient to use (between 0 and 1)
  13271. * @param color1 defines the color to affect to the specified gradient
  13272. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13273. * @returns this particle system
  13274. */
  13275. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13276. /**
  13277. * Remove a specific color gradient
  13278. * @param gradient defines the gradient to remove
  13279. * @returns this particle system
  13280. */
  13281. removeColorGradient(gradient: number): IParticleSystem;
  13282. private _fetchR;
  13283. protected _reset(): void;
  13284. private _resetEffect;
  13285. private _createVertexBuffers;
  13286. private _createIndexBuffer;
  13287. /**
  13288. * Gets the maximum number of particles active at the same time.
  13289. * @returns The max number of active particles.
  13290. */
  13291. getCapacity(): number;
  13292. /**
  13293. * Gets whether there are still active particles in the system.
  13294. * @returns True if it is alive, otherwise false.
  13295. */
  13296. isAlive(): boolean;
  13297. /**
  13298. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13299. * @returns True if it has been started, otherwise false.
  13300. */
  13301. isStarted(): boolean;
  13302. private _prepareSubEmitterInternalArray;
  13303. /**
  13304. * Starts the particle system and begins to emit
  13305. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13306. */
  13307. start(delay?: number): void;
  13308. /**
  13309. * Stops the particle system.
  13310. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  13311. */
  13312. stop(stopSubEmitters?: boolean): void;
  13313. /**
  13314. * Remove all active particles
  13315. */
  13316. reset(): void;
  13317. /**
  13318. * @hidden (for internal use only)
  13319. */
  13320. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13321. /**
  13322. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13323. * Its lifetime will start back at 0.
  13324. */
  13325. recycleParticle: (particle: Particle) => void;
  13326. private _stopSubEmitters;
  13327. private _createParticle;
  13328. private _removeFromRoot;
  13329. private _emitFromParticle;
  13330. private _update;
  13331. /** @hidden */
  13332. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13333. /** @hidden */
  13334. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13335. /**
  13336. * Fill the defines array according to the current settings of the particle system
  13337. * @param defines Array to be updated
  13338. * @param blendMode blend mode to take into account when updating the array
  13339. */
  13340. fillDefines(defines: Array<string>, blendMode: number): void;
  13341. /**
  13342. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13343. * @param uniforms Uniforms array to fill
  13344. * @param attributes Attributes array to fill
  13345. * @param samplers Samplers array to fill
  13346. */
  13347. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13348. /** @hidden */
  13349. private _getEffect;
  13350. /**
  13351. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13352. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13353. */
  13354. animate(preWarmOnly?: boolean): void;
  13355. private _appendParticleVertices;
  13356. /**
  13357. * Rebuilds the particle system.
  13358. */
  13359. rebuild(): void;
  13360. /**
  13361. * Is this system ready to be used/rendered
  13362. * @return true if the system is ready
  13363. */
  13364. isReady(): boolean;
  13365. private _render;
  13366. /**
  13367. * Renders the particle system in its current state.
  13368. * @returns the current number of particles
  13369. */
  13370. render(): number;
  13371. /**
  13372. * Disposes the particle system and free the associated resources
  13373. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13374. */
  13375. dispose(disposeTexture?: boolean): void;
  13376. /**
  13377. * Clones the particle system.
  13378. * @param name The name of the cloned object
  13379. * @param newEmitter The new emitter to use
  13380. * @returns the cloned particle system
  13381. */
  13382. clone(name: string, newEmitter: any): ParticleSystem;
  13383. /**
  13384. * Serializes the particle system to a JSON object
  13385. * @param serializeTexture defines if the texture must be serialized as well
  13386. * @returns the JSON object
  13387. */
  13388. serialize(serializeTexture?: boolean): any;
  13389. /** @hidden */
  13390. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13391. /** @hidden */
  13392. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13393. /**
  13394. * Parses a JSON object to create a particle system.
  13395. * @param parsedParticleSystem The JSON object to parse
  13396. * @param sceneOrEngine The scene or the engine to create the particle system in
  13397. * @param rootUrl The root url to use to load external dependencies like texture
  13398. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13399. * @returns the Parsed particle system
  13400. */
  13401. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13402. }
  13403. }
  13404. declare module "babylonjs/Particles/particle" {
  13405. import { Nullable } from "babylonjs/types";
  13406. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13407. import { Color4 } from "babylonjs/Maths/math.color";
  13408. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13409. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13410. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13411. /**
  13412. * A particle represents one of the element emitted by a particle system.
  13413. * This is mainly define by its coordinates, direction, velocity and age.
  13414. */
  13415. export class Particle {
  13416. /**
  13417. * The particle system the particle belongs to.
  13418. */
  13419. particleSystem: ParticleSystem;
  13420. private static _Count;
  13421. /**
  13422. * Unique ID of the particle
  13423. */
  13424. id: number;
  13425. /**
  13426. * The world position of the particle in the scene.
  13427. */
  13428. position: Vector3;
  13429. /**
  13430. * The world direction of the particle in the scene.
  13431. */
  13432. direction: Vector3;
  13433. /**
  13434. * The color of the particle.
  13435. */
  13436. color: Color4;
  13437. /**
  13438. * The color change of the particle per step.
  13439. */
  13440. colorStep: Color4;
  13441. /**
  13442. * Defines how long will the life of the particle be.
  13443. */
  13444. lifeTime: number;
  13445. /**
  13446. * The current age of the particle.
  13447. */
  13448. age: number;
  13449. /**
  13450. * The current size of the particle.
  13451. */
  13452. size: number;
  13453. /**
  13454. * The current scale of the particle.
  13455. */
  13456. scale: Vector2;
  13457. /**
  13458. * The current angle of the particle.
  13459. */
  13460. angle: number;
  13461. /**
  13462. * Defines how fast is the angle changing.
  13463. */
  13464. angularSpeed: number;
  13465. /**
  13466. * Defines the cell index used by the particle to be rendered from a sprite.
  13467. */
  13468. cellIndex: number;
  13469. /**
  13470. * The information required to support color remapping
  13471. */
  13472. remapData: Vector4;
  13473. /** @hidden */
  13474. _randomCellOffset?: number;
  13475. /** @hidden */
  13476. _initialDirection: Nullable<Vector3>;
  13477. /** @hidden */
  13478. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13479. /** @hidden */
  13480. _initialStartSpriteCellID: number;
  13481. /** @hidden */
  13482. _initialEndSpriteCellID: number;
  13483. /** @hidden */
  13484. _currentColorGradient: Nullable<ColorGradient>;
  13485. /** @hidden */
  13486. _currentColor1: Color4;
  13487. /** @hidden */
  13488. _currentColor2: Color4;
  13489. /** @hidden */
  13490. _currentSizeGradient: Nullable<FactorGradient>;
  13491. /** @hidden */
  13492. _currentSize1: number;
  13493. /** @hidden */
  13494. _currentSize2: number;
  13495. /** @hidden */
  13496. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13497. /** @hidden */
  13498. _currentAngularSpeed1: number;
  13499. /** @hidden */
  13500. _currentAngularSpeed2: number;
  13501. /** @hidden */
  13502. _currentVelocityGradient: Nullable<FactorGradient>;
  13503. /** @hidden */
  13504. _currentVelocity1: number;
  13505. /** @hidden */
  13506. _currentVelocity2: number;
  13507. /** @hidden */
  13508. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13509. /** @hidden */
  13510. _currentLimitVelocity1: number;
  13511. /** @hidden */
  13512. _currentLimitVelocity2: number;
  13513. /** @hidden */
  13514. _currentDragGradient: Nullable<FactorGradient>;
  13515. /** @hidden */
  13516. _currentDrag1: number;
  13517. /** @hidden */
  13518. _currentDrag2: number;
  13519. /** @hidden */
  13520. _randomNoiseCoordinates1: Vector3;
  13521. /** @hidden */
  13522. _randomNoiseCoordinates2: Vector3;
  13523. /** @hidden */
  13524. _localPosition?: Vector3;
  13525. /**
  13526. * Creates a new instance Particle
  13527. * @param particleSystem the particle system the particle belongs to
  13528. */
  13529. constructor(
  13530. /**
  13531. * The particle system the particle belongs to.
  13532. */
  13533. particleSystem: ParticleSystem);
  13534. private updateCellInfoFromSystem;
  13535. /**
  13536. * Defines how the sprite cell index is updated for the particle
  13537. */
  13538. updateCellIndex(): void;
  13539. /** @hidden */
  13540. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13541. /** @hidden */
  13542. _inheritParticleInfoToSubEmitters(): void;
  13543. /** @hidden */
  13544. _reset(): void;
  13545. /**
  13546. * Copy the properties of particle to another one.
  13547. * @param other the particle to copy the information to.
  13548. */
  13549. copyTo(other: Particle): void;
  13550. }
  13551. }
  13552. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13553. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13554. import { Effect } from "babylonjs/Materials/effect";
  13555. import { Particle } from "babylonjs/Particles/particle";
  13556. import { Nullable } from "babylonjs/types";
  13557. import { Scene } from "babylonjs/scene";
  13558. /**
  13559. * Particle emitter represents a volume emitting particles.
  13560. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13561. */
  13562. export interface IParticleEmitterType {
  13563. /**
  13564. * Called by the particle System when the direction is computed for the created particle.
  13565. * @param worldMatrix is the world matrix of the particle system
  13566. * @param directionToUpdate is the direction vector to update with the result
  13567. * @param particle is the particle we are computed the direction for
  13568. * @param isLocal defines if the direction should be set in local space
  13569. */
  13570. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13571. /**
  13572. * Called by the particle System when the position is computed for the created particle.
  13573. * @param worldMatrix is the world matrix of the particle system
  13574. * @param positionToUpdate is the position vector to update with the result
  13575. * @param particle is the particle we are computed the position for
  13576. * @param isLocal defines if the position should be set in local space
  13577. */
  13578. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13579. /**
  13580. * Clones the current emitter and returns a copy of it
  13581. * @returns the new emitter
  13582. */
  13583. clone(): IParticleEmitterType;
  13584. /**
  13585. * Called by the GPUParticleSystem to setup the update shader
  13586. * @param effect defines the update shader
  13587. */
  13588. applyToShader(effect: Effect): void;
  13589. /**
  13590. * Returns a string to use to update the GPU particles update shader
  13591. * @returns the effect defines string
  13592. */
  13593. getEffectDefines(): string;
  13594. /**
  13595. * Returns a string representing the class name
  13596. * @returns a string containing the class name
  13597. */
  13598. getClassName(): string;
  13599. /**
  13600. * Serializes the particle system to a JSON object.
  13601. * @returns the JSON object
  13602. */
  13603. serialize(): any;
  13604. /**
  13605. * Parse properties from a JSON object
  13606. * @param serializationObject defines the JSON object
  13607. * @param scene defines the hosting scene
  13608. */
  13609. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13610. }
  13611. }
  13612. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13613. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13614. import { Effect } from "babylonjs/Materials/effect";
  13615. import { Particle } from "babylonjs/Particles/particle";
  13616. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13617. /**
  13618. * Particle emitter emitting particles from the inside of a box.
  13619. * It emits the particles randomly between 2 given directions.
  13620. */
  13621. export class BoxParticleEmitter implements IParticleEmitterType {
  13622. /**
  13623. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13624. */
  13625. direction1: Vector3;
  13626. /**
  13627. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13628. */
  13629. direction2: Vector3;
  13630. /**
  13631. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13632. */
  13633. minEmitBox: Vector3;
  13634. /**
  13635. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13636. */
  13637. maxEmitBox: Vector3;
  13638. /**
  13639. * Creates a new instance BoxParticleEmitter
  13640. */
  13641. constructor();
  13642. /**
  13643. * Called by the particle System when the direction is computed for the created particle.
  13644. * @param worldMatrix is the world matrix of the particle system
  13645. * @param directionToUpdate is the direction vector to update with the result
  13646. * @param particle is the particle we are computed the direction for
  13647. * @param isLocal defines if the direction should be set in local space
  13648. */
  13649. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13650. /**
  13651. * Called by the particle System when the position is computed for the created particle.
  13652. * @param worldMatrix is the world matrix of the particle system
  13653. * @param positionToUpdate is the position vector to update with the result
  13654. * @param particle is the particle we are computed the position for
  13655. * @param isLocal defines if the position should be set in local space
  13656. */
  13657. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13658. /**
  13659. * Clones the current emitter and returns a copy of it
  13660. * @returns the new emitter
  13661. */
  13662. clone(): BoxParticleEmitter;
  13663. /**
  13664. * Called by the GPUParticleSystem to setup the update shader
  13665. * @param effect defines the update shader
  13666. */
  13667. applyToShader(effect: Effect): void;
  13668. /**
  13669. * Returns a string to use to update the GPU particles update shader
  13670. * @returns a string containng the defines string
  13671. */
  13672. getEffectDefines(): string;
  13673. /**
  13674. * Returns the string "BoxParticleEmitter"
  13675. * @returns a string containing the class name
  13676. */
  13677. getClassName(): string;
  13678. /**
  13679. * Serializes the particle system to a JSON object.
  13680. * @returns the JSON object
  13681. */
  13682. serialize(): any;
  13683. /**
  13684. * Parse properties from a JSON object
  13685. * @param serializationObject defines the JSON object
  13686. */
  13687. parse(serializationObject: any): void;
  13688. }
  13689. }
  13690. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13691. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13692. import { Effect } from "babylonjs/Materials/effect";
  13693. import { Particle } from "babylonjs/Particles/particle";
  13694. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13695. /**
  13696. * Particle emitter emitting particles from the inside of a cone.
  13697. * It emits the particles alongside the cone volume from the base to the particle.
  13698. * The emission direction might be randomized.
  13699. */
  13700. export class ConeParticleEmitter implements IParticleEmitterType {
  13701. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13702. directionRandomizer: number;
  13703. private _radius;
  13704. private _angle;
  13705. private _height;
  13706. /**
  13707. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13708. */
  13709. radiusRange: number;
  13710. /**
  13711. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13712. */
  13713. heightRange: number;
  13714. /**
  13715. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13716. */
  13717. emitFromSpawnPointOnly: boolean;
  13718. /**
  13719. * Gets or sets the radius of the emission cone
  13720. */
  13721. get radius(): number;
  13722. set radius(value: number);
  13723. /**
  13724. * Gets or sets the angle of the emission cone
  13725. */
  13726. get angle(): number;
  13727. set angle(value: number);
  13728. private _buildHeight;
  13729. /**
  13730. * Creates a new instance ConeParticleEmitter
  13731. * @param radius the radius of the emission cone (1 by default)
  13732. * @param angle the cone base angle (PI by default)
  13733. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13734. */
  13735. constructor(radius?: number, angle?: number,
  13736. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13737. directionRandomizer?: number);
  13738. /**
  13739. * Called by the particle System when the direction is computed for the created particle.
  13740. * @param worldMatrix is the world matrix of the particle system
  13741. * @param directionToUpdate is the direction vector to update with the result
  13742. * @param particle is the particle we are computed the direction for
  13743. * @param isLocal defines if the direction should be set in local space
  13744. */
  13745. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13746. /**
  13747. * Called by the particle System when the position is computed for the created particle.
  13748. * @param worldMatrix is the world matrix of the particle system
  13749. * @param positionToUpdate is the position vector to update with the result
  13750. * @param particle is the particle we are computed the position for
  13751. * @param isLocal defines if the position should be set in local space
  13752. */
  13753. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13754. /**
  13755. * Clones the current emitter and returns a copy of it
  13756. * @returns the new emitter
  13757. */
  13758. clone(): ConeParticleEmitter;
  13759. /**
  13760. * Called by the GPUParticleSystem to setup the update shader
  13761. * @param effect defines the update shader
  13762. */
  13763. applyToShader(effect: Effect): void;
  13764. /**
  13765. * Returns a string to use to update the GPU particles update shader
  13766. * @returns a string containng the defines string
  13767. */
  13768. getEffectDefines(): string;
  13769. /**
  13770. * Returns the string "ConeParticleEmitter"
  13771. * @returns a string containing the class name
  13772. */
  13773. getClassName(): string;
  13774. /**
  13775. * Serializes the particle system to a JSON object.
  13776. * @returns the JSON object
  13777. */
  13778. serialize(): any;
  13779. /**
  13780. * Parse properties from a JSON object
  13781. * @param serializationObject defines the JSON object
  13782. */
  13783. parse(serializationObject: any): void;
  13784. }
  13785. }
  13786. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13787. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13788. import { Effect } from "babylonjs/Materials/effect";
  13789. import { Particle } from "babylonjs/Particles/particle";
  13790. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13791. /**
  13792. * Particle emitter emitting particles from the inside of a cylinder.
  13793. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13794. */
  13795. export class CylinderParticleEmitter implements IParticleEmitterType {
  13796. /**
  13797. * The radius of the emission cylinder.
  13798. */
  13799. radius: number;
  13800. /**
  13801. * The height of the emission cylinder.
  13802. */
  13803. height: number;
  13804. /**
  13805. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13806. */
  13807. radiusRange: number;
  13808. /**
  13809. * How much to randomize the particle direction [0-1].
  13810. */
  13811. directionRandomizer: number;
  13812. /**
  13813. * Creates a new instance CylinderParticleEmitter
  13814. * @param radius the radius of the emission cylinder (1 by default)
  13815. * @param height the height of the emission cylinder (1 by default)
  13816. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13817. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13818. */
  13819. constructor(
  13820. /**
  13821. * The radius of the emission cylinder.
  13822. */
  13823. radius?: number,
  13824. /**
  13825. * The height of the emission cylinder.
  13826. */
  13827. height?: number,
  13828. /**
  13829. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13830. */
  13831. radiusRange?: number,
  13832. /**
  13833. * How much to randomize the particle direction [0-1].
  13834. */
  13835. directionRandomizer?: number);
  13836. /**
  13837. * Called by the particle System when the direction is computed for the created particle.
  13838. * @param worldMatrix is the world matrix of the particle system
  13839. * @param directionToUpdate is the direction vector to update with the result
  13840. * @param particle is the particle we are computed the direction for
  13841. * @param isLocal defines if the direction should be set in local space
  13842. */
  13843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13844. /**
  13845. * Called by the particle System when the position is computed for the created particle.
  13846. * @param worldMatrix is the world matrix of the particle system
  13847. * @param positionToUpdate is the position vector to update with the result
  13848. * @param particle is the particle we are computed the position for
  13849. * @param isLocal defines if the position should be set in local space
  13850. */
  13851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13852. /**
  13853. * Clones the current emitter and returns a copy of it
  13854. * @returns the new emitter
  13855. */
  13856. clone(): CylinderParticleEmitter;
  13857. /**
  13858. * Called by the GPUParticleSystem to setup the update shader
  13859. * @param effect defines the update shader
  13860. */
  13861. applyToShader(effect: Effect): void;
  13862. /**
  13863. * Returns a string to use to update the GPU particles update shader
  13864. * @returns a string containng the defines string
  13865. */
  13866. getEffectDefines(): string;
  13867. /**
  13868. * Returns the string "CylinderParticleEmitter"
  13869. * @returns a string containing the class name
  13870. */
  13871. getClassName(): string;
  13872. /**
  13873. * Serializes the particle system to a JSON object.
  13874. * @returns the JSON object
  13875. */
  13876. serialize(): any;
  13877. /**
  13878. * Parse properties from a JSON object
  13879. * @param serializationObject defines the JSON object
  13880. */
  13881. parse(serializationObject: any): void;
  13882. }
  13883. /**
  13884. * Particle emitter emitting particles from the inside of a cylinder.
  13885. * It emits the particles randomly between two vectors.
  13886. */
  13887. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13888. /**
  13889. * The min limit of the emission direction.
  13890. */
  13891. direction1: Vector3;
  13892. /**
  13893. * The max limit of the emission direction.
  13894. */
  13895. direction2: Vector3;
  13896. /**
  13897. * Creates a new instance CylinderDirectedParticleEmitter
  13898. * @param radius the radius of the emission cylinder (1 by default)
  13899. * @param height the height of the emission cylinder (1 by default)
  13900. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13901. * @param direction1 the min limit of the emission direction (up vector by default)
  13902. * @param direction2 the max limit of the emission direction (up vector by default)
  13903. */
  13904. constructor(radius?: number, height?: number, radiusRange?: number,
  13905. /**
  13906. * The min limit of the emission direction.
  13907. */
  13908. direction1?: Vector3,
  13909. /**
  13910. * The max limit of the emission direction.
  13911. */
  13912. direction2?: Vector3);
  13913. /**
  13914. * Called by the particle System when the direction is computed for the created particle.
  13915. * @param worldMatrix is the world matrix of the particle system
  13916. * @param directionToUpdate is the direction vector to update with the result
  13917. * @param particle is the particle we are computed the direction for
  13918. */
  13919. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13920. /**
  13921. * Clones the current emitter and returns a copy of it
  13922. * @returns the new emitter
  13923. */
  13924. clone(): CylinderDirectedParticleEmitter;
  13925. /**
  13926. * Called by the GPUParticleSystem to setup the update shader
  13927. * @param effect defines the update shader
  13928. */
  13929. applyToShader(effect: Effect): void;
  13930. /**
  13931. * Returns a string to use to update the GPU particles update shader
  13932. * @returns a string containng the defines string
  13933. */
  13934. getEffectDefines(): string;
  13935. /**
  13936. * Returns the string "CylinderDirectedParticleEmitter"
  13937. * @returns a string containing the class name
  13938. */
  13939. getClassName(): string;
  13940. /**
  13941. * Serializes the particle system to a JSON object.
  13942. * @returns the JSON object
  13943. */
  13944. serialize(): any;
  13945. /**
  13946. * Parse properties from a JSON object
  13947. * @param serializationObject defines the JSON object
  13948. */
  13949. parse(serializationObject: any): void;
  13950. }
  13951. }
  13952. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13953. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13954. import { Effect } from "babylonjs/Materials/effect";
  13955. import { Particle } from "babylonjs/Particles/particle";
  13956. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13957. /**
  13958. * Particle emitter emitting particles from the inside of a hemisphere.
  13959. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13960. */
  13961. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13962. /**
  13963. * The radius of the emission hemisphere.
  13964. */
  13965. radius: number;
  13966. /**
  13967. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13968. */
  13969. radiusRange: number;
  13970. /**
  13971. * How much to randomize the particle direction [0-1].
  13972. */
  13973. directionRandomizer: number;
  13974. /**
  13975. * Creates a new instance HemisphericParticleEmitter
  13976. * @param radius the radius of the emission hemisphere (1 by default)
  13977. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13978. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13979. */
  13980. constructor(
  13981. /**
  13982. * The radius of the emission hemisphere.
  13983. */
  13984. radius?: number,
  13985. /**
  13986. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13987. */
  13988. radiusRange?: number,
  13989. /**
  13990. * How much to randomize the particle direction [0-1].
  13991. */
  13992. directionRandomizer?: number);
  13993. /**
  13994. * Called by the particle System when the direction is computed for the created particle.
  13995. * @param worldMatrix is the world matrix of the particle system
  13996. * @param directionToUpdate is the direction vector to update with the result
  13997. * @param particle is the particle we are computed the direction for
  13998. * @param isLocal defines if the direction should be set in local space
  13999. */
  14000. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14001. /**
  14002. * Called by the particle System when the position is computed for the created particle.
  14003. * @param worldMatrix is the world matrix of the particle system
  14004. * @param positionToUpdate is the position vector to update with the result
  14005. * @param particle is the particle we are computed the position for
  14006. * @param isLocal defines if the position should be set in local space
  14007. */
  14008. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14009. /**
  14010. * Clones the current emitter and returns a copy of it
  14011. * @returns the new emitter
  14012. */
  14013. clone(): HemisphericParticleEmitter;
  14014. /**
  14015. * Called by the GPUParticleSystem to setup the update shader
  14016. * @param effect defines the update shader
  14017. */
  14018. applyToShader(effect: Effect): void;
  14019. /**
  14020. * Returns a string to use to update the GPU particles update shader
  14021. * @returns a string containng the defines string
  14022. */
  14023. getEffectDefines(): string;
  14024. /**
  14025. * Returns the string "HemisphericParticleEmitter"
  14026. * @returns a string containing the class name
  14027. */
  14028. getClassName(): string;
  14029. /**
  14030. * Serializes the particle system to a JSON object.
  14031. * @returns the JSON object
  14032. */
  14033. serialize(): any;
  14034. /**
  14035. * Parse properties from a JSON object
  14036. * @param serializationObject defines the JSON object
  14037. */
  14038. parse(serializationObject: any): void;
  14039. }
  14040. }
  14041. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14042. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14043. import { Effect } from "babylonjs/Materials/effect";
  14044. import { Particle } from "babylonjs/Particles/particle";
  14045. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14046. /**
  14047. * Particle emitter emitting particles from a point.
  14048. * It emits the particles randomly between 2 given directions.
  14049. */
  14050. export class PointParticleEmitter implements IParticleEmitterType {
  14051. /**
  14052. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14053. */
  14054. direction1: Vector3;
  14055. /**
  14056. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14057. */
  14058. direction2: Vector3;
  14059. /**
  14060. * Creates a new instance PointParticleEmitter
  14061. */
  14062. constructor();
  14063. /**
  14064. * Called by the particle System when the direction is computed for the created particle.
  14065. * @param worldMatrix is the world matrix of the particle system
  14066. * @param directionToUpdate is the direction vector to update with the result
  14067. * @param particle is the particle we are computed the direction for
  14068. * @param isLocal defines if the direction should be set in local space
  14069. */
  14070. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14071. /**
  14072. * Called by the particle System when the position is computed for the created particle.
  14073. * @param worldMatrix is the world matrix of the particle system
  14074. * @param positionToUpdate is the position vector to update with the result
  14075. * @param particle is the particle we are computed the position for
  14076. * @param isLocal defines if the position should be set in local space
  14077. */
  14078. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14079. /**
  14080. * Clones the current emitter and returns a copy of it
  14081. * @returns the new emitter
  14082. */
  14083. clone(): PointParticleEmitter;
  14084. /**
  14085. * Called by the GPUParticleSystem to setup the update shader
  14086. * @param effect defines the update shader
  14087. */
  14088. applyToShader(effect: Effect): void;
  14089. /**
  14090. * Returns a string to use to update the GPU particles update shader
  14091. * @returns a string containng the defines string
  14092. */
  14093. getEffectDefines(): string;
  14094. /**
  14095. * Returns the string "PointParticleEmitter"
  14096. * @returns a string containing the class name
  14097. */
  14098. getClassName(): string;
  14099. /**
  14100. * Serializes the particle system to a JSON object.
  14101. * @returns the JSON object
  14102. */
  14103. serialize(): any;
  14104. /**
  14105. * Parse properties from a JSON object
  14106. * @param serializationObject defines the JSON object
  14107. */
  14108. parse(serializationObject: any): void;
  14109. }
  14110. }
  14111. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14112. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14113. import { Effect } from "babylonjs/Materials/effect";
  14114. import { Particle } from "babylonjs/Particles/particle";
  14115. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14116. /**
  14117. * Particle emitter emitting particles from the inside of a sphere.
  14118. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14119. */
  14120. export class SphereParticleEmitter implements IParticleEmitterType {
  14121. /**
  14122. * The radius of the emission sphere.
  14123. */
  14124. radius: number;
  14125. /**
  14126. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14127. */
  14128. radiusRange: number;
  14129. /**
  14130. * How much to randomize the particle direction [0-1].
  14131. */
  14132. directionRandomizer: number;
  14133. /**
  14134. * Creates a new instance SphereParticleEmitter
  14135. * @param radius the radius of the emission sphere (1 by default)
  14136. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14137. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14138. */
  14139. constructor(
  14140. /**
  14141. * The radius of the emission sphere.
  14142. */
  14143. radius?: number,
  14144. /**
  14145. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14146. */
  14147. radiusRange?: number,
  14148. /**
  14149. * How much to randomize the particle direction [0-1].
  14150. */
  14151. directionRandomizer?: number);
  14152. /**
  14153. * Called by the particle System when the direction is computed for the created particle.
  14154. * @param worldMatrix is the world matrix of the particle system
  14155. * @param directionToUpdate is the direction vector to update with the result
  14156. * @param particle is the particle we are computed the direction for
  14157. * @param isLocal defines if the direction should be set in local space
  14158. */
  14159. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14160. /**
  14161. * Called by the particle System when the position is computed for the created particle.
  14162. * @param worldMatrix is the world matrix of the particle system
  14163. * @param positionToUpdate is the position vector to update with the result
  14164. * @param particle is the particle we are computed the position for
  14165. * @param isLocal defines if the position should be set in local space
  14166. */
  14167. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14168. /**
  14169. * Clones the current emitter and returns a copy of it
  14170. * @returns the new emitter
  14171. */
  14172. clone(): SphereParticleEmitter;
  14173. /**
  14174. * Called by the GPUParticleSystem to setup the update shader
  14175. * @param effect defines the update shader
  14176. */
  14177. applyToShader(effect: Effect): void;
  14178. /**
  14179. * Returns a string to use to update the GPU particles update shader
  14180. * @returns a string containng the defines string
  14181. */
  14182. getEffectDefines(): string;
  14183. /**
  14184. * Returns the string "SphereParticleEmitter"
  14185. * @returns a string containing the class name
  14186. */
  14187. getClassName(): string;
  14188. /**
  14189. * Serializes the particle system to a JSON object.
  14190. * @returns the JSON object
  14191. */
  14192. serialize(): any;
  14193. /**
  14194. * Parse properties from a JSON object
  14195. * @param serializationObject defines the JSON object
  14196. */
  14197. parse(serializationObject: any): void;
  14198. }
  14199. /**
  14200. * Particle emitter emitting particles from the inside of a sphere.
  14201. * It emits the particles randomly between two vectors.
  14202. */
  14203. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14204. /**
  14205. * The min limit of the emission direction.
  14206. */
  14207. direction1: Vector3;
  14208. /**
  14209. * The max limit of the emission direction.
  14210. */
  14211. direction2: Vector3;
  14212. /**
  14213. * Creates a new instance SphereDirectedParticleEmitter
  14214. * @param radius the radius of the emission sphere (1 by default)
  14215. * @param direction1 the min limit of the emission direction (up vector by default)
  14216. * @param direction2 the max limit of the emission direction (up vector by default)
  14217. */
  14218. constructor(radius?: number,
  14219. /**
  14220. * The min limit of the emission direction.
  14221. */
  14222. direction1?: Vector3,
  14223. /**
  14224. * The max limit of the emission direction.
  14225. */
  14226. direction2?: Vector3);
  14227. /**
  14228. * Called by the particle System when the direction is computed for the created particle.
  14229. * @param worldMatrix is the world matrix of the particle system
  14230. * @param directionToUpdate is the direction vector to update with the result
  14231. * @param particle is the particle we are computed the direction for
  14232. */
  14233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14234. /**
  14235. * Clones the current emitter and returns a copy of it
  14236. * @returns the new emitter
  14237. */
  14238. clone(): SphereDirectedParticleEmitter;
  14239. /**
  14240. * Called by the GPUParticleSystem to setup the update shader
  14241. * @param effect defines the update shader
  14242. */
  14243. applyToShader(effect: Effect): void;
  14244. /**
  14245. * Returns a string to use to update the GPU particles update shader
  14246. * @returns a string containng the defines string
  14247. */
  14248. getEffectDefines(): string;
  14249. /**
  14250. * Returns the string "SphereDirectedParticleEmitter"
  14251. * @returns a string containing the class name
  14252. */
  14253. getClassName(): string;
  14254. /**
  14255. * Serializes the particle system to a JSON object.
  14256. * @returns the JSON object
  14257. */
  14258. serialize(): any;
  14259. /**
  14260. * Parse properties from a JSON object
  14261. * @param serializationObject defines the JSON object
  14262. */
  14263. parse(serializationObject: any): void;
  14264. }
  14265. }
  14266. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14267. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14268. import { Effect } from "babylonjs/Materials/effect";
  14269. import { Particle } from "babylonjs/Particles/particle";
  14270. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14271. import { Nullable } from "babylonjs/types";
  14272. /**
  14273. * Particle emitter emitting particles from a custom list of positions.
  14274. */
  14275. export class CustomParticleEmitter implements IParticleEmitterType {
  14276. /**
  14277. * Gets or sets the position generator that will create the inital position of each particle.
  14278. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14279. */
  14280. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14281. /**
  14282. * Gets or sets the destination generator that will create the final destination of each particle.
  14283. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14284. */
  14285. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14286. /**
  14287. * Creates a new instance CustomParticleEmitter
  14288. */
  14289. constructor();
  14290. /**
  14291. * Called by the particle System when the direction is computed for the created particle.
  14292. * @param worldMatrix is the world matrix of the particle system
  14293. * @param directionToUpdate is the direction vector to update with the result
  14294. * @param particle is the particle we are computed the direction for
  14295. * @param isLocal defines if the direction should be set in local space
  14296. */
  14297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14298. /**
  14299. * Called by the particle System when the position is computed for the created particle.
  14300. * @param worldMatrix is the world matrix of the particle system
  14301. * @param positionToUpdate is the position vector to update with the result
  14302. * @param particle is the particle we are computed the position for
  14303. * @param isLocal defines if the position should be set in local space
  14304. */
  14305. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14306. /**
  14307. * Clones the current emitter and returns a copy of it
  14308. * @returns the new emitter
  14309. */
  14310. clone(): CustomParticleEmitter;
  14311. /**
  14312. * Called by the GPUParticleSystem to setup the update shader
  14313. * @param effect defines the update shader
  14314. */
  14315. applyToShader(effect: Effect): void;
  14316. /**
  14317. * Returns a string to use to update the GPU particles update shader
  14318. * @returns a string containng the defines string
  14319. */
  14320. getEffectDefines(): string;
  14321. /**
  14322. * Returns the string "PointParticleEmitter"
  14323. * @returns a string containing the class name
  14324. */
  14325. getClassName(): string;
  14326. /**
  14327. * Serializes the particle system to a JSON object.
  14328. * @returns the JSON object
  14329. */
  14330. serialize(): any;
  14331. /**
  14332. * Parse properties from a JSON object
  14333. * @param serializationObject defines the JSON object
  14334. */
  14335. parse(serializationObject: any): void;
  14336. }
  14337. }
  14338. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14339. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14340. import { Effect } from "babylonjs/Materials/effect";
  14341. import { Particle } from "babylonjs/Particles/particle";
  14342. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14343. import { Nullable } from "babylonjs/types";
  14344. import { Scene } from "babylonjs/scene";
  14345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14346. /**
  14347. * Particle emitter emitting particles from the inside of a box.
  14348. * It emits the particles randomly between 2 given directions.
  14349. */
  14350. export class MeshParticleEmitter implements IParticleEmitterType {
  14351. private _indices;
  14352. private _positions;
  14353. private _normals;
  14354. private _storedNormal;
  14355. private _mesh;
  14356. /**
  14357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14358. */
  14359. direction1: Vector3;
  14360. /**
  14361. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14362. */
  14363. direction2: Vector3;
  14364. /**
  14365. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14366. */
  14367. useMeshNormalsForDirection: boolean;
  14368. /** Defines the mesh to use as source */
  14369. get mesh(): Nullable<AbstractMesh>;
  14370. set mesh(value: Nullable<AbstractMesh>);
  14371. /**
  14372. * Creates a new instance MeshParticleEmitter
  14373. * @param mesh defines the mesh to use as source
  14374. */
  14375. constructor(mesh?: Nullable<AbstractMesh>);
  14376. /**
  14377. * Called by the particle System when the direction is computed for the created particle.
  14378. * @param worldMatrix is the world matrix of the particle system
  14379. * @param directionToUpdate is the direction vector to update with the result
  14380. * @param particle is the particle we are computed the direction for
  14381. * @param isLocal defines if the direction should be set in local space
  14382. */
  14383. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14384. /**
  14385. * Called by the particle System when the position is computed for the created particle.
  14386. * @param worldMatrix is the world matrix of the particle system
  14387. * @param positionToUpdate is the position vector to update with the result
  14388. * @param particle is the particle we are computed the position for
  14389. * @param isLocal defines if the position should be set in local space
  14390. */
  14391. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14392. /**
  14393. * Clones the current emitter and returns a copy of it
  14394. * @returns the new emitter
  14395. */
  14396. clone(): MeshParticleEmitter;
  14397. /**
  14398. * Called by the GPUParticleSystem to setup the update shader
  14399. * @param effect defines the update shader
  14400. */
  14401. applyToShader(effect: Effect): void;
  14402. /**
  14403. * Returns a string to use to update the GPU particles update shader
  14404. * @returns a string containng the defines string
  14405. */
  14406. getEffectDefines(): string;
  14407. /**
  14408. * Returns the string "BoxParticleEmitter"
  14409. * @returns a string containing the class name
  14410. */
  14411. getClassName(): string;
  14412. /**
  14413. * Serializes the particle system to a JSON object.
  14414. * @returns the JSON object
  14415. */
  14416. serialize(): any;
  14417. /**
  14418. * Parse properties from a JSON object
  14419. * @param serializationObject defines the JSON object
  14420. * @param scene defines the hosting scene
  14421. */
  14422. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14423. }
  14424. }
  14425. declare module "babylonjs/Particles/EmitterTypes/index" {
  14426. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14427. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14428. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14429. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14430. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14431. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14432. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14433. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14434. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14435. }
  14436. declare module "babylonjs/Particles/IParticleSystem" {
  14437. import { Nullable } from "babylonjs/types";
  14438. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14439. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14440. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14441. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14442. import { Scene } from "babylonjs/scene";
  14443. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14444. import { Effect } from "babylonjs/Materials/effect";
  14445. import { Observable } from "babylonjs/Misc/observable";
  14446. import { Animation } from "babylonjs/Animations/animation";
  14447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14448. /**
  14449. * Interface representing a particle system in Babylon.js.
  14450. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14451. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14452. */
  14453. export interface IParticleSystem {
  14454. /**
  14455. * List of animations used by the particle system.
  14456. */
  14457. animations: Animation[];
  14458. /**
  14459. * The id of the Particle system.
  14460. */
  14461. id: string;
  14462. /**
  14463. * The name of the Particle system.
  14464. */
  14465. name: string;
  14466. /**
  14467. * The emitter represents the Mesh or position we are attaching the particle system to.
  14468. */
  14469. emitter: Nullable<AbstractMesh | Vector3>;
  14470. /**
  14471. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14472. */
  14473. isBillboardBased: boolean;
  14474. /**
  14475. * The rendering group used by the Particle system to chose when to render.
  14476. */
  14477. renderingGroupId: number;
  14478. /**
  14479. * The layer mask we are rendering the particles through.
  14480. */
  14481. layerMask: number;
  14482. /**
  14483. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14484. */
  14485. updateSpeed: number;
  14486. /**
  14487. * The amount of time the particle system is running (depends of the overall update speed).
  14488. */
  14489. targetStopDuration: number;
  14490. /**
  14491. * The texture used to render each particle. (this can be a spritesheet)
  14492. */
  14493. particleTexture: Nullable<BaseTexture>;
  14494. /**
  14495. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14496. */
  14497. blendMode: number;
  14498. /**
  14499. * Minimum life time of emitting particles.
  14500. */
  14501. minLifeTime: number;
  14502. /**
  14503. * Maximum life time of emitting particles.
  14504. */
  14505. maxLifeTime: number;
  14506. /**
  14507. * Minimum Size of emitting particles.
  14508. */
  14509. minSize: number;
  14510. /**
  14511. * Maximum Size of emitting particles.
  14512. */
  14513. maxSize: number;
  14514. /**
  14515. * Minimum scale of emitting particles on X axis.
  14516. */
  14517. minScaleX: number;
  14518. /**
  14519. * Maximum scale of emitting particles on X axis.
  14520. */
  14521. maxScaleX: number;
  14522. /**
  14523. * Minimum scale of emitting particles on Y axis.
  14524. */
  14525. minScaleY: number;
  14526. /**
  14527. * Maximum scale of emitting particles on Y axis.
  14528. */
  14529. maxScaleY: number;
  14530. /**
  14531. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14532. */
  14533. color1: Color4;
  14534. /**
  14535. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14536. */
  14537. color2: Color4;
  14538. /**
  14539. * Color the particle will have at the end of its lifetime.
  14540. */
  14541. colorDead: Color4;
  14542. /**
  14543. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14544. */
  14545. emitRate: number;
  14546. /**
  14547. * You can use gravity if you want to give an orientation to your particles.
  14548. */
  14549. gravity: Vector3;
  14550. /**
  14551. * Minimum power of emitting particles.
  14552. */
  14553. minEmitPower: number;
  14554. /**
  14555. * Maximum power of emitting particles.
  14556. */
  14557. maxEmitPower: number;
  14558. /**
  14559. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14560. */
  14561. minAngularSpeed: number;
  14562. /**
  14563. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14564. */
  14565. maxAngularSpeed: number;
  14566. /**
  14567. * Gets or sets the minimal initial rotation in radians.
  14568. */
  14569. minInitialRotation: number;
  14570. /**
  14571. * Gets or sets the maximal initial rotation in radians.
  14572. */
  14573. maxInitialRotation: number;
  14574. /**
  14575. * The particle emitter type defines the emitter used by the particle system.
  14576. * It can be for example box, sphere, or cone...
  14577. */
  14578. particleEmitterType: Nullable<IParticleEmitterType>;
  14579. /**
  14580. * Defines the delay in milliseconds before starting the system (0 by default)
  14581. */
  14582. startDelay: number;
  14583. /**
  14584. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14585. */
  14586. preWarmCycles: number;
  14587. /**
  14588. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14589. */
  14590. preWarmStepOffset: number;
  14591. /**
  14592. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14593. */
  14594. spriteCellChangeSpeed: number;
  14595. /**
  14596. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14597. */
  14598. startSpriteCellID: number;
  14599. /**
  14600. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14601. */
  14602. endSpriteCellID: number;
  14603. /**
  14604. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14605. */
  14606. spriteCellWidth: number;
  14607. /**
  14608. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14609. */
  14610. spriteCellHeight: number;
  14611. /**
  14612. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14613. */
  14614. spriteRandomStartCell: boolean;
  14615. /**
  14616. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14617. */
  14618. isAnimationSheetEnabled: boolean;
  14619. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14620. translationPivot: Vector2;
  14621. /**
  14622. * Gets or sets a texture used to add random noise to particle positions
  14623. */
  14624. noiseTexture: Nullable<BaseTexture>;
  14625. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14626. noiseStrength: Vector3;
  14627. /**
  14628. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14629. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14630. */
  14631. billboardMode: number;
  14632. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14633. limitVelocityDamping: number;
  14634. /**
  14635. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14636. */
  14637. beginAnimationOnStart: boolean;
  14638. /**
  14639. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14640. */
  14641. beginAnimationFrom: number;
  14642. /**
  14643. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14644. */
  14645. beginAnimationTo: number;
  14646. /**
  14647. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14648. */
  14649. beginAnimationLoop: boolean;
  14650. /**
  14651. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14652. */
  14653. disposeOnStop: boolean;
  14654. /**
  14655. * Specifies if the particles are updated in emitter local space or world space
  14656. */
  14657. isLocal: boolean;
  14658. /** Snippet ID if the particle system was created from the snippet server */
  14659. snippetId: string;
  14660. /** Gets or sets a matrix to use to compute projection */
  14661. defaultProjectionMatrix: Matrix;
  14662. /**
  14663. * Gets the maximum number of particles active at the same time.
  14664. * @returns The max number of active particles.
  14665. */
  14666. getCapacity(): number;
  14667. /**
  14668. * Gets the number of particles active at the same time.
  14669. * @returns The number of active particles.
  14670. */
  14671. getActiveCount(): number;
  14672. /**
  14673. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14674. * @returns True if it has been started, otherwise false.
  14675. */
  14676. isStarted(): boolean;
  14677. /**
  14678. * Animates the particle system for this frame.
  14679. */
  14680. animate(): void;
  14681. /**
  14682. * Renders the particle system in its current state.
  14683. * @returns the current number of particles
  14684. */
  14685. render(): number;
  14686. /**
  14687. * Dispose the particle system and frees its associated resources.
  14688. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14689. */
  14690. dispose(disposeTexture?: boolean): void;
  14691. /**
  14692. * An event triggered when the system is disposed
  14693. */
  14694. onDisposeObservable: Observable<IParticleSystem>;
  14695. /**
  14696. * An event triggered when the system is stopped
  14697. */
  14698. onStoppedObservable: Observable<IParticleSystem>;
  14699. /**
  14700. * Clones the particle system.
  14701. * @param name The name of the cloned object
  14702. * @param newEmitter The new emitter to use
  14703. * @returns the cloned particle system
  14704. */
  14705. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14706. /**
  14707. * Serializes the particle system to a JSON object
  14708. * @param serializeTexture defines if the texture must be serialized as well
  14709. * @returns the JSON object
  14710. */
  14711. serialize(serializeTexture: boolean): any;
  14712. /**
  14713. * Rebuild the particle system
  14714. */
  14715. rebuild(): void;
  14716. /** Force the system to rebuild all gradients that need to be resync */
  14717. forceRefreshGradients(): void;
  14718. /**
  14719. * Starts the particle system and begins to emit
  14720. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14721. */
  14722. start(delay?: number): void;
  14723. /**
  14724. * Stops the particle system.
  14725. */
  14726. stop(): void;
  14727. /**
  14728. * Remove all active particles
  14729. */
  14730. reset(): void;
  14731. /**
  14732. * Gets a boolean indicating that the system is stopping
  14733. * @returns true if the system is currently stopping
  14734. */
  14735. isStopping(): boolean;
  14736. /**
  14737. * Is this system ready to be used/rendered
  14738. * @return true if the system is ready
  14739. */
  14740. isReady(): boolean;
  14741. /**
  14742. * Returns the string "ParticleSystem"
  14743. * @returns a string containing the class name
  14744. */
  14745. getClassName(): string;
  14746. /**
  14747. * Gets the custom effect used to render the particles
  14748. * @param blendMode Blend mode for which the effect should be retrieved
  14749. * @returns The effect
  14750. */
  14751. getCustomEffect(blendMode: number): Nullable<Effect>;
  14752. /**
  14753. * Sets the custom effect used to render the particles
  14754. * @param effect The effect to set
  14755. * @param blendMode Blend mode for which the effect should be set
  14756. */
  14757. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14758. /**
  14759. * Fill the defines array according to the current settings of the particle system
  14760. * @param defines Array to be updated
  14761. * @param blendMode blend mode to take into account when updating the array
  14762. */
  14763. fillDefines(defines: Array<string>, blendMode: number): void;
  14764. /**
  14765. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14766. * @param uniforms Uniforms array to fill
  14767. * @param attributes Attributes array to fill
  14768. * @param samplers Samplers array to fill
  14769. */
  14770. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14771. /**
  14772. * Observable that will be called just before the particles are drawn
  14773. */
  14774. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14775. /**
  14776. * Gets the name of the particle vertex shader
  14777. */
  14778. vertexShaderName: string;
  14779. /**
  14780. * Adds a new color gradient
  14781. * @param gradient defines the gradient to use (between 0 and 1)
  14782. * @param color1 defines the color to affect to the specified gradient
  14783. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14784. * @returns the current particle system
  14785. */
  14786. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14787. /**
  14788. * Remove a specific color gradient
  14789. * @param gradient defines the gradient to remove
  14790. * @returns the current particle system
  14791. */
  14792. removeColorGradient(gradient: number): IParticleSystem;
  14793. /**
  14794. * Adds a new size gradient
  14795. * @param gradient defines the gradient to use (between 0 and 1)
  14796. * @param factor defines the size factor to affect to the specified gradient
  14797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14798. * @returns the current particle system
  14799. */
  14800. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14801. /**
  14802. * Remove a specific size gradient
  14803. * @param gradient defines the gradient to remove
  14804. * @returns the current particle system
  14805. */
  14806. removeSizeGradient(gradient: number): IParticleSystem;
  14807. /**
  14808. * Gets the current list of color gradients.
  14809. * You must use addColorGradient and removeColorGradient to udpate this list
  14810. * @returns the list of color gradients
  14811. */
  14812. getColorGradients(): Nullable<Array<ColorGradient>>;
  14813. /**
  14814. * Gets the current list of size gradients.
  14815. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14816. * @returns the list of size gradients
  14817. */
  14818. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14819. /**
  14820. * Gets the current list of angular speed gradients.
  14821. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14822. * @returns the list of angular speed gradients
  14823. */
  14824. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14825. /**
  14826. * Adds a new angular speed gradient
  14827. * @param gradient defines the gradient to use (between 0 and 1)
  14828. * @param factor defines the angular speed to affect to the specified gradient
  14829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14830. * @returns the current particle system
  14831. */
  14832. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14833. /**
  14834. * Remove a specific angular speed gradient
  14835. * @param gradient defines the gradient to remove
  14836. * @returns the current particle system
  14837. */
  14838. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14839. /**
  14840. * Gets the current list of velocity gradients.
  14841. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14842. * @returns the list of velocity gradients
  14843. */
  14844. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14845. /**
  14846. * Adds a new velocity gradient
  14847. * @param gradient defines the gradient to use (between 0 and 1)
  14848. * @param factor defines the velocity to affect to the specified gradient
  14849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14850. * @returns the current particle system
  14851. */
  14852. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14853. /**
  14854. * Remove a specific velocity gradient
  14855. * @param gradient defines the gradient to remove
  14856. * @returns the current particle system
  14857. */
  14858. removeVelocityGradient(gradient: number): IParticleSystem;
  14859. /**
  14860. * Gets the current list of limit velocity gradients.
  14861. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14862. * @returns the list of limit velocity gradients
  14863. */
  14864. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14865. /**
  14866. * Adds a new limit velocity gradient
  14867. * @param gradient defines the gradient to use (between 0 and 1)
  14868. * @param factor defines the limit velocity to affect to the specified gradient
  14869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14870. * @returns the current particle system
  14871. */
  14872. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14873. /**
  14874. * Remove a specific limit velocity gradient
  14875. * @param gradient defines the gradient to remove
  14876. * @returns the current particle system
  14877. */
  14878. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14879. /**
  14880. * Adds a new drag gradient
  14881. * @param gradient defines the gradient to use (between 0 and 1)
  14882. * @param factor defines the drag to affect to the specified gradient
  14883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14884. * @returns the current particle system
  14885. */
  14886. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14887. /**
  14888. * Remove a specific drag gradient
  14889. * @param gradient defines the gradient to remove
  14890. * @returns the current particle system
  14891. */
  14892. removeDragGradient(gradient: number): IParticleSystem;
  14893. /**
  14894. * Gets the current list of drag gradients.
  14895. * You must use addDragGradient and removeDragGradient to udpate this list
  14896. * @returns the list of drag gradients
  14897. */
  14898. getDragGradients(): Nullable<Array<FactorGradient>>;
  14899. /**
  14900. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14901. * @param gradient defines the gradient to use (between 0 and 1)
  14902. * @param factor defines the emit rate to affect to the specified gradient
  14903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14904. * @returns the current particle system
  14905. */
  14906. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14907. /**
  14908. * Remove a specific emit rate gradient
  14909. * @param gradient defines the gradient to remove
  14910. * @returns the current particle system
  14911. */
  14912. removeEmitRateGradient(gradient: number): IParticleSystem;
  14913. /**
  14914. * Gets the current list of emit rate gradients.
  14915. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14916. * @returns the list of emit rate gradients
  14917. */
  14918. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14919. /**
  14920. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14921. * @param gradient defines the gradient to use (between 0 and 1)
  14922. * @param factor defines the start size to affect to the specified gradient
  14923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14924. * @returns the current particle system
  14925. */
  14926. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14927. /**
  14928. * Remove a specific start size gradient
  14929. * @param gradient defines the gradient to remove
  14930. * @returns the current particle system
  14931. */
  14932. removeStartSizeGradient(gradient: number): IParticleSystem;
  14933. /**
  14934. * Gets the current list of start size gradients.
  14935. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14936. * @returns the list of start size gradients
  14937. */
  14938. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14939. /**
  14940. * Adds a new life time gradient
  14941. * @param gradient defines the gradient to use (between 0 and 1)
  14942. * @param factor defines the life time factor to affect to the specified gradient
  14943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14944. * @returns the current particle system
  14945. */
  14946. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14947. /**
  14948. * Remove a specific life time gradient
  14949. * @param gradient defines the gradient to remove
  14950. * @returns the current particle system
  14951. */
  14952. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14953. /**
  14954. * Gets the current list of life time gradients.
  14955. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14956. * @returns the list of life time gradients
  14957. */
  14958. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14959. /**
  14960. * Gets the current list of color gradients.
  14961. * You must use addColorGradient and removeColorGradient to udpate this list
  14962. * @returns the list of color gradients
  14963. */
  14964. getColorGradients(): Nullable<Array<ColorGradient>>;
  14965. /**
  14966. * Adds a new ramp gradient used to remap particle colors
  14967. * @param gradient defines the gradient to use (between 0 and 1)
  14968. * @param color defines the color to affect to the specified gradient
  14969. * @returns the current particle system
  14970. */
  14971. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14972. /**
  14973. * Gets the current list of ramp gradients.
  14974. * You must use addRampGradient and removeRampGradient to udpate this list
  14975. * @returns the list of ramp gradients
  14976. */
  14977. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14978. /** Gets or sets a boolean indicating that ramp gradients must be used
  14979. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14980. */
  14981. useRampGradients: boolean;
  14982. /**
  14983. * Adds a new color remap gradient
  14984. * @param gradient defines the gradient to use (between 0 and 1)
  14985. * @param min defines the color remap minimal range
  14986. * @param max defines the color remap maximal range
  14987. * @returns the current particle system
  14988. */
  14989. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14990. /**
  14991. * Gets the current list of color remap gradients.
  14992. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14993. * @returns the list of color remap gradients
  14994. */
  14995. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14996. /**
  14997. * Adds a new alpha remap gradient
  14998. * @param gradient defines the gradient to use (between 0 and 1)
  14999. * @param min defines the alpha remap minimal range
  15000. * @param max defines the alpha remap maximal range
  15001. * @returns the current particle system
  15002. */
  15003. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15004. /**
  15005. * Gets the current list of alpha remap gradients.
  15006. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15007. * @returns the list of alpha remap gradients
  15008. */
  15009. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15010. /**
  15011. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15012. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15013. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15014. * @returns the emitter
  15015. */
  15016. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15017. /**
  15018. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15019. * @param radius The radius of the hemisphere to emit from
  15020. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15021. * @returns the emitter
  15022. */
  15023. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15024. /**
  15025. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15026. * @param radius The radius of the sphere to emit from
  15027. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15028. * @returns the emitter
  15029. */
  15030. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15031. /**
  15032. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15033. * @param radius The radius of the sphere to emit from
  15034. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15035. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15036. * @returns the emitter
  15037. */
  15038. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15039. /**
  15040. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15041. * @param radius The radius of the emission cylinder
  15042. * @param height The height of the emission cylinder
  15043. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15044. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15045. * @returns the emitter
  15046. */
  15047. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15048. /**
  15049. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15050. * @param radius The radius of the cylinder to emit from
  15051. * @param height The height of the emission cylinder
  15052. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15053. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15054. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15055. * @returns the emitter
  15056. */
  15057. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15058. /**
  15059. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15060. * @param radius The radius of the cone to emit from
  15061. * @param angle The base angle of the cone
  15062. * @returns the emitter
  15063. */
  15064. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15065. /**
  15066. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15067. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15068. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15069. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15070. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15071. * @returns the emitter
  15072. */
  15073. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15074. /**
  15075. * Get hosting scene
  15076. * @returns the scene
  15077. */
  15078. getScene(): Nullable<Scene>;
  15079. }
  15080. }
  15081. declare module "babylonjs/Meshes/transformNode" {
  15082. import { DeepImmutable } from "babylonjs/types";
  15083. import { Observable } from "babylonjs/Misc/observable";
  15084. import { Nullable } from "babylonjs/types";
  15085. import { Camera } from "babylonjs/Cameras/camera";
  15086. import { Scene } from "babylonjs/scene";
  15087. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15088. import { Node } from "babylonjs/node";
  15089. import { Bone } from "babylonjs/Bones/bone";
  15090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15091. import { Space } from "babylonjs/Maths/math.axis";
  15092. /**
  15093. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  15094. * @see https://doc.babylonjs.com/how_to/transformnode
  15095. */
  15096. export class TransformNode extends Node {
  15097. /**
  15098. * Object will not rotate to face the camera
  15099. */
  15100. static BILLBOARDMODE_NONE: number;
  15101. /**
  15102. * Object will rotate to face the camera but only on the x axis
  15103. */
  15104. static BILLBOARDMODE_X: number;
  15105. /**
  15106. * Object will rotate to face the camera but only on the y axis
  15107. */
  15108. static BILLBOARDMODE_Y: number;
  15109. /**
  15110. * Object will rotate to face the camera but only on the z axis
  15111. */
  15112. static BILLBOARDMODE_Z: number;
  15113. /**
  15114. * Object will rotate to face the camera
  15115. */
  15116. static BILLBOARDMODE_ALL: number;
  15117. /**
  15118. * Object will rotate to face the camera's position instead of orientation
  15119. */
  15120. static BILLBOARDMODE_USE_POSITION: number;
  15121. private static _TmpRotation;
  15122. private static _TmpScaling;
  15123. private static _TmpTranslation;
  15124. private _forward;
  15125. private _forwardInverted;
  15126. private _up;
  15127. private _right;
  15128. private _rightInverted;
  15129. private _position;
  15130. private _rotation;
  15131. private _rotationQuaternion;
  15132. protected _scaling: Vector3;
  15133. protected _isDirty: boolean;
  15134. private _transformToBoneReferal;
  15135. private _isAbsoluteSynced;
  15136. private _billboardMode;
  15137. /**
  15138. * Gets or sets the billboard mode. Default is 0.
  15139. *
  15140. * | Value | Type | Description |
  15141. * | --- | --- | --- |
  15142. * | 0 | BILLBOARDMODE_NONE | |
  15143. * | 1 | BILLBOARDMODE_X | |
  15144. * | 2 | BILLBOARDMODE_Y | |
  15145. * | 4 | BILLBOARDMODE_Z | |
  15146. * | 7 | BILLBOARDMODE_ALL | |
  15147. *
  15148. */
  15149. get billboardMode(): number;
  15150. set billboardMode(value: number);
  15151. private _preserveParentRotationForBillboard;
  15152. /**
  15153. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15154. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15155. */
  15156. get preserveParentRotationForBillboard(): boolean;
  15157. set preserveParentRotationForBillboard(value: boolean);
  15158. /**
  15159. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  15160. */
  15161. scalingDeterminant: number;
  15162. private _infiniteDistance;
  15163. /**
  15164. * Gets or sets the distance of the object to max, often used by skybox
  15165. */
  15166. get infiniteDistance(): boolean;
  15167. set infiniteDistance(value: boolean);
  15168. /**
  15169. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15170. * By default the system will update normals to compensate
  15171. */
  15172. ignoreNonUniformScaling: boolean;
  15173. /**
  15174. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  15175. */
  15176. reIntegrateRotationIntoRotationQuaternion: boolean;
  15177. /** @hidden */
  15178. _poseMatrix: Nullable<Matrix>;
  15179. /** @hidden */
  15180. _localMatrix: Matrix;
  15181. private _usePivotMatrix;
  15182. private _absolutePosition;
  15183. private _absoluteScaling;
  15184. private _absoluteRotationQuaternion;
  15185. private _pivotMatrix;
  15186. private _pivotMatrixInverse;
  15187. /** @hidden */
  15188. _postMultiplyPivotMatrix: boolean;
  15189. protected _isWorldMatrixFrozen: boolean;
  15190. /** @hidden */
  15191. _indexInSceneTransformNodesArray: number;
  15192. /**
  15193. * An event triggered after the world matrix is updated
  15194. */
  15195. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15196. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15197. /**
  15198. * Gets a string identifying the name of the class
  15199. * @returns "TransformNode" string
  15200. */
  15201. getClassName(): string;
  15202. /**
  15203. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15204. */
  15205. get position(): Vector3;
  15206. set position(newPosition: Vector3);
  15207. /**
  15208. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  15209. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15210. */
  15211. get rotation(): Vector3;
  15212. set rotation(newRotation: Vector3);
  15213. /**
  15214. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  15215. */
  15216. get scaling(): Vector3;
  15217. set scaling(newScaling: Vector3);
  15218. /**
  15219. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  15220. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15221. */
  15222. get rotationQuaternion(): Nullable<Quaternion>;
  15223. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15224. /**
  15225. * The forward direction of that transform in world space.
  15226. */
  15227. get forward(): Vector3;
  15228. /**
  15229. * The up direction of that transform in world space.
  15230. */
  15231. get up(): Vector3;
  15232. /**
  15233. * The right direction of that transform in world space.
  15234. */
  15235. get right(): Vector3;
  15236. /**
  15237. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15238. * @param matrix the matrix to copy the pose from
  15239. * @returns this TransformNode.
  15240. */
  15241. updatePoseMatrix(matrix: Matrix): TransformNode;
  15242. /**
  15243. * Returns the mesh Pose matrix.
  15244. * @returns the pose matrix
  15245. */
  15246. getPoseMatrix(): Matrix;
  15247. /** @hidden */
  15248. _isSynchronized(): boolean;
  15249. /** @hidden */
  15250. _initCache(): void;
  15251. /**
  15252. * Flag the transform node as dirty (Forcing it to update everything)
  15253. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15254. * @returns this transform node
  15255. */
  15256. markAsDirty(property: string): TransformNode;
  15257. /**
  15258. * Returns the current mesh absolute position.
  15259. * Returns a Vector3.
  15260. */
  15261. get absolutePosition(): Vector3;
  15262. /**
  15263. * Returns the current mesh absolute scaling.
  15264. * Returns a Vector3.
  15265. */
  15266. get absoluteScaling(): Vector3;
  15267. /**
  15268. * Returns the current mesh absolute rotation.
  15269. * Returns a Quaternion.
  15270. */
  15271. get absoluteRotationQuaternion(): Quaternion;
  15272. /**
  15273. * Sets a new matrix to apply before all other transformation
  15274. * @param matrix defines the transform matrix
  15275. * @returns the current TransformNode
  15276. */
  15277. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15278. /**
  15279. * Sets a new pivot matrix to the current node
  15280. * @param matrix defines the new pivot matrix to use
  15281. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  15282. * @returns the current TransformNode
  15283. */
  15284. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15285. /**
  15286. * Returns the mesh pivot matrix.
  15287. * Default : Identity.
  15288. * @returns the matrix
  15289. */
  15290. getPivotMatrix(): Matrix;
  15291. /**
  15292. * Instantiate (when possible) or clone that node with its hierarchy
  15293. * @param newParent defines the new parent to use for the instance (or clone)
  15294. * @param options defines options to configure how copy is done
  15295. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15296. * @returns an instance (or a clone) of the current node with its hiearchy
  15297. */
  15298. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15299. doNotInstantiate: boolean;
  15300. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15301. /**
  15302. * Prevents the World matrix to be computed any longer
  15303. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15304. * @returns the TransformNode.
  15305. */
  15306. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15307. /**
  15308. * Allows back the World matrix computation.
  15309. * @returns the TransformNode.
  15310. */
  15311. unfreezeWorldMatrix(): this;
  15312. /**
  15313. * True if the World matrix has been frozen.
  15314. */
  15315. get isWorldMatrixFrozen(): boolean;
  15316. /**
  15317. * Retuns the mesh absolute position in the World.
  15318. * @returns a Vector3.
  15319. */
  15320. getAbsolutePosition(): Vector3;
  15321. /**
  15322. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15323. * @param absolutePosition the absolute position to set
  15324. * @returns the TransformNode.
  15325. */
  15326. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15327. /**
  15328. * Sets the mesh position in its local space.
  15329. * @param vector3 the position to set in localspace
  15330. * @returns the TransformNode.
  15331. */
  15332. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15333. /**
  15334. * Returns the mesh position in the local space from the current World matrix values.
  15335. * @returns a new Vector3.
  15336. */
  15337. getPositionExpressedInLocalSpace(): Vector3;
  15338. /**
  15339. * Translates the mesh along the passed Vector3 in its local space.
  15340. * @param vector3 the distance to translate in localspace
  15341. * @returns the TransformNode.
  15342. */
  15343. locallyTranslate(vector3: Vector3): TransformNode;
  15344. private static _lookAtVectorCache;
  15345. /**
  15346. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15347. * @param targetPoint the position (must be in same space as current mesh) to look at
  15348. * @param yawCor optional yaw (y-axis) correction in radians
  15349. * @param pitchCor optional pitch (x-axis) correction in radians
  15350. * @param rollCor optional roll (z-axis) correction in radians
  15351. * @param space the choosen space of the target
  15352. * @returns the TransformNode.
  15353. */
  15354. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15355. /**
  15356. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15357. * This Vector3 is expressed in the World space.
  15358. * @param localAxis axis to rotate
  15359. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15360. */
  15361. getDirection(localAxis: Vector3): Vector3;
  15362. /**
  15363. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15364. * localAxis is expressed in the mesh local space.
  15365. * result is computed in the Wordl space from the mesh World matrix.
  15366. * @param localAxis axis to rotate
  15367. * @param result the resulting transformnode
  15368. * @returns this TransformNode.
  15369. */
  15370. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15371. /**
  15372. * Sets this transform node rotation to the given local axis.
  15373. * @param localAxis the axis in local space
  15374. * @param yawCor optional yaw (y-axis) correction in radians
  15375. * @param pitchCor optional pitch (x-axis) correction in radians
  15376. * @param rollCor optional roll (z-axis) correction in radians
  15377. * @returns this TransformNode
  15378. */
  15379. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15380. /**
  15381. * Sets a new pivot point to the current node
  15382. * @param point defines the new pivot point to use
  15383. * @param space defines if the point is in world or local space (local by default)
  15384. * @returns the current TransformNode
  15385. */
  15386. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15387. /**
  15388. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15389. * @returns the pivot point
  15390. */
  15391. getPivotPoint(): Vector3;
  15392. /**
  15393. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15394. * @param result the vector3 to store the result
  15395. * @returns this TransformNode.
  15396. */
  15397. getPivotPointToRef(result: Vector3): TransformNode;
  15398. /**
  15399. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15400. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15401. */
  15402. getAbsolutePivotPoint(): Vector3;
  15403. /**
  15404. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15405. * @param result vector3 to store the result
  15406. * @returns this TransformNode.
  15407. */
  15408. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15409. /**
  15410. * Defines the passed node as the parent of the current node.
  15411. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15412. * @see https://doc.babylonjs.com/how_to/parenting
  15413. * @param node the node ot set as the parent
  15414. * @returns this TransformNode.
  15415. */
  15416. setParent(node: Nullable<Node>): TransformNode;
  15417. private _nonUniformScaling;
  15418. /**
  15419. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15420. */
  15421. get nonUniformScaling(): boolean;
  15422. /** @hidden */
  15423. _updateNonUniformScalingState(value: boolean): boolean;
  15424. /**
  15425. * Attach the current TransformNode to another TransformNode associated with a bone
  15426. * @param bone Bone affecting the TransformNode
  15427. * @param affectedTransformNode TransformNode associated with the bone
  15428. * @returns this object
  15429. */
  15430. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15431. /**
  15432. * Detach the transform node if its associated with a bone
  15433. * @returns this object
  15434. */
  15435. detachFromBone(): TransformNode;
  15436. private static _rotationAxisCache;
  15437. /**
  15438. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15439. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15440. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15441. * The passed axis is also normalized.
  15442. * @param axis the axis to rotate around
  15443. * @param amount the amount to rotate in radians
  15444. * @param space Space to rotate in (Default: local)
  15445. * @returns the TransformNode.
  15446. */
  15447. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15448. /**
  15449. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15450. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15451. * The passed axis is also normalized. .
  15452. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15453. * @param point the point to rotate around
  15454. * @param axis the axis to rotate around
  15455. * @param amount the amount to rotate in radians
  15456. * @returns the TransformNode
  15457. */
  15458. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15459. /**
  15460. * Translates the mesh along the axis vector for the passed distance in the given space.
  15461. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15462. * @param axis the axis to translate in
  15463. * @param distance the distance to translate
  15464. * @param space Space to rotate in (Default: local)
  15465. * @returns the TransformNode.
  15466. */
  15467. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15468. /**
  15469. * Adds a rotation step to the mesh current rotation.
  15470. * x, y, z are Euler angles expressed in radians.
  15471. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15472. * This means this rotation is made in the mesh local space only.
  15473. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15474. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15475. * ```javascript
  15476. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15477. * ```
  15478. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15479. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  15480. * @param x Rotation to add
  15481. * @param y Rotation to add
  15482. * @param z Rotation to add
  15483. * @returns the TransformNode.
  15484. */
  15485. addRotation(x: number, y: number, z: number): TransformNode;
  15486. /**
  15487. * @hidden
  15488. */
  15489. protected _getEffectiveParent(): Nullable<Node>;
  15490. /**
  15491. * Computes the world matrix of the node
  15492. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15493. * @returns the world matrix
  15494. */
  15495. computeWorldMatrix(force?: boolean): Matrix;
  15496. /**
  15497. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15498. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15499. */
  15500. resetLocalMatrix(independentOfChildren?: boolean): void;
  15501. protected _afterComputeWorldMatrix(): void;
  15502. /**
  15503. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15504. * @param func callback function to add
  15505. *
  15506. * @returns the TransformNode.
  15507. */
  15508. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15509. /**
  15510. * Removes a registered callback function.
  15511. * @param func callback function to remove
  15512. * @returns the TransformNode.
  15513. */
  15514. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15515. /**
  15516. * Gets the position of the current mesh in camera space
  15517. * @param camera defines the camera to use
  15518. * @returns a position
  15519. */
  15520. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15521. /**
  15522. * Returns the distance from the mesh to the active camera
  15523. * @param camera defines the camera to use
  15524. * @returns the distance
  15525. */
  15526. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15527. /**
  15528. * Clone the current transform node
  15529. * @param name Name of the new clone
  15530. * @param newParent New parent for the clone
  15531. * @param doNotCloneChildren Do not clone children hierarchy
  15532. * @returns the new transform node
  15533. */
  15534. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15535. /**
  15536. * Serializes the objects information.
  15537. * @param currentSerializationObject defines the object to serialize in
  15538. * @returns the serialized object
  15539. */
  15540. serialize(currentSerializationObject?: any): any;
  15541. /**
  15542. * Returns a new TransformNode object parsed from the source provided.
  15543. * @param parsedTransformNode is the source.
  15544. * @param scene the scne the object belongs to
  15545. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15546. * @returns a new TransformNode object parsed from the source provided.
  15547. */
  15548. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15549. /**
  15550. * Get all child-transformNodes of this node
  15551. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  15552. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  15553. * @returns an array of TransformNode
  15554. */
  15555. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15556. /**
  15557. * Releases resources associated with this transform node.
  15558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15560. */
  15561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15562. /**
  15563. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15564. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15565. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15566. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15567. * @returns the current mesh
  15568. */
  15569. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15570. private _syncAbsoluteScalingAndRotation;
  15571. }
  15572. }
  15573. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15574. /**
  15575. * Class used to override all child animations of a given target
  15576. */
  15577. export class AnimationPropertiesOverride {
  15578. /**
  15579. * Gets or sets a value indicating if animation blending must be used
  15580. */
  15581. enableBlending: boolean;
  15582. /**
  15583. * Gets or sets the blending speed to use when enableBlending is true
  15584. */
  15585. blendingSpeed: number;
  15586. /**
  15587. * Gets or sets the default loop mode to use
  15588. */
  15589. loopMode: number;
  15590. }
  15591. }
  15592. declare module "babylonjs/Bones/bone" {
  15593. import { Skeleton } from "babylonjs/Bones/skeleton";
  15594. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15595. import { Nullable } from "babylonjs/types";
  15596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15597. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15598. import { Node } from "babylonjs/node";
  15599. import { Space } from "babylonjs/Maths/math.axis";
  15600. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15601. /**
  15602. * Class used to store bone information
  15603. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15604. */
  15605. export class Bone extends Node {
  15606. /**
  15607. * defines the bone name
  15608. */
  15609. name: string;
  15610. private static _tmpVecs;
  15611. private static _tmpQuat;
  15612. private static _tmpMats;
  15613. /**
  15614. * Gets the list of child bones
  15615. */
  15616. children: Bone[];
  15617. /** Gets the animations associated with this bone */
  15618. animations: import("babylonjs/Animations/animation").Animation[];
  15619. /**
  15620. * Gets or sets bone length
  15621. */
  15622. length: number;
  15623. /**
  15624. * @hidden Internal only
  15625. * Set this value to map this bone to a different index in the transform matrices
  15626. * Set this value to -1 to exclude the bone from the transform matrices
  15627. */
  15628. _index: Nullable<number>;
  15629. private _skeleton;
  15630. private _localMatrix;
  15631. private _restPose;
  15632. private _bindPose;
  15633. private _baseMatrix;
  15634. private _absoluteTransform;
  15635. private _invertedAbsoluteTransform;
  15636. private _parent;
  15637. private _scalingDeterminant;
  15638. private _worldTransform;
  15639. private _localScaling;
  15640. private _localRotation;
  15641. private _localPosition;
  15642. private _needToDecompose;
  15643. private _needToCompose;
  15644. /** @hidden */
  15645. _linkedTransformNode: Nullable<TransformNode>;
  15646. /** @hidden */
  15647. _waitingTransformNodeId: Nullable<string>;
  15648. /** @hidden */
  15649. get _matrix(): Matrix;
  15650. /** @hidden */
  15651. set _matrix(value: Matrix);
  15652. /**
  15653. * Create a new bone
  15654. * @param name defines the bone name
  15655. * @param skeleton defines the parent skeleton
  15656. * @param parentBone defines the parent (can be null if the bone is the root)
  15657. * @param localMatrix defines the local matrix
  15658. * @param restPose defines the rest pose matrix
  15659. * @param baseMatrix defines the base matrix
  15660. * @param index defines index of the bone in the hiearchy
  15661. */
  15662. constructor(
  15663. /**
  15664. * defines the bone name
  15665. */
  15666. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15667. /**
  15668. * Gets the current object class name.
  15669. * @return the class name
  15670. */
  15671. getClassName(): string;
  15672. /**
  15673. * Gets the parent skeleton
  15674. * @returns a skeleton
  15675. */
  15676. getSkeleton(): Skeleton;
  15677. /**
  15678. * Gets parent bone
  15679. * @returns a bone or null if the bone is the root of the bone hierarchy
  15680. */
  15681. getParent(): Nullable<Bone>;
  15682. /**
  15683. * Returns an array containing the root bones
  15684. * @returns an array containing the root bones
  15685. */
  15686. getChildren(): Array<Bone>;
  15687. /**
  15688. * Gets the node index in matrix array generated for rendering
  15689. * @returns the node index
  15690. */
  15691. getIndex(): number;
  15692. /**
  15693. * Sets the parent bone
  15694. * @param parent defines the parent (can be null if the bone is the root)
  15695. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15696. */
  15697. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15698. /**
  15699. * Gets the local matrix
  15700. * @returns a matrix
  15701. */
  15702. getLocalMatrix(): Matrix;
  15703. /**
  15704. * Gets the base matrix (initial matrix which remains unchanged)
  15705. * @returns a matrix
  15706. */
  15707. getBaseMatrix(): Matrix;
  15708. /**
  15709. * Gets the rest pose matrix
  15710. * @returns a matrix
  15711. */
  15712. getRestPose(): Matrix;
  15713. /**
  15714. * Sets the rest pose matrix
  15715. * @param matrix the local-space rest pose to set for this bone
  15716. */
  15717. setRestPose(matrix: Matrix): void;
  15718. /**
  15719. * Gets the bind pose matrix
  15720. * @returns the bind pose matrix
  15721. */
  15722. getBindPose(): Matrix;
  15723. /**
  15724. * Sets the bind pose matrix
  15725. * @param matrix the local-space bind pose to set for this bone
  15726. */
  15727. setBindPose(matrix: Matrix): void;
  15728. /**
  15729. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15730. */
  15731. getWorldMatrix(): Matrix;
  15732. /**
  15733. * Sets the local matrix to rest pose matrix
  15734. */
  15735. returnToRest(): void;
  15736. /**
  15737. * Gets the inverse of the absolute transform matrix.
  15738. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15739. * @returns a matrix
  15740. */
  15741. getInvertedAbsoluteTransform(): Matrix;
  15742. /**
  15743. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15744. * @returns a matrix
  15745. */
  15746. getAbsoluteTransform(): Matrix;
  15747. /**
  15748. * Links with the given transform node.
  15749. * The local matrix of this bone is copied from the transform node every frame.
  15750. * @param transformNode defines the transform node to link to
  15751. */
  15752. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15753. /**
  15754. * Gets the node used to drive the bone's transformation
  15755. * @returns a transform node or null
  15756. */
  15757. getTransformNode(): Nullable<TransformNode>;
  15758. /** Gets or sets current position (in local space) */
  15759. get position(): Vector3;
  15760. set position(newPosition: Vector3);
  15761. /** Gets or sets current rotation (in local space) */
  15762. get rotation(): Vector3;
  15763. set rotation(newRotation: Vector3);
  15764. /** Gets or sets current rotation quaternion (in local space) */
  15765. get rotationQuaternion(): Quaternion;
  15766. set rotationQuaternion(newRotation: Quaternion);
  15767. /** Gets or sets current scaling (in local space) */
  15768. get scaling(): Vector3;
  15769. set scaling(newScaling: Vector3);
  15770. /**
  15771. * Gets the animation properties override
  15772. */
  15773. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15774. private _decompose;
  15775. private _compose;
  15776. /**
  15777. * Update the base and local matrices
  15778. * @param matrix defines the new base or local matrix
  15779. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15780. * @param updateLocalMatrix defines if the local matrix should be updated
  15781. */
  15782. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15783. /** @hidden */
  15784. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15785. /**
  15786. * Flag the bone as dirty (Forcing it to update everything)
  15787. */
  15788. markAsDirty(): void;
  15789. /** @hidden */
  15790. _markAsDirtyAndCompose(): void;
  15791. private _markAsDirtyAndDecompose;
  15792. /**
  15793. * Translate the bone in local or world space
  15794. * @param vec The amount to translate the bone
  15795. * @param space The space that the translation is in
  15796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15797. */
  15798. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15799. /**
  15800. * Set the postion of the bone in local or world space
  15801. * @param position The position to set the bone
  15802. * @param space The space that the position is in
  15803. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15804. */
  15805. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15806. /**
  15807. * Set the absolute position of the bone (world space)
  15808. * @param position The position to set the bone
  15809. * @param mesh The mesh that this bone is attached to
  15810. */
  15811. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15812. /**
  15813. * Scale the bone on the x, y and z axes (in local space)
  15814. * @param x The amount to scale the bone on the x axis
  15815. * @param y The amount to scale the bone on the y axis
  15816. * @param z The amount to scale the bone on the z axis
  15817. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15818. */
  15819. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15820. /**
  15821. * Set the bone scaling in local space
  15822. * @param scale defines the scaling vector
  15823. */
  15824. setScale(scale: Vector3): void;
  15825. /**
  15826. * Gets the current scaling in local space
  15827. * @returns the current scaling vector
  15828. */
  15829. getScale(): Vector3;
  15830. /**
  15831. * Gets the current scaling in local space and stores it in a target vector
  15832. * @param result defines the target vector
  15833. */
  15834. getScaleToRef(result: Vector3): void;
  15835. /**
  15836. * Set the yaw, pitch, and roll of the bone in local or world space
  15837. * @param yaw The rotation of the bone on the y axis
  15838. * @param pitch The rotation of the bone on the x axis
  15839. * @param roll The rotation of the bone on the z axis
  15840. * @param space The space that the axes of rotation are in
  15841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15842. */
  15843. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15844. /**
  15845. * Add a rotation to the bone on an axis in local or world space
  15846. * @param axis The axis to rotate the bone on
  15847. * @param amount The amount to rotate the bone
  15848. * @param space The space that the axis is in
  15849. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15850. */
  15851. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15852. /**
  15853. * Set the rotation of the bone to a particular axis angle in local or world space
  15854. * @param axis The axis to rotate the bone on
  15855. * @param angle The angle that the bone should be rotated to
  15856. * @param space The space that the axis is in
  15857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15858. */
  15859. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15860. /**
  15861. * Set the euler rotation of the bone in local or world space
  15862. * @param rotation The euler rotation that the bone should be set to
  15863. * @param space The space that the rotation is in
  15864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15865. */
  15866. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15867. /**
  15868. * Set the quaternion rotation of the bone in local or world space
  15869. * @param quat The quaternion rotation that the bone should be set to
  15870. * @param space The space that the rotation is in
  15871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15872. */
  15873. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15874. /**
  15875. * Set the rotation matrix of the bone in local or world space
  15876. * @param rotMat The rotation matrix that the bone should be set to
  15877. * @param space The space that the rotation is in
  15878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15879. */
  15880. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15881. private _rotateWithMatrix;
  15882. private _getNegativeRotationToRef;
  15883. /**
  15884. * Get the position of the bone in local or world space
  15885. * @param space The space that the returned position is in
  15886. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15887. * @returns The position of the bone
  15888. */
  15889. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15890. /**
  15891. * Copy the position of the bone to a vector3 in local or world space
  15892. * @param space The space that the returned position is in
  15893. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15894. * @param result The vector3 to copy the position to
  15895. */
  15896. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15897. /**
  15898. * Get the absolute position of the bone (world space)
  15899. * @param mesh The mesh that this bone is attached to
  15900. * @returns The absolute position of the bone
  15901. */
  15902. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15903. /**
  15904. * Copy the absolute position of the bone (world space) to the result param
  15905. * @param mesh The mesh that this bone is attached to
  15906. * @param result The vector3 to copy the absolute position to
  15907. */
  15908. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15909. /**
  15910. * Compute the absolute transforms of this bone and its children
  15911. */
  15912. computeAbsoluteTransforms(): void;
  15913. /**
  15914. * Get the world direction from an axis that is in the local space of the bone
  15915. * @param localAxis The local direction that is used to compute the world direction
  15916. * @param mesh The mesh that this bone is attached to
  15917. * @returns The world direction
  15918. */
  15919. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15920. /**
  15921. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15922. * @param localAxis The local direction that is used to compute the world direction
  15923. * @param mesh The mesh that this bone is attached to
  15924. * @param result The vector3 that the world direction will be copied to
  15925. */
  15926. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15927. /**
  15928. * Get the euler rotation of the bone in local or world space
  15929. * @param space The space that the rotation should be in
  15930. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15931. * @returns The euler rotation
  15932. */
  15933. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15934. /**
  15935. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15936. * @param space The space that the rotation should be in
  15937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15938. * @param result The vector3 that the rotation should be copied to
  15939. */
  15940. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15941. /**
  15942. * Get the quaternion rotation of the bone in either local or world space
  15943. * @param space The space that the rotation should be in
  15944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15945. * @returns The quaternion rotation
  15946. */
  15947. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15948. /**
  15949. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15950. * @param space The space that the rotation should be in
  15951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15952. * @param result The quaternion that the rotation should be copied to
  15953. */
  15954. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15955. /**
  15956. * Get the rotation matrix of the bone in local or world space
  15957. * @param space The space that the rotation should be in
  15958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15959. * @returns The rotation matrix
  15960. */
  15961. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15962. /**
  15963. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15964. * @param space The space that the rotation should be in
  15965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15966. * @param result The quaternion that the rotation should be copied to
  15967. */
  15968. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15969. /**
  15970. * Get the world position of a point that is in the local space of the bone
  15971. * @param position The local position
  15972. * @param mesh The mesh that this bone is attached to
  15973. * @returns The world position
  15974. */
  15975. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15976. /**
  15977. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15978. * @param position The local position
  15979. * @param mesh The mesh that this bone is attached to
  15980. * @param result The vector3 that the world position should be copied to
  15981. */
  15982. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15983. /**
  15984. * Get the local position of a point that is in world space
  15985. * @param position The world position
  15986. * @param mesh The mesh that this bone is attached to
  15987. * @returns The local position
  15988. */
  15989. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15990. /**
  15991. * Get the local position of a point that is in world space and copy it to the result param
  15992. * @param position The world position
  15993. * @param mesh The mesh that this bone is attached to
  15994. * @param result The vector3 that the local position should be copied to
  15995. */
  15996. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15997. /**
  15998. * Set the current local matrix as the restPose for this bone.
  15999. */
  16000. setCurrentPoseAsRest(): void;
  16001. }
  16002. }
  16003. declare module "babylonjs/Animations/runtimeAnimation" {
  16004. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  16005. import { Animatable } from "babylonjs/Animations/animatable";
  16006. import { Scene } from "babylonjs/scene";
  16007. /**
  16008. * Defines a runtime animation
  16009. */
  16010. export class RuntimeAnimation {
  16011. private _events;
  16012. /**
  16013. * The current frame of the runtime animation
  16014. */
  16015. private _currentFrame;
  16016. /**
  16017. * The animation used by the runtime animation
  16018. */
  16019. private _animation;
  16020. /**
  16021. * The target of the runtime animation
  16022. */
  16023. private _target;
  16024. /**
  16025. * The initiating animatable
  16026. */
  16027. private _host;
  16028. /**
  16029. * The original value of the runtime animation
  16030. */
  16031. private _originalValue;
  16032. /**
  16033. * The original blend value of the runtime animation
  16034. */
  16035. private _originalBlendValue;
  16036. /**
  16037. * The offsets cache of the runtime animation
  16038. */
  16039. private _offsetsCache;
  16040. /**
  16041. * The high limits cache of the runtime animation
  16042. */
  16043. private _highLimitsCache;
  16044. /**
  16045. * Specifies if the runtime animation has been stopped
  16046. */
  16047. private _stopped;
  16048. /**
  16049. * The blending factor of the runtime animation
  16050. */
  16051. private _blendingFactor;
  16052. /**
  16053. * The BabylonJS scene
  16054. */
  16055. private _scene;
  16056. /**
  16057. * The current value of the runtime animation
  16058. */
  16059. private _currentValue;
  16060. /** @hidden */
  16061. _animationState: _IAnimationState;
  16062. /**
  16063. * The active target of the runtime animation
  16064. */
  16065. private _activeTargets;
  16066. private _currentActiveTarget;
  16067. private _directTarget;
  16068. /**
  16069. * The target path of the runtime animation
  16070. */
  16071. private _targetPath;
  16072. /**
  16073. * The weight of the runtime animation
  16074. */
  16075. private _weight;
  16076. /**
  16077. * The ratio offset of the runtime animation
  16078. */
  16079. private _ratioOffset;
  16080. /**
  16081. * The previous delay of the runtime animation
  16082. */
  16083. private _previousDelay;
  16084. /**
  16085. * The previous ratio of the runtime animation
  16086. */
  16087. private _previousRatio;
  16088. private _enableBlending;
  16089. private _keys;
  16090. private _minFrame;
  16091. private _maxFrame;
  16092. private _minValue;
  16093. private _maxValue;
  16094. private _targetIsArray;
  16095. /**
  16096. * Gets the current frame of the runtime animation
  16097. */
  16098. get currentFrame(): number;
  16099. /**
  16100. * Gets the weight of the runtime animation
  16101. */
  16102. get weight(): number;
  16103. /**
  16104. * Gets the current value of the runtime animation
  16105. */
  16106. get currentValue(): any;
  16107. /**
  16108. * Gets the target path of the runtime animation
  16109. */
  16110. get targetPath(): string;
  16111. /**
  16112. * Gets the actual target of the runtime animation
  16113. */
  16114. get target(): any;
  16115. /**
  16116. * Gets the additive state of the runtime animation
  16117. */
  16118. get isAdditive(): boolean;
  16119. /** @hidden */
  16120. _onLoop: () => void;
  16121. /**
  16122. * Create a new RuntimeAnimation object
  16123. * @param target defines the target of the animation
  16124. * @param animation defines the source animation object
  16125. * @param scene defines the hosting scene
  16126. * @param host defines the initiating Animatable
  16127. */
  16128. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16129. private _preparePath;
  16130. /**
  16131. * Gets the animation from the runtime animation
  16132. */
  16133. get animation(): Animation;
  16134. /**
  16135. * Resets the runtime animation to the beginning
  16136. * @param restoreOriginal defines whether to restore the target property to the original value
  16137. */
  16138. reset(restoreOriginal?: boolean): void;
  16139. /**
  16140. * Specifies if the runtime animation is stopped
  16141. * @returns Boolean specifying if the runtime animation is stopped
  16142. */
  16143. isStopped(): boolean;
  16144. /**
  16145. * Disposes of the runtime animation
  16146. */
  16147. dispose(): void;
  16148. /**
  16149. * Apply the interpolated value to the target
  16150. * @param currentValue defines the value computed by the animation
  16151. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16152. */
  16153. setValue(currentValue: any, weight: number): void;
  16154. private _getOriginalValues;
  16155. private _setValue;
  16156. /**
  16157. * Gets the loop pmode of the runtime animation
  16158. * @returns Loop Mode
  16159. */
  16160. private _getCorrectLoopMode;
  16161. /**
  16162. * Move the current animation to a given frame
  16163. * @param frame defines the frame to move to
  16164. */
  16165. goToFrame(frame: number): void;
  16166. /**
  16167. * @hidden Internal use only
  16168. */
  16169. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16170. /**
  16171. * Execute the current animation
  16172. * @param delay defines the delay to add to the current frame
  16173. * @param from defines the lower bound of the animation range
  16174. * @param to defines the upper bound of the animation range
  16175. * @param loop defines if the current animation must loop
  16176. * @param speedRatio defines the current speed ratio
  16177. * @param weight defines the weight of the animation (default is -1 so no weight)
  16178. * @param onLoop optional callback called when animation loops
  16179. * @returns a boolean indicating if the animation is running
  16180. */
  16181. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16182. }
  16183. }
  16184. declare module "babylonjs/Animations/animatable" {
  16185. import { Animation } from "babylonjs/Animations/animation";
  16186. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16187. import { Nullable } from "babylonjs/types";
  16188. import { Observable } from "babylonjs/Misc/observable";
  16189. import { Scene } from "babylonjs/scene";
  16190. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16191. import { Node } from "babylonjs/node";
  16192. /**
  16193. * Class used to store an actual running animation
  16194. */
  16195. export class Animatable {
  16196. /** defines the target object */
  16197. target: any;
  16198. /** defines the starting frame number (default is 0) */
  16199. fromFrame: number;
  16200. /** defines the ending frame number (default is 100) */
  16201. toFrame: number;
  16202. /** defines if the animation must loop (default is false) */
  16203. loopAnimation: boolean;
  16204. /** defines a callback to call when animation ends if it is not looping */
  16205. onAnimationEnd?: (() => void) | null | undefined;
  16206. /** defines a callback to call when animation loops */
  16207. onAnimationLoop?: (() => void) | null | undefined;
  16208. /** defines whether the animation should be evaluated additively */
  16209. isAdditive: boolean;
  16210. private _localDelayOffset;
  16211. private _pausedDelay;
  16212. private _runtimeAnimations;
  16213. private _paused;
  16214. private _scene;
  16215. private _speedRatio;
  16216. private _weight;
  16217. private _syncRoot;
  16218. /**
  16219. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16220. * This will only apply for non looping animation (default is true)
  16221. */
  16222. disposeOnEnd: boolean;
  16223. /**
  16224. * Gets a boolean indicating if the animation has started
  16225. */
  16226. animationStarted: boolean;
  16227. /**
  16228. * Observer raised when the animation ends
  16229. */
  16230. onAnimationEndObservable: Observable<Animatable>;
  16231. /**
  16232. * Observer raised when the animation loops
  16233. */
  16234. onAnimationLoopObservable: Observable<Animatable>;
  16235. /**
  16236. * Gets the root Animatable used to synchronize and normalize animations
  16237. */
  16238. get syncRoot(): Nullable<Animatable>;
  16239. /**
  16240. * Gets the current frame of the first RuntimeAnimation
  16241. * Used to synchronize Animatables
  16242. */
  16243. get masterFrame(): number;
  16244. /**
  16245. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16246. */
  16247. get weight(): number;
  16248. set weight(value: number);
  16249. /**
  16250. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16251. */
  16252. get speedRatio(): number;
  16253. set speedRatio(value: number);
  16254. /**
  16255. * Creates a new Animatable
  16256. * @param scene defines the hosting scene
  16257. * @param target defines the target object
  16258. * @param fromFrame defines the starting frame number (default is 0)
  16259. * @param toFrame defines the ending frame number (default is 100)
  16260. * @param loopAnimation defines if the animation must loop (default is false)
  16261. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16262. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16263. * @param animations defines a group of animation to add to the new Animatable
  16264. * @param onAnimationLoop defines a callback to call when animation loops
  16265. * @param isAdditive defines whether the animation should be evaluated additively
  16266. */
  16267. constructor(scene: Scene,
  16268. /** defines the target object */
  16269. target: any,
  16270. /** defines the starting frame number (default is 0) */
  16271. fromFrame?: number,
  16272. /** defines the ending frame number (default is 100) */
  16273. toFrame?: number,
  16274. /** defines if the animation must loop (default is false) */
  16275. loopAnimation?: boolean, speedRatio?: number,
  16276. /** defines a callback to call when animation ends if it is not looping */
  16277. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16278. /** defines a callback to call when animation loops */
  16279. onAnimationLoop?: (() => void) | null | undefined,
  16280. /** defines whether the animation should be evaluated additively */
  16281. isAdditive?: boolean);
  16282. /**
  16283. * Synchronize and normalize current Animatable with a source Animatable
  16284. * This is useful when using animation weights and when animations are not of the same length
  16285. * @param root defines the root Animatable to synchronize with
  16286. * @returns the current Animatable
  16287. */
  16288. syncWith(root: Animatable): Animatable;
  16289. /**
  16290. * Gets the list of runtime animations
  16291. * @returns an array of RuntimeAnimation
  16292. */
  16293. getAnimations(): RuntimeAnimation[];
  16294. /**
  16295. * Adds more animations to the current animatable
  16296. * @param target defines the target of the animations
  16297. * @param animations defines the new animations to add
  16298. */
  16299. appendAnimations(target: any, animations: Animation[]): void;
  16300. /**
  16301. * Gets the source animation for a specific property
  16302. * @param property defines the propertyu to look for
  16303. * @returns null or the source animation for the given property
  16304. */
  16305. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16306. /**
  16307. * Gets the runtime animation for a specific property
  16308. * @param property defines the propertyu to look for
  16309. * @returns null or the runtime animation for the given property
  16310. */
  16311. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16312. /**
  16313. * Resets the animatable to its original state
  16314. */
  16315. reset(): void;
  16316. /**
  16317. * Allows the animatable to blend with current running animations
  16318. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16319. * @param blendingSpeed defines the blending speed to use
  16320. */
  16321. enableBlending(blendingSpeed: number): void;
  16322. /**
  16323. * Disable animation blending
  16324. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16325. */
  16326. disableBlending(): void;
  16327. /**
  16328. * Jump directly to a given frame
  16329. * @param frame defines the frame to jump to
  16330. */
  16331. goToFrame(frame: number): void;
  16332. /**
  16333. * Pause the animation
  16334. */
  16335. pause(): void;
  16336. /**
  16337. * Restart the animation
  16338. */
  16339. restart(): void;
  16340. private _raiseOnAnimationEnd;
  16341. /**
  16342. * Stop and delete the current animation
  16343. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16344. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  16345. */
  16346. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16347. /**
  16348. * Wait asynchronously for the animation to end
  16349. * @returns a promise which will be fullfilled when the animation ends
  16350. */
  16351. waitAsync(): Promise<Animatable>;
  16352. /** @hidden */
  16353. _animate(delay: number): boolean;
  16354. }
  16355. module "babylonjs/scene" {
  16356. interface Scene {
  16357. /** @hidden */
  16358. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16359. /** @hidden */
  16360. _processLateAnimationBindingsForMatrices(holder: {
  16361. totalWeight: number;
  16362. totalAdditiveWeight: number;
  16363. animations: RuntimeAnimation[];
  16364. additiveAnimations: RuntimeAnimation[];
  16365. originalValue: Matrix;
  16366. }): any;
  16367. /** @hidden */
  16368. _processLateAnimationBindingsForQuaternions(holder: {
  16369. totalWeight: number;
  16370. totalAdditiveWeight: number;
  16371. animations: RuntimeAnimation[];
  16372. additiveAnimations: RuntimeAnimation[];
  16373. originalValue: Quaternion;
  16374. }, refQuaternion: Quaternion): Quaternion;
  16375. /** @hidden */
  16376. _processLateAnimationBindings(): void;
  16377. /**
  16378. * Will start the animation sequence of a given target
  16379. * @param target defines the target
  16380. * @param from defines from which frame should animation start
  16381. * @param to defines until which frame should animation run.
  16382. * @param weight defines the weight to apply to the animation (1.0 by default)
  16383. * @param loop defines if the animation loops
  16384. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16385. * @param onAnimationEnd defines the function to be executed when the animation ends
  16386. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16387. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16388. * @param onAnimationLoop defines the callback to call when an animation loops
  16389. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16390. * @returns the animatable object created for this animation
  16391. */
  16392. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16393. /**
  16394. * Will start the animation sequence of a given target
  16395. * @param target defines the target
  16396. * @param from defines from which frame should animation start
  16397. * @param to defines until which frame should animation run.
  16398. * @param loop defines if the animation loops
  16399. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16400. * @param onAnimationEnd defines the function to be executed when the animation ends
  16401. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16402. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16403. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16404. * @param onAnimationLoop defines the callback to call when an animation loops
  16405. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16406. * @returns the animatable object created for this animation
  16407. */
  16408. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16409. /**
  16410. * Will start the animation sequence of a given target and its hierarchy
  16411. * @param target defines the target
  16412. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16413. * @param from defines from which frame should animation start
  16414. * @param to defines until which frame should animation run.
  16415. * @param loop defines if the animation loops
  16416. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16417. * @param onAnimationEnd defines the function to be executed when the animation ends
  16418. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16419. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16420. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16421. * @param onAnimationLoop defines the callback to call when an animation loops
  16422. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16423. * @returns the list of created animatables
  16424. */
  16425. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16426. /**
  16427. * Begin a new animation on a given node
  16428. * @param target defines the target where the animation will take place
  16429. * @param animations defines the list of animations to start
  16430. * @param from defines the initial value
  16431. * @param to defines the final value
  16432. * @param loop defines if you want animation to loop (off by default)
  16433. * @param speedRatio defines the speed ratio to apply to all animations
  16434. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16435. * @param onAnimationLoop defines the callback to call when an animation loops
  16436. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16437. * @returns the list of created animatables
  16438. */
  16439. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16440. /**
  16441. * Begin a new animation on a given node and its hierarchy
  16442. * @param target defines the root node where the animation will take place
  16443. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16444. * @param animations defines the list of animations to start
  16445. * @param from defines the initial value
  16446. * @param to defines the final value
  16447. * @param loop defines if you want animation to loop (off by default)
  16448. * @param speedRatio defines the speed ratio to apply to all animations
  16449. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16450. * @param onAnimationLoop defines the callback to call when an animation loops
  16451. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16452. * @returns the list of animatables created for all nodes
  16453. */
  16454. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16455. /**
  16456. * Gets the animatable associated with a specific target
  16457. * @param target defines the target of the animatable
  16458. * @returns the required animatable if found
  16459. */
  16460. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16461. /**
  16462. * Gets all animatables associated with a given target
  16463. * @param target defines the target to look animatables for
  16464. * @returns an array of Animatables
  16465. */
  16466. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16467. /**
  16468. * Stops and removes all animations that have been applied to the scene
  16469. */
  16470. stopAllAnimations(): void;
  16471. /**
  16472. * Gets the current delta time used by animation engine
  16473. */
  16474. deltaTime: number;
  16475. }
  16476. }
  16477. module "babylonjs/Bones/bone" {
  16478. interface Bone {
  16479. /**
  16480. * Copy an animation range from another bone
  16481. * @param source defines the source bone
  16482. * @param rangeName defines the range name to copy
  16483. * @param frameOffset defines the frame offset
  16484. * @param rescaleAsRequired defines if rescaling must be applied if required
  16485. * @param skelDimensionsRatio defines the scaling ratio
  16486. * @returns true if operation was successful
  16487. */
  16488. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16489. }
  16490. }
  16491. }
  16492. declare module "babylonjs/Bones/skeleton" {
  16493. import { Bone } from "babylonjs/Bones/bone";
  16494. import { Observable } from "babylonjs/Misc/observable";
  16495. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16496. import { Scene } from "babylonjs/scene";
  16497. import { Nullable } from "babylonjs/types";
  16498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16499. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16500. import { Animatable } from "babylonjs/Animations/animatable";
  16501. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16502. import { Animation } from "babylonjs/Animations/animation";
  16503. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16504. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16505. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16506. /**
  16507. * Class used to handle skinning animations
  16508. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16509. */
  16510. export class Skeleton implements IAnimatable {
  16511. /** defines the skeleton name */
  16512. name: string;
  16513. /** defines the skeleton Id */
  16514. id: string;
  16515. /**
  16516. * Defines the list of child bones
  16517. */
  16518. bones: Bone[];
  16519. /**
  16520. * Defines an estimate of the dimension of the skeleton at rest
  16521. */
  16522. dimensionsAtRest: Vector3;
  16523. /**
  16524. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16525. */
  16526. needInitialSkinMatrix: boolean;
  16527. /**
  16528. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16529. */
  16530. overrideMesh: Nullable<AbstractMesh>;
  16531. /**
  16532. * Gets the list of animations attached to this skeleton
  16533. */
  16534. animations: Array<Animation>;
  16535. private _scene;
  16536. private _isDirty;
  16537. private _transformMatrices;
  16538. private _transformMatrixTexture;
  16539. private _meshesWithPoseMatrix;
  16540. private _animatables;
  16541. private _identity;
  16542. private _synchronizedWithMesh;
  16543. private _ranges;
  16544. private _lastAbsoluteTransformsUpdateId;
  16545. private _canUseTextureForBones;
  16546. private _uniqueId;
  16547. /** @hidden */
  16548. _numBonesWithLinkedTransformNode: number;
  16549. /** @hidden */
  16550. _hasWaitingData: Nullable<boolean>;
  16551. /** @hidden */
  16552. _waitingOverrideMeshId: Nullable<string>;
  16553. /**
  16554. * Specifies if the skeleton should be serialized
  16555. */
  16556. doNotSerialize: boolean;
  16557. private _useTextureToStoreBoneMatrices;
  16558. /**
  16559. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16560. * Please note that this option is not available if the hardware does not support it
  16561. */
  16562. get useTextureToStoreBoneMatrices(): boolean;
  16563. set useTextureToStoreBoneMatrices(value: boolean);
  16564. private _animationPropertiesOverride;
  16565. /**
  16566. * Gets or sets the animation properties override
  16567. */
  16568. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16569. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16570. /**
  16571. * List of inspectable custom properties (used by the Inspector)
  16572. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16573. */
  16574. inspectableCustomProperties: IInspectable[];
  16575. /**
  16576. * An observable triggered before computing the skeleton's matrices
  16577. */
  16578. onBeforeComputeObservable: Observable<Skeleton>;
  16579. /**
  16580. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16581. */
  16582. get isUsingTextureForMatrices(): boolean;
  16583. /**
  16584. * Gets the unique ID of this skeleton
  16585. */
  16586. get uniqueId(): number;
  16587. /**
  16588. * Creates a new skeleton
  16589. * @param name defines the skeleton name
  16590. * @param id defines the skeleton Id
  16591. * @param scene defines the hosting scene
  16592. */
  16593. constructor(
  16594. /** defines the skeleton name */
  16595. name: string,
  16596. /** defines the skeleton Id */
  16597. id: string, scene: Scene);
  16598. /**
  16599. * Gets the current object class name.
  16600. * @return the class name
  16601. */
  16602. getClassName(): string;
  16603. /**
  16604. * Returns an array containing the root bones
  16605. * @returns an array containing the root bones
  16606. */
  16607. getChildren(): Array<Bone>;
  16608. /**
  16609. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16610. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16611. * @returns a Float32Array containing matrices data
  16612. */
  16613. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16614. /**
  16615. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16616. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16617. * @returns a raw texture containing the data
  16618. */
  16619. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16620. /**
  16621. * Gets the current hosting scene
  16622. * @returns a scene object
  16623. */
  16624. getScene(): Scene;
  16625. /**
  16626. * Gets a string representing the current skeleton data
  16627. * @param fullDetails defines a boolean indicating if we want a verbose version
  16628. * @returns a string representing the current skeleton data
  16629. */
  16630. toString(fullDetails?: boolean): string;
  16631. /**
  16632. * Get bone's index searching by name
  16633. * @param name defines bone's name to search for
  16634. * @return the indice of the bone. Returns -1 if not found
  16635. */
  16636. getBoneIndexByName(name: string): number;
  16637. /**
  16638. * Creater a new animation range
  16639. * @param name defines the name of the range
  16640. * @param from defines the start key
  16641. * @param to defines the end key
  16642. */
  16643. createAnimationRange(name: string, from: number, to: number): void;
  16644. /**
  16645. * Delete a specific animation range
  16646. * @param name defines the name of the range
  16647. * @param deleteFrames defines if frames must be removed as well
  16648. */
  16649. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16650. /**
  16651. * Gets a specific animation range
  16652. * @param name defines the name of the range to look for
  16653. * @returns the requested animation range or null if not found
  16654. */
  16655. getAnimationRange(name: string): Nullable<AnimationRange>;
  16656. /**
  16657. * Gets the list of all animation ranges defined on this skeleton
  16658. * @returns an array
  16659. */
  16660. getAnimationRanges(): Nullable<AnimationRange>[];
  16661. /**
  16662. * Copy animation range from a source skeleton.
  16663. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16664. * @param source defines the source skeleton
  16665. * @param name defines the name of the range to copy
  16666. * @param rescaleAsRequired defines if rescaling must be applied if required
  16667. * @returns true if operation was successful
  16668. */
  16669. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16670. /**
  16671. * Forces the skeleton to go to rest pose
  16672. */
  16673. returnToRest(): void;
  16674. private _getHighestAnimationFrame;
  16675. /**
  16676. * Begin a specific animation range
  16677. * @param name defines the name of the range to start
  16678. * @param loop defines if looping must be turned on (false by default)
  16679. * @param speedRatio defines the speed ratio to apply (1 by default)
  16680. * @param onAnimationEnd defines a callback which will be called when animation will end
  16681. * @returns a new animatable
  16682. */
  16683. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16684. /**
  16685. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16686. * @param skeleton defines the Skeleton containing the animation range to convert
  16687. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16688. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16689. * @returns the original skeleton
  16690. */
  16691. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16692. /** @hidden */
  16693. _markAsDirty(): void;
  16694. /** @hidden */
  16695. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16696. /** @hidden */
  16697. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16698. private _computeTransformMatrices;
  16699. /**
  16700. * Build all resources required to render a skeleton
  16701. */
  16702. prepare(): void;
  16703. /**
  16704. * Gets the list of animatables currently running for this skeleton
  16705. * @returns an array of animatables
  16706. */
  16707. getAnimatables(): IAnimatable[];
  16708. /**
  16709. * Clone the current skeleton
  16710. * @param name defines the name of the new skeleton
  16711. * @param id defines the id of the new skeleton
  16712. * @returns the new skeleton
  16713. */
  16714. clone(name: string, id?: string): Skeleton;
  16715. /**
  16716. * Enable animation blending for this skeleton
  16717. * @param blendingSpeed defines the blending speed to apply
  16718. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16719. */
  16720. enableBlending(blendingSpeed?: number): void;
  16721. /**
  16722. * Releases all resources associated with the current skeleton
  16723. */
  16724. dispose(): void;
  16725. /**
  16726. * Serialize the skeleton in a JSON object
  16727. * @returns a JSON object
  16728. */
  16729. serialize(): any;
  16730. /**
  16731. * Creates a new skeleton from serialized data
  16732. * @param parsedSkeleton defines the serialized data
  16733. * @param scene defines the hosting scene
  16734. * @returns a new skeleton
  16735. */
  16736. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16737. /**
  16738. * Compute all node absolute transforms
  16739. * @param forceUpdate defines if computation must be done even if cache is up to date
  16740. */
  16741. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16742. /**
  16743. * Gets the root pose matrix
  16744. * @returns a matrix
  16745. */
  16746. getPoseMatrix(): Nullable<Matrix>;
  16747. /**
  16748. * Sorts bones per internal index
  16749. */
  16750. sortBones(): void;
  16751. private _sortBones;
  16752. /**
  16753. * Set the current local matrix as the restPose for all bones in the skeleton.
  16754. */
  16755. setCurrentPoseAsRest(): void;
  16756. }
  16757. }
  16758. declare module "babylonjs/Meshes/instancedMesh" {
  16759. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16760. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16761. import { Camera } from "babylonjs/Cameras/camera";
  16762. import { Node } from "babylonjs/node";
  16763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16764. import { Mesh } from "babylonjs/Meshes/mesh";
  16765. import { Material } from "babylonjs/Materials/material";
  16766. import { Skeleton } from "babylonjs/Bones/skeleton";
  16767. import { Light } from "babylonjs/Lights/light";
  16768. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16769. /**
  16770. * Creates an instance based on a source mesh.
  16771. */
  16772. export class InstancedMesh extends AbstractMesh {
  16773. private _sourceMesh;
  16774. private _currentLOD;
  16775. /** @hidden */
  16776. _indexInSourceMeshInstanceArray: number;
  16777. constructor(name: string, source: Mesh);
  16778. /**
  16779. * Returns the string "InstancedMesh".
  16780. */
  16781. getClassName(): string;
  16782. /** Gets the list of lights affecting that mesh */
  16783. get lightSources(): Light[];
  16784. _resyncLightSources(): void;
  16785. _resyncLightSource(light: Light): void;
  16786. _removeLightSource(light: Light, dispose: boolean): void;
  16787. /**
  16788. * If the source mesh receives shadows
  16789. */
  16790. get receiveShadows(): boolean;
  16791. /**
  16792. * The material of the source mesh
  16793. */
  16794. get material(): Nullable<Material>;
  16795. /**
  16796. * Visibility of the source mesh
  16797. */
  16798. get visibility(): number;
  16799. /**
  16800. * Skeleton of the source mesh
  16801. */
  16802. get skeleton(): Nullable<Skeleton>;
  16803. /**
  16804. * Rendering ground id of the source mesh
  16805. */
  16806. get renderingGroupId(): number;
  16807. set renderingGroupId(value: number);
  16808. /**
  16809. * Returns the total number of vertices (integer).
  16810. */
  16811. getTotalVertices(): number;
  16812. /**
  16813. * Returns a positive integer : the total number of indices in this mesh geometry.
  16814. * @returns the numner of indices or zero if the mesh has no geometry.
  16815. */
  16816. getTotalIndices(): number;
  16817. /**
  16818. * The source mesh of the instance
  16819. */
  16820. get sourceMesh(): Mesh;
  16821. /**
  16822. * Creates a new InstancedMesh object from the mesh model.
  16823. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16824. * @param name defines the name of the new instance
  16825. * @returns a new InstancedMesh
  16826. */
  16827. createInstance(name: string): InstancedMesh;
  16828. /**
  16829. * Is this node ready to be used/rendered
  16830. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16831. * @return {boolean} is it ready
  16832. */
  16833. isReady(completeCheck?: boolean): boolean;
  16834. /**
  16835. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16836. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16837. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16838. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16839. */
  16840. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16841. /**
  16842. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16843. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16844. * The `data` are either a numeric array either a Float32Array.
  16845. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16846. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16847. * Note that a new underlying VertexBuffer object is created each call.
  16848. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16849. *
  16850. * Possible `kind` values :
  16851. * - VertexBuffer.PositionKind
  16852. * - VertexBuffer.UVKind
  16853. * - VertexBuffer.UV2Kind
  16854. * - VertexBuffer.UV3Kind
  16855. * - VertexBuffer.UV4Kind
  16856. * - VertexBuffer.UV5Kind
  16857. * - VertexBuffer.UV6Kind
  16858. * - VertexBuffer.ColorKind
  16859. * - VertexBuffer.MatricesIndicesKind
  16860. * - VertexBuffer.MatricesIndicesExtraKind
  16861. * - VertexBuffer.MatricesWeightsKind
  16862. * - VertexBuffer.MatricesWeightsExtraKind
  16863. *
  16864. * Returns the Mesh.
  16865. */
  16866. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16867. /**
  16868. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16869. * If the mesh has no geometry, it is simply returned as it is.
  16870. * The `data` are either a numeric array either a Float32Array.
  16871. * No new underlying VertexBuffer object is created.
  16872. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16873. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16874. *
  16875. * Possible `kind` values :
  16876. * - VertexBuffer.PositionKind
  16877. * - VertexBuffer.UVKind
  16878. * - VertexBuffer.UV2Kind
  16879. * - VertexBuffer.UV3Kind
  16880. * - VertexBuffer.UV4Kind
  16881. * - VertexBuffer.UV5Kind
  16882. * - VertexBuffer.UV6Kind
  16883. * - VertexBuffer.ColorKind
  16884. * - VertexBuffer.MatricesIndicesKind
  16885. * - VertexBuffer.MatricesIndicesExtraKind
  16886. * - VertexBuffer.MatricesWeightsKind
  16887. * - VertexBuffer.MatricesWeightsExtraKind
  16888. *
  16889. * Returns the Mesh.
  16890. */
  16891. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16892. /**
  16893. * Sets the mesh indices.
  16894. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16895. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16896. * This method creates a new index buffer each call.
  16897. * Returns the Mesh.
  16898. */
  16899. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16900. /**
  16901. * Boolean : True if the mesh owns the requested kind of data.
  16902. */
  16903. isVerticesDataPresent(kind: string): boolean;
  16904. /**
  16905. * Returns an array of indices (IndicesArray).
  16906. */
  16907. getIndices(): Nullable<IndicesArray>;
  16908. get _positions(): Nullable<Vector3[]>;
  16909. /**
  16910. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16911. * This means the mesh underlying bounding box and sphere are recomputed.
  16912. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16913. * @returns the current mesh
  16914. */
  16915. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16916. /** @hidden */
  16917. _preActivate(): InstancedMesh;
  16918. /** @hidden */
  16919. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16920. /** @hidden */
  16921. _postActivate(): void;
  16922. getWorldMatrix(): Matrix;
  16923. get isAnInstance(): boolean;
  16924. /**
  16925. * Returns the current associated LOD AbstractMesh.
  16926. */
  16927. getLOD(camera: Camera): AbstractMesh;
  16928. /** @hidden */
  16929. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16930. /** @hidden */
  16931. _syncSubMeshes(): InstancedMesh;
  16932. /** @hidden */
  16933. _generatePointsArray(): boolean;
  16934. /** @hidden */
  16935. _updateBoundingInfo(): AbstractMesh;
  16936. /**
  16937. * Creates a new InstancedMesh from the current mesh.
  16938. * - name (string) : the cloned mesh name
  16939. * - newParent (optional Node) : the optional Node to parent the clone to.
  16940. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16941. *
  16942. * Returns the clone.
  16943. */
  16944. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16945. /**
  16946. * Disposes the InstancedMesh.
  16947. * Returns nothing.
  16948. */
  16949. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16950. }
  16951. module "babylonjs/Meshes/mesh" {
  16952. interface Mesh {
  16953. /**
  16954. * Register a custom buffer that will be instanced
  16955. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16956. * @param kind defines the buffer kind
  16957. * @param stride defines the stride in floats
  16958. */
  16959. registerInstancedBuffer(kind: string, stride: number): void;
  16960. /**
  16961. * true to use the edge renderer for all instances of this mesh
  16962. */
  16963. edgesShareWithInstances: boolean;
  16964. /** @hidden */
  16965. _userInstancedBuffersStorage: {
  16966. data: {
  16967. [key: string]: Float32Array;
  16968. };
  16969. sizes: {
  16970. [key: string]: number;
  16971. };
  16972. vertexBuffers: {
  16973. [key: string]: Nullable<VertexBuffer>;
  16974. };
  16975. strides: {
  16976. [key: string]: number;
  16977. };
  16978. };
  16979. }
  16980. }
  16981. module "babylonjs/Meshes/abstractMesh" {
  16982. interface AbstractMesh {
  16983. /**
  16984. * Object used to store instanced buffers defined by user
  16985. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16986. */
  16987. instancedBuffers: {
  16988. [key: string]: any;
  16989. };
  16990. }
  16991. }
  16992. }
  16993. declare module "babylonjs/Materials/shaderMaterial" {
  16994. import { Nullable } from "babylonjs/types";
  16995. import { Scene } from "babylonjs/scene";
  16996. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16998. import { Mesh } from "babylonjs/Meshes/mesh";
  16999. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17000. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17001. import { Effect } from "babylonjs/Materials/effect";
  17002. import { Material } from "babylonjs/Materials/material";
  17003. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17004. /**
  17005. * Defines the options associated with the creation of a shader material.
  17006. */
  17007. export interface IShaderMaterialOptions {
  17008. /**
  17009. * Does the material work in alpha blend mode
  17010. */
  17011. needAlphaBlending: boolean;
  17012. /**
  17013. * Does the material work in alpha test mode
  17014. */
  17015. needAlphaTesting: boolean;
  17016. /**
  17017. * The list of attribute names used in the shader
  17018. */
  17019. attributes: string[];
  17020. /**
  17021. * The list of unifrom names used in the shader
  17022. */
  17023. uniforms: string[];
  17024. /**
  17025. * The list of UBO names used in the shader
  17026. */
  17027. uniformBuffers: string[];
  17028. /**
  17029. * The list of sampler names used in the shader
  17030. */
  17031. samplers: string[];
  17032. /**
  17033. * The list of defines used in the shader
  17034. */
  17035. defines: string[];
  17036. }
  17037. /**
  17038. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  17039. *
  17040. * This returned material effects how the mesh will look based on the code in the shaders.
  17041. *
  17042. * @see https://doc.babylonjs.com/how_to/shader_material
  17043. */
  17044. export class ShaderMaterial extends Material {
  17045. private _shaderPath;
  17046. private _options;
  17047. private _textures;
  17048. private _textureArrays;
  17049. private _floats;
  17050. private _ints;
  17051. private _floatsArrays;
  17052. private _colors3;
  17053. private _colors3Arrays;
  17054. private _colors4;
  17055. private _colors4Arrays;
  17056. private _vectors2;
  17057. private _vectors3;
  17058. private _vectors4;
  17059. private _matrices;
  17060. private _matrixArrays;
  17061. private _matrices3x3;
  17062. private _matrices2x2;
  17063. private _vectors2Arrays;
  17064. private _vectors3Arrays;
  17065. private _vectors4Arrays;
  17066. private _cachedWorldViewMatrix;
  17067. private _cachedWorldViewProjectionMatrix;
  17068. private _renderId;
  17069. private _multiview;
  17070. private _cachedDefines;
  17071. /** Define the Url to load snippets */
  17072. static SnippetUrl: string;
  17073. /** Snippet ID if the material was created from the snippet server */
  17074. snippetId: string;
  17075. /**
  17076. * Instantiate a new shader material.
  17077. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  17078. * This returned material effects how the mesh will look based on the code in the shaders.
  17079. * @see https://doc.babylonjs.com/how_to/shader_material
  17080. * @param name Define the name of the material in the scene
  17081. * @param scene Define the scene the material belongs to
  17082. * @param shaderPath Defines the route to the shader code in one of three ways:
  17083. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17084. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17085. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17086. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17087. * @param options Define the options used to create the shader
  17088. */
  17089. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17090. /**
  17091. * Gets the shader path used to define the shader code
  17092. * It can be modified to trigger a new compilation
  17093. */
  17094. get shaderPath(): any;
  17095. /**
  17096. * Sets the shader path used to define the shader code
  17097. * It can be modified to trigger a new compilation
  17098. */
  17099. set shaderPath(shaderPath: any);
  17100. /**
  17101. * Gets the options used to compile the shader.
  17102. * They can be modified to trigger a new compilation
  17103. */
  17104. get options(): IShaderMaterialOptions;
  17105. /**
  17106. * Gets the current class name of the material e.g. "ShaderMaterial"
  17107. * Mainly use in serialization.
  17108. * @returns the class name
  17109. */
  17110. getClassName(): string;
  17111. /**
  17112. * Specifies if the material will require alpha blending
  17113. * @returns a boolean specifying if alpha blending is needed
  17114. */
  17115. needAlphaBlending(): boolean;
  17116. /**
  17117. * Specifies if this material should be rendered in alpha test mode
  17118. * @returns a boolean specifying if an alpha test is needed.
  17119. */
  17120. needAlphaTesting(): boolean;
  17121. private _checkUniform;
  17122. /**
  17123. * Set a texture in the shader.
  17124. * @param name Define the name of the uniform samplers as defined in the shader
  17125. * @param texture Define the texture to bind to this sampler
  17126. * @return the material itself allowing "fluent" like uniform updates
  17127. */
  17128. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17129. /**
  17130. * Set a texture array in the shader.
  17131. * @param name Define the name of the uniform sampler array as defined in the shader
  17132. * @param textures Define the list of textures to bind to this sampler
  17133. * @return the material itself allowing "fluent" like uniform updates
  17134. */
  17135. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17136. /**
  17137. * Set a float in the shader.
  17138. * @param name Define the name of the uniform as defined in the shader
  17139. * @param value Define the value to give to the uniform
  17140. * @return the material itself allowing "fluent" like uniform updates
  17141. */
  17142. setFloat(name: string, value: number): ShaderMaterial;
  17143. /**
  17144. * Set a int in the shader.
  17145. * @param name Define the name of the uniform as defined in the shader
  17146. * @param value Define the value to give to the uniform
  17147. * @return the material itself allowing "fluent" like uniform updates
  17148. */
  17149. setInt(name: string, value: number): ShaderMaterial;
  17150. /**
  17151. * Set an array of floats in the shader.
  17152. * @param name Define the name of the uniform as defined in the shader
  17153. * @param value Define the value to give to the uniform
  17154. * @return the material itself allowing "fluent" like uniform updates
  17155. */
  17156. setFloats(name: string, value: number[]): ShaderMaterial;
  17157. /**
  17158. * Set a vec3 in the shader from a Color3.
  17159. * @param name Define the name of the uniform as defined in the shader
  17160. * @param value Define the value to give to the uniform
  17161. * @return the material itself allowing "fluent" like uniform updates
  17162. */
  17163. setColor3(name: string, value: Color3): ShaderMaterial;
  17164. /**
  17165. * Set a vec3 array in the shader from a Color3 array.
  17166. * @param name Define the name of the uniform as defined in the shader
  17167. * @param value Define the value to give to the uniform
  17168. * @return the material itself allowing "fluent" like uniform updates
  17169. */
  17170. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17171. /**
  17172. * Set a vec4 in the shader from a Color4.
  17173. * @param name Define the name of the uniform as defined in the shader
  17174. * @param value Define the value to give to the uniform
  17175. * @return the material itself allowing "fluent" like uniform updates
  17176. */
  17177. setColor4(name: string, value: Color4): ShaderMaterial;
  17178. /**
  17179. * Set a vec4 array in the shader from a Color4 array.
  17180. * @param name Define the name of the uniform as defined in the shader
  17181. * @param value Define the value to give to the uniform
  17182. * @return the material itself allowing "fluent" like uniform updates
  17183. */
  17184. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17185. /**
  17186. * Set a vec2 in the shader from a Vector2.
  17187. * @param name Define the name of the uniform as defined in the shader
  17188. * @param value Define the value to give to the uniform
  17189. * @return the material itself allowing "fluent" like uniform updates
  17190. */
  17191. setVector2(name: string, value: Vector2): ShaderMaterial;
  17192. /**
  17193. * Set a vec3 in the shader from a Vector3.
  17194. * @param name Define the name of the uniform as defined in the shader
  17195. * @param value Define the value to give to the uniform
  17196. * @return the material itself allowing "fluent" like uniform updates
  17197. */
  17198. setVector3(name: string, value: Vector3): ShaderMaterial;
  17199. /**
  17200. * Set a vec4 in the shader from a Vector4.
  17201. * @param name Define the name of the uniform as defined in the shader
  17202. * @param value Define the value to give to the uniform
  17203. * @return the material itself allowing "fluent" like uniform updates
  17204. */
  17205. setVector4(name: string, value: Vector4): ShaderMaterial;
  17206. /**
  17207. * Set a mat4 in the shader from a Matrix.
  17208. * @param name Define the name of the uniform as defined in the shader
  17209. * @param value Define the value to give to the uniform
  17210. * @return the material itself allowing "fluent" like uniform updates
  17211. */
  17212. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17213. /**
  17214. * Set a float32Array in the shader from a matrix array.
  17215. * @param name Define the name of the uniform as defined in the shader
  17216. * @param value Define the value to give to the uniform
  17217. * @return the material itself allowing "fluent" like uniform updates
  17218. */
  17219. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17220. /**
  17221. * Set a mat3 in the shader from a Float32Array.
  17222. * @param name Define the name of the uniform as defined in the shader
  17223. * @param value Define the value to give to the uniform
  17224. * @return the material itself allowing "fluent" like uniform updates
  17225. */
  17226. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17227. /**
  17228. * Set a mat2 in the shader from a Float32Array.
  17229. * @param name Define the name of the uniform as defined in the shader
  17230. * @param value Define the value to give to the uniform
  17231. * @return the material itself allowing "fluent" like uniform updates
  17232. */
  17233. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17234. /**
  17235. * Set a vec2 array in the shader from a number array.
  17236. * @param name Define the name of the uniform as defined in the shader
  17237. * @param value Define the value to give to the uniform
  17238. * @return the material itself allowing "fluent" like uniform updates
  17239. */
  17240. setArray2(name: string, value: number[]): ShaderMaterial;
  17241. /**
  17242. * Set a vec3 array in the shader from a number array.
  17243. * @param name Define the name of the uniform as defined in the shader
  17244. * @param value Define the value to give to the uniform
  17245. * @return the material itself allowing "fluent" like uniform updates
  17246. */
  17247. setArray3(name: string, value: number[]): ShaderMaterial;
  17248. /**
  17249. * Set a vec4 array in the shader from a number array.
  17250. * @param name Define the name of the uniform as defined in the shader
  17251. * @param value Define the value to give to the uniform
  17252. * @return the material itself allowing "fluent" like uniform updates
  17253. */
  17254. setArray4(name: string, value: number[]): ShaderMaterial;
  17255. private _checkCache;
  17256. /**
  17257. * Specifies that the submesh is ready to be used
  17258. * @param mesh defines the mesh to check
  17259. * @param subMesh defines which submesh to check
  17260. * @param useInstances specifies that instances should be used
  17261. * @returns a boolean indicating that the submesh is ready or not
  17262. */
  17263. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17264. /**
  17265. * Checks if the material is ready to render the requested mesh
  17266. * @param mesh Define the mesh to render
  17267. * @param useInstances Define whether or not the material is used with instances
  17268. * @returns true if ready, otherwise false
  17269. */
  17270. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17271. /**
  17272. * Binds the world matrix to the material
  17273. * @param world defines the world transformation matrix
  17274. * @param effectOverride - If provided, use this effect instead of internal effect
  17275. */
  17276. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17277. /**
  17278. * Binds the submesh to this material by preparing the effect and shader to draw
  17279. * @param world defines the world transformation matrix
  17280. * @param mesh defines the mesh containing the submesh
  17281. * @param subMesh defines the submesh to bind the material to
  17282. */
  17283. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17284. /**
  17285. * Binds the material to the mesh
  17286. * @param world defines the world transformation matrix
  17287. * @param mesh defines the mesh to bind the material to
  17288. * @param effectOverride - If provided, use this effect instead of internal effect
  17289. */
  17290. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17291. protected _afterBind(mesh?: Mesh): void;
  17292. /**
  17293. * Gets the active textures from the material
  17294. * @returns an array of textures
  17295. */
  17296. getActiveTextures(): BaseTexture[];
  17297. /**
  17298. * Specifies if the material uses a texture
  17299. * @param texture defines the texture to check against the material
  17300. * @returns a boolean specifying if the material uses the texture
  17301. */
  17302. hasTexture(texture: BaseTexture): boolean;
  17303. /**
  17304. * Makes a duplicate of the material, and gives it a new name
  17305. * @param name defines the new name for the duplicated material
  17306. * @returns the cloned material
  17307. */
  17308. clone(name: string): ShaderMaterial;
  17309. /**
  17310. * Disposes the material
  17311. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17312. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17313. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17314. */
  17315. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17316. /**
  17317. * Serializes this material in a JSON representation
  17318. * @returns the serialized material object
  17319. */
  17320. serialize(): any;
  17321. /**
  17322. * Creates a shader material from parsed shader material data
  17323. * @param source defines the JSON represnetation of the material
  17324. * @param scene defines the hosting scene
  17325. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17326. * @returns a new material
  17327. */
  17328. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17329. /**
  17330. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17331. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17332. * @param url defines the url to load from
  17333. * @param scene defines the hosting scene
  17334. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17335. * @returns a promise that will resolve to the new ShaderMaterial
  17336. */
  17337. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17338. /**
  17339. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17340. * @param snippetId defines the snippet to load
  17341. * @param scene defines the hosting scene
  17342. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17343. * @returns a promise that will resolve to the new ShaderMaterial
  17344. */
  17345. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17346. }
  17347. }
  17348. declare module "babylonjs/Shaders/color.fragment" {
  17349. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17350. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17351. /** @hidden */
  17352. export var colorPixelShader: {
  17353. name: string;
  17354. shader: string;
  17355. };
  17356. }
  17357. declare module "babylonjs/Shaders/color.vertex" {
  17358. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17359. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17360. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17361. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17362. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17363. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17364. /** @hidden */
  17365. export var colorVertexShader: {
  17366. name: string;
  17367. shader: string;
  17368. };
  17369. }
  17370. declare module "babylonjs/Meshes/linesMesh" {
  17371. import { Nullable } from "babylonjs/types";
  17372. import { Scene } from "babylonjs/scene";
  17373. import { Color3 } from "babylonjs/Maths/math.color";
  17374. import { Node } from "babylonjs/node";
  17375. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17376. import { Mesh } from "babylonjs/Meshes/mesh";
  17377. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17378. import { Effect } from "babylonjs/Materials/effect";
  17379. import { Material } from "babylonjs/Materials/material";
  17380. import "babylonjs/Shaders/color.fragment";
  17381. import "babylonjs/Shaders/color.vertex";
  17382. /**
  17383. * Line mesh
  17384. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17385. */
  17386. export class LinesMesh extends Mesh {
  17387. /**
  17388. * If vertex color should be applied to the mesh
  17389. */
  17390. readonly useVertexColor?: boolean | undefined;
  17391. /**
  17392. * If vertex alpha should be applied to the mesh
  17393. */
  17394. readonly useVertexAlpha?: boolean | undefined;
  17395. /**
  17396. * Color of the line (Default: White)
  17397. */
  17398. color: Color3;
  17399. /**
  17400. * Alpha of the line (Default: 1)
  17401. */
  17402. alpha: number;
  17403. /**
  17404. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17405. * This margin is expressed in world space coordinates, so its value may vary.
  17406. * Default value is 0.1
  17407. */
  17408. intersectionThreshold: number;
  17409. private _colorShader;
  17410. private color4;
  17411. /**
  17412. * Creates a new LinesMesh
  17413. * @param name defines the name
  17414. * @param scene defines the hosting scene
  17415. * @param parent defines the parent mesh if any
  17416. * @param source defines the optional source LinesMesh used to clone data from
  17417. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17418. * When false, achieved by calling a clone(), also passing False.
  17419. * This will make creation of children, recursive.
  17420. * @param useVertexColor defines if this LinesMesh supports vertex color
  17421. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17422. */
  17423. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17424. /**
  17425. * If vertex color should be applied to the mesh
  17426. */
  17427. useVertexColor?: boolean | undefined,
  17428. /**
  17429. * If vertex alpha should be applied to the mesh
  17430. */
  17431. useVertexAlpha?: boolean | undefined);
  17432. private _addClipPlaneDefine;
  17433. private _removeClipPlaneDefine;
  17434. isReady(): boolean;
  17435. /**
  17436. * Returns the string "LineMesh"
  17437. */
  17438. getClassName(): string;
  17439. /**
  17440. * @hidden
  17441. */
  17442. get material(): Material;
  17443. /**
  17444. * @hidden
  17445. */
  17446. set material(value: Material);
  17447. /**
  17448. * @hidden
  17449. */
  17450. get checkCollisions(): boolean;
  17451. /** @hidden */
  17452. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17453. /** @hidden */
  17454. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17455. /**
  17456. * Disposes of the line mesh
  17457. * @param doNotRecurse If children should be disposed
  17458. */
  17459. dispose(doNotRecurse?: boolean): void;
  17460. /**
  17461. * Returns a new LineMesh object cloned from the current one.
  17462. */
  17463. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17464. /**
  17465. * Creates a new InstancedLinesMesh object from the mesh model.
  17466. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17467. * @param name defines the name of the new instance
  17468. * @returns a new InstancedLinesMesh
  17469. */
  17470. createInstance(name: string): InstancedLinesMesh;
  17471. }
  17472. /**
  17473. * Creates an instance based on a source LinesMesh
  17474. */
  17475. export class InstancedLinesMesh extends InstancedMesh {
  17476. /**
  17477. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17478. * This margin is expressed in world space coordinates, so its value may vary.
  17479. * Initilized with the intersectionThreshold value of the source LinesMesh
  17480. */
  17481. intersectionThreshold: number;
  17482. constructor(name: string, source: LinesMesh);
  17483. /**
  17484. * Returns the string "InstancedLinesMesh".
  17485. */
  17486. getClassName(): string;
  17487. }
  17488. }
  17489. declare module "babylonjs/Shaders/line.fragment" {
  17490. /** @hidden */
  17491. export var linePixelShader: {
  17492. name: string;
  17493. shader: string;
  17494. };
  17495. }
  17496. declare module "babylonjs/Shaders/line.vertex" {
  17497. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17498. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17499. /** @hidden */
  17500. export var lineVertexShader: {
  17501. name: string;
  17502. shader: string;
  17503. };
  17504. }
  17505. declare module "babylonjs/Rendering/edgesRenderer" {
  17506. import { Nullable } from "babylonjs/types";
  17507. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17509. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17510. import { IDisposable } from "babylonjs/scene";
  17511. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17512. import "babylonjs/Shaders/line.fragment";
  17513. import "babylonjs/Shaders/line.vertex";
  17514. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17515. import { SmartArray } from "babylonjs/Misc/smartArray";
  17516. module "babylonjs/scene" {
  17517. interface Scene {
  17518. /** @hidden */
  17519. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17520. }
  17521. }
  17522. module "babylonjs/Meshes/abstractMesh" {
  17523. interface AbstractMesh {
  17524. /**
  17525. * Gets the edgesRenderer associated with the mesh
  17526. */
  17527. edgesRenderer: Nullable<EdgesRenderer>;
  17528. }
  17529. }
  17530. module "babylonjs/Meshes/linesMesh" {
  17531. interface LinesMesh {
  17532. /**
  17533. * Enables the edge rendering mode on the mesh.
  17534. * This mode makes the mesh edges visible
  17535. * @param epsilon defines the maximal distance between two angles to detect a face
  17536. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17537. * @returns the currentAbstractMesh
  17538. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17539. */
  17540. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17541. }
  17542. }
  17543. module "babylonjs/Meshes/linesMesh" {
  17544. interface InstancedLinesMesh {
  17545. /**
  17546. * Enables the edge rendering mode on the mesh.
  17547. * This mode makes the mesh edges visible
  17548. * @param epsilon defines the maximal distance between two angles to detect a face
  17549. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17550. * @returns the current InstancedLinesMesh
  17551. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17552. */
  17553. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17554. }
  17555. }
  17556. /**
  17557. * Defines the minimum contract an Edges renderer should follow.
  17558. */
  17559. export interface IEdgesRenderer extends IDisposable {
  17560. /**
  17561. * Gets or sets a boolean indicating if the edgesRenderer is active
  17562. */
  17563. isEnabled: boolean;
  17564. /**
  17565. * Renders the edges of the attached mesh,
  17566. */
  17567. render(): void;
  17568. /**
  17569. * Checks wether or not the edges renderer is ready to render.
  17570. * @return true if ready, otherwise false.
  17571. */
  17572. isReady(): boolean;
  17573. /**
  17574. * List of instances to render in case the source mesh has instances
  17575. */
  17576. customInstances: SmartArray<Matrix>;
  17577. }
  17578. /**
  17579. * Defines the additional options of the edges renderer
  17580. */
  17581. export interface IEdgesRendererOptions {
  17582. /**
  17583. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17584. * If not defined, the default value is true
  17585. */
  17586. useAlternateEdgeFinder?: boolean;
  17587. /**
  17588. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17589. * If not defined, the default value is true.
  17590. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  17591. * This option is used only if useAlternateEdgeFinder = true
  17592. */
  17593. useFastVertexMerger?: boolean;
  17594. /**
  17595. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17596. * The default value is 1e-6
  17597. * This option is used only if useAlternateEdgeFinder = true
  17598. */
  17599. epsilonVertexMerge?: number;
  17600. /**
  17601. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  17602. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  17603. * This option is used only if useAlternateEdgeFinder = true
  17604. */
  17605. applyTessellation?: boolean;
  17606. /**
  17607. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  17608. * The default value is 1e-6
  17609. * This option is used only if useAlternateEdgeFinder = true
  17610. */
  17611. epsilonVertexAligned?: number;
  17612. }
  17613. /**
  17614. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17615. */
  17616. export class EdgesRenderer implements IEdgesRenderer {
  17617. /**
  17618. * Define the size of the edges with an orthographic camera
  17619. */
  17620. edgesWidthScalerForOrthographic: number;
  17621. /**
  17622. * Define the size of the edges with a perspective camera
  17623. */
  17624. edgesWidthScalerForPerspective: number;
  17625. protected _source: AbstractMesh;
  17626. protected _linesPositions: number[];
  17627. protected _linesNormals: number[];
  17628. protected _linesIndices: number[];
  17629. protected _epsilon: number;
  17630. protected _indicesCount: number;
  17631. protected _lineShader: ShaderMaterial;
  17632. protected _ib: DataBuffer;
  17633. protected _buffers: {
  17634. [key: string]: Nullable<VertexBuffer>;
  17635. };
  17636. protected _buffersForInstances: {
  17637. [key: string]: Nullable<VertexBuffer>;
  17638. };
  17639. protected _checkVerticesInsteadOfIndices: boolean;
  17640. protected _options: Nullable<IEdgesRendererOptions>;
  17641. private _meshRebuildObserver;
  17642. private _meshDisposeObserver;
  17643. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17644. isEnabled: boolean;
  17645. /**
  17646. * List of instances to render in case the source mesh has instances
  17647. */
  17648. customInstances: SmartArray<Matrix>;
  17649. private static GetShader;
  17650. /**
  17651. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17652. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17653. * @param source Mesh used to create edges
  17654. * @param epsilon sum of angles in adjacency to check for edge
  17655. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17656. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17657. * @param options The options to apply when generating the edges
  17658. */
  17659. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17660. protected _prepareRessources(): void;
  17661. /** @hidden */
  17662. _rebuild(): void;
  17663. /**
  17664. * Releases the required resources for the edges renderer
  17665. */
  17666. dispose(): void;
  17667. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17668. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17669. /**
  17670. * Checks if the pair of p0 and p1 is en edge
  17671. * @param faceIndex
  17672. * @param edge
  17673. * @param faceNormals
  17674. * @param p0
  17675. * @param p1
  17676. * @private
  17677. */
  17678. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17679. /**
  17680. * push line into the position, normal and index buffer
  17681. * @protected
  17682. */
  17683. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17684. /**
  17685. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17686. */
  17687. private _tessellateTriangle;
  17688. private _generateEdgesLinesAlternate;
  17689. /**
  17690. * Generates lines edges from adjacencjes
  17691. * @private
  17692. */
  17693. _generateEdgesLines(): void;
  17694. /**
  17695. * Checks wether or not the edges renderer is ready to render.
  17696. * @return true if ready, otherwise false.
  17697. */
  17698. isReady(): boolean;
  17699. /**
  17700. * Renders the edges of the attached mesh,
  17701. */
  17702. render(): void;
  17703. }
  17704. /**
  17705. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17706. */
  17707. export class LineEdgesRenderer extends EdgesRenderer {
  17708. /**
  17709. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17710. * @param source LineMesh used to generate edges
  17711. * @param epsilon not important (specified angle for edge detection)
  17712. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17713. */
  17714. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17715. /**
  17716. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17717. */
  17718. _generateEdgesLines(): void;
  17719. }
  17720. }
  17721. declare module "babylonjs/Rendering/renderingGroup" {
  17722. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17723. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17725. import { Nullable } from "babylonjs/types";
  17726. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17727. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17728. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17729. import { Material } from "babylonjs/Materials/material";
  17730. import { Scene } from "babylonjs/scene";
  17731. /**
  17732. * This represents the object necessary to create a rendering group.
  17733. * This is exclusively used and created by the rendering manager.
  17734. * To modify the behavior, you use the available helpers in your scene or meshes.
  17735. * @hidden
  17736. */
  17737. export class RenderingGroup {
  17738. index: number;
  17739. private static _zeroVector;
  17740. private _scene;
  17741. private _opaqueSubMeshes;
  17742. private _transparentSubMeshes;
  17743. private _alphaTestSubMeshes;
  17744. private _depthOnlySubMeshes;
  17745. private _particleSystems;
  17746. private _spriteManagers;
  17747. private _opaqueSortCompareFn;
  17748. private _alphaTestSortCompareFn;
  17749. private _transparentSortCompareFn;
  17750. private _renderOpaque;
  17751. private _renderAlphaTest;
  17752. private _renderTransparent;
  17753. /** @hidden */
  17754. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17755. onBeforeTransparentRendering: () => void;
  17756. /**
  17757. * Set the opaque sort comparison function.
  17758. * If null the sub meshes will be render in the order they were created
  17759. */
  17760. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17761. /**
  17762. * Set the alpha test sort comparison function.
  17763. * If null the sub meshes will be render in the order they were created
  17764. */
  17765. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17766. /**
  17767. * Set the transparent sort comparison function.
  17768. * If null the sub meshes will be render in the order they were created
  17769. */
  17770. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17771. /**
  17772. * Creates a new rendering group.
  17773. * @param index The rendering group index
  17774. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17775. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17776. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17777. */
  17778. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17779. /**
  17780. * Render all the sub meshes contained in the group.
  17781. * @param customRenderFunction Used to override the default render behaviour of the group.
  17782. * @returns true if rendered some submeshes.
  17783. */
  17784. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17785. /**
  17786. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17787. * @param subMeshes The submeshes to render
  17788. */
  17789. private renderOpaqueSorted;
  17790. /**
  17791. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17792. * @param subMeshes The submeshes to render
  17793. */
  17794. private renderAlphaTestSorted;
  17795. /**
  17796. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17797. * @param subMeshes The submeshes to render
  17798. */
  17799. private renderTransparentSorted;
  17800. /**
  17801. * Renders the submeshes in a specified order.
  17802. * @param subMeshes The submeshes to sort before render
  17803. * @param sortCompareFn The comparison function use to sort
  17804. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17805. * @param transparent Specifies to activate blending if true
  17806. */
  17807. private static renderSorted;
  17808. /**
  17809. * Renders the submeshes in the order they were dispatched (no sort applied).
  17810. * @param subMeshes The submeshes to render
  17811. */
  17812. private static renderUnsorted;
  17813. /**
  17814. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17815. * are rendered back to front if in the same alpha index.
  17816. *
  17817. * @param a The first submesh
  17818. * @param b The second submesh
  17819. * @returns The result of the comparison
  17820. */
  17821. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17822. /**
  17823. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17824. * are rendered back to front.
  17825. *
  17826. * @param a The first submesh
  17827. * @param b The second submesh
  17828. * @returns The result of the comparison
  17829. */
  17830. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17831. /**
  17832. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17833. * are rendered front to back (prevent overdraw).
  17834. *
  17835. * @param a The first submesh
  17836. * @param b The second submesh
  17837. * @returns The result of the comparison
  17838. */
  17839. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17840. /**
  17841. * Resets the different lists of submeshes to prepare a new frame.
  17842. */
  17843. prepare(): void;
  17844. dispose(): void;
  17845. /**
  17846. * Inserts the submesh in its correct queue depending on its material.
  17847. * @param subMesh The submesh to dispatch
  17848. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17849. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17850. */
  17851. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17852. dispatchSprites(spriteManager: ISpriteManager): void;
  17853. dispatchParticles(particleSystem: IParticleSystem): void;
  17854. private _renderParticles;
  17855. private _renderSprites;
  17856. }
  17857. }
  17858. declare module "babylonjs/Rendering/renderingManager" {
  17859. import { Nullable } from "babylonjs/types";
  17860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17861. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17862. import { SmartArray } from "babylonjs/Misc/smartArray";
  17863. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17864. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17865. import { Material } from "babylonjs/Materials/material";
  17866. import { Scene } from "babylonjs/scene";
  17867. import { Camera } from "babylonjs/Cameras/camera";
  17868. /**
  17869. * Interface describing the different options available in the rendering manager
  17870. * regarding Auto Clear between groups.
  17871. */
  17872. export interface IRenderingManagerAutoClearSetup {
  17873. /**
  17874. * Defines whether or not autoclear is enable.
  17875. */
  17876. autoClear: boolean;
  17877. /**
  17878. * Defines whether or not to autoclear the depth buffer.
  17879. */
  17880. depth: boolean;
  17881. /**
  17882. * Defines whether or not to autoclear the stencil buffer.
  17883. */
  17884. stencil: boolean;
  17885. }
  17886. /**
  17887. * This class is used by the onRenderingGroupObservable
  17888. */
  17889. export class RenderingGroupInfo {
  17890. /**
  17891. * The Scene that being rendered
  17892. */
  17893. scene: Scene;
  17894. /**
  17895. * The camera currently used for the rendering pass
  17896. */
  17897. camera: Nullable<Camera>;
  17898. /**
  17899. * The ID of the renderingGroup being processed
  17900. */
  17901. renderingGroupId: number;
  17902. }
  17903. /**
  17904. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17905. * It is enable to manage the different groups as well as the different necessary sort functions.
  17906. * This should not be used directly aside of the few static configurations
  17907. */
  17908. export class RenderingManager {
  17909. /**
  17910. * The max id used for rendering groups (not included)
  17911. */
  17912. static MAX_RENDERINGGROUPS: number;
  17913. /**
  17914. * The min id used for rendering groups (included)
  17915. */
  17916. static MIN_RENDERINGGROUPS: number;
  17917. /**
  17918. * Used to globally prevent autoclearing scenes.
  17919. */
  17920. static AUTOCLEAR: boolean;
  17921. /**
  17922. * @hidden
  17923. */
  17924. _useSceneAutoClearSetup: boolean;
  17925. private _scene;
  17926. private _renderingGroups;
  17927. private _depthStencilBufferAlreadyCleaned;
  17928. private _autoClearDepthStencil;
  17929. private _customOpaqueSortCompareFn;
  17930. private _customAlphaTestSortCompareFn;
  17931. private _customTransparentSortCompareFn;
  17932. private _renderingGroupInfo;
  17933. /**
  17934. * Instantiates a new rendering group for a particular scene
  17935. * @param scene Defines the scene the groups belongs to
  17936. */
  17937. constructor(scene: Scene);
  17938. private _clearDepthStencilBuffer;
  17939. /**
  17940. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17941. * @hidden
  17942. */
  17943. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17944. /**
  17945. * Resets the different information of the group to prepare a new frame
  17946. * @hidden
  17947. */
  17948. reset(): void;
  17949. /**
  17950. * Dispose and release the group and its associated resources.
  17951. * @hidden
  17952. */
  17953. dispose(): void;
  17954. /**
  17955. * Clear the info related to rendering groups preventing retention points during dispose.
  17956. */
  17957. freeRenderingGroups(): void;
  17958. private _prepareRenderingGroup;
  17959. /**
  17960. * Add a sprite manager to the rendering manager in order to render it this frame.
  17961. * @param spriteManager Define the sprite manager to render
  17962. */
  17963. dispatchSprites(spriteManager: ISpriteManager): void;
  17964. /**
  17965. * Add a particle system to the rendering manager in order to render it this frame.
  17966. * @param particleSystem Define the particle system to render
  17967. */
  17968. dispatchParticles(particleSystem: IParticleSystem): void;
  17969. /**
  17970. * Add a submesh to the manager in order to render it this frame
  17971. * @param subMesh The submesh to dispatch
  17972. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17973. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17974. */
  17975. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17976. /**
  17977. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17978. * This allowed control for front to back rendering or reversly depending of the special needs.
  17979. *
  17980. * @param renderingGroupId The rendering group id corresponding to its index
  17981. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17982. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17983. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17984. */
  17985. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17986. /**
  17987. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17988. *
  17989. * @param renderingGroupId The rendering group id corresponding to its index
  17990. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17991. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17992. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17993. */
  17994. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17995. /**
  17996. * Gets the current auto clear configuration for one rendering group of the rendering
  17997. * manager.
  17998. * @param index the rendering group index to get the information for
  17999. * @returns The auto clear setup for the requested rendering group
  18000. */
  18001. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18002. }
  18003. }
  18004. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  18005. import { SmartArray } from "babylonjs/Misc/smartArray";
  18006. import { Nullable } from "babylonjs/types";
  18007. import { Scene } from "babylonjs/scene";
  18008. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  18009. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18011. import { Mesh } from "babylonjs/Meshes/mesh";
  18012. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  18013. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18014. import { Effect } from "babylonjs/Materials/effect";
  18015. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18016. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18017. import "babylonjs/Shaders/shadowMap.fragment";
  18018. import "babylonjs/Shaders/shadowMap.vertex";
  18019. import "babylonjs/Shaders/depthBoxBlur.fragment";
  18020. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  18021. import { Observable } from "babylonjs/Misc/observable";
  18022. /**
  18023. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18024. */
  18025. export interface ICustomShaderOptions {
  18026. /**
  18027. * Gets or sets the custom shader name to use
  18028. */
  18029. shaderName: string;
  18030. /**
  18031. * The list of attribute names used in the shader
  18032. */
  18033. attributes?: string[];
  18034. /**
  18035. * The list of unifrom names used in the shader
  18036. */
  18037. uniforms?: string[];
  18038. /**
  18039. * The list of sampler names used in the shader
  18040. */
  18041. samplers?: string[];
  18042. /**
  18043. * The list of defines used in the shader
  18044. */
  18045. defines?: string[];
  18046. }
  18047. /**
  18048. * Interface to implement to create a shadow generator compatible with BJS.
  18049. */
  18050. export interface IShadowGenerator {
  18051. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18052. id: string;
  18053. /**
  18054. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18055. * @returns The render target texture if present otherwise, null
  18056. */
  18057. getShadowMap(): Nullable<RenderTargetTexture>;
  18058. /**
  18059. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18060. * @param subMesh The submesh we want to render in the shadow map
  18061. * @param useInstances Defines wether will draw in the map using instances
  18062. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18063. * @returns true if ready otherwise, false
  18064. */
  18065. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18066. /**
  18067. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18068. * @param defines Defines of the material we want to update
  18069. * @param lightIndex Index of the light in the enabled light list of the material
  18070. */
  18071. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18072. /**
  18073. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18074. * defined in the generator but impacting the effect).
  18075. * It implies the unifroms available on the materials are the standard BJS ones.
  18076. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18077. * @param effect The effect we are binfing the information for
  18078. */
  18079. bindShadowLight(lightIndex: string, effect: Effect): void;
  18080. /**
  18081. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18082. * (eq to shadow prjection matrix * light transform matrix)
  18083. * @returns The transform matrix used to create the shadow map
  18084. */
  18085. getTransformMatrix(): Matrix;
  18086. /**
  18087. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18088. * Cube and 2D textures for instance.
  18089. */
  18090. recreateShadowMap(): void;
  18091. /**
  18092. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18093. * @param onCompiled Callback triggered at the and of the effects compilation
  18094. * @param options Sets of optional options forcing the compilation with different modes
  18095. */
  18096. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18097. useInstances: boolean;
  18098. }>): void;
  18099. /**
  18100. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18101. * @param options Sets of optional options forcing the compilation with different modes
  18102. * @returns A promise that resolves when the compilation completes
  18103. */
  18104. forceCompilationAsync(options?: Partial<{
  18105. useInstances: boolean;
  18106. }>): Promise<void>;
  18107. /**
  18108. * Serializes the shadow generator setup to a json object.
  18109. * @returns The serialized JSON object
  18110. */
  18111. serialize(): any;
  18112. /**
  18113. * Disposes the Shadow map and related Textures and effects.
  18114. */
  18115. dispose(): void;
  18116. }
  18117. /**
  18118. * Default implementation IShadowGenerator.
  18119. * This is the main object responsible of generating shadows in the framework.
  18120. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18121. */
  18122. export class ShadowGenerator implements IShadowGenerator {
  18123. /**
  18124. * Name of the shadow generator class
  18125. */
  18126. static CLASSNAME: string;
  18127. /**
  18128. * Shadow generator mode None: no filtering applied.
  18129. */
  18130. static readonly FILTER_NONE: number;
  18131. /**
  18132. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18133. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18134. */
  18135. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18136. /**
  18137. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18138. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18139. */
  18140. static readonly FILTER_POISSONSAMPLING: number;
  18141. /**
  18142. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18143. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18144. */
  18145. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18146. /**
  18147. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18148. * edge artifacts on steep falloff.
  18149. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18150. */
  18151. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18152. /**
  18153. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18154. * edge artifacts on steep falloff.
  18155. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18156. */
  18157. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18158. /**
  18159. * Shadow generator mode PCF: Percentage Closer Filtering
  18160. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18161. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18162. */
  18163. static readonly FILTER_PCF: number;
  18164. /**
  18165. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18166. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18167. * Contact Hardening
  18168. */
  18169. static readonly FILTER_PCSS: number;
  18170. /**
  18171. * Reserved for PCF and PCSS
  18172. * Highest Quality.
  18173. *
  18174. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18175. *
  18176. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18177. */
  18178. static readonly QUALITY_HIGH: number;
  18179. /**
  18180. * Reserved for PCF and PCSS
  18181. * Good tradeoff for quality/perf cross devices
  18182. *
  18183. * Execute PCF on a 3*3 kernel.
  18184. *
  18185. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18186. */
  18187. static readonly QUALITY_MEDIUM: number;
  18188. /**
  18189. * Reserved for PCF and PCSS
  18190. * The lowest quality but the fastest.
  18191. *
  18192. * Execute PCF on a 1*1 kernel.
  18193. *
  18194. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18195. */
  18196. static readonly QUALITY_LOW: number;
  18197. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18198. id: string;
  18199. /** Gets or sets the custom shader name to use */
  18200. customShaderOptions: ICustomShaderOptions;
  18201. /**
  18202. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18203. */
  18204. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18205. /**
  18206. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18207. */
  18208. onAfterShadowMapRenderObservable: Observable<Effect>;
  18209. /**
  18210. * Observable triggered before a mesh is rendered in the shadow map.
  18211. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18212. */
  18213. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18214. /**
  18215. * Observable triggered after a mesh is rendered in the shadow map.
  18216. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18217. */
  18218. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18219. protected _bias: number;
  18220. /**
  18221. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18222. */
  18223. get bias(): number;
  18224. /**
  18225. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18226. */
  18227. set bias(bias: number);
  18228. protected _normalBias: number;
  18229. /**
  18230. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18231. */
  18232. get normalBias(): number;
  18233. /**
  18234. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18235. */
  18236. set normalBias(normalBias: number);
  18237. protected _blurBoxOffset: number;
  18238. /**
  18239. * Gets the blur box offset: offset applied during the blur pass.
  18240. * Only useful if useKernelBlur = false
  18241. */
  18242. get blurBoxOffset(): number;
  18243. /**
  18244. * Sets the blur box offset: offset applied during the blur pass.
  18245. * Only useful if useKernelBlur = false
  18246. */
  18247. set blurBoxOffset(value: number);
  18248. protected _blurScale: number;
  18249. /**
  18250. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18251. * 2 means half of the size.
  18252. */
  18253. get blurScale(): number;
  18254. /**
  18255. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18256. * 2 means half of the size.
  18257. */
  18258. set blurScale(value: number);
  18259. protected _blurKernel: number;
  18260. /**
  18261. * Gets the blur kernel: kernel size of the blur pass.
  18262. * Only useful if useKernelBlur = true
  18263. */
  18264. get blurKernel(): number;
  18265. /**
  18266. * Sets the blur kernel: kernel size of the blur pass.
  18267. * Only useful if useKernelBlur = true
  18268. */
  18269. set blurKernel(value: number);
  18270. protected _useKernelBlur: boolean;
  18271. /**
  18272. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18273. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18274. */
  18275. get useKernelBlur(): boolean;
  18276. /**
  18277. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18278. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18279. */
  18280. set useKernelBlur(value: boolean);
  18281. protected _depthScale: number;
  18282. /**
  18283. * Gets the depth scale used in ESM mode.
  18284. */
  18285. get depthScale(): number;
  18286. /**
  18287. * Sets the depth scale used in ESM mode.
  18288. * This can override the scale stored on the light.
  18289. */
  18290. set depthScale(value: number);
  18291. protected _validateFilter(filter: number): number;
  18292. protected _filter: number;
  18293. /**
  18294. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18295. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18296. */
  18297. get filter(): number;
  18298. /**
  18299. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18300. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18301. */
  18302. set filter(value: number);
  18303. /**
  18304. * Gets if the current filter is set to Poisson Sampling.
  18305. */
  18306. get usePoissonSampling(): boolean;
  18307. /**
  18308. * Sets the current filter to Poisson Sampling.
  18309. */
  18310. set usePoissonSampling(value: boolean);
  18311. /**
  18312. * Gets if the current filter is set to ESM.
  18313. */
  18314. get useExponentialShadowMap(): boolean;
  18315. /**
  18316. * Sets the current filter is to ESM.
  18317. */
  18318. set useExponentialShadowMap(value: boolean);
  18319. /**
  18320. * Gets if the current filter is set to filtered ESM.
  18321. */
  18322. get useBlurExponentialShadowMap(): boolean;
  18323. /**
  18324. * Gets if the current filter is set to filtered ESM.
  18325. */
  18326. set useBlurExponentialShadowMap(value: boolean);
  18327. /**
  18328. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18329. * exponential to prevent steep falloff artifacts).
  18330. */
  18331. get useCloseExponentialShadowMap(): boolean;
  18332. /**
  18333. * Sets the current filter to "close ESM" (using the inverse of the
  18334. * exponential to prevent steep falloff artifacts).
  18335. */
  18336. set useCloseExponentialShadowMap(value: boolean);
  18337. /**
  18338. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18339. * exponential to prevent steep falloff artifacts).
  18340. */
  18341. get useBlurCloseExponentialShadowMap(): boolean;
  18342. /**
  18343. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18344. * exponential to prevent steep falloff artifacts).
  18345. */
  18346. set useBlurCloseExponentialShadowMap(value: boolean);
  18347. /**
  18348. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18349. */
  18350. get usePercentageCloserFiltering(): boolean;
  18351. /**
  18352. * Sets the current filter to "PCF" (percentage closer filtering).
  18353. */
  18354. set usePercentageCloserFiltering(value: boolean);
  18355. protected _filteringQuality: number;
  18356. /**
  18357. * Gets the PCF or PCSS Quality.
  18358. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18359. */
  18360. get filteringQuality(): number;
  18361. /**
  18362. * Sets the PCF or PCSS Quality.
  18363. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18364. */
  18365. set filteringQuality(filteringQuality: number);
  18366. /**
  18367. * Gets if the current filter is set to "PCSS" (contact hardening).
  18368. */
  18369. get useContactHardeningShadow(): boolean;
  18370. /**
  18371. * Sets the current filter to "PCSS" (contact hardening).
  18372. */
  18373. set useContactHardeningShadow(value: boolean);
  18374. protected _contactHardeningLightSizeUVRatio: number;
  18375. /**
  18376. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18377. * Using a ratio helps keeping shape stability independently of the map size.
  18378. *
  18379. * It does not account for the light projection as it was having too much
  18380. * instability during the light setup or during light position changes.
  18381. *
  18382. * Only valid if useContactHardeningShadow is true.
  18383. */
  18384. get contactHardeningLightSizeUVRatio(): number;
  18385. /**
  18386. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18387. * Using a ratio helps keeping shape stability independently of the map size.
  18388. *
  18389. * It does not account for the light projection as it was having too much
  18390. * instability during the light setup or during light position changes.
  18391. *
  18392. * Only valid if useContactHardeningShadow is true.
  18393. */
  18394. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18395. protected _darkness: number;
  18396. /** Gets or sets the actual darkness of a shadow */
  18397. get darkness(): number;
  18398. set darkness(value: number);
  18399. /**
  18400. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18401. * 0 means strongest and 1 would means no shadow.
  18402. * @returns the darkness.
  18403. */
  18404. getDarkness(): number;
  18405. /**
  18406. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18407. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18408. * @returns the shadow generator allowing fluent coding.
  18409. */
  18410. setDarkness(darkness: number): ShadowGenerator;
  18411. protected _transparencyShadow: boolean;
  18412. /** Gets or sets the ability to have transparent shadow */
  18413. get transparencyShadow(): boolean;
  18414. set transparencyShadow(value: boolean);
  18415. /**
  18416. * Sets the ability to have transparent shadow (boolean).
  18417. * @param transparent True if transparent else False
  18418. * @returns the shadow generator allowing fluent coding
  18419. */
  18420. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18421. /**
  18422. * Enables or disables shadows with varying strength based on the transparency
  18423. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18424. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18425. * mesh.visibility * alphaTexture.a
  18426. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18427. */
  18428. enableSoftTransparentShadow: boolean;
  18429. protected _shadowMap: Nullable<RenderTargetTexture>;
  18430. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18431. /**
  18432. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18433. * @returns The render target texture if present otherwise, null
  18434. */
  18435. getShadowMap(): Nullable<RenderTargetTexture>;
  18436. /**
  18437. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18438. * @returns The render target texture if the shadow map is present otherwise, null
  18439. */
  18440. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18441. /**
  18442. * Gets the class name of that object
  18443. * @returns "ShadowGenerator"
  18444. */
  18445. getClassName(): string;
  18446. /**
  18447. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18448. * @param mesh Mesh to add
  18449. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18450. * @returns the Shadow Generator itself
  18451. */
  18452. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18453. /**
  18454. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18455. * @param mesh Mesh to remove
  18456. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18457. * @returns the Shadow Generator itself
  18458. */
  18459. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18460. /**
  18461. * Controls the extent to which the shadows fade out at the edge of the frustum
  18462. */
  18463. frustumEdgeFalloff: number;
  18464. protected _light: IShadowLight;
  18465. /**
  18466. * Returns the associated light object.
  18467. * @returns the light generating the shadow
  18468. */
  18469. getLight(): IShadowLight;
  18470. /**
  18471. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18472. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18473. * It might on the other hand introduce peter panning.
  18474. */
  18475. forceBackFacesOnly: boolean;
  18476. protected _scene: Scene;
  18477. protected _lightDirection: Vector3;
  18478. protected _effect: Effect;
  18479. protected _viewMatrix: Matrix;
  18480. protected _projectionMatrix: Matrix;
  18481. protected _transformMatrix: Matrix;
  18482. protected _cachedPosition: Vector3;
  18483. protected _cachedDirection: Vector3;
  18484. protected _cachedDefines: string;
  18485. protected _currentRenderID: number;
  18486. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18487. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18488. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18489. protected _blurPostProcesses: PostProcess[];
  18490. protected _mapSize: number;
  18491. protected _currentFaceIndex: number;
  18492. protected _currentFaceIndexCache: number;
  18493. protected _textureType: number;
  18494. protected _defaultTextureMatrix: Matrix;
  18495. protected _storedUniqueId: Nullable<number>;
  18496. /** @hidden */
  18497. static _SceneComponentInitialization: (scene: Scene) => void;
  18498. /**
  18499. * Gets or sets the size of the texture what stores the shadows
  18500. */
  18501. get mapSize(): number;
  18502. set mapSize(size: number);
  18503. /**
  18504. * Creates a ShadowGenerator object.
  18505. * A ShadowGenerator is the required tool to use the shadows.
  18506. * Each light casting shadows needs to use its own ShadowGenerator.
  18507. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18508. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18509. * @param light The light object generating the shadows.
  18510. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  18511. */
  18512. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18513. protected _initializeGenerator(): void;
  18514. protected _createTargetRenderTexture(): void;
  18515. protected _initializeShadowMap(): void;
  18516. protected _initializeBlurRTTAndPostProcesses(): void;
  18517. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18518. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18519. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18520. protected _applyFilterValues(): void;
  18521. /**
  18522. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18523. * @param onCompiled Callback triggered at the and of the effects compilation
  18524. * @param options Sets of optional options forcing the compilation with different modes
  18525. */
  18526. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18527. useInstances: boolean;
  18528. }>): void;
  18529. /**
  18530. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18531. * @param options Sets of optional options forcing the compilation with different modes
  18532. * @returns A promise that resolves when the compilation completes
  18533. */
  18534. forceCompilationAsync(options?: Partial<{
  18535. useInstances: boolean;
  18536. }>): Promise<void>;
  18537. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18538. private _prepareShadowDefines;
  18539. /**
  18540. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18541. * @param subMesh The submesh we want to render in the shadow map
  18542. * @param useInstances Defines wether will draw in the map using instances
  18543. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18544. * @returns true if ready otherwise, false
  18545. */
  18546. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18547. /**
  18548. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18549. * @param defines Defines of the material we want to update
  18550. * @param lightIndex Index of the light in the enabled light list of the material
  18551. */
  18552. prepareDefines(defines: any, lightIndex: number): void;
  18553. /**
  18554. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18555. * defined in the generator but impacting the effect).
  18556. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18557. * @param effect The effect we are binfing the information for
  18558. */
  18559. bindShadowLight(lightIndex: string, effect: Effect): void;
  18560. /**
  18561. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18562. * (eq to shadow prjection matrix * light transform matrix)
  18563. * @returns The transform matrix used to create the shadow map
  18564. */
  18565. getTransformMatrix(): Matrix;
  18566. /**
  18567. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18568. * Cube and 2D textures for instance.
  18569. */
  18570. recreateShadowMap(): void;
  18571. protected _disposeBlurPostProcesses(): void;
  18572. protected _disposeRTTandPostProcesses(): void;
  18573. /**
  18574. * Disposes the ShadowGenerator.
  18575. * Returns nothing.
  18576. */
  18577. dispose(): void;
  18578. /**
  18579. * Serializes the shadow generator setup to a json object.
  18580. * @returns The serialized JSON object
  18581. */
  18582. serialize(): any;
  18583. /**
  18584. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18585. * @param parsedShadowGenerator The JSON object to parse
  18586. * @param scene The scene to create the shadow map for
  18587. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18588. * @returns The parsed shadow generator
  18589. */
  18590. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18591. }
  18592. }
  18593. declare module "babylonjs/Lights/light" {
  18594. import { Nullable } from "babylonjs/types";
  18595. import { Scene } from "babylonjs/scene";
  18596. import { Vector3 } from "babylonjs/Maths/math.vector";
  18597. import { Color3 } from "babylonjs/Maths/math.color";
  18598. import { Node } from "babylonjs/node";
  18599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18600. import { Effect } from "babylonjs/Materials/effect";
  18601. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18602. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18603. /**
  18604. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18605. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18606. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  18607. */
  18608. export abstract class Light extends Node {
  18609. /**
  18610. * Falloff Default: light is falling off following the material specification:
  18611. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18612. */
  18613. static readonly FALLOFF_DEFAULT: number;
  18614. /**
  18615. * Falloff Physical: light is falling off following the inverse squared distance law.
  18616. */
  18617. static readonly FALLOFF_PHYSICAL: number;
  18618. /**
  18619. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18620. * to enhance interoperability with other engines.
  18621. */
  18622. static readonly FALLOFF_GLTF: number;
  18623. /**
  18624. * Falloff Standard: light is falling off like in the standard material
  18625. * to enhance interoperability with other materials.
  18626. */
  18627. static readonly FALLOFF_STANDARD: number;
  18628. /**
  18629. * If every light affecting the material is in this lightmapMode,
  18630. * material.lightmapTexture adds or multiplies
  18631. * (depends on material.useLightmapAsShadowmap)
  18632. * after every other light calculations.
  18633. */
  18634. static readonly LIGHTMAP_DEFAULT: number;
  18635. /**
  18636. * material.lightmapTexture as only diffuse lighting from this light
  18637. * adds only specular lighting from this light
  18638. * adds dynamic shadows
  18639. */
  18640. static readonly LIGHTMAP_SPECULAR: number;
  18641. /**
  18642. * material.lightmapTexture as only lighting
  18643. * no light calculation from this light
  18644. * only adds dynamic shadows from this light
  18645. */
  18646. static readonly LIGHTMAP_SHADOWSONLY: number;
  18647. /**
  18648. * Each light type uses the default quantity according to its type:
  18649. * point/spot lights use luminous intensity
  18650. * directional lights use illuminance
  18651. */
  18652. static readonly INTENSITYMODE_AUTOMATIC: number;
  18653. /**
  18654. * lumen (lm)
  18655. */
  18656. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18657. /**
  18658. * candela (lm/sr)
  18659. */
  18660. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18661. /**
  18662. * lux (lm/m^2)
  18663. */
  18664. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18665. /**
  18666. * nit (cd/m^2)
  18667. */
  18668. static readonly INTENSITYMODE_LUMINANCE: number;
  18669. /**
  18670. * Light type const id of the point light.
  18671. */
  18672. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18673. /**
  18674. * Light type const id of the directional light.
  18675. */
  18676. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18677. /**
  18678. * Light type const id of the spot light.
  18679. */
  18680. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18681. /**
  18682. * Light type const id of the hemispheric light.
  18683. */
  18684. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18685. /**
  18686. * Diffuse gives the basic color to an object.
  18687. */
  18688. diffuse: Color3;
  18689. /**
  18690. * Specular produces a highlight color on an object.
  18691. * Note: This is note affecting PBR materials.
  18692. */
  18693. specular: Color3;
  18694. /**
  18695. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18696. * falling off base on range or angle.
  18697. * This can be set to any values in Light.FALLOFF_x.
  18698. *
  18699. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18700. * other types of materials.
  18701. */
  18702. falloffType: number;
  18703. /**
  18704. * Strength of the light.
  18705. * Note: By default it is define in the framework own unit.
  18706. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18707. */
  18708. intensity: number;
  18709. private _range;
  18710. protected _inverseSquaredRange: number;
  18711. /**
  18712. * Defines how far from the source the light is impacting in scene units.
  18713. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18714. */
  18715. get range(): number;
  18716. /**
  18717. * Defines how far from the source the light is impacting in scene units.
  18718. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18719. */
  18720. set range(value: number);
  18721. /**
  18722. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18723. * of light.
  18724. */
  18725. private _photometricScale;
  18726. private _intensityMode;
  18727. /**
  18728. * Gets the photometric scale used to interpret the intensity.
  18729. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18730. */
  18731. get intensityMode(): number;
  18732. /**
  18733. * Sets the photometric scale used to interpret the intensity.
  18734. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18735. */
  18736. set intensityMode(value: number);
  18737. private _radius;
  18738. /**
  18739. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18740. */
  18741. get radius(): number;
  18742. /**
  18743. * sets the light radius used by PBR Materials to simulate soft area lights.
  18744. */
  18745. set radius(value: number);
  18746. private _renderPriority;
  18747. /**
  18748. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18749. * exceeding the number allowed of the materials.
  18750. */
  18751. renderPriority: number;
  18752. private _shadowEnabled;
  18753. /**
  18754. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18755. * the current shadow generator.
  18756. */
  18757. get shadowEnabled(): boolean;
  18758. /**
  18759. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18760. * the current shadow generator.
  18761. */
  18762. set shadowEnabled(value: boolean);
  18763. private _includedOnlyMeshes;
  18764. /**
  18765. * Gets the only meshes impacted by this light.
  18766. */
  18767. get includedOnlyMeshes(): AbstractMesh[];
  18768. /**
  18769. * Sets the only meshes impacted by this light.
  18770. */
  18771. set includedOnlyMeshes(value: AbstractMesh[]);
  18772. private _excludedMeshes;
  18773. /**
  18774. * Gets the meshes not impacted by this light.
  18775. */
  18776. get excludedMeshes(): AbstractMesh[];
  18777. /**
  18778. * Sets the meshes not impacted by this light.
  18779. */
  18780. set excludedMeshes(value: AbstractMesh[]);
  18781. private _excludeWithLayerMask;
  18782. /**
  18783. * Gets the layer id use to find what meshes are not impacted by the light.
  18784. * Inactive if 0
  18785. */
  18786. get excludeWithLayerMask(): number;
  18787. /**
  18788. * Sets the layer id use to find what meshes are not impacted by the light.
  18789. * Inactive if 0
  18790. */
  18791. set excludeWithLayerMask(value: number);
  18792. private _includeOnlyWithLayerMask;
  18793. /**
  18794. * Gets the layer id use to find what meshes are impacted by the light.
  18795. * Inactive if 0
  18796. */
  18797. get includeOnlyWithLayerMask(): number;
  18798. /**
  18799. * Sets the layer id use to find what meshes are impacted by the light.
  18800. * Inactive if 0
  18801. */
  18802. set includeOnlyWithLayerMask(value: number);
  18803. private _lightmapMode;
  18804. /**
  18805. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18806. */
  18807. get lightmapMode(): number;
  18808. /**
  18809. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18810. */
  18811. set lightmapMode(value: number);
  18812. /**
  18813. * Shadow generator associted to the light.
  18814. * @hidden Internal use only.
  18815. */
  18816. _shadowGenerator: Nullable<IShadowGenerator>;
  18817. /**
  18818. * @hidden Internal use only.
  18819. */
  18820. _excludedMeshesIds: string[];
  18821. /**
  18822. * @hidden Internal use only.
  18823. */
  18824. _includedOnlyMeshesIds: string[];
  18825. /**
  18826. * The current light unifom buffer.
  18827. * @hidden Internal use only.
  18828. */
  18829. _uniformBuffer: UniformBuffer;
  18830. /** @hidden */
  18831. _renderId: number;
  18832. /**
  18833. * Creates a Light object in the scene.
  18834. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18835. * @param name The firendly name of the light
  18836. * @param scene The scene the light belongs too
  18837. */
  18838. constructor(name: string, scene: Scene);
  18839. protected abstract _buildUniformLayout(): void;
  18840. /**
  18841. * Sets the passed Effect "effect" with the Light information.
  18842. * @param effect The effect to update
  18843. * @param lightIndex The index of the light in the effect to update
  18844. * @returns The light
  18845. */
  18846. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18847. /**
  18848. * Sets the passed Effect "effect" with the Light textures.
  18849. * @param effect The effect to update
  18850. * @param lightIndex The index of the light in the effect to update
  18851. * @returns The light
  18852. */
  18853. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18854. /**
  18855. * Binds the lights information from the scene to the effect for the given mesh.
  18856. * @param lightIndex Light index
  18857. * @param scene The scene where the light belongs to
  18858. * @param effect The effect we are binding the data to
  18859. * @param useSpecular Defines if specular is supported
  18860. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18861. */
  18862. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18863. /**
  18864. * Sets the passed Effect "effect" with the Light information.
  18865. * @param effect The effect to update
  18866. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18867. * @returns The light
  18868. */
  18869. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18870. /**
  18871. * Returns the string "Light".
  18872. * @returns the class name
  18873. */
  18874. getClassName(): string;
  18875. /** @hidden */
  18876. readonly _isLight: boolean;
  18877. /**
  18878. * Converts the light information to a readable string for debug purpose.
  18879. * @param fullDetails Supports for multiple levels of logging within scene loading
  18880. * @returns the human readable light info
  18881. */
  18882. toString(fullDetails?: boolean): string;
  18883. /** @hidden */
  18884. protected _syncParentEnabledState(): void;
  18885. /**
  18886. * Set the enabled state of this node.
  18887. * @param value - the new enabled state
  18888. */
  18889. setEnabled(value: boolean): void;
  18890. /**
  18891. * Returns the Light associated shadow generator if any.
  18892. * @return the associated shadow generator.
  18893. */
  18894. getShadowGenerator(): Nullable<IShadowGenerator>;
  18895. /**
  18896. * Returns a Vector3, the absolute light position in the World.
  18897. * @returns the world space position of the light
  18898. */
  18899. getAbsolutePosition(): Vector3;
  18900. /**
  18901. * Specifies if the light will affect the passed mesh.
  18902. * @param mesh The mesh to test against the light
  18903. * @return true the mesh is affected otherwise, false.
  18904. */
  18905. canAffectMesh(mesh: AbstractMesh): boolean;
  18906. /**
  18907. * Sort function to order lights for rendering.
  18908. * @param a First Light object to compare to second.
  18909. * @param b Second Light object to compare first.
  18910. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18911. */
  18912. static CompareLightsPriority(a: Light, b: Light): number;
  18913. /**
  18914. * Releases resources associated with this node.
  18915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18917. */
  18918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18919. /**
  18920. * Returns the light type ID (integer).
  18921. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18922. */
  18923. getTypeID(): number;
  18924. /**
  18925. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18926. * @returns the scaled intensity in intensity mode unit
  18927. */
  18928. getScaledIntensity(): number;
  18929. /**
  18930. * Returns a new Light object, named "name", from the current one.
  18931. * @param name The name of the cloned light
  18932. * @param newParent The parent of this light, if it has one
  18933. * @returns the new created light
  18934. */
  18935. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18936. /**
  18937. * Serializes the current light into a Serialization object.
  18938. * @returns the serialized object.
  18939. */
  18940. serialize(): any;
  18941. /**
  18942. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18943. * This new light is named "name" and added to the passed scene.
  18944. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18945. * @param name The friendly name of the light
  18946. * @param scene The scene the new light will belong to
  18947. * @returns the constructor function
  18948. */
  18949. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18950. /**
  18951. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18952. * @param parsedLight The JSON representation of the light
  18953. * @param scene The scene to create the parsed light in
  18954. * @returns the created light after parsing
  18955. */
  18956. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18957. private _hookArrayForExcluded;
  18958. private _hookArrayForIncludedOnly;
  18959. private _resyncMeshes;
  18960. /**
  18961. * Forces the meshes to update their light related information in their rendering used effects
  18962. * @hidden Internal Use Only
  18963. */
  18964. _markMeshesAsLightDirty(): void;
  18965. /**
  18966. * Recomputes the cached photometric scale if needed.
  18967. */
  18968. private _computePhotometricScale;
  18969. /**
  18970. * Returns the Photometric Scale according to the light type and intensity mode.
  18971. */
  18972. private _getPhotometricScale;
  18973. /**
  18974. * Reorder the light in the scene according to their defined priority.
  18975. * @hidden Internal Use Only
  18976. */
  18977. _reorderLightsInScene(): void;
  18978. /**
  18979. * Prepares the list of defines specific to the light type.
  18980. * @param defines the list of defines
  18981. * @param lightIndex defines the index of the light for the effect
  18982. */
  18983. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18984. }
  18985. }
  18986. declare module "babylonjs/Materials/prePassConfiguration" {
  18987. import { Matrix } from "babylonjs/Maths/math.vector";
  18988. import { Mesh } from "babylonjs/Meshes/mesh";
  18989. import { Scene } from "babylonjs/scene";
  18990. import { Effect } from "babylonjs/Materials/effect";
  18991. /**
  18992. * Configuration needed for prepass-capable materials
  18993. */
  18994. export class PrePassConfiguration {
  18995. /**
  18996. * Previous world matrices of meshes carrying this material
  18997. * Used for computing velocity
  18998. */
  18999. previousWorldMatrices: {
  19000. [index: number]: Matrix;
  19001. };
  19002. /**
  19003. * Previous view project matrix
  19004. * Used for computing velocity
  19005. */
  19006. previousViewProjection: Matrix;
  19007. /**
  19008. * Previous bones of meshes carrying this material
  19009. * Used for computing velocity
  19010. */
  19011. previousBones: {
  19012. [index: number]: Float32Array;
  19013. };
  19014. /**
  19015. * Add the required uniforms to the current list.
  19016. * @param uniforms defines the current uniform list.
  19017. */
  19018. static AddUniforms(uniforms: string[]): void;
  19019. /**
  19020. * Add the required samplers to the current list.
  19021. * @param samplers defines the current sampler list.
  19022. */
  19023. static AddSamplers(samplers: string[]): void;
  19024. /**
  19025. * Binds the material data.
  19026. * @param effect defines the effect to update
  19027. * @param scene defines the scene the material belongs to.
  19028. * @param mesh The mesh
  19029. * @param world World matrix of this mesh
  19030. * @param isFrozen Is the material frozen
  19031. */
  19032. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19033. }
  19034. }
  19035. declare module "babylonjs/Cameras/targetCamera" {
  19036. import { Nullable } from "babylonjs/types";
  19037. import { Camera } from "babylonjs/Cameras/camera";
  19038. import { Scene } from "babylonjs/scene";
  19039. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19040. /**
  19041. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19042. * This is the base of the follow, arc rotate cameras and Free camera
  19043. * @see https://doc.babylonjs.com/features/cameras
  19044. */
  19045. export class TargetCamera extends Camera {
  19046. private static _RigCamTransformMatrix;
  19047. private static _TargetTransformMatrix;
  19048. private static _TargetFocalPoint;
  19049. private _tmpUpVector;
  19050. private _tmpTargetVector;
  19051. /**
  19052. * Define the current direction the camera is moving to
  19053. */
  19054. cameraDirection: Vector3;
  19055. /**
  19056. * Define the current rotation the camera is rotating to
  19057. */
  19058. cameraRotation: Vector2;
  19059. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19060. ignoreParentScaling: boolean;
  19061. /**
  19062. * When set, the up vector of the camera will be updated by the rotation of the camera
  19063. */
  19064. updateUpVectorFromRotation: boolean;
  19065. private _tmpQuaternion;
  19066. /**
  19067. * Define the current rotation of the camera
  19068. */
  19069. rotation: Vector3;
  19070. /**
  19071. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19072. */
  19073. rotationQuaternion: Quaternion;
  19074. /**
  19075. * Define the current speed of the camera
  19076. */
  19077. speed: number;
  19078. /**
  19079. * Add constraint to the camera to prevent it to move freely in all directions and
  19080. * around all axis.
  19081. */
  19082. noRotationConstraint: boolean;
  19083. /**
  19084. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19085. * panning
  19086. */
  19087. invertRotation: boolean;
  19088. /**
  19089. * Speed multiplier for inverse camera panning
  19090. */
  19091. inverseRotationSpeed: number;
  19092. /**
  19093. * Define the current target of the camera as an object or a position.
  19094. */
  19095. lockedTarget: any;
  19096. /** @hidden */
  19097. _currentTarget: Vector3;
  19098. /** @hidden */
  19099. _initialFocalDistance: number;
  19100. /** @hidden */
  19101. _viewMatrix: Matrix;
  19102. /** @hidden */
  19103. _camMatrix: Matrix;
  19104. /** @hidden */
  19105. _cameraTransformMatrix: Matrix;
  19106. /** @hidden */
  19107. _cameraRotationMatrix: Matrix;
  19108. /** @hidden */
  19109. _referencePoint: Vector3;
  19110. /** @hidden */
  19111. _transformedReferencePoint: Vector3;
  19112. /** @hidden */
  19113. _reset: () => void;
  19114. private _defaultUp;
  19115. /**
  19116. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19117. * This is the base of the follow, arc rotate cameras and Free camera
  19118. * @see https://doc.babylonjs.com/features/cameras
  19119. * @param name Defines the name of the camera in the scene
  19120. * @param position Defines the start position of the camera in the scene
  19121. * @param scene Defines the scene the camera belongs to
  19122. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19123. */
  19124. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19125. /**
  19126. * Gets the position in front of the camera at a given distance.
  19127. * @param distance The distance from the camera we want the position to be
  19128. * @returns the position
  19129. */
  19130. getFrontPosition(distance: number): Vector3;
  19131. /** @hidden */
  19132. _getLockedTargetPosition(): Nullable<Vector3>;
  19133. private _storedPosition;
  19134. private _storedRotation;
  19135. private _storedRotationQuaternion;
  19136. /**
  19137. * Store current camera state of the camera (fov, position, rotation, etc..)
  19138. * @returns the camera
  19139. */
  19140. storeState(): Camera;
  19141. /**
  19142. * Restored camera state. You must call storeState() first
  19143. * @returns whether it was successful or not
  19144. * @hidden
  19145. */
  19146. _restoreStateValues(): boolean;
  19147. /** @hidden */
  19148. _initCache(): void;
  19149. /** @hidden */
  19150. _updateCache(ignoreParentClass?: boolean): void;
  19151. /** @hidden */
  19152. _isSynchronizedViewMatrix(): boolean;
  19153. /** @hidden */
  19154. _computeLocalCameraSpeed(): number;
  19155. /**
  19156. * Defines the target the camera should look at.
  19157. * @param target Defines the new target as a Vector or a mesh
  19158. */
  19159. setTarget(target: Vector3): void;
  19160. /**
  19161. * Defines the target point of the camera.
  19162. * The camera looks towards it form the radius distance.
  19163. */
  19164. get target(): Vector3;
  19165. set target(value: Vector3);
  19166. /**
  19167. * Return the current target position of the camera. This value is expressed in local space.
  19168. * @returns the target position
  19169. */
  19170. getTarget(): Vector3;
  19171. /** @hidden */
  19172. _decideIfNeedsToMove(): boolean;
  19173. /** @hidden */
  19174. _updatePosition(): void;
  19175. /** @hidden */
  19176. _checkInputs(): void;
  19177. protected _updateCameraRotationMatrix(): void;
  19178. /**
  19179. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  19180. * @returns the current camera
  19181. */
  19182. private _rotateUpVectorWithCameraRotationMatrix;
  19183. private _cachedRotationZ;
  19184. private _cachedQuaternionRotationZ;
  19185. /** @hidden */
  19186. _getViewMatrix(): Matrix;
  19187. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19188. /**
  19189. * @hidden
  19190. */
  19191. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19192. /**
  19193. * @hidden
  19194. */
  19195. _updateRigCameras(): void;
  19196. private _getRigCamPositionAndTarget;
  19197. /**
  19198. * Gets the current object class name.
  19199. * @return the class name
  19200. */
  19201. getClassName(): string;
  19202. }
  19203. }
  19204. declare module "babylonjs/Events/keyboardEvents" {
  19205. /**
  19206. * Gather the list of keyboard event types as constants.
  19207. */
  19208. export class KeyboardEventTypes {
  19209. /**
  19210. * The keydown event is fired when a key becomes active (pressed).
  19211. */
  19212. static readonly KEYDOWN: number;
  19213. /**
  19214. * The keyup event is fired when a key has been released.
  19215. */
  19216. static readonly KEYUP: number;
  19217. }
  19218. /**
  19219. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19220. */
  19221. export class KeyboardInfo {
  19222. /**
  19223. * Defines the type of event (KeyboardEventTypes)
  19224. */
  19225. type: number;
  19226. /**
  19227. * Defines the related dom event
  19228. */
  19229. event: KeyboardEvent;
  19230. /**
  19231. * Instantiates a new keyboard info.
  19232. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19233. * @param type Defines the type of event (KeyboardEventTypes)
  19234. * @param event Defines the related dom event
  19235. */
  19236. constructor(
  19237. /**
  19238. * Defines the type of event (KeyboardEventTypes)
  19239. */
  19240. type: number,
  19241. /**
  19242. * Defines the related dom event
  19243. */
  19244. event: KeyboardEvent);
  19245. }
  19246. /**
  19247. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19248. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19249. */
  19250. export class KeyboardInfoPre extends KeyboardInfo {
  19251. /**
  19252. * Defines the type of event (KeyboardEventTypes)
  19253. */
  19254. type: number;
  19255. /**
  19256. * Defines the related dom event
  19257. */
  19258. event: KeyboardEvent;
  19259. /**
  19260. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19261. */
  19262. skipOnPointerObservable: boolean;
  19263. /**
  19264. * Instantiates a new keyboard pre info.
  19265. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19266. * @param type Defines the type of event (KeyboardEventTypes)
  19267. * @param event Defines the related dom event
  19268. */
  19269. constructor(
  19270. /**
  19271. * Defines the type of event (KeyboardEventTypes)
  19272. */
  19273. type: number,
  19274. /**
  19275. * Defines the related dom event
  19276. */
  19277. event: KeyboardEvent);
  19278. }
  19279. }
  19280. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19281. import { Nullable } from "babylonjs/types";
  19282. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19283. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19284. /**
  19285. * Manage the keyboard inputs to control the movement of a free camera.
  19286. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19287. */
  19288. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19289. /**
  19290. * Defines the camera the input is attached to.
  19291. */
  19292. camera: FreeCamera;
  19293. /**
  19294. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19295. */
  19296. keysUp: number[];
  19297. /**
  19298. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19299. */
  19300. keysUpward: number[];
  19301. /**
  19302. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19303. */
  19304. keysDown: number[];
  19305. /**
  19306. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19307. */
  19308. keysDownward: number[];
  19309. /**
  19310. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19311. */
  19312. keysLeft: number[];
  19313. /**
  19314. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19315. */
  19316. keysRight: number[];
  19317. private _keys;
  19318. private _onCanvasBlurObserver;
  19319. private _onKeyboardObserver;
  19320. private _engine;
  19321. private _scene;
  19322. /**
  19323. * Attach the input controls to a specific dom element to get the input from.
  19324. * @param element Defines the element the controls should be listened from
  19325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19326. */
  19327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19328. /**
  19329. * Detach the current controls from the specified dom element.
  19330. * @param element Defines the element to stop listening the inputs from
  19331. */
  19332. detachControl(element: Nullable<HTMLElement>): void;
  19333. /**
  19334. * Update the current camera state depending on the inputs that have been used this frame.
  19335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19336. */
  19337. checkInputs(): void;
  19338. /**
  19339. * Gets the class name of the current intput.
  19340. * @returns the class name
  19341. */
  19342. getClassName(): string;
  19343. /** @hidden */
  19344. _onLostFocus(): void;
  19345. /**
  19346. * Get the friendly name associated with the input class.
  19347. * @returns the input friendly name
  19348. */
  19349. getSimpleName(): string;
  19350. }
  19351. }
  19352. declare module "babylonjs/Events/pointerEvents" {
  19353. import { Nullable } from "babylonjs/types";
  19354. import { Vector2 } from "babylonjs/Maths/math.vector";
  19355. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19356. import { Ray } from "babylonjs/Culling/ray";
  19357. /**
  19358. * Gather the list of pointer event types as constants.
  19359. */
  19360. export class PointerEventTypes {
  19361. /**
  19362. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  19363. */
  19364. static readonly POINTERDOWN: number;
  19365. /**
  19366. * The pointerup event is fired when a pointer is no longer active.
  19367. */
  19368. static readonly POINTERUP: number;
  19369. /**
  19370. * The pointermove event is fired when a pointer changes coordinates.
  19371. */
  19372. static readonly POINTERMOVE: number;
  19373. /**
  19374. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19375. */
  19376. static readonly POINTERWHEEL: number;
  19377. /**
  19378. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19379. */
  19380. static readonly POINTERPICK: number;
  19381. /**
  19382. * The pointertap event is fired when a the object has been touched and released without drag.
  19383. */
  19384. static readonly POINTERTAP: number;
  19385. /**
  19386. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19387. */
  19388. static readonly POINTERDOUBLETAP: number;
  19389. }
  19390. /**
  19391. * Base class of pointer info types.
  19392. */
  19393. export class PointerInfoBase {
  19394. /**
  19395. * Defines the type of event (PointerEventTypes)
  19396. */
  19397. type: number;
  19398. /**
  19399. * Defines the related dom event
  19400. */
  19401. event: PointerEvent | MouseWheelEvent;
  19402. /**
  19403. * Instantiates the base class of pointers info.
  19404. * @param type Defines the type of event (PointerEventTypes)
  19405. * @param event Defines the related dom event
  19406. */
  19407. constructor(
  19408. /**
  19409. * Defines the type of event (PointerEventTypes)
  19410. */
  19411. type: number,
  19412. /**
  19413. * Defines the related dom event
  19414. */
  19415. event: PointerEvent | MouseWheelEvent);
  19416. }
  19417. /**
  19418. * This class is used to store pointer related info for the onPrePointerObservable event.
  19419. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19420. */
  19421. export class PointerInfoPre extends PointerInfoBase {
  19422. /**
  19423. * Ray from a pointer if availible (eg. 6dof controller)
  19424. */
  19425. ray: Nullable<Ray>;
  19426. /**
  19427. * Defines the local position of the pointer on the canvas.
  19428. */
  19429. localPosition: Vector2;
  19430. /**
  19431. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19432. */
  19433. skipOnPointerObservable: boolean;
  19434. /**
  19435. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19436. * @param type Defines the type of event (PointerEventTypes)
  19437. * @param event Defines the related dom event
  19438. * @param localX Defines the local x coordinates of the pointer when the event occured
  19439. * @param localY Defines the local y coordinates of the pointer when the event occured
  19440. */
  19441. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19442. }
  19443. /**
  19444. * This type contains all the data related to a pointer event in Babylon.js.
  19445. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  19446. */
  19447. export class PointerInfo extends PointerInfoBase {
  19448. /**
  19449. * Defines the picking info associated to the info (if any)\
  19450. */
  19451. pickInfo: Nullable<PickingInfo>;
  19452. /**
  19453. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19454. * @param type Defines the type of event (PointerEventTypes)
  19455. * @param event Defines the related dom event
  19456. * @param pickInfo Defines the picking info associated to the info (if any)\
  19457. */
  19458. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19459. /**
  19460. * Defines the picking info associated to the info (if any)\
  19461. */
  19462. pickInfo: Nullable<PickingInfo>);
  19463. }
  19464. /**
  19465. * Data relating to a touch event on the screen.
  19466. */
  19467. export interface PointerTouch {
  19468. /**
  19469. * X coordinate of touch.
  19470. */
  19471. x: number;
  19472. /**
  19473. * Y coordinate of touch.
  19474. */
  19475. y: number;
  19476. /**
  19477. * Id of touch. Unique for each finger.
  19478. */
  19479. pointerId: number;
  19480. /**
  19481. * Event type passed from DOM.
  19482. */
  19483. type: any;
  19484. }
  19485. }
  19486. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19487. import { Observable } from "babylonjs/Misc/observable";
  19488. import { Nullable } from "babylonjs/types";
  19489. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19490. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19491. /**
  19492. * Manage the mouse inputs to control the movement of a free camera.
  19493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19494. */
  19495. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19496. /**
  19497. * Define if touch is enabled in the mouse input
  19498. */
  19499. touchEnabled: boolean;
  19500. /**
  19501. * Defines the camera the input is attached to.
  19502. */
  19503. camera: FreeCamera;
  19504. /**
  19505. * Defines the buttons associated with the input to handle camera move.
  19506. */
  19507. buttons: number[];
  19508. /**
  19509. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19510. */
  19511. angularSensibility: number;
  19512. private _pointerInput;
  19513. private _onMouseMove;
  19514. private _observer;
  19515. private previousPosition;
  19516. /**
  19517. * Observable for when a pointer move event occurs containing the move offset
  19518. */
  19519. onPointerMovedObservable: Observable<{
  19520. offsetX: number;
  19521. offsetY: number;
  19522. }>;
  19523. /**
  19524. * @hidden
  19525. * If the camera should be rotated automatically based on pointer movement
  19526. */
  19527. _allowCameraRotation: boolean;
  19528. /**
  19529. * Manage the mouse inputs to control the movement of a free camera.
  19530. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19531. * @param touchEnabled Defines if touch is enabled or not
  19532. */
  19533. constructor(
  19534. /**
  19535. * Define if touch is enabled in the mouse input
  19536. */
  19537. touchEnabled?: boolean);
  19538. /**
  19539. * Attach the input controls to a specific dom element to get the input from.
  19540. * @param element Defines the element the controls should be listened from
  19541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19542. */
  19543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19544. /**
  19545. * Called on JS contextmenu event.
  19546. * Override this method to provide functionality.
  19547. */
  19548. protected onContextMenu(evt: PointerEvent): void;
  19549. /**
  19550. * Detach the current controls from the specified dom element.
  19551. * @param element Defines the element to stop listening the inputs from
  19552. */
  19553. detachControl(element: Nullable<HTMLElement>): void;
  19554. /**
  19555. * Gets the class name of the current intput.
  19556. * @returns the class name
  19557. */
  19558. getClassName(): string;
  19559. /**
  19560. * Get the friendly name associated with the input class.
  19561. * @returns the input friendly name
  19562. */
  19563. getSimpleName(): string;
  19564. }
  19565. }
  19566. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19567. import { Nullable } from "babylonjs/types";
  19568. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19569. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19570. /**
  19571. * Manage the touch inputs to control the movement of a free camera.
  19572. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19573. */
  19574. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19575. /**
  19576. * Define if mouse events can be treated as touch events
  19577. */
  19578. allowMouse: boolean;
  19579. /**
  19580. * Defines the camera the input is attached to.
  19581. */
  19582. camera: FreeCamera;
  19583. /**
  19584. * Defines the touch sensibility for rotation.
  19585. * The higher the faster.
  19586. */
  19587. touchAngularSensibility: number;
  19588. /**
  19589. * Defines the touch sensibility for move.
  19590. * The higher the faster.
  19591. */
  19592. touchMoveSensibility: number;
  19593. private _offsetX;
  19594. private _offsetY;
  19595. private _pointerPressed;
  19596. private _pointerInput;
  19597. private _observer;
  19598. private _onLostFocus;
  19599. /**
  19600. * Manage the touch inputs to control the movement of a free camera.
  19601. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19602. * @param allowMouse Defines if mouse events can be treated as touch events
  19603. */
  19604. constructor(
  19605. /**
  19606. * Define if mouse events can be treated as touch events
  19607. */
  19608. allowMouse?: boolean);
  19609. /**
  19610. * Attach the input controls to a specific dom element to get the input from.
  19611. * @param element Defines the element the controls should be listened from
  19612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19613. */
  19614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19615. /**
  19616. * Detach the current controls from the specified dom element.
  19617. * @param element Defines the element to stop listening the inputs from
  19618. */
  19619. detachControl(element: Nullable<HTMLElement>): void;
  19620. /**
  19621. * Update the current camera state depending on the inputs that have been used this frame.
  19622. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19623. */
  19624. checkInputs(): void;
  19625. /**
  19626. * Gets the class name of the current intput.
  19627. * @returns the class name
  19628. */
  19629. getClassName(): string;
  19630. /**
  19631. * Get the friendly name associated with the input class.
  19632. * @returns the input friendly name
  19633. */
  19634. getSimpleName(): string;
  19635. }
  19636. }
  19637. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19638. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19639. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19640. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19641. import { Nullable } from "babylonjs/types";
  19642. /**
  19643. * Default Inputs manager for the FreeCamera.
  19644. * It groups all the default supported inputs for ease of use.
  19645. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19646. */
  19647. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19648. /**
  19649. * @hidden
  19650. */
  19651. _mouseInput: Nullable<FreeCameraMouseInput>;
  19652. /**
  19653. * Instantiates a new FreeCameraInputsManager.
  19654. * @param camera Defines the camera the inputs belong to
  19655. */
  19656. constructor(camera: FreeCamera);
  19657. /**
  19658. * Add keyboard input support to the input manager.
  19659. * @returns the current input manager
  19660. */
  19661. addKeyboard(): FreeCameraInputsManager;
  19662. /**
  19663. * Add mouse input support to the input manager.
  19664. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19665. * @returns the current input manager
  19666. */
  19667. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19668. /**
  19669. * Removes the mouse input support from the manager
  19670. * @returns the current input manager
  19671. */
  19672. removeMouse(): FreeCameraInputsManager;
  19673. /**
  19674. * Add touch input support to the input manager.
  19675. * @returns the current input manager
  19676. */
  19677. addTouch(): FreeCameraInputsManager;
  19678. /**
  19679. * Remove all attached input methods from a camera
  19680. */
  19681. clear(): void;
  19682. }
  19683. }
  19684. declare module "babylonjs/Cameras/freeCamera" {
  19685. import { Vector3 } from "babylonjs/Maths/math.vector";
  19686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19687. import { Scene } from "babylonjs/scene";
  19688. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19689. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19690. /**
  19691. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19692. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19693. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19694. */
  19695. export class FreeCamera extends TargetCamera {
  19696. /**
  19697. * Define the collision ellipsoid of the camera.
  19698. * This is helpful to simulate a camera body like the player body around the camera
  19699. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19700. */
  19701. ellipsoid: Vector3;
  19702. /**
  19703. * Define an offset for the position of the ellipsoid around the camera.
  19704. * This can be helpful to determine the center of the body near the gravity center of the body
  19705. * instead of its head.
  19706. */
  19707. ellipsoidOffset: Vector3;
  19708. /**
  19709. * Enable or disable collisions of the camera with the rest of the scene objects.
  19710. */
  19711. checkCollisions: boolean;
  19712. /**
  19713. * Enable or disable gravity on the camera.
  19714. */
  19715. applyGravity: boolean;
  19716. /**
  19717. * Define the input manager associated to the camera.
  19718. */
  19719. inputs: FreeCameraInputsManager;
  19720. /**
  19721. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19722. * Higher values reduce sensitivity.
  19723. */
  19724. get angularSensibility(): number;
  19725. /**
  19726. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19727. * Higher values reduce sensitivity.
  19728. */
  19729. set angularSensibility(value: number);
  19730. /**
  19731. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19732. */
  19733. get keysUp(): number[];
  19734. set keysUp(value: number[]);
  19735. /**
  19736. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19737. */
  19738. get keysUpward(): number[];
  19739. set keysUpward(value: number[]);
  19740. /**
  19741. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19742. */
  19743. get keysDown(): number[];
  19744. set keysDown(value: number[]);
  19745. /**
  19746. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19747. */
  19748. get keysDownward(): number[];
  19749. set keysDownward(value: number[]);
  19750. /**
  19751. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19752. */
  19753. get keysLeft(): number[];
  19754. set keysLeft(value: number[]);
  19755. /**
  19756. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19757. */
  19758. get keysRight(): number[];
  19759. set keysRight(value: number[]);
  19760. /**
  19761. * Event raised when the camera collide with a mesh in the scene.
  19762. */
  19763. onCollide: (collidedMesh: AbstractMesh) => void;
  19764. private _collider;
  19765. private _needMoveForGravity;
  19766. private _oldPosition;
  19767. private _diffPosition;
  19768. private _newPosition;
  19769. /** @hidden */
  19770. _localDirection: Vector3;
  19771. /** @hidden */
  19772. _transformedDirection: Vector3;
  19773. /**
  19774. * Instantiates a Free Camera.
  19775. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19776. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19777. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19778. * @param name Define the name of the camera in the scene
  19779. * @param position Define the start position of the camera in the scene
  19780. * @param scene Define the scene the camera belongs to
  19781. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19782. */
  19783. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19784. /**
  19785. * Attached controls to the current camera.
  19786. * @param element Defines the element the controls should be listened from
  19787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19788. */
  19789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19790. /**
  19791. * Detach the current controls from the camera.
  19792. * The camera will stop reacting to inputs.
  19793. * @param element Defines the element to stop listening the inputs from
  19794. */
  19795. detachControl(element: HTMLElement): void;
  19796. private _collisionMask;
  19797. /**
  19798. * Define a collision mask to limit the list of object the camera can collide with
  19799. */
  19800. get collisionMask(): number;
  19801. set collisionMask(mask: number);
  19802. /** @hidden */
  19803. _collideWithWorld(displacement: Vector3): void;
  19804. private _onCollisionPositionChange;
  19805. /** @hidden */
  19806. _checkInputs(): void;
  19807. /** @hidden */
  19808. _decideIfNeedsToMove(): boolean;
  19809. /** @hidden */
  19810. _updatePosition(): void;
  19811. /**
  19812. * Destroy the camera and release the current resources hold by it.
  19813. */
  19814. dispose(): void;
  19815. /**
  19816. * Gets the current object class name.
  19817. * @return the class name
  19818. */
  19819. getClassName(): string;
  19820. }
  19821. }
  19822. declare module "babylonjs/Gamepads/gamepad" {
  19823. import { Observable } from "babylonjs/Misc/observable";
  19824. /**
  19825. * Represents a gamepad control stick position
  19826. */
  19827. export class StickValues {
  19828. /**
  19829. * The x component of the control stick
  19830. */
  19831. x: number;
  19832. /**
  19833. * The y component of the control stick
  19834. */
  19835. y: number;
  19836. /**
  19837. * Initializes the gamepad x and y control stick values
  19838. * @param x The x component of the gamepad control stick value
  19839. * @param y The y component of the gamepad control stick value
  19840. */
  19841. constructor(
  19842. /**
  19843. * The x component of the control stick
  19844. */
  19845. x: number,
  19846. /**
  19847. * The y component of the control stick
  19848. */
  19849. y: number);
  19850. }
  19851. /**
  19852. * An interface which manages callbacks for gamepad button changes
  19853. */
  19854. export interface GamepadButtonChanges {
  19855. /**
  19856. * Called when a gamepad has been changed
  19857. */
  19858. changed: boolean;
  19859. /**
  19860. * Called when a gamepad press event has been triggered
  19861. */
  19862. pressChanged: boolean;
  19863. /**
  19864. * Called when a touch event has been triggered
  19865. */
  19866. touchChanged: boolean;
  19867. /**
  19868. * Called when a value has changed
  19869. */
  19870. valueChanged: boolean;
  19871. }
  19872. /**
  19873. * Represents a gamepad
  19874. */
  19875. export class Gamepad {
  19876. /**
  19877. * The id of the gamepad
  19878. */
  19879. id: string;
  19880. /**
  19881. * The index of the gamepad
  19882. */
  19883. index: number;
  19884. /**
  19885. * The browser gamepad
  19886. */
  19887. browserGamepad: any;
  19888. /**
  19889. * Specifies what type of gamepad this represents
  19890. */
  19891. type: number;
  19892. private _leftStick;
  19893. private _rightStick;
  19894. /** @hidden */
  19895. _isConnected: boolean;
  19896. private _leftStickAxisX;
  19897. private _leftStickAxisY;
  19898. private _rightStickAxisX;
  19899. private _rightStickAxisY;
  19900. /**
  19901. * Triggered when the left control stick has been changed
  19902. */
  19903. private _onleftstickchanged;
  19904. /**
  19905. * Triggered when the right control stick has been changed
  19906. */
  19907. private _onrightstickchanged;
  19908. /**
  19909. * Represents a gamepad controller
  19910. */
  19911. static GAMEPAD: number;
  19912. /**
  19913. * Represents a generic controller
  19914. */
  19915. static GENERIC: number;
  19916. /**
  19917. * Represents an XBox controller
  19918. */
  19919. static XBOX: number;
  19920. /**
  19921. * Represents a pose-enabled controller
  19922. */
  19923. static POSE_ENABLED: number;
  19924. /**
  19925. * Represents an Dual Shock controller
  19926. */
  19927. static DUALSHOCK: number;
  19928. /**
  19929. * Specifies whether the left control stick should be Y-inverted
  19930. */
  19931. protected _invertLeftStickY: boolean;
  19932. /**
  19933. * Specifies if the gamepad has been connected
  19934. */
  19935. get isConnected(): boolean;
  19936. /**
  19937. * Initializes the gamepad
  19938. * @param id The id of the gamepad
  19939. * @param index The index of the gamepad
  19940. * @param browserGamepad The browser gamepad
  19941. * @param leftStickX The x component of the left joystick
  19942. * @param leftStickY The y component of the left joystick
  19943. * @param rightStickX The x component of the right joystick
  19944. * @param rightStickY The y component of the right joystick
  19945. */
  19946. constructor(
  19947. /**
  19948. * The id of the gamepad
  19949. */
  19950. id: string,
  19951. /**
  19952. * The index of the gamepad
  19953. */
  19954. index: number,
  19955. /**
  19956. * The browser gamepad
  19957. */
  19958. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19959. /**
  19960. * Callback triggered when the left joystick has changed
  19961. * @param callback
  19962. */
  19963. onleftstickchanged(callback: (values: StickValues) => void): void;
  19964. /**
  19965. * Callback triggered when the right joystick has changed
  19966. * @param callback
  19967. */
  19968. onrightstickchanged(callback: (values: StickValues) => void): void;
  19969. /**
  19970. * Gets the left joystick
  19971. */
  19972. get leftStick(): StickValues;
  19973. /**
  19974. * Sets the left joystick values
  19975. */
  19976. set leftStick(newValues: StickValues);
  19977. /**
  19978. * Gets the right joystick
  19979. */
  19980. get rightStick(): StickValues;
  19981. /**
  19982. * Sets the right joystick value
  19983. */
  19984. set rightStick(newValues: StickValues);
  19985. /**
  19986. * Updates the gamepad joystick positions
  19987. */
  19988. update(): void;
  19989. /**
  19990. * Disposes the gamepad
  19991. */
  19992. dispose(): void;
  19993. }
  19994. /**
  19995. * Represents a generic gamepad
  19996. */
  19997. export class GenericPad extends Gamepad {
  19998. private _buttons;
  19999. private _onbuttondown;
  20000. private _onbuttonup;
  20001. /**
  20002. * Observable triggered when a button has been pressed
  20003. */
  20004. onButtonDownObservable: Observable<number>;
  20005. /**
  20006. * Observable triggered when a button has been released
  20007. */
  20008. onButtonUpObservable: Observable<number>;
  20009. /**
  20010. * Callback triggered when a button has been pressed
  20011. * @param callback Called when a button has been pressed
  20012. */
  20013. onbuttondown(callback: (buttonPressed: number) => void): void;
  20014. /**
  20015. * Callback triggered when a button has been released
  20016. * @param callback Called when a button has been released
  20017. */
  20018. onbuttonup(callback: (buttonReleased: number) => void): void;
  20019. /**
  20020. * Initializes the generic gamepad
  20021. * @param id The id of the generic gamepad
  20022. * @param index The index of the generic gamepad
  20023. * @param browserGamepad The browser gamepad
  20024. */
  20025. constructor(id: string, index: number, browserGamepad: any);
  20026. private _setButtonValue;
  20027. /**
  20028. * Updates the generic gamepad
  20029. */
  20030. update(): void;
  20031. /**
  20032. * Disposes the generic gamepad
  20033. */
  20034. dispose(): void;
  20035. }
  20036. }
  20037. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20038. import { Observable } from "babylonjs/Misc/observable";
  20039. import { Nullable } from "babylonjs/types";
  20040. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20041. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20043. import { Ray } from "babylonjs/Culling/ray";
  20044. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20045. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20046. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20047. /**
  20048. * Defines the types of pose enabled controllers that are supported
  20049. */
  20050. export enum PoseEnabledControllerType {
  20051. /**
  20052. * HTC Vive
  20053. */
  20054. VIVE = 0,
  20055. /**
  20056. * Oculus Rift
  20057. */
  20058. OCULUS = 1,
  20059. /**
  20060. * Windows mixed reality
  20061. */
  20062. WINDOWS = 2,
  20063. /**
  20064. * Samsung gear VR
  20065. */
  20066. GEAR_VR = 3,
  20067. /**
  20068. * Google Daydream
  20069. */
  20070. DAYDREAM = 4,
  20071. /**
  20072. * Generic
  20073. */
  20074. GENERIC = 5
  20075. }
  20076. /**
  20077. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20078. */
  20079. export interface MutableGamepadButton {
  20080. /**
  20081. * Value of the button/trigger
  20082. */
  20083. value: number;
  20084. /**
  20085. * If the button/trigger is currently touched
  20086. */
  20087. touched: boolean;
  20088. /**
  20089. * If the button/trigger is currently pressed
  20090. */
  20091. pressed: boolean;
  20092. }
  20093. /**
  20094. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20095. * @hidden
  20096. */
  20097. export interface ExtendedGamepadButton extends GamepadButton {
  20098. /**
  20099. * If the button/trigger is currently pressed
  20100. */
  20101. readonly pressed: boolean;
  20102. /**
  20103. * If the button/trigger is currently touched
  20104. */
  20105. readonly touched: boolean;
  20106. /**
  20107. * Value of the button/trigger
  20108. */
  20109. readonly value: number;
  20110. }
  20111. /** @hidden */
  20112. export interface _GamePadFactory {
  20113. /**
  20114. * Returns whether or not the current gamepad can be created for this type of controller.
  20115. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20116. * @returns true if it can be created, otherwise false
  20117. */
  20118. canCreate(gamepadInfo: any): boolean;
  20119. /**
  20120. * Creates a new instance of the Gamepad.
  20121. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20122. * @returns the new gamepad instance
  20123. */
  20124. create(gamepadInfo: any): Gamepad;
  20125. }
  20126. /**
  20127. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20128. */
  20129. export class PoseEnabledControllerHelper {
  20130. /** @hidden */
  20131. static _ControllerFactories: _GamePadFactory[];
  20132. /** @hidden */
  20133. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20134. /**
  20135. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20136. * @param vrGamepad the gamepad to initialized
  20137. * @returns a vr controller of the type the gamepad identified as
  20138. */
  20139. static InitiateController(vrGamepad: any): Gamepad;
  20140. }
  20141. /**
  20142. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20143. */
  20144. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20145. /**
  20146. * If the controller is used in a webXR session
  20147. */
  20148. isXR: boolean;
  20149. private _deviceRoomPosition;
  20150. private _deviceRoomRotationQuaternion;
  20151. /**
  20152. * The device position in babylon space
  20153. */
  20154. devicePosition: Vector3;
  20155. /**
  20156. * The device rotation in babylon space
  20157. */
  20158. deviceRotationQuaternion: Quaternion;
  20159. /**
  20160. * The scale factor of the device in babylon space
  20161. */
  20162. deviceScaleFactor: number;
  20163. /**
  20164. * (Likely devicePosition should be used instead) The device position in its room space
  20165. */
  20166. position: Vector3;
  20167. /**
  20168. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20169. */
  20170. rotationQuaternion: Quaternion;
  20171. /**
  20172. * The type of controller (Eg. Windows mixed reality)
  20173. */
  20174. controllerType: PoseEnabledControllerType;
  20175. protected _calculatedPosition: Vector3;
  20176. private _calculatedRotation;
  20177. /**
  20178. * The raw pose from the device
  20179. */
  20180. rawPose: DevicePose;
  20181. private _trackPosition;
  20182. private _maxRotationDistFromHeadset;
  20183. private _draggedRoomRotation;
  20184. /**
  20185. * @hidden
  20186. */
  20187. _disableTrackPosition(fixedPosition: Vector3): void;
  20188. /**
  20189. * Internal, the mesh attached to the controller
  20190. * @hidden
  20191. */
  20192. _mesh: Nullable<AbstractMesh>;
  20193. private _poseControlledCamera;
  20194. private _leftHandSystemQuaternion;
  20195. /**
  20196. * Internal, matrix used to convert room space to babylon space
  20197. * @hidden
  20198. */
  20199. _deviceToWorld: Matrix;
  20200. /**
  20201. * Node to be used when casting a ray from the controller
  20202. * @hidden
  20203. */
  20204. _pointingPoseNode: Nullable<TransformNode>;
  20205. /**
  20206. * Name of the child mesh that can be used to cast a ray from the controller
  20207. */
  20208. static readonly POINTING_POSE: string;
  20209. /**
  20210. * Creates a new PoseEnabledController from a gamepad
  20211. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20212. */
  20213. constructor(browserGamepad: any);
  20214. private _workingMatrix;
  20215. /**
  20216. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20217. */
  20218. update(): void;
  20219. /**
  20220. * Updates only the pose device and mesh without doing any button event checking
  20221. */
  20222. protected _updatePoseAndMesh(): void;
  20223. /**
  20224. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20225. * @param poseData raw pose fromthe device
  20226. */
  20227. updateFromDevice(poseData: DevicePose): void;
  20228. /**
  20229. * @hidden
  20230. */
  20231. _meshAttachedObservable: Observable<AbstractMesh>;
  20232. /**
  20233. * Attaches a mesh to the controller
  20234. * @param mesh the mesh to be attached
  20235. */
  20236. attachToMesh(mesh: AbstractMesh): void;
  20237. /**
  20238. * Attaches the controllers mesh to a camera
  20239. * @param camera the camera the mesh should be attached to
  20240. */
  20241. attachToPoseControlledCamera(camera: TargetCamera): void;
  20242. /**
  20243. * Disposes of the controller
  20244. */
  20245. dispose(): void;
  20246. /**
  20247. * The mesh that is attached to the controller
  20248. */
  20249. get mesh(): Nullable<AbstractMesh>;
  20250. /**
  20251. * Gets the ray of the controller in the direction the controller is pointing
  20252. * @param length the length the resulting ray should be
  20253. * @returns a ray in the direction the controller is pointing
  20254. */
  20255. getForwardRay(length?: number): Ray;
  20256. }
  20257. }
  20258. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20259. import { Observable } from "babylonjs/Misc/observable";
  20260. import { Scene } from "babylonjs/scene";
  20261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20262. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20263. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20264. import { Nullable } from "babylonjs/types";
  20265. /**
  20266. * Defines the WebVRController object that represents controllers tracked in 3D space
  20267. */
  20268. export abstract class WebVRController extends PoseEnabledController {
  20269. /**
  20270. * Internal, the default controller model for the controller
  20271. */
  20272. protected _defaultModel: Nullable<AbstractMesh>;
  20273. /**
  20274. * Fired when the trigger state has changed
  20275. */
  20276. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20277. /**
  20278. * Fired when the main button state has changed
  20279. */
  20280. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20281. /**
  20282. * Fired when the secondary button state has changed
  20283. */
  20284. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20285. /**
  20286. * Fired when the pad state has changed
  20287. */
  20288. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20289. /**
  20290. * Fired when controllers stick values have changed
  20291. */
  20292. onPadValuesChangedObservable: Observable<StickValues>;
  20293. /**
  20294. * Array of button availible on the controller
  20295. */
  20296. protected _buttons: Array<MutableGamepadButton>;
  20297. private _onButtonStateChange;
  20298. /**
  20299. * Fired when a controller button's state has changed
  20300. * @param callback the callback containing the button that was modified
  20301. */
  20302. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20303. /**
  20304. * X and Y axis corresponding to the controllers joystick
  20305. */
  20306. pad: StickValues;
  20307. /**
  20308. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20309. */
  20310. hand: string;
  20311. /**
  20312. * The default controller model for the controller
  20313. */
  20314. get defaultModel(): Nullable<AbstractMesh>;
  20315. /**
  20316. * Creates a new WebVRController from a gamepad
  20317. * @param vrGamepad the gamepad that the WebVRController should be created from
  20318. */
  20319. constructor(vrGamepad: any);
  20320. /**
  20321. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20322. */
  20323. update(): void;
  20324. /**
  20325. * Function to be called when a button is modified
  20326. */
  20327. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20328. /**
  20329. * Loads a mesh and attaches it to the controller
  20330. * @param scene the scene the mesh should be added to
  20331. * @param meshLoaded callback for when the mesh has been loaded
  20332. */
  20333. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20334. private _setButtonValue;
  20335. private _changes;
  20336. private _checkChanges;
  20337. /**
  20338. * Disposes of th webVRCOntroller
  20339. */
  20340. dispose(): void;
  20341. }
  20342. }
  20343. declare module "babylonjs/Lights/hemisphericLight" {
  20344. import { Nullable } from "babylonjs/types";
  20345. import { Scene } from "babylonjs/scene";
  20346. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20347. import { Color3 } from "babylonjs/Maths/math.color";
  20348. import { Effect } from "babylonjs/Materials/effect";
  20349. import { Light } from "babylonjs/Lights/light";
  20350. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20351. /**
  20352. * The HemisphericLight simulates the ambient environment light,
  20353. * so the passed direction is the light reflection direction, not the incoming direction.
  20354. */
  20355. export class HemisphericLight extends Light {
  20356. /**
  20357. * The groundColor is the light in the opposite direction to the one specified during creation.
  20358. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  20359. */
  20360. groundColor: Color3;
  20361. /**
  20362. * The light reflection direction, not the incoming direction.
  20363. */
  20364. direction: Vector3;
  20365. /**
  20366. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20367. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20368. * The HemisphericLight can't cast shadows.
  20369. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20370. * @param name The friendly name of the light
  20371. * @param direction The direction of the light reflection
  20372. * @param scene The scene the light belongs to
  20373. */
  20374. constructor(name: string, direction: Vector3, scene: Scene);
  20375. protected _buildUniformLayout(): void;
  20376. /**
  20377. * Returns the string "HemisphericLight".
  20378. * @return The class name
  20379. */
  20380. getClassName(): string;
  20381. /**
  20382. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20383. * Returns the updated direction.
  20384. * @param target The target the direction should point to
  20385. * @return The computed direction
  20386. */
  20387. setDirectionToTarget(target: Vector3): Vector3;
  20388. /**
  20389. * Returns the shadow generator associated to the light.
  20390. * @returns Always null for hemispheric lights because it does not support shadows.
  20391. */
  20392. getShadowGenerator(): Nullable<IShadowGenerator>;
  20393. /**
  20394. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20395. * @param effect The effect to update
  20396. * @param lightIndex The index of the light in the effect to update
  20397. * @returns The hemispheric light
  20398. */
  20399. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20400. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20401. /**
  20402. * Computes the world matrix of the node
  20403. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20404. * @param useWasUpdatedFlag defines a reserved property
  20405. * @returns the world matrix
  20406. */
  20407. computeWorldMatrix(): Matrix;
  20408. /**
  20409. * Returns the integer 3.
  20410. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20411. */
  20412. getTypeID(): number;
  20413. /**
  20414. * Prepares the list of defines specific to the light type.
  20415. * @param defines the list of defines
  20416. * @param lightIndex defines the index of the light for the effect
  20417. */
  20418. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20419. }
  20420. }
  20421. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20422. /** @hidden */
  20423. export var vrMultiviewToSingleviewPixelShader: {
  20424. name: string;
  20425. shader: string;
  20426. };
  20427. }
  20428. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20429. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20430. import { Scene } from "babylonjs/scene";
  20431. /**
  20432. * Renders to multiple views with a single draw call
  20433. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20434. */
  20435. export class MultiviewRenderTarget extends RenderTargetTexture {
  20436. /**
  20437. * Creates a multiview render target
  20438. * @param scene scene used with the render target
  20439. * @param size the size of the render target (used for each view)
  20440. */
  20441. constructor(scene: Scene, size?: number | {
  20442. width: number;
  20443. height: number;
  20444. } | {
  20445. ratio: number;
  20446. });
  20447. /**
  20448. * @hidden
  20449. * @param faceIndex the face index, if its a cube texture
  20450. */
  20451. _bindFrameBuffer(faceIndex?: number): void;
  20452. /**
  20453. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20454. * @returns the view count
  20455. */
  20456. getViewCount(): number;
  20457. }
  20458. }
  20459. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20460. import { Camera } from "babylonjs/Cameras/camera";
  20461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20462. import { Nullable } from "babylonjs/types";
  20463. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20464. import { Matrix } from "babylonjs/Maths/math.vector";
  20465. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20466. module "babylonjs/Engines/engine" {
  20467. interface Engine {
  20468. /**
  20469. * Creates a new multiview render target
  20470. * @param width defines the width of the texture
  20471. * @param height defines the height of the texture
  20472. * @returns the created multiview texture
  20473. */
  20474. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20475. /**
  20476. * Binds a multiview framebuffer to be drawn to
  20477. * @param multiviewTexture texture to bind
  20478. */
  20479. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20480. }
  20481. }
  20482. module "babylonjs/Cameras/camera" {
  20483. interface Camera {
  20484. /**
  20485. * @hidden
  20486. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20487. */
  20488. _useMultiviewToSingleView: boolean;
  20489. /**
  20490. * @hidden
  20491. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20492. */
  20493. _multiviewTexture: Nullable<RenderTargetTexture>;
  20494. /**
  20495. * @hidden
  20496. * ensures the multiview texture of the camera exists and has the specified width/height
  20497. * @param width height to set on the multiview texture
  20498. * @param height width to set on the multiview texture
  20499. */
  20500. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20501. }
  20502. }
  20503. module "babylonjs/scene" {
  20504. interface Scene {
  20505. /** @hidden */
  20506. _transformMatrixR: Matrix;
  20507. /** @hidden */
  20508. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20509. /** @hidden */
  20510. _createMultiviewUbo(): void;
  20511. /** @hidden */
  20512. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20513. /** @hidden */
  20514. _renderMultiviewToSingleView(camera: Camera): void;
  20515. }
  20516. }
  20517. }
  20518. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20519. import { Camera } from "babylonjs/Cameras/camera";
  20520. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20521. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20522. import "babylonjs/Engines/Extensions/engine.multiview";
  20523. /**
  20524. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20525. * This will not be used for webXR as it supports displaying texture arrays directly
  20526. */
  20527. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20528. /**
  20529. * Gets a string identifying the name of the class
  20530. * @returns "VRMultiviewToSingleviewPostProcess" string
  20531. */
  20532. getClassName(): string;
  20533. /**
  20534. * Initializes a VRMultiviewToSingleview
  20535. * @param name name of the post process
  20536. * @param camera camera to be applied to
  20537. * @param scaleFactor scaling factor to the size of the output texture
  20538. */
  20539. constructor(name: string, camera: Camera, scaleFactor: number);
  20540. }
  20541. }
  20542. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20543. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20544. import { Nullable } from "babylonjs/types";
  20545. import { Size } from "babylonjs/Maths/math.size";
  20546. import { Observable } from "babylonjs/Misc/observable";
  20547. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20548. /**
  20549. * Interface used to define additional presentation attributes
  20550. */
  20551. export interface IVRPresentationAttributes {
  20552. /**
  20553. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20554. */
  20555. highRefreshRate: boolean;
  20556. /**
  20557. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20558. */
  20559. foveationLevel: number;
  20560. }
  20561. module "babylonjs/Engines/engine" {
  20562. interface Engine {
  20563. /** @hidden */
  20564. _vrDisplay: any;
  20565. /** @hidden */
  20566. _vrSupported: boolean;
  20567. /** @hidden */
  20568. _oldSize: Size;
  20569. /** @hidden */
  20570. _oldHardwareScaleFactor: number;
  20571. /** @hidden */
  20572. _vrExclusivePointerMode: boolean;
  20573. /** @hidden */
  20574. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20575. /** @hidden */
  20576. _onVRDisplayPointerRestricted: () => void;
  20577. /** @hidden */
  20578. _onVRDisplayPointerUnrestricted: () => void;
  20579. /** @hidden */
  20580. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20581. /** @hidden */
  20582. _onVrDisplayDisconnect: Nullable<() => void>;
  20583. /** @hidden */
  20584. _onVrDisplayPresentChange: Nullable<() => void>;
  20585. /**
  20586. * Observable signaled when VR display mode changes
  20587. */
  20588. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20589. /**
  20590. * Observable signaled when VR request present is complete
  20591. */
  20592. onVRRequestPresentComplete: Observable<boolean>;
  20593. /**
  20594. * Observable signaled when VR request present starts
  20595. */
  20596. onVRRequestPresentStart: Observable<Engine>;
  20597. /**
  20598. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20599. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20600. */
  20601. isInVRExclusivePointerMode: boolean;
  20602. /**
  20603. * Gets a boolean indicating if a webVR device was detected
  20604. * @returns true if a webVR device was detected
  20605. */
  20606. isVRDevicePresent(): boolean;
  20607. /**
  20608. * Gets the current webVR device
  20609. * @returns the current webVR device (or null)
  20610. */
  20611. getVRDevice(): any;
  20612. /**
  20613. * Initializes a webVR display and starts listening to display change events
  20614. * The onVRDisplayChangedObservable will be notified upon these changes
  20615. * @returns A promise containing a VRDisplay and if vr is supported
  20616. */
  20617. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20618. /** @hidden */
  20619. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20620. /**
  20621. * Gets or sets the presentation attributes used to configure VR rendering
  20622. */
  20623. vrPresentationAttributes?: IVRPresentationAttributes;
  20624. /**
  20625. * Call this function to switch to webVR mode
  20626. * Will do nothing if webVR is not supported or if there is no webVR device
  20627. * @param options the webvr options provided to the camera. mainly used for multiview
  20628. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20629. */
  20630. enableVR(options: WebVROptions): void;
  20631. /** @hidden */
  20632. _onVRFullScreenTriggered(): void;
  20633. }
  20634. }
  20635. }
  20636. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20637. import { Nullable } from "babylonjs/types";
  20638. import { Observable } from "babylonjs/Misc/observable";
  20639. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20640. import { Scene } from "babylonjs/scene";
  20641. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20642. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20643. import { Node } from "babylonjs/node";
  20644. import { Ray } from "babylonjs/Culling/ray";
  20645. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20646. import "babylonjs/Engines/Extensions/engine.webVR";
  20647. /**
  20648. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20649. * IMPORTANT!! The data is right-hand data.
  20650. * @export
  20651. * @interface DevicePose
  20652. */
  20653. export interface DevicePose {
  20654. /**
  20655. * The position of the device, values in array are [x,y,z].
  20656. */
  20657. readonly position: Nullable<Float32Array>;
  20658. /**
  20659. * The linearVelocity of the device, values in array are [x,y,z].
  20660. */
  20661. readonly linearVelocity: Nullable<Float32Array>;
  20662. /**
  20663. * The linearAcceleration of the device, values in array are [x,y,z].
  20664. */
  20665. readonly linearAcceleration: Nullable<Float32Array>;
  20666. /**
  20667. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20668. */
  20669. readonly orientation: Nullable<Float32Array>;
  20670. /**
  20671. * The angularVelocity of the device, values in array are [x,y,z].
  20672. */
  20673. readonly angularVelocity: Nullable<Float32Array>;
  20674. /**
  20675. * The angularAcceleration of the device, values in array are [x,y,z].
  20676. */
  20677. readonly angularAcceleration: Nullable<Float32Array>;
  20678. }
  20679. /**
  20680. * Interface representing a pose controlled object in Babylon.
  20681. * A pose controlled object has both regular pose values as well as pose values
  20682. * from an external device such as a VR head mounted display
  20683. */
  20684. export interface PoseControlled {
  20685. /**
  20686. * The position of the object in babylon space.
  20687. */
  20688. position: Vector3;
  20689. /**
  20690. * The rotation quaternion of the object in babylon space.
  20691. */
  20692. rotationQuaternion: Quaternion;
  20693. /**
  20694. * The position of the device in babylon space.
  20695. */
  20696. devicePosition?: Vector3;
  20697. /**
  20698. * The rotation quaternion of the device in babylon space.
  20699. */
  20700. deviceRotationQuaternion: Quaternion;
  20701. /**
  20702. * The raw pose coming from the device.
  20703. */
  20704. rawPose: Nullable<DevicePose>;
  20705. /**
  20706. * The scale of the device to be used when translating from device space to babylon space.
  20707. */
  20708. deviceScaleFactor: number;
  20709. /**
  20710. * Updates the poseControlled values based on the input device pose.
  20711. * @param poseData the pose data to update the object with
  20712. */
  20713. updateFromDevice(poseData: DevicePose): void;
  20714. }
  20715. /**
  20716. * Set of options to customize the webVRCamera
  20717. */
  20718. export interface WebVROptions {
  20719. /**
  20720. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20721. */
  20722. trackPosition?: boolean;
  20723. /**
  20724. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20725. */
  20726. positionScale?: number;
  20727. /**
  20728. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20729. */
  20730. displayName?: string;
  20731. /**
  20732. * Should the native controller meshes be initialized. (default: true)
  20733. */
  20734. controllerMeshes?: boolean;
  20735. /**
  20736. * Creating a default HemiLight only on controllers. (default: true)
  20737. */
  20738. defaultLightingOnControllers?: boolean;
  20739. /**
  20740. * If you don't want to use the default VR button of the helper. (default: false)
  20741. */
  20742. useCustomVRButton?: boolean;
  20743. /**
  20744. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20745. */
  20746. customVRButton?: HTMLButtonElement;
  20747. /**
  20748. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20749. */
  20750. rayLength?: number;
  20751. /**
  20752. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20753. */
  20754. defaultHeight?: number;
  20755. /**
  20756. * If multiview should be used if availible (default: false)
  20757. */
  20758. useMultiview?: boolean;
  20759. }
  20760. /**
  20761. * This represents a WebVR camera.
  20762. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20763. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20764. */
  20765. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20766. private webVROptions;
  20767. /**
  20768. * @hidden
  20769. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20770. */
  20771. _vrDevice: any;
  20772. /**
  20773. * The rawPose of the vrDevice.
  20774. */
  20775. rawPose: Nullable<DevicePose>;
  20776. private _onVREnabled;
  20777. private _specsVersion;
  20778. private _attached;
  20779. private _frameData;
  20780. protected _descendants: Array<Node>;
  20781. private _deviceRoomPosition;
  20782. /** @hidden */
  20783. _deviceRoomRotationQuaternion: Quaternion;
  20784. private _standingMatrix;
  20785. /**
  20786. * Represents device position in babylon space.
  20787. */
  20788. devicePosition: Vector3;
  20789. /**
  20790. * Represents device rotation in babylon space.
  20791. */
  20792. deviceRotationQuaternion: Quaternion;
  20793. /**
  20794. * The scale of the device to be used when translating from device space to babylon space.
  20795. */
  20796. deviceScaleFactor: number;
  20797. private _deviceToWorld;
  20798. private _worldToDevice;
  20799. /**
  20800. * References to the webVR controllers for the vrDevice.
  20801. */
  20802. controllers: Array<WebVRController>;
  20803. /**
  20804. * Emits an event when a controller is attached.
  20805. */
  20806. onControllersAttachedObservable: Observable<WebVRController[]>;
  20807. /**
  20808. * Emits an event when a controller's mesh has been loaded;
  20809. */
  20810. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20811. /**
  20812. * Emits an event when the HMD's pose has been updated.
  20813. */
  20814. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20815. private _poseSet;
  20816. /**
  20817. * If the rig cameras be used as parent instead of this camera.
  20818. */
  20819. rigParenting: boolean;
  20820. private _lightOnControllers;
  20821. private _defaultHeight?;
  20822. /**
  20823. * Instantiates a WebVRFreeCamera.
  20824. * @param name The name of the WebVRFreeCamera
  20825. * @param position The starting anchor position for the camera
  20826. * @param scene The scene the camera belongs to
  20827. * @param webVROptions a set of customizable options for the webVRCamera
  20828. */
  20829. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20830. /**
  20831. * Gets the device distance from the ground in meters.
  20832. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  20833. */
  20834. deviceDistanceToRoomGround(): number;
  20835. /**
  20836. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20837. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20838. */
  20839. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20840. /**
  20841. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20842. * @returns A promise with a boolean set to if the standing matrix is supported.
  20843. */
  20844. useStandingMatrixAsync(): Promise<boolean>;
  20845. /**
  20846. * Disposes the camera
  20847. */
  20848. dispose(): void;
  20849. /**
  20850. * Gets a vrController by name.
  20851. * @param name The name of the controller to retreive
  20852. * @returns the controller matching the name specified or null if not found
  20853. */
  20854. getControllerByName(name: string): Nullable<WebVRController>;
  20855. private _leftController;
  20856. /**
  20857. * The controller corresponding to the users left hand.
  20858. */
  20859. get leftController(): Nullable<WebVRController>;
  20860. private _rightController;
  20861. /**
  20862. * The controller corresponding to the users right hand.
  20863. */
  20864. get rightController(): Nullable<WebVRController>;
  20865. /**
  20866. * Casts a ray forward from the vrCamera's gaze.
  20867. * @param length Length of the ray (default: 100)
  20868. * @returns the ray corresponding to the gaze
  20869. */
  20870. getForwardRay(length?: number): Ray;
  20871. /**
  20872. * @hidden
  20873. * Updates the camera based on device's frame data
  20874. */
  20875. _checkInputs(): void;
  20876. /**
  20877. * Updates the poseControlled values based on the input device pose.
  20878. * @param poseData Pose coming from the device
  20879. */
  20880. updateFromDevice(poseData: DevicePose): void;
  20881. private _htmlElementAttached;
  20882. private _detachIfAttached;
  20883. /**
  20884. * WebVR's attach control will start broadcasting frames to the device.
  20885. * Note that in certain browsers (chrome for example) this function must be called
  20886. * within a user-interaction callback. Example:
  20887. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20888. *
  20889. * @param element html element to attach the vrDevice to
  20890. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20891. */
  20892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20893. /**
  20894. * Detaches the camera from the html element and disables VR
  20895. *
  20896. * @param element html element to detach from
  20897. */
  20898. detachControl(element: HTMLElement): void;
  20899. /**
  20900. * @returns the name of this class
  20901. */
  20902. getClassName(): string;
  20903. /**
  20904. * Calls resetPose on the vrDisplay
  20905. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20906. */
  20907. resetToCurrentRotation(): void;
  20908. /**
  20909. * @hidden
  20910. * Updates the rig cameras (left and right eye)
  20911. */
  20912. _updateRigCameras(): void;
  20913. private _workingVector;
  20914. private _oneVector;
  20915. private _workingMatrix;
  20916. private updateCacheCalled;
  20917. private _correctPositionIfNotTrackPosition;
  20918. /**
  20919. * @hidden
  20920. * Updates the cached values of the camera
  20921. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20922. */
  20923. _updateCache(ignoreParentClass?: boolean): void;
  20924. /**
  20925. * @hidden
  20926. * Get current device position in babylon world
  20927. */
  20928. _computeDevicePosition(): void;
  20929. /**
  20930. * Updates the current device position and rotation in the babylon world
  20931. */
  20932. update(): void;
  20933. /**
  20934. * @hidden
  20935. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20936. * @returns an identity matrix
  20937. */
  20938. _getViewMatrix(): Matrix;
  20939. private _tmpMatrix;
  20940. /**
  20941. * This function is called by the two RIG cameras.
  20942. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20943. * @hidden
  20944. */
  20945. _getWebVRViewMatrix(): Matrix;
  20946. /** @hidden */
  20947. _getWebVRProjectionMatrix(): Matrix;
  20948. private _onGamepadConnectedObserver;
  20949. private _onGamepadDisconnectedObserver;
  20950. private _updateCacheWhenTrackingDisabledObserver;
  20951. /**
  20952. * Initializes the controllers and their meshes
  20953. */
  20954. initControllers(): void;
  20955. }
  20956. }
  20957. declare module "babylonjs/Materials/materialHelper" {
  20958. import { Nullable } from "babylonjs/types";
  20959. import { Scene } from "babylonjs/scene";
  20960. import { Engine } from "babylonjs/Engines/engine";
  20961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20962. import { Light } from "babylonjs/Lights/light";
  20963. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20964. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20965. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20966. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20967. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20968. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20969. /**
  20970. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20971. *
  20972. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20973. *
  20974. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20975. */
  20976. export class MaterialHelper {
  20977. /**
  20978. * Bind the current view position to an effect.
  20979. * @param effect The effect to be bound
  20980. * @param scene The scene the eyes position is used from
  20981. * @param variableName name of the shader variable that will hold the eye position
  20982. */
  20983. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20984. /**
  20985. * Helps preparing the defines values about the UVs in used in the effect.
  20986. * UVs are shared as much as we can accross channels in the shaders.
  20987. * @param texture The texture we are preparing the UVs for
  20988. * @param defines The defines to update
  20989. * @param key The channel key "diffuse", "specular"... used in the shader
  20990. */
  20991. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20992. /**
  20993. * Binds a texture matrix value to its corrsponding uniform
  20994. * @param texture The texture to bind the matrix for
  20995. * @param uniformBuffer The uniform buffer receivin the data
  20996. * @param key The channel key "diffuse", "specular"... used in the shader
  20997. */
  20998. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20999. /**
  21000. * Gets the current status of the fog (should it be enabled?)
  21001. * @param mesh defines the mesh to evaluate for fog support
  21002. * @param scene defines the hosting scene
  21003. * @returns true if fog must be enabled
  21004. */
  21005. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  21006. /**
  21007. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  21008. * @param mesh defines the current mesh
  21009. * @param scene defines the current scene
  21010. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21011. * @param pointsCloud defines if point cloud rendering has to be turned on
  21012. * @param fogEnabled defines if fog has to be turned on
  21013. * @param alphaTest defines if alpha testing has to be turned on
  21014. * @param defines defines the current list of defines
  21015. */
  21016. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21017. /**
  21018. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21019. * @param scene defines the current scene
  21020. * @param engine defines the current engine
  21021. * @param defines specifies the list of active defines
  21022. * @param useInstances defines if instances have to be turned on
  21023. * @param useClipPlane defines if clip plane have to be turned on
  21024. * @param useInstances defines if instances have to be turned on
  21025. * @param useThinInstances defines if thin instances have to be turned on
  21026. */
  21027. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21028. /**
  21029. * Prepares the defines for bones
  21030. * @param mesh The mesh containing the geometry data we will draw
  21031. * @param defines The defines to update
  21032. */
  21033. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21034. /**
  21035. * Prepares the defines for morph targets
  21036. * @param mesh The mesh containing the geometry data we will draw
  21037. * @param defines The defines to update
  21038. */
  21039. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21040. /**
  21041. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21042. * @param mesh The mesh containing the geometry data we will draw
  21043. * @param defines The defines to update
  21044. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21045. * @param useBones Precise whether bones should be used or not (override mesh info)
  21046. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21047. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21048. * @returns false if defines are considered not dirty and have not been checked
  21049. */
  21050. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21051. /**
  21052. * Prepares the defines related to multiview
  21053. * @param scene The scene we are intending to draw
  21054. * @param defines The defines to update
  21055. */
  21056. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21057. /**
  21058. * Prepares the defines related to the prepass
  21059. * @param scene The scene we are intending to draw
  21060. * @param defines The defines to update
  21061. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21062. */
  21063. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21064. /**
  21065. * Prepares the defines related to the light information passed in parameter
  21066. * @param scene The scene we are intending to draw
  21067. * @param mesh The mesh the effect is compiling for
  21068. * @param light The light the effect is compiling for
  21069. * @param lightIndex The index of the light
  21070. * @param defines The defines to update
  21071. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21072. * @param state Defines the current state regarding what is needed (normals, etc...)
  21073. */
  21074. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21075. needNormals: boolean;
  21076. needRebuild: boolean;
  21077. shadowEnabled: boolean;
  21078. specularEnabled: boolean;
  21079. lightmapMode: boolean;
  21080. }): void;
  21081. /**
  21082. * Prepares the defines related to the light information passed in parameter
  21083. * @param scene The scene we are intending to draw
  21084. * @param mesh The mesh the effect is compiling for
  21085. * @param defines The defines to update
  21086. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21087. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21088. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21089. * @returns true if normals will be required for the rest of the effect
  21090. */
  21091. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21092. /**
  21093. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21094. * @param lightIndex defines the light index
  21095. * @param uniformsList The uniform list
  21096. * @param samplersList The sampler list
  21097. * @param projectedLightTexture defines if projected texture must be used
  21098. * @param uniformBuffersList defines an optional list of uniform buffers
  21099. */
  21100. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21101. /**
  21102. * Prepares the uniforms and samplers list to be used in the effect
  21103. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21104. * @param samplersList The sampler list
  21105. * @param defines The defines helping in the list generation
  21106. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21107. */
  21108. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21109. /**
  21110. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21111. * @param defines The defines to update while falling back
  21112. * @param fallbacks The authorized effect fallbacks
  21113. * @param maxSimultaneousLights The maximum number of lights allowed
  21114. * @param rank the current rank of the Effect
  21115. * @returns The newly affected rank
  21116. */
  21117. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21118. private static _TmpMorphInfluencers;
  21119. /**
  21120. * Prepares the list of attributes required for morph targets according to the effect defines.
  21121. * @param attribs The current list of supported attribs
  21122. * @param mesh The mesh to prepare the morph targets attributes for
  21123. * @param influencers The number of influencers
  21124. */
  21125. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21126. /**
  21127. * Prepares the list of attributes required for morph targets according to the effect defines.
  21128. * @param attribs The current list of supported attribs
  21129. * @param mesh The mesh to prepare the morph targets attributes for
  21130. * @param defines The current Defines of the effect
  21131. */
  21132. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21133. /**
  21134. * Prepares the list of attributes required for bones according to the effect defines.
  21135. * @param attribs The current list of supported attribs
  21136. * @param mesh The mesh to prepare the bones attributes for
  21137. * @param defines The current Defines of the effect
  21138. * @param fallbacks The current efffect fallback strategy
  21139. */
  21140. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21141. /**
  21142. * Check and prepare the list of attributes required for instances according to the effect defines.
  21143. * @param attribs The current list of supported attribs
  21144. * @param defines The current MaterialDefines of the effect
  21145. */
  21146. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21147. /**
  21148. * Add the list of attributes required for instances to the attribs array.
  21149. * @param attribs The current list of supported attribs
  21150. */
  21151. static PushAttributesForInstances(attribs: string[]): void;
  21152. /**
  21153. * Binds the light information to the effect.
  21154. * @param light The light containing the generator
  21155. * @param effect The effect we are binding the data to
  21156. * @param lightIndex The light index in the effect used to render
  21157. */
  21158. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21159. /**
  21160. * Binds the lights information from the scene to the effect for the given mesh.
  21161. * @param light Light to bind
  21162. * @param lightIndex Light index
  21163. * @param scene The scene where the light belongs to
  21164. * @param effect The effect we are binding the data to
  21165. * @param useSpecular Defines if specular is supported
  21166. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21167. */
  21168. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21169. /**
  21170. * Binds the lights information from the scene to the effect for the given mesh.
  21171. * @param scene The scene the lights belongs to
  21172. * @param mesh The mesh we are binding the information to render
  21173. * @param effect The effect we are binding the data to
  21174. * @param defines The generated defines for the effect
  21175. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21176. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21177. */
  21178. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21179. private static _tempFogColor;
  21180. /**
  21181. * Binds the fog information from the scene to the effect for the given mesh.
  21182. * @param scene The scene the lights belongs to
  21183. * @param mesh The mesh we are binding the information to render
  21184. * @param effect The effect we are binding the data to
  21185. * @param linearSpace Defines if the fog effect is applied in linear space
  21186. */
  21187. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21188. /**
  21189. * Binds the bones information from the mesh to the effect.
  21190. * @param mesh The mesh we are binding the information to render
  21191. * @param effect The effect we are binding the data to
  21192. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21193. */
  21194. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21195. private static _CopyBonesTransformationMatrices;
  21196. /**
  21197. * Binds the morph targets information from the mesh to the effect.
  21198. * @param abstractMesh The mesh we are binding the information to render
  21199. * @param effect The effect we are binding the data to
  21200. */
  21201. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21202. /**
  21203. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21204. * @param defines The generated defines used in the effect
  21205. * @param effect The effect we are binding the data to
  21206. * @param scene The scene we are willing to render with logarithmic scale for
  21207. */
  21208. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21209. /**
  21210. * Binds the clip plane information from the scene to the effect.
  21211. * @param scene The scene the clip plane information are extracted from
  21212. * @param effect The effect we are binding the data to
  21213. */
  21214. static BindClipPlane(effect: Effect, scene: Scene): void;
  21215. }
  21216. }
  21217. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21219. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21220. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21221. import { Nullable } from "babylonjs/types";
  21222. import { Effect } from "babylonjs/Materials/effect";
  21223. import { Matrix } from "babylonjs/Maths/math.vector";
  21224. import { Scene } from "babylonjs/scene";
  21225. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21227. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21228. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21229. import { Observable } from "babylonjs/Misc/observable";
  21230. /**
  21231. * Block used to expose an input value
  21232. */
  21233. export class InputBlock extends NodeMaterialBlock {
  21234. private _mode;
  21235. private _associatedVariableName;
  21236. private _storedValue;
  21237. private _valueCallback;
  21238. private _type;
  21239. private _animationType;
  21240. /** Gets or set a value used to limit the range of float values */
  21241. min: number;
  21242. /** Gets or set a value used to limit the range of float values */
  21243. max: number;
  21244. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21245. isBoolean: boolean;
  21246. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21247. matrixMode: number;
  21248. /** @hidden */
  21249. _systemValue: Nullable<NodeMaterialSystemValues>;
  21250. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21251. isConstant: boolean;
  21252. /** Gets or sets the group to use to display this block in the Inspector */
  21253. groupInInspector: string;
  21254. /** Gets an observable raised when the value is changed */
  21255. onValueChangedObservable: Observable<InputBlock>;
  21256. /**
  21257. * Gets or sets the connection point type (default is float)
  21258. */
  21259. get type(): NodeMaterialBlockConnectionPointTypes;
  21260. /**
  21261. * Creates a new InputBlock
  21262. * @param name defines the block name
  21263. * @param target defines the target of that block (Vertex by default)
  21264. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21265. */
  21266. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21267. /**
  21268. * Validates if a name is a reserve word.
  21269. * @param newName the new name to be given to the node.
  21270. * @returns false if the name is a reserve word, else true.
  21271. */
  21272. validateBlockName(newName: string): boolean;
  21273. /**
  21274. * Gets the output component
  21275. */
  21276. get output(): NodeMaterialConnectionPoint;
  21277. /**
  21278. * Set the source of this connection point to a vertex attribute
  21279. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21280. * @returns the current connection point
  21281. */
  21282. setAsAttribute(attributeName?: string): InputBlock;
  21283. /**
  21284. * Set the source of this connection point to a system value
  21285. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21286. * @returns the current connection point
  21287. */
  21288. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21289. /**
  21290. * Gets or sets the value of that point.
  21291. * Please note that this value will be ignored if valueCallback is defined
  21292. */
  21293. get value(): any;
  21294. set value(value: any);
  21295. /**
  21296. * Gets or sets a callback used to get the value of that point.
  21297. * Please note that setting this value will force the connection point to ignore the value property
  21298. */
  21299. get valueCallback(): () => any;
  21300. set valueCallback(value: () => any);
  21301. /**
  21302. * Gets or sets the associated variable name in the shader
  21303. */
  21304. get associatedVariableName(): string;
  21305. set associatedVariableName(value: string);
  21306. /** Gets or sets the type of animation applied to the input */
  21307. get animationType(): AnimatedInputBlockTypes;
  21308. set animationType(value: AnimatedInputBlockTypes);
  21309. /**
  21310. * Gets a boolean indicating that this connection point not defined yet
  21311. */
  21312. get isUndefined(): boolean;
  21313. /**
  21314. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21315. * In this case the connection point name must be the name of the uniform to use.
  21316. * Can only be set on inputs
  21317. */
  21318. get isUniform(): boolean;
  21319. set isUniform(value: boolean);
  21320. /**
  21321. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21322. * In this case the connection point name must be the name of the attribute to use
  21323. * Can only be set on inputs
  21324. */
  21325. get isAttribute(): boolean;
  21326. set isAttribute(value: boolean);
  21327. /**
  21328. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21329. * Can only be set on exit points
  21330. */
  21331. get isVarying(): boolean;
  21332. set isVarying(value: boolean);
  21333. /**
  21334. * Gets a boolean indicating that the current connection point is a system value
  21335. */
  21336. get isSystemValue(): boolean;
  21337. /**
  21338. * Gets or sets the current well known value or null if not defined as a system value
  21339. */
  21340. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21341. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21342. /**
  21343. * Gets the current class name
  21344. * @returns the class name
  21345. */
  21346. getClassName(): string;
  21347. /**
  21348. * Animate the input if animationType !== None
  21349. * @param scene defines the rendering scene
  21350. */
  21351. animate(scene: Scene): void;
  21352. private _emitDefine;
  21353. initialize(state: NodeMaterialBuildState): void;
  21354. /**
  21355. * Set the input block to its default value (based on its type)
  21356. */
  21357. setDefaultValue(): void;
  21358. private _emitConstant;
  21359. /** @hidden */
  21360. get _noContextSwitch(): boolean;
  21361. private _emit;
  21362. /** @hidden */
  21363. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21364. /** @hidden */
  21365. _transmit(effect: Effect, scene: Scene): void;
  21366. protected _buildBlock(state: NodeMaterialBuildState): void;
  21367. protected _dumpPropertiesCode(): string;
  21368. dispose(): void;
  21369. serialize(): any;
  21370. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21371. }
  21372. }
  21373. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21374. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21375. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21376. import { Nullable } from "babylonjs/types";
  21377. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21378. import { Observable } from "babylonjs/Misc/observable";
  21379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21380. /**
  21381. * Enum used to define the compatibility state between two connection points
  21382. */
  21383. export enum NodeMaterialConnectionPointCompatibilityStates {
  21384. /** Points are compatibles */
  21385. Compatible = 0,
  21386. /** Points are incompatible because of their types */
  21387. TypeIncompatible = 1,
  21388. /** Points are incompatible because of their targets (vertex vs fragment) */
  21389. TargetIncompatible = 2
  21390. }
  21391. /**
  21392. * Defines the direction of a connection point
  21393. */
  21394. export enum NodeMaterialConnectionPointDirection {
  21395. /** Input */
  21396. Input = 0,
  21397. /** Output */
  21398. Output = 1
  21399. }
  21400. /**
  21401. * Defines a connection point for a block
  21402. */
  21403. export class NodeMaterialConnectionPoint {
  21404. /** @hidden */
  21405. _ownerBlock: NodeMaterialBlock;
  21406. /** @hidden */
  21407. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21408. private _endpoints;
  21409. private _associatedVariableName;
  21410. private _direction;
  21411. /** @hidden */
  21412. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21413. /** @hidden */
  21414. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21415. private _type;
  21416. /** @hidden */
  21417. _enforceAssociatedVariableName: boolean;
  21418. /** Gets the direction of the point */
  21419. get direction(): NodeMaterialConnectionPointDirection;
  21420. /** Indicates that this connection point needs dual validation before being connected to another point */
  21421. needDualDirectionValidation: boolean;
  21422. /**
  21423. * Gets or sets the additional types supported by this connection point
  21424. */
  21425. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21426. /**
  21427. * Gets or sets the additional types excluded by this connection point
  21428. */
  21429. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21430. /**
  21431. * Observable triggered when this point is connected
  21432. */
  21433. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21434. /**
  21435. * Gets or sets the associated variable name in the shader
  21436. */
  21437. get associatedVariableName(): string;
  21438. set associatedVariableName(value: string);
  21439. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21440. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21441. /**
  21442. * Gets or sets the connection point type (default is float)
  21443. */
  21444. get type(): NodeMaterialBlockConnectionPointTypes;
  21445. set type(value: NodeMaterialBlockConnectionPointTypes);
  21446. /**
  21447. * Gets or sets the connection point name
  21448. */
  21449. name: string;
  21450. /**
  21451. * Gets or sets the connection point name
  21452. */
  21453. displayName: string;
  21454. /**
  21455. * Gets or sets a boolean indicating that this connection point can be omitted
  21456. */
  21457. isOptional: boolean;
  21458. /**
  21459. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21460. */
  21461. isExposedOnFrame: boolean;
  21462. /**
  21463. * Gets or sets number indicating the position that the port is exposed to on a frame
  21464. */
  21465. exposedPortPosition: number;
  21466. /**
  21467. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21468. */
  21469. define: string;
  21470. /** @hidden */
  21471. _prioritizeVertex: boolean;
  21472. private _target;
  21473. /** Gets or sets the target of that connection point */
  21474. get target(): NodeMaterialBlockTargets;
  21475. set target(value: NodeMaterialBlockTargets);
  21476. /**
  21477. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21478. */
  21479. get isConnected(): boolean;
  21480. /**
  21481. * Gets a boolean indicating that the current point is connected to an input block
  21482. */
  21483. get isConnectedToInputBlock(): boolean;
  21484. /**
  21485. * Gets a the connected input block (if any)
  21486. */
  21487. get connectInputBlock(): Nullable<InputBlock>;
  21488. /** Get the other side of the connection (if any) */
  21489. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21490. /** Get the block that owns this connection point */
  21491. get ownerBlock(): NodeMaterialBlock;
  21492. /** Get the block connected on the other side of this connection (if any) */
  21493. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21494. /** Get the block connected on the endpoints of this connection (if any) */
  21495. get connectedBlocks(): Array<NodeMaterialBlock>;
  21496. /** Gets the list of connected endpoints */
  21497. get endpoints(): NodeMaterialConnectionPoint[];
  21498. /** Gets a boolean indicating if that output point is connected to at least one input */
  21499. get hasEndpoints(): boolean;
  21500. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21501. get isConnectedInVertexShader(): boolean;
  21502. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21503. get isConnectedInFragmentShader(): boolean;
  21504. /**
  21505. * Creates a block suitable to be used as an input for this input point.
  21506. * If null is returned, a block based on the point type will be created.
  21507. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21508. */
  21509. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21510. /**
  21511. * Creates a new connection point
  21512. * @param name defines the connection point name
  21513. * @param ownerBlock defines the block hosting this connection point
  21514. * @param direction defines the direction of the connection point
  21515. */
  21516. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21517. /**
  21518. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21519. * @returns the class name
  21520. */
  21521. getClassName(): string;
  21522. /**
  21523. * Gets a boolean indicating if the current point can be connected to another point
  21524. * @param connectionPoint defines the other connection point
  21525. * @returns a boolean
  21526. */
  21527. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21528. /**
  21529. * Gets a number indicating if the current point can be connected to another point
  21530. * @param connectionPoint defines the other connection point
  21531. * @returns a number defining the compatibility state
  21532. */
  21533. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21534. /**
  21535. * Connect this point to another connection point
  21536. * @param connectionPoint defines the other connection point
  21537. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21538. * @returns the current connection point
  21539. */
  21540. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21541. /**
  21542. * Disconnect this point from one of his endpoint
  21543. * @param endpoint defines the other connection point
  21544. * @returns the current connection point
  21545. */
  21546. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21547. /**
  21548. * Serializes this point in a JSON representation
  21549. * @param isInput defines if the connection point is an input (default is true)
  21550. * @returns the serialized point object
  21551. */
  21552. serialize(isInput?: boolean): any;
  21553. /**
  21554. * Release resources
  21555. */
  21556. dispose(): void;
  21557. }
  21558. }
  21559. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21560. /**
  21561. * Enum used to define the material modes
  21562. */
  21563. export enum NodeMaterialModes {
  21564. /** Regular material */
  21565. Material = 0,
  21566. /** For post process */
  21567. PostProcess = 1,
  21568. /** For particle system */
  21569. Particle = 2,
  21570. /** For procedural texture */
  21571. ProceduralTexture = 3
  21572. }
  21573. }
  21574. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21576. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21577. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21578. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21580. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21581. import { Effect } from "babylonjs/Materials/effect";
  21582. import { Mesh } from "babylonjs/Meshes/mesh";
  21583. import { Nullable } from "babylonjs/types";
  21584. import { Texture } from "babylonjs/Materials/Textures/texture";
  21585. import { Scene } from "babylonjs/scene";
  21586. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21587. /**
  21588. * Block used to read a texture from a sampler
  21589. */
  21590. export class TextureBlock extends NodeMaterialBlock {
  21591. private _defineName;
  21592. private _linearDefineName;
  21593. private _gammaDefineName;
  21594. private _tempTextureRead;
  21595. private _samplerName;
  21596. private _transformedUVName;
  21597. private _textureTransformName;
  21598. private _textureInfoName;
  21599. private _mainUVName;
  21600. private _mainUVDefineName;
  21601. private _fragmentOnly;
  21602. /**
  21603. * Gets or sets the texture associated with the node
  21604. */
  21605. texture: Nullable<Texture>;
  21606. /**
  21607. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21608. */
  21609. convertToGammaSpace: boolean;
  21610. /**
  21611. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21612. */
  21613. convertToLinearSpace: boolean;
  21614. /**
  21615. * Create a new TextureBlock
  21616. * @param name defines the block name
  21617. */
  21618. constructor(name: string, fragmentOnly?: boolean);
  21619. /**
  21620. * Gets the current class name
  21621. * @returns the class name
  21622. */
  21623. getClassName(): string;
  21624. /**
  21625. * Gets the uv input component
  21626. */
  21627. get uv(): NodeMaterialConnectionPoint;
  21628. /**
  21629. * Gets the rgba output component
  21630. */
  21631. get rgba(): NodeMaterialConnectionPoint;
  21632. /**
  21633. * Gets the rgb output component
  21634. */
  21635. get rgb(): NodeMaterialConnectionPoint;
  21636. /**
  21637. * Gets the r output component
  21638. */
  21639. get r(): NodeMaterialConnectionPoint;
  21640. /**
  21641. * Gets the g output component
  21642. */
  21643. get g(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the b output component
  21646. */
  21647. get b(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the a output component
  21650. */
  21651. get a(): NodeMaterialConnectionPoint;
  21652. get target(): NodeMaterialBlockTargets;
  21653. autoConfigure(material: NodeMaterial): void;
  21654. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21655. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21656. isReady(): boolean;
  21657. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21658. private get _isMixed();
  21659. private _injectVertexCode;
  21660. private _writeTextureRead;
  21661. private _writeOutput;
  21662. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21663. protected _dumpPropertiesCode(): string;
  21664. serialize(): any;
  21665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21666. }
  21667. }
  21668. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21669. /** @hidden */
  21670. export var reflectionFunction: {
  21671. name: string;
  21672. shader: string;
  21673. };
  21674. }
  21675. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21681. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21682. import { Effect } from "babylonjs/Materials/effect";
  21683. import { Mesh } from "babylonjs/Meshes/mesh";
  21684. import { Nullable } from "babylonjs/types";
  21685. import { Scene } from "babylonjs/scene";
  21686. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21687. /**
  21688. * Base block used to read a reflection texture from a sampler
  21689. */
  21690. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21691. /** @hidden */
  21692. _define3DName: string;
  21693. /** @hidden */
  21694. _defineCubicName: string;
  21695. /** @hidden */
  21696. _defineExplicitName: string;
  21697. /** @hidden */
  21698. _defineProjectionName: string;
  21699. /** @hidden */
  21700. _defineLocalCubicName: string;
  21701. /** @hidden */
  21702. _defineSphericalName: string;
  21703. /** @hidden */
  21704. _definePlanarName: string;
  21705. /** @hidden */
  21706. _defineEquirectangularName: string;
  21707. /** @hidden */
  21708. _defineMirroredEquirectangularFixedName: string;
  21709. /** @hidden */
  21710. _defineEquirectangularFixedName: string;
  21711. /** @hidden */
  21712. _defineSkyboxName: string;
  21713. /** @hidden */
  21714. _defineOppositeZ: string;
  21715. /** @hidden */
  21716. _cubeSamplerName: string;
  21717. /** @hidden */
  21718. _2DSamplerName: string;
  21719. protected _positionUVWName: string;
  21720. protected _directionWName: string;
  21721. protected _reflectionVectorName: string;
  21722. /** @hidden */
  21723. _reflectionCoordsName: string;
  21724. /** @hidden */
  21725. _reflectionMatrixName: string;
  21726. protected _reflectionColorName: string;
  21727. /**
  21728. * Gets or sets the texture associated with the node
  21729. */
  21730. texture: Nullable<BaseTexture>;
  21731. /**
  21732. * Create a new ReflectionTextureBaseBlock
  21733. * @param name defines the block name
  21734. */
  21735. constructor(name: string);
  21736. /**
  21737. * Gets the current class name
  21738. * @returns the class name
  21739. */
  21740. getClassName(): string;
  21741. /**
  21742. * Gets the world position input component
  21743. */
  21744. abstract get position(): NodeMaterialConnectionPoint;
  21745. /**
  21746. * Gets the world position input component
  21747. */
  21748. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21749. /**
  21750. * Gets the world normal input component
  21751. */
  21752. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21753. /**
  21754. * Gets the world input component
  21755. */
  21756. abstract get world(): NodeMaterialConnectionPoint;
  21757. /**
  21758. * Gets the camera (or eye) position component
  21759. */
  21760. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21761. /**
  21762. * Gets the view input component
  21763. */
  21764. abstract get view(): NodeMaterialConnectionPoint;
  21765. protected _getTexture(): Nullable<BaseTexture>;
  21766. autoConfigure(material: NodeMaterial): void;
  21767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21768. isReady(): boolean;
  21769. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21770. /**
  21771. * Gets the code to inject in the vertex shader
  21772. * @param state current state of the node material building
  21773. * @returns the shader code
  21774. */
  21775. handleVertexSide(state: NodeMaterialBuildState): string;
  21776. /**
  21777. * Handles the inits for the fragment code path
  21778. * @param state node material build state
  21779. */
  21780. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21781. /**
  21782. * Generates the reflection coords code for the fragment code path
  21783. * @param worldNormalVarName name of the world normal variable
  21784. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21785. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21786. * @returns the shader code
  21787. */
  21788. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21789. /**
  21790. * Generates the reflection color code for the fragment code path
  21791. * @param lodVarName name of the lod variable
  21792. * @param swizzleLookupTexture swizzle to use for the final color variable
  21793. * @returns the shader code
  21794. */
  21795. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21796. /**
  21797. * Generates the code corresponding to the connected output points
  21798. * @param state node material build state
  21799. * @param varName name of the variable to output
  21800. * @returns the shader code
  21801. */
  21802. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21803. protected _buildBlock(state: NodeMaterialBuildState): this;
  21804. protected _dumpPropertiesCode(): string;
  21805. serialize(): any;
  21806. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21807. }
  21808. }
  21809. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21810. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21811. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21812. import { Nullable } from "babylonjs/types";
  21813. /**
  21814. * Defines a connection point to be used for points with a custom object type
  21815. */
  21816. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21817. private _blockType;
  21818. private _blockName;
  21819. private _nameForCheking?;
  21820. /**
  21821. * Creates a new connection point
  21822. * @param name defines the connection point name
  21823. * @param ownerBlock defines the block hosting this connection point
  21824. * @param direction defines the direction of the connection point
  21825. */
  21826. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21827. /**
  21828. * Gets a number indicating if the current point can be connected to another point
  21829. * @param connectionPoint defines the other connection point
  21830. * @returns a number defining the compatibility state
  21831. */
  21832. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21833. /**
  21834. * Creates a block suitable to be used as an input for this input point.
  21835. * If null is returned, a block based on the point type will be created.
  21836. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21837. */
  21838. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21839. }
  21840. }
  21841. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21842. /**
  21843. * Enum defining the type of properties that can be edited in the property pages in the NME
  21844. */
  21845. export enum PropertyTypeForEdition {
  21846. /** property is a boolean */
  21847. Boolean = 0,
  21848. /** property is a float */
  21849. Float = 1,
  21850. /** property is a Vector2 */
  21851. Vector2 = 2,
  21852. /** property is a list of values */
  21853. List = 3
  21854. }
  21855. /**
  21856. * Interface that defines an option in a variable of type list
  21857. */
  21858. export interface IEditablePropertyListOption {
  21859. /** label of the option */
  21860. "label": string;
  21861. /** value of the option */
  21862. "value": number;
  21863. }
  21864. /**
  21865. * Interface that defines the options available for an editable property
  21866. */
  21867. export interface IEditablePropertyOption {
  21868. /** min value */
  21869. "min"?: number;
  21870. /** max value */
  21871. "max"?: number;
  21872. /** notifiers: indicates which actions to take when the property is changed */
  21873. "notifiers"?: {
  21874. /** the material should be rebuilt */
  21875. "rebuild"?: boolean;
  21876. /** the preview should be updated */
  21877. "update"?: boolean;
  21878. };
  21879. /** list of the options for a variable of type list */
  21880. "options"?: IEditablePropertyListOption[];
  21881. }
  21882. /**
  21883. * Interface that describes an editable property
  21884. */
  21885. export interface IPropertyDescriptionForEdition {
  21886. /** name of the property */
  21887. "propertyName": string;
  21888. /** display name of the property */
  21889. "displayName": string;
  21890. /** type of the property */
  21891. "type": PropertyTypeForEdition;
  21892. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21893. "groupName": string;
  21894. /** options for the property */
  21895. "options": IEditablePropertyOption;
  21896. }
  21897. /**
  21898. * Decorator that flags a property in a node material block as being editable
  21899. */
  21900. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21901. }
  21902. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21905. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21907. import { Nullable } from "babylonjs/types";
  21908. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21909. import { Mesh } from "babylonjs/Meshes/mesh";
  21910. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21911. import { Effect } from "babylonjs/Materials/effect";
  21912. import { Scene } from "babylonjs/scene";
  21913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21914. /**
  21915. * Block used to implement the refraction part of the sub surface module of the PBR material
  21916. */
  21917. export class RefractionBlock extends NodeMaterialBlock {
  21918. /** @hidden */
  21919. _define3DName: string;
  21920. /** @hidden */
  21921. _refractionMatrixName: string;
  21922. /** @hidden */
  21923. _defineLODRefractionAlpha: string;
  21924. /** @hidden */
  21925. _defineLinearSpecularRefraction: string;
  21926. /** @hidden */
  21927. _defineOppositeZ: string;
  21928. /** @hidden */
  21929. _cubeSamplerName: string;
  21930. /** @hidden */
  21931. _2DSamplerName: string;
  21932. /** @hidden */
  21933. _vRefractionMicrosurfaceInfosName: string;
  21934. /** @hidden */
  21935. _vRefractionInfosName: string;
  21936. private _scene;
  21937. /**
  21938. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21939. * Materials half opaque for instance using refraction could benefit from this control.
  21940. */
  21941. linkRefractionWithTransparency: boolean;
  21942. /**
  21943. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21944. */
  21945. invertRefractionY: boolean;
  21946. /**
  21947. * Gets or sets the texture associated with the node
  21948. */
  21949. texture: Nullable<BaseTexture>;
  21950. /**
  21951. * Create a new RefractionBlock
  21952. * @param name defines the block name
  21953. */
  21954. constructor(name: string);
  21955. /**
  21956. * Gets the current class name
  21957. * @returns the class name
  21958. */
  21959. getClassName(): string;
  21960. /**
  21961. * Gets the intensity input component
  21962. */
  21963. get intensity(): NodeMaterialConnectionPoint;
  21964. /**
  21965. * Gets the index of refraction input component
  21966. */
  21967. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21968. /**
  21969. * Gets the tint at distance input component
  21970. */
  21971. get tintAtDistance(): NodeMaterialConnectionPoint;
  21972. /**
  21973. * Gets the view input component
  21974. */
  21975. get view(): NodeMaterialConnectionPoint;
  21976. /**
  21977. * Gets the refraction object output component
  21978. */
  21979. get refraction(): NodeMaterialConnectionPoint;
  21980. /**
  21981. * Returns true if the block has a texture
  21982. */
  21983. get hasTexture(): boolean;
  21984. protected _getTexture(): Nullable<BaseTexture>;
  21985. autoConfigure(material: NodeMaterial): void;
  21986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21987. isReady(): boolean;
  21988. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21989. /**
  21990. * Gets the main code of the block (fragment side)
  21991. * @param state current state of the node material building
  21992. * @returns the shader code
  21993. */
  21994. getCode(state: NodeMaterialBuildState): string;
  21995. protected _buildBlock(state: NodeMaterialBuildState): this;
  21996. protected _dumpPropertiesCode(): string;
  21997. serialize(): any;
  21998. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21999. }
  22000. }
  22001. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  22002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22004. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22007. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22009. import { Nullable } from "babylonjs/types";
  22010. import { Scene } from "babylonjs/scene";
  22011. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22012. /**
  22013. * Base block used as input for post process
  22014. */
  22015. export class CurrentScreenBlock extends NodeMaterialBlock {
  22016. private _samplerName;
  22017. private _linearDefineName;
  22018. private _gammaDefineName;
  22019. private _mainUVName;
  22020. private _tempTextureRead;
  22021. /**
  22022. * Gets or sets the texture associated with the node
  22023. */
  22024. texture: Nullable<BaseTexture>;
  22025. /**
  22026. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22027. */
  22028. convertToGammaSpace: boolean;
  22029. /**
  22030. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22031. */
  22032. convertToLinearSpace: boolean;
  22033. /**
  22034. * Create a new CurrentScreenBlock
  22035. * @param name defines the block name
  22036. */
  22037. constructor(name: string);
  22038. /**
  22039. * Gets the current class name
  22040. * @returns the class name
  22041. */
  22042. getClassName(): string;
  22043. /**
  22044. * Gets the uv input component
  22045. */
  22046. get uv(): NodeMaterialConnectionPoint;
  22047. /**
  22048. * Gets the rgba output component
  22049. */
  22050. get rgba(): NodeMaterialConnectionPoint;
  22051. /**
  22052. * Gets the rgb output component
  22053. */
  22054. get rgb(): NodeMaterialConnectionPoint;
  22055. /**
  22056. * Gets the r output component
  22057. */
  22058. get r(): NodeMaterialConnectionPoint;
  22059. /**
  22060. * Gets the g output component
  22061. */
  22062. get g(): NodeMaterialConnectionPoint;
  22063. /**
  22064. * Gets the b output component
  22065. */
  22066. get b(): NodeMaterialConnectionPoint;
  22067. /**
  22068. * Gets the a output component
  22069. */
  22070. get a(): NodeMaterialConnectionPoint;
  22071. /**
  22072. * Initialize the block and prepare the context for build
  22073. * @param state defines the state that will be used for the build
  22074. */
  22075. initialize(state: NodeMaterialBuildState): void;
  22076. get target(): NodeMaterialBlockTargets;
  22077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22078. isReady(): boolean;
  22079. private _injectVertexCode;
  22080. private _writeTextureRead;
  22081. private _writeOutput;
  22082. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22083. serialize(): any;
  22084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22085. }
  22086. }
  22087. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22092. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22093. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22094. import { Nullable } from "babylonjs/types";
  22095. import { Scene } from "babylonjs/scene";
  22096. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22097. /**
  22098. * Base block used for the particle texture
  22099. */
  22100. export class ParticleTextureBlock extends NodeMaterialBlock {
  22101. private _samplerName;
  22102. private _linearDefineName;
  22103. private _gammaDefineName;
  22104. private _tempTextureRead;
  22105. /**
  22106. * Gets or sets the texture associated with the node
  22107. */
  22108. texture: Nullable<BaseTexture>;
  22109. /**
  22110. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22111. */
  22112. convertToGammaSpace: boolean;
  22113. /**
  22114. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22115. */
  22116. convertToLinearSpace: boolean;
  22117. /**
  22118. * Create a new ParticleTextureBlock
  22119. * @param name defines the block name
  22120. */
  22121. constructor(name: string);
  22122. /**
  22123. * Gets the current class name
  22124. * @returns the class name
  22125. */
  22126. getClassName(): string;
  22127. /**
  22128. * Gets the uv input component
  22129. */
  22130. get uv(): NodeMaterialConnectionPoint;
  22131. /**
  22132. * Gets the rgba output component
  22133. */
  22134. get rgba(): NodeMaterialConnectionPoint;
  22135. /**
  22136. * Gets the rgb output component
  22137. */
  22138. get rgb(): NodeMaterialConnectionPoint;
  22139. /**
  22140. * Gets the r output component
  22141. */
  22142. get r(): NodeMaterialConnectionPoint;
  22143. /**
  22144. * Gets the g output component
  22145. */
  22146. get g(): NodeMaterialConnectionPoint;
  22147. /**
  22148. * Gets the b output component
  22149. */
  22150. get b(): NodeMaterialConnectionPoint;
  22151. /**
  22152. * Gets the a output component
  22153. */
  22154. get a(): NodeMaterialConnectionPoint;
  22155. /**
  22156. * Initialize the block and prepare the context for build
  22157. * @param state defines the state that will be used for the build
  22158. */
  22159. initialize(state: NodeMaterialBuildState): void;
  22160. autoConfigure(material: NodeMaterial): void;
  22161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22162. isReady(): boolean;
  22163. private _writeOutput;
  22164. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22165. serialize(): any;
  22166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22167. }
  22168. }
  22169. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22172. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22173. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22174. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22175. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22176. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22177. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22178. import { Scene } from "babylonjs/scene";
  22179. /**
  22180. * Class used to store shared data between 2 NodeMaterialBuildState
  22181. */
  22182. export class NodeMaterialBuildStateSharedData {
  22183. /**
  22184. * Gets the list of emitted varyings
  22185. */
  22186. temps: string[];
  22187. /**
  22188. * Gets the list of emitted varyings
  22189. */
  22190. varyings: string[];
  22191. /**
  22192. * Gets the varying declaration string
  22193. */
  22194. varyingDeclaration: string;
  22195. /**
  22196. * Input blocks
  22197. */
  22198. inputBlocks: InputBlock[];
  22199. /**
  22200. * Input blocks
  22201. */
  22202. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22203. /**
  22204. * Bindable blocks (Blocks that need to set data to the effect)
  22205. */
  22206. bindableBlocks: NodeMaterialBlock[];
  22207. /**
  22208. * List of blocks that can provide a compilation fallback
  22209. */
  22210. blocksWithFallbacks: NodeMaterialBlock[];
  22211. /**
  22212. * List of blocks that can provide a define update
  22213. */
  22214. blocksWithDefines: NodeMaterialBlock[];
  22215. /**
  22216. * List of blocks that can provide a repeatable content
  22217. */
  22218. repeatableContentBlocks: NodeMaterialBlock[];
  22219. /**
  22220. * List of blocks that can provide a dynamic list of uniforms
  22221. */
  22222. dynamicUniformBlocks: NodeMaterialBlock[];
  22223. /**
  22224. * List of blocks that can block the isReady function for the material
  22225. */
  22226. blockingBlocks: NodeMaterialBlock[];
  22227. /**
  22228. * Gets the list of animated inputs
  22229. */
  22230. animatedInputs: InputBlock[];
  22231. /**
  22232. * Build Id used to avoid multiple recompilations
  22233. */
  22234. buildId: number;
  22235. /** List of emitted variables */
  22236. variableNames: {
  22237. [key: string]: number;
  22238. };
  22239. /** List of emitted defines */
  22240. defineNames: {
  22241. [key: string]: number;
  22242. };
  22243. /** Should emit comments? */
  22244. emitComments: boolean;
  22245. /** Emit build activity */
  22246. verbose: boolean;
  22247. /** Gets or sets the hosting scene */
  22248. scene: Scene;
  22249. /**
  22250. * Gets the compilation hints emitted at compilation time
  22251. */
  22252. hints: {
  22253. needWorldViewMatrix: boolean;
  22254. needWorldViewProjectionMatrix: boolean;
  22255. needAlphaBlending: boolean;
  22256. needAlphaTesting: boolean;
  22257. };
  22258. /**
  22259. * List of compilation checks
  22260. */
  22261. checks: {
  22262. emitVertex: boolean;
  22263. emitFragment: boolean;
  22264. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22265. };
  22266. /**
  22267. * Is vertex program allowed to be empty?
  22268. */
  22269. allowEmptyVertexProgram: boolean;
  22270. /** Creates a new shared data */
  22271. constructor();
  22272. /**
  22273. * Emits console errors and exceptions if there is a failing check
  22274. */
  22275. emitErrors(): void;
  22276. }
  22277. }
  22278. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22279. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22280. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22281. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22282. /**
  22283. * Class used to store node based material build state
  22284. */
  22285. export class NodeMaterialBuildState {
  22286. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22287. supportUniformBuffers: boolean;
  22288. /**
  22289. * Gets the list of emitted attributes
  22290. */
  22291. attributes: string[];
  22292. /**
  22293. * Gets the list of emitted uniforms
  22294. */
  22295. uniforms: string[];
  22296. /**
  22297. * Gets the list of emitted constants
  22298. */
  22299. constants: string[];
  22300. /**
  22301. * Gets the list of emitted samplers
  22302. */
  22303. samplers: string[];
  22304. /**
  22305. * Gets the list of emitted functions
  22306. */
  22307. functions: {
  22308. [key: string]: string;
  22309. };
  22310. /**
  22311. * Gets the list of emitted extensions
  22312. */
  22313. extensions: {
  22314. [key: string]: string;
  22315. };
  22316. /**
  22317. * Gets the target of the compilation state
  22318. */
  22319. target: NodeMaterialBlockTargets;
  22320. /**
  22321. * Gets the list of emitted counters
  22322. */
  22323. counters: {
  22324. [key: string]: number;
  22325. };
  22326. /**
  22327. * Shared data between multiple NodeMaterialBuildState instances
  22328. */
  22329. sharedData: NodeMaterialBuildStateSharedData;
  22330. /** @hidden */
  22331. _vertexState: NodeMaterialBuildState;
  22332. /** @hidden */
  22333. _attributeDeclaration: string;
  22334. /** @hidden */
  22335. _uniformDeclaration: string;
  22336. /** @hidden */
  22337. _constantDeclaration: string;
  22338. /** @hidden */
  22339. _samplerDeclaration: string;
  22340. /** @hidden */
  22341. _varyingTransfer: string;
  22342. /** @hidden */
  22343. _injectAtEnd: string;
  22344. private _repeatableContentAnchorIndex;
  22345. /** @hidden */
  22346. _builtCompilationString: string;
  22347. /**
  22348. * Gets the emitted compilation strings
  22349. */
  22350. compilationString: string;
  22351. /**
  22352. * Finalize the compilation strings
  22353. * @param state defines the current compilation state
  22354. */
  22355. finalize(state: NodeMaterialBuildState): void;
  22356. /** @hidden */
  22357. get _repeatableContentAnchor(): string;
  22358. /** @hidden */
  22359. _getFreeVariableName(prefix: string): string;
  22360. /** @hidden */
  22361. _getFreeDefineName(prefix: string): string;
  22362. /** @hidden */
  22363. _excludeVariableName(name: string): void;
  22364. /** @hidden */
  22365. _emit2DSampler(name: string): void;
  22366. /** @hidden */
  22367. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22368. /** @hidden */
  22369. _emitExtension(name: string, extension: string, define?: string): void;
  22370. /** @hidden */
  22371. _emitFunction(name: string, code: string, comments: string): void;
  22372. /** @hidden */
  22373. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22374. replaceStrings?: {
  22375. search: RegExp;
  22376. replace: string;
  22377. }[];
  22378. repeatKey?: string;
  22379. }): string;
  22380. /** @hidden */
  22381. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22382. repeatKey?: string;
  22383. removeAttributes?: boolean;
  22384. removeUniforms?: boolean;
  22385. removeVaryings?: boolean;
  22386. removeIfDef?: boolean;
  22387. replaceStrings?: {
  22388. search: RegExp;
  22389. replace: string;
  22390. }[];
  22391. }, storeKey?: string): void;
  22392. /** @hidden */
  22393. _registerTempVariable(name: string): boolean;
  22394. /** @hidden */
  22395. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22396. /** @hidden */
  22397. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22398. /** @hidden */
  22399. _emitFloat(value: number): string;
  22400. }
  22401. }
  22402. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22403. /**
  22404. * Helper class used to generate session unique ID
  22405. */
  22406. export class UniqueIdGenerator {
  22407. private static _UniqueIdCounter;
  22408. /**
  22409. * Gets an unique (relatively to the current scene) Id
  22410. */
  22411. static get UniqueId(): number;
  22412. }
  22413. }
  22414. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22415. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22417. import { Nullable } from "babylonjs/types";
  22418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22419. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22420. import { Effect } from "babylonjs/Materials/effect";
  22421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22422. import { Mesh } from "babylonjs/Meshes/mesh";
  22423. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22424. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22425. import { Scene } from "babylonjs/scene";
  22426. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22427. /**
  22428. * Defines a block that can be used inside a node based material
  22429. */
  22430. export class NodeMaterialBlock {
  22431. private _buildId;
  22432. private _buildTarget;
  22433. private _target;
  22434. private _isFinalMerger;
  22435. private _isInput;
  22436. private _name;
  22437. protected _isUnique: boolean;
  22438. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22439. inputsAreExclusive: boolean;
  22440. /** @hidden */
  22441. _codeVariableName: string;
  22442. /** @hidden */
  22443. _inputs: NodeMaterialConnectionPoint[];
  22444. /** @hidden */
  22445. _outputs: NodeMaterialConnectionPoint[];
  22446. /** @hidden */
  22447. _preparationId: number;
  22448. /**
  22449. * Gets the name of the block
  22450. */
  22451. get name(): string;
  22452. /**
  22453. * Sets the name of the block. Will check if the name is valid.
  22454. */
  22455. set name(newName: string);
  22456. /**
  22457. * Gets or sets the unique id of the node
  22458. */
  22459. uniqueId: number;
  22460. /**
  22461. * Gets or sets the comments associated with this block
  22462. */
  22463. comments: string;
  22464. /**
  22465. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22466. */
  22467. get isUnique(): boolean;
  22468. /**
  22469. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22470. */
  22471. get isFinalMerger(): boolean;
  22472. /**
  22473. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22474. */
  22475. get isInput(): boolean;
  22476. /**
  22477. * Gets or sets the build Id
  22478. */
  22479. get buildId(): number;
  22480. set buildId(value: number);
  22481. /**
  22482. * Gets or sets the target of the block
  22483. */
  22484. get target(): NodeMaterialBlockTargets;
  22485. set target(value: NodeMaterialBlockTargets);
  22486. /**
  22487. * Gets the list of input points
  22488. */
  22489. get inputs(): NodeMaterialConnectionPoint[];
  22490. /** Gets the list of output points */
  22491. get outputs(): NodeMaterialConnectionPoint[];
  22492. /**
  22493. * Find an input by its name
  22494. * @param name defines the name of the input to look for
  22495. * @returns the input or null if not found
  22496. */
  22497. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22498. /**
  22499. * Find an output by its name
  22500. * @param name defines the name of the outputto look for
  22501. * @returns the output or null if not found
  22502. */
  22503. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22504. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22505. visibleInInspector: boolean;
  22506. /**
  22507. * Creates a new NodeMaterialBlock
  22508. * @param name defines the block name
  22509. * @param target defines the target of that block (Vertex by default)
  22510. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22511. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22512. */
  22513. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22514. /**
  22515. * Initialize the block and prepare the context for build
  22516. * @param state defines the state that will be used for the build
  22517. */
  22518. initialize(state: NodeMaterialBuildState): void;
  22519. /**
  22520. * Bind data to effect. Will only be called for blocks with isBindable === true
  22521. * @param effect defines the effect to bind data to
  22522. * @param nodeMaterial defines the hosting NodeMaterial
  22523. * @param mesh defines the mesh that will be rendered
  22524. * @param subMesh defines the submesh that will be rendered
  22525. */
  22526. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22527. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22528. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22529. protected _writeFloat(value: number): string;
  22530. /**
  22531. * Gets the current class name e.g. "NodeMaterialBlock"
  22532. * @returns the class name
  22533. */
  22534. getClassName(): string;
  22535. /**
  22536. * Register a new input. Must be called inside a block constructor
  22537. * @param name defines the connection point name
  22538. * @param type defines the connection point type
  22539. * @param isOptional defines a boolean indicating that this input can be omitted
  22540. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22541. * @param point an already created connection point. If not provided, create a new one
  22542. * @returns the current block
  22543. */
  22544. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22545. /**
  22546. * Register a new output. Must be called inside a block constructor
  22547. * @param name defines the connection point name
  22548. * @param type defines the connection point type
  22549. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22550. * @param point an already created connection point. If not provided, create a new one
  22551. * @returns the current block
  22552. */
  22553. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22554. /**
  22555. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22556. * @param forOutput defines an optional connection point to check compatibility with
  22557. * @returns the first available input or null
  22558. */
  22559. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22560. /**
  22561. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22562. * @param forBlock defines an optional block to check compatibility with
  22563. * @returns the first available input or null
  22564. */
  22565. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22566. /**
  22567. * Gets the sibling of the given output
  22568. * @param current defines the current output
  22569. * @returns the next output in the list or null
  22570. */
  22571. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22572. /**
  22573. * Connect current block with another block
  22574. * @param other defines the block to connect with
  22575. * @param options define the various options to help pick the right connections
  22576. * @returns the current block
  22577. */
  22578. connectTo(other: NodeMaterialBlock, options?: {
  22579. input?: string;
  22580. output?: string;
  22581. outputSwizzle?: string;
  22582. }): this | undefined;
  22583. protected _buildBlock(state: NodeMaterialBuildState): void;
  22584. /**
  22585. * Add uniforms, samplers and uniform buffers at compilation time
  22586. * @param state defines the state to update
  22587. * @param nodeMaterial defines the node material requesting the update
  22588. * @param defines defines the material defines to update
  22589. * @param uniformBuffers defines the list of uniform buffer names
  22590. */
  22591. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22592. /**
  22593. * Add potential fallbacks if shader compilation fails
  22594. * @param mesh defines the mesh to be rendered
  22595. * @param fallbacks defines the current prioritized list of fallbacks
  22596. */
  22597. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22598. /**
  22599. * Initialize defines for shader compilation
  22600. * @param mesh defines the mesh to be rendered
  22601. * @param nodeMaterial defines the node material requesting the update
  22602. * @param defines defines the material defines to update
  22603. * @param useInstances specifies that instances should be used
  22604. */
  22605. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22606. /**
  22607. * Update defines for shader compilation
  22608. * @param mesh defines the mesh to be rendered
  22609. * @param nodeMaterial defines the node material requesting the update
  22610. * @param defines defines the material defines to update
  22611. * @param useInstances specifies that instances should be used
  22612. * @param subMesh defines which submesh to render
  22613. */
  22614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22615. /**
  22616. * Lets the block try to connect some inputs automatically
  22617. * @param material defines the hosting NodeMaterial
  22618. */
  22619. autoConfigure(material: NodeMaterial): void;
  22620. /**
  22621. * Function called when a block is declared as repeatable content generator
  22622. * @param vertexShaderState defines the current compilation state for the vertex shader
  22623. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22624. * @param mesh defines the mesh to be rendered
  22625. * @param defines defines the material defines to update
  22626. */
  22627. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22628. /**
  22629. * Checks if the block is ready
  22630. * @param mesh defines the mesh to be rendered
  22631. * @param nodeMaterial defines the node material requesting the update
  22632. * @param defines defines the material defines to update
  22633. * @param useInstances specifies that instances should be used
  22634. * @returns true if the block is ready
  22635. */
  22636. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22637. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22638. private _processBuild;
  22639. /**
  22640. * Validates the new name for the block node.
  22641. * @param newName the new name to be given to the node.
  22642. * @returns false if the name is a reserve word, else true.
  22643. */
  22644. validateBlockName(newName: string): boolean;
  22645. /**
  22646. * Compile the current node and generate the shader code
  22647. * @param state defines the current compilation state (uniforms, samplers, current string)
  22648. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22649. * @returns true if already built
  22650. */
  22651. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22652. protected _inputRename(name: string): string;
  22653. protected _outputRename(name: string): string;
  22654. protected _dumpPropertiesCode(): string;
  22655. /** @hidden */
  22656. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22657. /** @hidden */
  22658. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22659. /**
  22660. * Clone the current block to a new identical block
  22661. * @param scene defines the hosting scene
  22662. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22663. * @returns a copy of the current block
  22664. */
  22665. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22666. /**
  22667. * Serializes this block in a JSON representation
  22668. * @returns the serialized block object
  22669. */
  22670. serialize(): any;
  22671. /** @hidden */
  22672. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22673. private _deserializePortDisplayNamesAndExposedOnFrame;
  22674. /**
  22675. * Release resources
  22676. */
  22677. dispose(): void;
  22678. }
  22679. }
  22680. declare module "babylonjs/Materials/pushMaterial" {
  22681. import { Nullable } from "babylonjs/types";
  22682. import { Scene } from "babylonjs/scene";
  22683. import { Matrix } from "babylonjs/Maths/math.vector";
  22684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22685. import { Mesh } from "babylonjs/Meshes/mesh";
  22686. import { Material } from "babylonjs/Materials/material";
  22687. import { Effect } from "babylonjs/Materials/effect";
  22688. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22689. /**
  22690. * Base class of materials working in push mode in babylon JS
  22691. * @hidden
  22692. */
  22693. export class PushMaterial extends Material {
  22694. protected _activeEffect: Effect;
  22695. protected _normalMatrix: Matrix;
  22696. constructor(name: string, scene: Scene);
  22697. getEffect(): Effect;
  22698. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22699. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22700. /**
  22701. * Binds the given world matrix to the active effect
  22702. *
  22703. * @param world the matrix to bind
  22704. */
  22705. bindOnlyWorldMatrix(world: Matrix): void;
  22706. /**
  22707. * Binds the given normal matrix to the active effect
  22708. *
  22709. * @param normalMatrix the matrix to bind
  22710. */
  22711. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22712. bind(world: Matrix, mesh?: Mesh): void;
  22713. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22714. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22715. }
  22716. }
  22717. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22719. /**
  22720. * Root class for all node material optimizers
  22721. */
  22722. export class NodeMaterialOptimizer {
  22723. /**
  22724. * Function used to optimize a NodeMaterial graph
  22725. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22726. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22727. */
  22728. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22729. }
  22730. }
  22731. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22735. import { Scene } from "babylonjs/scene";
  22736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22737. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22738. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22739. /**
  22740. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22741. */
  22742. export class TransformBlock extends NodeMaterialBlock {
  22743. /**
  22744. * Defines the value to use to complement W value to transform it to a Vector4
  22745. */
  22746. complementW: number;
  22747. /**
  22748. * Defines the value to use to complement z value to transform it to a Vector4
  22749. */
  22750. complementZ: number;
  22751. /**
  22752. * Creates a new TransformBlock
  22753. * @param name defines the block name
  22754. */
  22755. constructor(name: string);
  22756. /**
  22757. * Gets the current class name
  22758. * @returns the class name
  22759. */
  22760. getClassName(): string;
  22761. /**
  22762. * Gets the vector input
  22763. */
  22764. get vector(): NodeMaterialConnectionPoint;
  22765. /**
  22766. * Gets the output component
  22767. */
  22768. get output(): NodeMaterialConnectionPoint;
  22769. /**
  22770. * Gets the xyz output component
  22771. */
  22772. get xyz(): NodeMaterialConnectionPoint;
  22773. /**
  22774. * Gets the matrix transform input
  22775. */
  22776. get transform(): NodeMaterialConnectionPoint;
  22777. protected _buildBlock(state: NodeMaterialBuildState): this;
  22778. /**
  22779. * Update defines for shader compilation
  22780. * @param mesh defines the mesh to be rendered
  22781. * @param nodeMaterial defines the node material requesting the update
  22782. * @param defines defines the material defines to update
  22783. * @param useInstances specifies that instances should be used
  22784. * @param subMesh defines which submesh to render
  22785. */
  22786. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22787. serialize(): any;
  22788. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22789. protected _dumpPropertiesCode(): string;
  22790. }
  22791. }
  22792. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22796. /**
  22797. * Block used to output the vertex position
  22798. */
  22799. export class VertexOutputBlock extends NodeMaterialBlock {
  22800. /**
  22801. * Creates a new VertexOutputBlock
  22802. * @param name defines the block name
  22803. */
  22804. constructor(name: string);
  22805. /**
  22806. * Gets the current class name
  22807. * @returns the class name
  22808. */
  22809. getClassName(): string;
  22810. /**
  22811. * Gets the vector input component
  22812. */
  22813. get vector(): NodeMaterialConnectionPoint;
  22814. protected _buildBlock(state: NodeMaterialBuildState): this;
  22815. }
  22816. }
  22817. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22819. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22820. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22821. /**
  22822. * Block used to output the final color
  22823. */
  22824. export class FragmentOutputBlock extends NodeMaterialBlock {
  22825. /**
  22826. * Create a new FragmentOutputBlock
  22827. * @param name defines the block name
  22828. */
  22829. constructor(name: string);
  22830. /**
  22831. * Gets the current class name
  22832. * @returns the class name
  22833. */
  22834. getClassName(): string;
  22835. /**
  22836. * Gets the rgba input component
  22837. */
  22838. get rgba(): NodeMaterialConnectionPoint;
  22839. /**
  22840. * Gets the rgb input component
  22841. */
  22842. get rgb(): NodeMaterialConnectionPoint;
  22843. /**
  22844. * Gets the a input component
  22845. */
  22846. get a(): NodeMaterialConnectionPoint;
  22847. protected _buildBlock(state: NodeMaterialBuildState): this;
  22848. }
  22849. }
  22850. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22854. /**
  22855. * Block used for the particle ramp gradient section
  22856. */
  22857. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22858. /**
  22859. * Create a new ParticleRampGradientBlock
  22860. * @param name defines the block name
  22861. */
  22862. constructor(name: string);
  22863. /**
  22864. * Gets the current class name
  22865. * @returns the class name
  22866. */
  22867. getClassName(): string;
  22868. /**
  22869. * Gets the color input component
  22870. */
  22871. get color(): NodeMaterialConnectionPoint;
  22872. /**
  22873. * Gets the rampColor output component
  22874. */
  22875. get rampColor(): NodeMaterialConnectionPoint;
  22876. /**
  22877. * Initialize the block and prepare the context for build
  22878. * @param state defines the state that will be used for the build
  22879. */
  22880. initialize(state: NodeMaterialBuildState): void;
  22881. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22882. }
  22883. }
  22884. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22888. /**
  22889. * Block used for the particle blend multiply section
  22890. */
  22891. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22892. /**
  22893. * Create a new ParticleBlendMultiplyBlock
  22894. * @param name defines the block name
  22895. */
  22896. constructor(name: string);
  22897. /**
  22898. * Gets the current class name
  22899. * @returns the class name
  22900. */
  22901. getClassName(): string;
  22902. /**
  22903. * Gets the color input component
  22904. */
  22905. get color(): NodeMaterialConnectionPoint;
  22906. /**
  22907. * Gets the alphaTexture input component
  22908. */
  22909. get alphaTexture(): NodeMaterialConnectionPoint;
  22910. /**
  22911. * Gets the alphaColor input component
  22912. */
  22913. get alphaColor(): NodeMaterialConnectionPoint;
  22914. /**
  22915. * Gets the blendColor output component
  22916. */
  22917. get blendColor(): NodeMaterialConnectionPoint;
  22918. /**
  22919. * Initialize the block and prepare the context for build
  22920. * @param state defines the state that will be used for the build
  22921. */
  22922. initialize(state: NodeMaterialBuildState): void;
  22923. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22924. }
  22925. }
  22926. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22927. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22928. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22929. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22930. /**
  22931. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22932. */
  22933. export class VectorMergerBlock extends NodeMaterialBlock {
  22934. /**
  22935. * Create a new VectorMergerBlock
  22936. * @param name defines the block name
  22937. */
  22938. constructor(name: string);
  22939. /**
  22940. * Gets the current class name
  22941. * @returns the class name
  22942. */
  22943. getClassName(): string;
  22944. /**
  22945. * Gets the xyz component (input)
  22946. */
  22947. get xyzIn(): NodeMaterialConnectionPoint;
  22948. /**
  22949. * Gets the xy component (input)
  22950. */
  22951. get xyIn(): NodeMaterialConnectionPoint;
  22952. /**
  22953. * Gets the x component (input)
  22954. */
  22955. get x(): NodeMaterialConnectionPoint;
  22956. /**
  22957. * Gets the y component (input)
  22958. */
  22959. get y(): NodeMaterialConnectionPoint;
  22960. /**
  22961. * Gets the z component (input)
  22962. */
  22963. get z(): NodeMaterialConnectionPoint;
  22964. /**
  22965. * Gets the w component (input)
  22966. */
  22967. get w(): NodeMaterialConnectionPoint;
  22968. /**
  22969. * Gets the xyzw component (output)
  22970. */
  22971. get xyzw(): NodeMaterialConnectionPoint;
  22972. /**
  22973. * Gets the xyz component (output)
  22974. */
  22975. get xyzOut(): NodeMaterialConnectionPoint;
  22976. /**
  22977. * Gets the xy component (output)
  22978. */
  22979. get xyOut(): NodeMaterialConnectionPoint;
  22980. /**
  22981. * Gets the xy component (output)
  22982. * @deprecated Please use xyOut instead.
  22983. */
  22984. get xy(): NodeMaterialConnectionPoint;
  22985. /**
  22986. * Gets the xyz component (output)
  22987. * @deprecated Please use xyzOut instead.
  22988. */
  22989. get xyz(): NodeMaterialConnectionPoint;
  22990. protected _buildBlock(state: NodeMaterialBuildState): this;
  22991. }
  22992. }
  22993. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22997. import { Vector2 } from "babylonjs/Maths/math.vector";
  22998. import { Scene } from "babylonjs/scene";
  22999. /**
  23000. * Block used to remap a float from a range to a new one
  23001. */
  23002. export class RemapBlock extends NodeMaterialBlock {
  23003. /**
  23004. * Gets or sets the source range
  23005. */
  23006. sourceRange: Vector2;
  23007. /**
  23008. * Gets or sets the target range
  23009. */
  23010. targetRange: Vector2;
  23011. /**
  23012. * Creates a new RemapBlock
  23013. * @param name defines the block name
  23014. */
  23015. constructor(name: string);
  23016. /**
  23017. * Gets the current class name
  23018. * @returns the class name
  23019. */
  23020. getClassName(): string;
  23021. /**
  23022. * Gets the input component
  23023. */
  23024. get input(): NodeMaterialConnectionPoint;
  23025. /**
  23026. * Gets the source min input component
  23027. */
  23028. get sourceMin(): NodeMaterialConnectionPoint;
  23029. /**
  23030. * Gets the source max input component
  23031. */
  23032. get sourceMax(): NodeMaterialConnectionPoint;
  23033. /**
  23034. * Gets the target min input component
  23035. */
  23036. get targetMin(): NodeMaterialConnectionPoint;
  23037. /**
  23038. * Gets the target max input component
  23039. */
  23040. get targetMax(): NodeMaterialConnectionPoint;
  23041. /**
  23042. * Gets the output component
  23043. */
  23044. get output(): NodeMaterialConnectionPoint;
  23045. protected _buildBlock(state: NodeMaterialBuildState): this;
  23046. protected _dumpPropertiesCode(): string;
  23047. serialize(): any;
  23048. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23049. }
  23050. }
  23051. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23055. /**
  23056. * Block used to multiply 2 values
  23057. */
  23058. export class MultiplyBlock extends NodeMaterialBlock {
  23059. /**
  23060. * Creates a new MultiplyBlock
  23061. * @param name defines the block name
  23062. */
  23063. constructor(name: string);
  23064. /**
  23065. * Gets the current class name
  23066. * @returns the class name
  23067. */
  23068. getClassName(): string;
  23069. /**
  23070. * Gets the left operand input component
  23071. */
  23072. get left(): NodeMaterialConnectionPoint;
  23073. /**
  23074. * Gets the right operand input component
  23075. */
  23076. get right(): NodeMaterialConnectionPoint;
  23077. /**
  23078. * Gets the output component
  23079. */
  23080. get output(): NodeMaterialConnectionPoint;
  23081. protected _buildBlock(state: NodeMaterialBuildState): this;
  23082. }
  23083. }
  23084. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23088. /**
  23089. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23090. */
  23091. export class ColorSplitterBlock extends NodeMaterialBlock {
  23092. /**
  23093. * Create a new ColorSplitterBlock
  23094. * @param name defines the block name
  23095. */
  23096. constructor(name: string);
  23097. /**
  23098. * Gets the current class name
  23099. * @returns the class name
  23100. */
  23101. getClassName(): string;
  23102. /**
  23103. * Gets the rgba component (input)
  23104. */
  23105. get rgba(): NodeMaterialConnectionPoint;
  23106. /**
  23107. * Gets the rgb component (input)
  23108. */
  23109. get rgbIn(): NodeMaterialConnectionPoint;
  23110. /**
  23111. * Gets the rgb component (output)
  23112. */
  23113. get rgbOut(): NodeMaterialConnectionPoint;
  23114. /**
  23115. * Gets the r component (output)
  23116. */
  23117. get r(): NodeMaterialConnectionPoint;
  23118. /**
  23119. * Gets the g component (output)
  23120. */
  23121. get g(): NodeMaterialConnectionPoint;
  23122. /**
  23123. * Gets the b component (output)
  23124. */
  23125. get b(): NodeMaterialConnectionPoint;
  23126. /**
  23127. * Gets the a component (output)
  23128. */
  23129. get a(): NodeMaterialConnectionPoint;
  23130. protected _inputRename(name: string): string;
  23131. protected _outputRename(name: string): string;
  23132. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23133. }
  23134. }
  23135. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23136. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23138. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23139. import { Scene } from "babylonjs/scene";
  23140. /**
  23141. * Operations supported by the Trigonometry block
  23142. */
  23143. export enum TrigonometryBlockOperations {
  23144. /** Cos */
  23145. Cos = 0,
  23146. /** Sin */
  23147. Sin = 1,
  23148. /** Abs */
  23149. Abs = 2,
  23150. /** Exp */
  23151. Exp = 3,
  23152. /** Exp2 */
  23153. Exp2 = 4,
  23154. /** Round */
  23155. Round = 5,
  23156. /** Floor */
  23157. Floor = 6,
  23158. /** Ceiling */
  23159. Ceiling = 7,
  23160. /** Square root */
  23161. Sqrt = 8,
  23162. /** Log */
  23163. Log = 9,
  23164. /** Tangent */
  23165. Tan = 10,
  23166. /** Arc tangent */
  23167. ArcTan = 11,
  23168. /** Arc cosinus */
  23169. ArcCos = 12,
  23170. /** Arc sinus */
  23171. ArcSin = 13,
  23172. /** Fraction */
  23173. Fract = 14,
  23174. /** Sign */
  23175. Sign = 15,
  23176. /** To radians (from degrees) */
  23177. Radians = 16,
  23178. /** To degrees (from radians) */
  23179. Degrees = 17
  23180. }
  23181. /**
  23182. * Block used to apply trigonometry operation to floats
  23183. */
  23184. export class TrigonometryBlock extends NodeMaterialBlock {
  23185. /**
  23186. * Gets or sets the operation applied by the block
  23187. */
  23188. operation: TrigonometryBlockOperations;
  23189. /**
  23190. * Creates a new TrigonometryBlock
  23191. * @param name defines the block name
  23192. */
  23193. constructor(name: string);
  23194. /**
  23195. * Gets the current class name
  23196. * @returns the class name
  23197. */
  23198. getClassName(): string;
  23199. /**
  23200. * Gets the input component
  23201. */
  23202. get input(): NodeMaterialConnectionPoint;
  23203. /**
  23204. * Gets the output component
  23205. */
  23206. get output(): NodeMaterialConnectionPoint;
  23207. protected _buildBlock(state: NodeMaterialBuildState): this;
  23208. serialize(): any;
  23209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23210. protected _dumpPropertiesCode(): string;
  23211. }
  23212. }
  23213. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23215. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23216. import { Scene } from "babylonjs/scene";
  23217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23218. import { Matrix } from "babylonjs/Maths/math.vector";
  23219. import { Mesh } from "babylonjs/Meshes/mesh";
  23220. import { Engine } from "babylonjs/Engines/engine";
  23221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23222. import { Observable } from "babylonjs/Misc/observable";
  23223. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23224. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23225. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23226. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23227. import { Nullable } from "babylonjs/types";
  23228. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23229. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23230. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23231. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23232. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23233. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23234. import { Effect } from "babylonjs/Materials/effect";
  23235. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23236. import { Camera } from "babylonjs/Cameras/camera";
  23237. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23238. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23239. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23240. /**
  23241. * Interface used to configure the node material editor
  23242. */
  23243. export interface INodeMaterialEditorOptions {
  23244. /** Define the URl to load node editor script */
  23245. editorURL?: string;
  23246. }
  23247. /** @hidden */
  23248. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23249. NORMAL: boolean;
  23250. TANGENT: boolean;
  23251. UV1: boolean;
  23252. /** BONES */
  23253. NUM_BONE_INFLUENCERS: number;
  23254. BonesPerMesh: number;
  23255. BONETEXTURE: boolean;
  23256. /** MORPH TARGETS */
  23257. MORPHTARGETS: boolean;
  23258. MORPHTARGETS_NORMAL: boolean;
  23259. MORPHTARGETS_TANGENT: boolean;
  23260. MORPHTARGETS_UV: boolean;
  23261. NUM_MORPH_INFLUENCERS: number;
  23262. /** IMAGE PROCESSING */
  23263. IMAGEPROCESSING: boolean;
  23264. VIGNETTE: boolean;
  23265. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23266. VIGNETTEBLENDMODEOPAQUE: boolean;
  23267. TONEMAPPING: boolean;
  23268. TONEMAPPING_ACES: boolean;
  23269. CONTRAST: boolean;
  23270. EXPOSURE: boolean;
  23271. COLORCURVES: boolean;
  23272. COLORGRADING: boolean;
  23273. COLORGRADING3D: boolean;
  23274. SAMPLER3DGREENDEPTH: boolean;
  23275. SAMPLER3DBGRMAP: boolean;
  23276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23277. /** MISC. */
  23278. BUMPDIRECTUV: number;
  23279. constructor();
  23280. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23281. }
  23282. /**
  23283. * Class used to configure NodeMaterial
  23284. */
  23285. export interface INodeMaterialOptions {
  23286. /**
  23287. * Defines if blocks should emit comments
  23288. */
  23289. emitComments: boolean;
  23290. }
  23291. /**
  23292. * Class used to create a node based material built by assembling shader blocks
  23293. */
  23294. export class NodeMaterial extends PushMaterial {
  23295. private static _BuildIdGenerator;
  23296. private _options;
  23297. private _vertexCompilationState;
  23298. private _fragmentCompilationState;
  23299. private _sharedData;
  23300. private _buildId;
  23301. private _buildWasSuccessful;
  23302. private _cachedWorldViewMatrix;
  23303. private _cachedWorldViewProjectionMatrix;
  23304. private _optimizers;
  23305. private _animationFrame;
  23306. /** Define the Url to load node editor script */
  23307. static EditorURL: string;
  23308. /** Define the Url to load snippets */
  23309. static SnippetUrl: string;
  23310. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23311. static IgnoreTexturesAtLoadTime: boolean;
  23312. private BJSNODEMATERIALEDITOR;
  23313. /** Get the inspector from bundle or global */
  23314. private _getGlobalNodeMaterialEditor;
  23315. /**
  23316. * Snippet ID if the material was created from the snippet server
  23317. */
  23318. snippetId: string;
  23319. /**
  23320. * Gets or sets data used by visual editor
  23321. * @see https://nme.babylonjs.com
  23322. */
  23323. editorData: any;
  23324. /**
  23325. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  23326. */
  23327. ignoreAlpha: boolean;
  23328. /**
  23329. * Defines the maximum number of lights that can be used in the material
  23330. */
  23331. maxSimultaneousLights: number;
  23332. /**
  23333. * Observable raised when the material is built
  23334. */
  23335. onBuildObservable: Observable<NodeMaterial>;
  23336. /**
  23337. * Gets or sets the root nodes of the material vertex shader
  23338. */
  23339. _vertexOutputNodes: NodeMaterialBlock[];
  23340. /**
  23341. * Gets or sets the root nodes of the material fragment (pixel) shader
  23342. */
  23343. _fragmentOutputNodes: NodeMaterialBlock[];
  23344. /** Gets or sets options to control the node material overall behavior */
  23345. get options(): INodeMaterialOptions;
  23346. set options(options: INodeMaterialOptions);
  23347. /**
  23348. * Default configuration related to image processing available in the standard Material.
  23349. */
  23350. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23351. /**
  23352. * Gets the image processing configuration used either in this material.
  23353. */
  23354. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23355. /**
  23356. * Sets the Default image processing configuration used either in the this material.
  23357. *
  23358. * If sets to null, the scene one is in use.
  23359. */
  23360. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23361. /**
  23362. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23363. */
  23364. attachedBlocks: NodeMaterialBlock[];
  23365. /**
  23366. * Specifies the mode of the node material
  23367. * @hidden
  23368. */
  23369. _mode: NodeMaterialModes;
  23370. /**
  23371. * Gets the mode property
  23372. */
  23373. get mode(): NodeMaterialModes;
  23374. /**
  23375. * Create a new node based material
  23376. * @param name defines the material name
  23377. * @param scene defines the hosting scene
  23378. * @param options defines creation option
  23379. */
  23380. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23381. /**
  23382. * Gets the current class name of the material e.g. "NodeMaterial"
  23383. * @returns the class name
  23384. */
  23385. getClassName(): string;
  23386. /**
  23387. * Keep track of the image processing observer to allow dispose and replace.
  23388. */
  23389. private _imageProcessingObserver;
  23390. /**
  23391. * Attaches a new image processing configuration to the Standard Material.
  23392. * @param configuration
  23393. */
  23394. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23395. /**
  23396. * Get a block by its name
  23397. * @param name defines the name of the block to retrieve
  23398. * @returns the required block or null if not found
  23399. */
  23400. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23401. /**
  23402. * Get a block by its name
  23403. * @param predicate defines the predicate used to find the good candidate
  23404. * @returns the required block or null if not found
  23405. */
  23406. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23407. /**
  23408. * Get an input block by its name
  23409. * @param predicate defines the predicate used to find the good candidate
  23410. * @returns the required input block or null if not found
  23411. */
  23412. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23413. /**
  23414. * Gets the list of input blocks attached to this material
  23415. * @returns an array of InputBlocks
  23416. */
  23417. getInputBlocks(): InputBlock[];
  23418. /**
  23419. * Adds a new optimizer to the list of optimizers
  23420. * @param optimizer defines the optimizers to add
  23421. * @returns the current material
  23422. */
  23423. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23424. /**
  23425. * Remove an optimizer from the list of optimizers
  23426. * @param optimizer defines the optimizers to remove
  23427. * @returns the current material
  23428. */
  23429. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23430. /**
  23431. * Add a new block to the list of output nodes
  23432. * @param node defines the node to add
  23433. * @returns the current material
  23434. */
  23435. addOutputNode(node: NodeMaterialBlock): this;
  23436. /**
  23437. * Remove a block from the list of root nodes
  23438. * @param node defines the node to remove
  23439. * @returns the current material
  23440. */
  23441. removeOutputNode(node: NodeMaterialBlock): this;
  23442. private _addVertexOutputNode;
  23443. private _removeVertexOutputNode;
  23444. private _addFragmentOutputNode;
  23445. private _removeFragmentOutputNode;
  23446. /**
  23447. * Specifies if the material will require alpha blending
  23448. * @returns a boolean specifying if alpha blending is needed
  23449. */
  23450. needAlphaBlending(): boolean;
  23451. /**
  23452. * Specifies if this material should be rendered in alpha test mode
  23453. * @returns a boolean specifying if an alpha test is needed.
  23454. */
  23455. needAlphaTesting(): boolean;
  23456. private _initializeBlock;
  23457. private _resetDualBlocks;
  23458. /**
  23459. * Remove a block from the current node material
  23460. * @param block defines the block to remove
  23461. */
  23462. removeBlock(block: NodeMaterialBlock): void;
  23463. /**
  23464. * Build the material and generates the inner effect
  23465. * @param verbose defines if the build should log activity
  23466. */
  23467. build(verbose?: boolean): void;
  23468. /**
  23469. * Runs an otpimization phase to try to improve the shader code
  23470. */
  23471. optimize(): void;
  23472. private _prepareDefinesForAttributes;
  23473. /**
  23474. * Create a post process from the material
  23475. * @param camera The camera to apply the render pass to.
  23476. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23478. * @param engine The engine which the post process will be applied. (default: current engine)
  23479. * @param reusable If the post process can be reused on the same frame. (default: false)
  23480. * @param textureType Type of textures used when performing the post process. (default: 0)
  23481. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23482. * @returns the post process created
  23483. */
  23484. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23485. /**
  23486. * Create the post process effect from the material
  23487. * @param postProcess The post process to create the effect for
  23488. */
  23489. createEffectForPostProcess(postProcess: PostProcess): void;
  23490. private _createEffectForPostProcess;
  23491. /**
  23492. * Create a new procedural texture based on this node material
  23493. * @param size defines the size of the texture
  23494. * @param scene defines the hosting scene
  23495. * @returns the new procedural texture attached to this node material
  23496. */
  23497. createProceduralTexture(size: number | {
  23498. width: number;
  23499. height: number;
  23500. layers?: number;
  23501. }, scene: Scene): Nullable<ProceduralTexture>;
  23502. private _createEffectForParticles;
  23503. private _checkInternals;
  23504. /**
  23505. * Create the effect to be used as the custom effect for a particle system
  23506. * @param particleSystem Particle system to create the effect for
  23507. * @param onCompiled defines a function to call when the effect creation is successful
  23508. * @param onError defines a function to call when the effect creation has failed
  23509. */
  23510. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23511. private _processDefines;
  23512. /**
  23513. * Get if the submesh is ready to be used and all its information available.
  23514. * Child classes can use it to update shaders
  23515. * @param mesh defines the mesh to check
  23516. * @param subMesh defines which submesh to check
  23517. * @param useInstances specifies that instances should be used
  23518. * @returns a boolean indicating that the submesh is ready or not
  23519. */
  23520. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23521. /**
  23522. * Get a string representing the shaders built by the current node graph
  23523. */
  23524. get compiledShaders(): string;
  23525. /**
  23526. * Binds the world matrix to the material
  23527. * @param world defines the world transformation matrix
  23528. */
  23529. bindOnlyWorldMatrix(world: Matrix): void;
  23530. /**
  23531. * Binds the submesh to this material by preparing the effect and shader to draw
  23532. * @param world defines the world transformation matrix
  23533. * @param mesh defines the mesh containing the submesh
  23534. * @param subMesh defines the submesh to bind the material to
  23535. */
  23536. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23537. /**
  23538. * Gets the active textures from the material
  23539. * @returns an array of textures
  23540. */
  23541. getActiveTextures(): BaseTexture[];
  23542. /**
  23543. * Gets the list of texture blocks
  23544. * @returns an array of texture blocks
  23545. */
  23546. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23547. /**
  23548. * Specifies if the material uses a texture
  23549. * @param texture defines the texture to check against the material
  23550. * @returns a boolean specifying if the material uses the texture
  23551. */
  23552. hasTexture(texture: BaseTexture): boolean;
  23553. /**
  23554. * Disposes the material
  23555. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23556. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23557. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23558. */
  23559. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23560. /** Creates the node editor window. */
  23561. private _createNodeEditor;
  23562. /**
  23563. * Launch the node material editor
  23564. * @param config Define the configuration of the editor
  23565. * @return a promise fulfilled when the node editor is visible
  23566. */
  23567. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23568. /**
  23569. * Clear the current material
  23570. */
  23571. clear(): void;
  23572. /**
  23573. * Clear the current material and set it to a default state
  23574. */
  23575. setToDefault(): void;
  23576. /**
  23577. * Clear the current material and set it to a default state for post process
  23578. */
  23579. setToDefaultPostProcess(): void;
  23580. /**
  23581. * Clear the current material and set it to a default state for procedural texture
  23582. */
  23583. setToDefaultProceduralTexture(): void;
  23584. /**
  23585. * Clear the current material and set it to a default state for particle
  23586. */
  23587. setToDefaultParticle(): void;
  23588. /**
  23589. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23590. * @param url defines the url to load from
  23591. * @returns a promise that will fullfil when the material is fully loaded
  23592. */
  23593. loadAsync(url: string): Promise<void>;
  23594. private _gatherBlocks;
  23595. /**
  23596. * Generate a string containing the code declaration required to create an equivalent of this material
  23597. * @returns a string
  23598. */
  23599. generateCode(): string;
  23600. /**
  23601. * Serializes this material in a JSON representation
  23602. * @returns the serialized material object
  23603. */
  23604. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23605. private _restoreConnections;
  23606. /**
  23607. * Clear the current graph and load a new one from a serialization object
  23608. * @param source defines the JSON representation of the material
  23609. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23610. * @param merge defines whether or not the source must be merged or replace the current content
  23611. */
  23612. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23613. /**
  23614. * Makes a duplicate of the current material.
  23615. * @param name - name to use for the new material.
  23616. */
  23617. clone(name: string): NodeMaterial;
  23618. /**
  23619. * Creates a node material from parsed material data
  23620. * @param source defines the JSON representation of the material
  23621. * @param scene defines the hosting scene
  23622. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23623. * @returns a new node material
  23624. */
  23625. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23626. /**
  23627. * Creates a node material from a snippet saved in a remote file
  23628. * @param name defines the name of the material to create
  23629. * @param url defines the url to load from
  23630. * @param scene defines the hosting scene
  23631. * @returns a promise that will resolve to the new node material
  23632. */
  23633. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23634. /**
  23635. * Creates a node material from a snippet saved by the node material editor
  23636. * @param snippetId defines the snippet to load
  23637. * @param scene defines the hosting scene
  23638. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23639. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23640. * @returns a promise that will resolve to the new node material
  23641. */
  23642. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23643. /**
  23644. * Creates a new node material set to default basic configuration
  23645. * @param name defines the name of the material
  23646. * @param scene defines the hosting scene
  23647. * @returns a new NodeMaterial
  23648. */
  23649. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23650. }
  23651. }
  23652. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23653. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23654. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23655. import { Nullable } from "babylonjs/types";
  23656. module "babylonjs/Engines/thinEngine" {
  23657. interface ThinEngine {
  23658. /**
  23659. * Unbind a list of render target textures from the webGL context
  23660. * This is used only when drawBuffer extension or webGL2 are active
  23661. * @param textures defines the render target textures to unbind
  23662. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23663. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23664. */
  23665. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23666. /**
  23667. * Create a multi render target texture
  23668. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23669. * @param size defines the size of the texture
  23670. * @param options defines the creation options
  23671. * @returns the cube texture as an InternalTexture
  23672. */
  23673. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23674. /**
  23675. * Update the sample count for a given multiple render target texture
  23676. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23677. * @param textures defines the textures to update
  23678. * @param samples defines the sample count to set
  23679. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23680. */
  23681. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23682. /**
  23683. * Select a subsets of attachments to draw to.
  23684. * @param attachments gl attachments
  23685. */
  23686. bindAttachments(attachments: number[]): void;
  23687. /**
  23688. * Creates a layout object to draw/clear on specific textures in a MRT
  23689. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23690. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23691. */
  23692. buildTextureLayout(textureStatus: boolean[]): number[];
  23693. /**
  23694. * Restores the webgl state to only draw on the main color attachment
  23695. */
  23696. restoreSingleAttachment(): void;
  23697. }
  23698. }
  23699. }
  23700. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23701. import { Scene } from "babylonjs/scene";
  23702. import { Engine } from "babylonjs/Engines/engine";
  23703. import { Texture } from "babylonjs/Materials/Textures/texture";
  23704. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23705. import "babylonjs/Engines/Extensions/engine.multiRender";
  23706. /**
  23707. * Creation options of the multi render target texture.
  23708. */
  23709. export interface IMultiRenderTargetOptions {
  23710. /**
  23711. * Define if the texture needs to create mip maps after render.
  23712. */
  23713. generateMipMaps?: boolean;
  23714. /**
  23715. * Define the types of all the draw buffers we want to create
  23716. */
  23717. types?: number[];
  23718. /**
  23719. * Define the sampling modes of all the draw buffers we want to create
  23720. */
  23721. samplingModes?: number[];
  23722. /**
  23723. * Define if a depth buffer is required
  23724. */
  23725. generateDepthBuffer?: boolean;
  23726. /**
  23727. * Define if a stencil buffer is required
  23728. */
  23729. generateStencilBuffer?: boolean;
  23730. /**
  23731. * Define if a depth texture is required instead of a depth buffer
  23732. */
  23733. generateDepthTexture?: boolean;
  23734. /**
  23735. * Define the number of desired draw buffers
  23736. */
  23737. textureCount?: number;
  23738. /**
  23739. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23740. */
  23741. doNotChangeAspectRatio?: boolean;
  23742. /**
  23743. * Define the default type of the buffers we are creating
  23744. */
  23745. defaultType?: number;
  23746. }
  23747. /**
  23748. * A multi render target, like a render target provides the ability to render to a texture.
  23749. * Unlike the render target, it can render to several draw buffers in one draw.
  23750. * This is specially interesting in deferred rendering or for any effects requiring more than
  23751. * just one color from a single pass.
  23752. */
  23753. export class MultiRenderTarget extends RenderTargetTexture {
  23754. private _internalTextures;
  23755. private _textures;
  23756. private _multiRenderTargetOptions;
  23757. private _count;
  23758. /**
  23759. * Get if draw buffers are currently supported by the used hardware and browser.
  23760. */
  23761. get isSupported(): boolean;
  23762. /**
  23763. * Get the list of textures generated by the multi render target.
  23764. */
  23765. get textures(): Texture[];
  23766. /**
  23767. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23768. */
  23769. get count(): number;
  23770. /**
  23771. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23772. */
  23773. get depthTexture(): Texture;
  23774. /**
  23775. * Set the wrapping mode on U of all the textures we are rendering to.
  23776. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23777. */
  23778. set wrapU(wrap: number);
  23779. /**
  23780. * Set the wrapping mode on V of all the textures we are rendering to.
  23781. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23782. */
  23783. set wrapV(wrap: number);
  23784. /**
  23785. * Instantiate a new multi render target texture.
  23786. * A multi render target, like a render target provides the ability to render to a texture.
  23787. * Unlike the render target, it can render to several draw buffers in one draw.
  23788. * This is specially interesting in deferred rendering or for any effects requiring more than
  23789. * just one color from a single pass.
  23790. * @param name Define the name of the texture
  23791. * @param size Define the size of the buffers to render to
  23792. * @param count Define the number of target we are rendering into
  23793. * @param scene Define the scene the texture belongs to
  23794. * @param options Define the options used to create the multi render target
  23795. */
  23796. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23797. private _initTypes;
  23798. /** @hidden */
  23799. _rebuild(forceFullRebuild?: boolean): void;
  23800. private _createInternalTextures;
  23801. private _createTextures;
  23802. /**
  23803. * Replaces a texture within the MRT.
  23804. * @param texture The new texture to insert in the MRT
  23805. * @param index The index of the texture to replace
  23806. */
  23807. replaceTexture(texture: Texture, index: number): void;
  23808. /**
  23809. * Define the number of samples used if MSAA is enabled.
  23810. */
  23811. get samples(): number;
  23812. set samples(value: number);
  23813. /**
  23814. * Resize all the textures in the multi render target.
  23815. * Be careful as it will recreate all the data in the new texture.
  23816. * @param size Define the new size
  23817. */
  23818. resize(size: any): void;
  23819. /**
  23820. * Changes the number of render targets in this MRT
  23821. * Be careful as it will recreate all the data in the new texture.
  23822. * @param count new texture count
  23823. * @param options Specifies texture types and sampling modes for new textures
  23824. */
  23825. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23826. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23827. /**
  23828. * Dispose the render targets and their associated resources
  23829. */
  23830. dispose(): void;
  23831. /**
  23832. * Release all the underlying texture used as draw buffers.
  23833. */
  23834. releaseInternalTextures(): void;
  23835. }
  23836. }
  23837. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  23838. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  23839. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  23840. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  23841. /** @hidden */
  23842. export var imageProcessingPixelShader: {
  23843. name: string;
  23844. shader: string;
  23845. };
  23846. }
  23847. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  23848. import { Nullable } from "babylonjs/types";
  23849. import { Color4 } from "babylonjs/Maths/math.color";
  23850. import { Camera } from "babylonjs/Cameras/camera";
  23851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23852. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23853. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23854. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23855. import { Engine } from "babylonjs/Engines/engine";
  23856. import "babylonjs/Shaders/imageProcessing.fragment";
  23857. import "babylonjs/Shaders/postprocess.vertex";
  23858. /**
  23859. * ImageProcessingPostProcess
  23860. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23861. */
  23862. export class ImageProcessingPostProcess extends PostProcess {
  23863. /**
  23864. * Default configuration related to image processing available in the PBR Material.
  23865. */
  23866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23867. /**
  23868. * Gets the image processing configuration used either in this material.
  23869. */
  23870. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23871. /**
  23872. * Sets the Default image processing configuration used either in the this material.
  23873. *
  23874. * If sets to null, the scene one is in use.
  23875. */
  23876. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23877. /**
  23878. * Keep track of the image processing observer to allow dispose and replace.
  23879. */
  23880. private _imageProcessingObserver;
  23881. /**
  23882. * Attaches a new image processing configuration to the PBR Material.
  23883. * @param configuration
  23884. */
  23885. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23886. /**
  23887. * If the post process is supported.
  23888. */
  23889. get isSupported(): boolean;
  23890. /**
  23891. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23892. */
  23893. get colorCurves(): Nullable<ColorCurves>;
  23894. /**
  23895. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23896. */
  23897. set colorCurves(value: Nullable<ColorCurves>);
  23898. /**
  23899. * Gets wether the color curves effect is enabled.
  23900. */
  23901. get colorCurvesEnabled(): boolean;
  23902. /**
  23903. * Sets wether the color curves effect is enabled.
  23904. */
  23905. set colorCurvesEnabled(value: boolean);
  23906. /**
  23907. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23908. */
  23909. get colorGradingTexture(): Nullable<BaseTexture>;
  23910. /**
  23911. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23912. */
  23913. set colorGradingTexture(value: Nullable<BaseTexture>);
  23914. /**
  23915. * Gets wether the color grading effect is enabled.
  23916. */
  23917. get colorGradingEnabled(): boolean;
  23918. /**
  23919. * Gets wether the color grading effect is enabled.
  23920. */
  23921. set colorGradingEnabled(value: boolean);
  23922. /**
  23923. * Gets exposure used in the effect.
  23924. */
  23925. get exposure(): number;
  23926. /**
  23927. * Sets exposure used in the effect.
  23928. */
  23929. set exposure(value: number);
  23930. /**
  23931. * Gets wether tonemapping is enabled or not.
  23932. */
  23933. get toneMappingEnabled(): boolean;
  23934. /**
  23935. * Sets wether tonemapping is enabled or not
  23936. */
  23937. set toneMappingEnabled(value: boolean);
  23938. /**
  23939. * Gets the type of tone mapping effect.
  23940. */
  23941. get toneMappingType(): number;
  23942. /**
  23943. * Sets the type of tone mapping effect.
  23944. */
  23945. set toneMappingType(value: number);
  23946. /**
  23947. * Gets contrast used in the effect.
  23948. */
  23949. get contrast(): number;
  23950. /**
  23951. * Sets contrast used in the effect.
  23952. */
  23953. set contrast(value: number);
  23954. /**
  23955. * Gets Vignette stretch size.
  23956. */
  23957. get vignetteStretch(): number;
  23958. /**
  23959. * Sets Vignette stretch size.
  23960. */
  23961. set vignetteStretch(value: number);
  23962. /**
  23963. * Gets Vignette centre X Offset.
  23964. */
  23965. get vignetteCentreX(): number;
  23966. /**
  23967. * Sets Vignette centre X Offset.
  23968. */
  23969. set vignetteCentreX(value: number);
  23970. /**
  23971. * Gets Vignette centre Y Offset.
  23972. */
  23973. get vignetteCentreY(): number;
  23974. /**
  23975. * Sets Vignette centre Y Offset.
  23976. */
  23977. set vignetteCentreY(value: number);
  23978. /**
  23979. * Gets Vignette weight or intensity of the vignette effect.
  23980. */
  23981. get vignetteWeight(): number;
  23982. /**
  23983. * Sets Vignette weight or intensity of the vignette effect.
  23984. */
  23985. set vignetteWeight(value: number);
  23986. /**
  23987. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23988. * if vignetteEnabled is set to true.
  23989. */
  23990. get vignetteColor(): Color4;
  23991. /**
  23992. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23993. * if vignetteEnabled is set to true.
  23994. */
  23995. set vignetteColor(value: Color4);
  23996. /**
  23997. * Gets Camera field of view used by the Vignette effect.
  23998. */
  23999. get vignetteCameraFov(): number;
  24000. /**
  24001. * Sets Camera field of view used by the Vignette effect.
  24002. */
  24003. set vignetteCameraFov(value: number);
  24004. /**
  24005. * Gets the vignette blend mode allowing different kind of effect.
  24006. */
  24007. get vignetteBlendMode(): number;
  24008. /**
  24009. * Sets the vignette blend mode allowing different kind of effect.
  24010. */
  24011. set vignetteBlendMode(value: number);
  24012. /**
  24013. * Gets wether the vignette effect is enabled.
  24014. */
  24015. get vignetteEnabled(): boolean;
  24016. /**
  24017. * Sets wether the vignette effect is enabled.
  24018. */
  24019. set vignetteEnabled(value: boolean);
  24020. private _fromLinearSpace;
  24021. /**
  24022. * Gets wether the input of the processing is in Gamma or Linear Space.
  24023. */
  24024. get fromLinearSpace(): boolean;
  24025. /**
  24026. * Sets wether the input of the processing is in Gamma or Linear Space.
  24027. */
  24028. set fromLinearSpace(value: boolean);
  24029. /**
  24030. * Defines cache preventing GC.
  24031. */
  24032. private _defines;
  24033. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24034. /**
  24035. * "ImageProcessingPostProcess"
  24036. * @returns "ImageProcessingPostProcess"
  24037. */
  24038. getClassName(): string;
  24039. /**
  24040. * @hidden
  24041. */
  24042. _updateParameters(): void;
  24043. dispose(camera?: Camera): void;
  24044. }
  24045. }
  24046. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24047. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24048. /**
  24049. * Interface for defining prepass effects in the prepass post-process pipeline
  24050. */
  24051. export interface PrePassEffectConfiguration {
  24052. /**
  24053. * Name of the effect
  24054. */
  24055. name: string;
  24056. /**
  24057. * Post process to attach for this effect
  24058. */
  24059. postProcess?: PostProcess;
  24060. /**
  24061. * Textures required in the MRT
  24062. */
  24063. texturesRequired: number[];
  24064. /**
  24065. * Is the effect enabled
  24066. */
  24067. enabled: boolean;
  24068. /**
  24069. * Disposes the effect configuration
  24070. */
  24071. dispose?: () => void;
  24072. /**
  24073. * Creates the associated post process
  24074. */
  24075. createPostProcess?: () => PostProcess;
  24076. }
  24077. }
  24078. declare module "babylonjs/Materials/fresnelParameters" {
  24079. import { DeepImmutable } from "babylonjs/types";
  24080. import { Color3 } from "babylonjs/Maths/math.color";
  24081. /**
  24082. * Options to be used when creating a FresnelParameters.
  24083. */
  24084. export type IFresnelParametersCreationOptions = {
  24085. /**
  24086. * Define the color used on edges (grazing angle)
  24087. */
  24088. leftColor?: Color3;
  24089. /**
  24090. * Define the color used on center
  24091. */
  24092. rightColor?: Color3;
  24093. /**
  24094. * Define bias applied to computed fresnel term
  24095. */
  24096. bias?: number;
  24097. /**
  24098. * Defined the power exponent applied to fresnel term
  24099. */
  24100. power?: number;
  24101. /**
  24102. * Define if the fresnel effect is enable or not.
  24103. */
  24104. isEnabled?: boolean;
  24105. };
  24106. /**
  24107. * Serialized format for FresnelParameters.
  24108. */
  24109. export type IFresnelParametersSerialized = {
  24110. /**
  24111. * Define the color used on edges (grazing angle) [as an array]
  24112. */
  24113. leftColor: number[];
  24114. /**
  24115. * Define the color used on center [as an array]
  24116. */
  24117. rightColor: number[];
  24118. /**
  24119. * Define bias applied to computed fresnel term
  24120. */
  24121. bias: number;
  24122. /**
  24123. * Defined the power exponent applied to fresnel term
  24124. */
  24125. power?: number;
  24126. /**
  24127. * Define if the fresnel effect is enable or not.
  24128. */
  24129. isEnabled: boolean;
  24130. };
  24131. /**
  24132. * This represents all the required information to add a fresnel effect on a material:
  24133. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24134. */
  24135. export class FresnelParameters {
  24136. private _isEnabled;
  24137. /**
  24138. * Define if the fresnel effect is enable or not.
  24139. */
  24140. get isEnabled(): boolean;
  24141. set isEnabled(value: boolean);
  24142. /**
  24143. * Define the color used on edges (grazing angle)
  24144. */
  24145. leftColor: Color3;
  24146. /**
  24147. * Define the color used on center
  24148. */
  24149. rightColor: Color3;
  24150. /**
  24151. * Define bias applied to computed fresnel term
  24152. */
  24153. bias: number;
  24154. /**
  24155. * Defined the power exponent applied to fresnel term
  24156. */
  24157. power: number;
  24158. /**
  24159. * Creates a new FresnelParameters object.
  24160. *
  24161. * @param options provide your own settings to optionally to override defaults
  24162. */
  24163. constructor(options?: IFresnelParametersCreationOptions);
  24164. /**
  24165. * Clones the current fresnel and its valuues
  24166. * @returns a clone fresnel configuration
  24167. */
  24168. clone(): FresnelParameters;
  24169. /**
  24170. * Determines equality between FresnelParameters objects
  24171. * @param otherFresnelParameters defines the second operand
  24172. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24173. */
  24174. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24175. /**
  24176. * Serializes the current fresnel parameters to a JSON representation.
  24177. * @return the JSON serialization
  24178. */
  24179. serialize(): IFresnelParametersSerialized;
  24180. /**
  24181. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24182. * @param parsedFresnelParameters Define the JSON representation
  24183. * @returns the parsed parameters
  24184. */
  24185. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24186. }
  24187. }
  24188. declare module "babylonjs/Materials/materialFlags" {
  24189. /**
  24190. * This groups all the flags used to control the materials channel.
  24191. */
  24192. export class MaterialFlags {
  24193. private static _DiffuseTextureEnabled;
  24194. /**
  24195. * Are diffuse textures enabled in the application.
  24196. */
  24197. static get DiffuseTextureEnabled(): boolean;
  24198. static set DiffuseTextureEnabled(value: boolean);
  24199. private static _DetailTextureEnabled;
  24200. /**
  24201. * Are detail textures enabled in the application.
  24202. */
  24203. static get DetailTextureEnabled(): boolean;
  24204. static set DetailTextureEnabled(value: boolean);
  24205. private static _AmbientTextureEnabled;
  24206. /**
  24207. * Are ambient textures enabled in the application.
  24208. */
  24209. static get AmbientTextureEnabled(): boolean;
  24210. static set AmbientTextureEnabled(value: boolean);
  24211. private static _OpacityTextureEnabled;
  24212. /**
  24213. * Are opacity textures enabled in the application.
  24214. */
  24215. static get OpacityTextureEnabled(): boolean;
  24216. static set OpacityTextureEnabled(value: boolean);
  24217. private static _ReflectionTextureEnabled;
  24218. /**
  24219. * Are reflection textures enabled in the application.
  24220. */
  24221. static get ReflectionTextureEnabled(): boolean;
  24222. static set ReflectionTextureEnabled(value: boolean);
  24223. private static _EmissiveTextureEnabled;
  24224. /**
  24225. * Are emissive textures enabled in the application.
  24226. */
  24227. static get EmissiveTextureEnabled(): boolean;
  24228. static set EmissiveTextureEnabled(value: boolean);
  24229. private static _SpecularTextureEnabled;
  24230. /**
  24231. * Are specular textures enabled in the application.
  24232. */
  24233. static get SpecularTextureEnabled(): boolean;
  24234. static set SpecularTextureEnabled(value: boolean);
  24235. private static _BumpTextureEnabled;
  24236. /**
  24237. * Are bump textures enabled in the application.
  24238. */
  24239. static get BumpTextureEnabled(): boolean;
  24240. static set BumpTextureEnabled(value: boolean);
  24241. private static _LightmapTextureEnabled;
  24242. /**
  24243. * Are lightmap textures enabled in the application.
  24244. */
  24245. static get LightmapTextureEnabled(): boolean;
  24246. static set LightmapTextureEnabled(value: boolean);
  24247. private static _RefractionTextureEnabled;
  24248. /**
  24249. * Are refraction textures enabled in the application.
  24250. */
  24251. static get RefractionTextureEnabled(): boolean;
  24252. static set RefractionTextureEnabled(value: boolean);
  24253. private static _ColorGradingTextureEnabled;
  24254. /**
  24255. * Are color grading textures enabled in the application.
  24256. */
  24257. static get ColorGradingTextureEnabled(): boolean;
  24258. static set ColorGradingTextureEnabled(value: boolean);
  24259. private static _FresnelEnabled;
  24260. /**
  24261. * Are fresnels enabled in the application.
  24262. */
  24263. static get FresnelEnabled(): boolean;
  24264. static set FresnelEnabled(value: boolean);
  24265. private static _ClearCoatTextureEnabled;
  24266. /**
  24267. * Are clear coat textures enabled in the application.
  24268. */
  24269. static get ClearCoatTextureEnabled(): boolean;
  24270. static set ClearCoatTextureEnabled(value: boolean);
  24271. private static _ClearCoatBumpTextureEnabled;
  24272. /**
  24273. * Are clear coat bump textures enabled in the application.
  24274. */
  24275. static get ClearCoatBumpTextureEnabled(): boolean;
  24276. static set ClearCoatBumpTextureEnabled(value: boolean);
  24277. private static _ClearCoatTintTextureEnabled;
  24278. /**
  24279. * Are clear coat tint textures enabled in the application.
  24280. */
  24281. static get ClearCoatTintTextureEnabled(): boolean;
  24282. static set ClearCoatTintTextureEnabled(value: boolean);
  24283. private static _SheenTextureEnabled;
  24284. /**
  24285. * Are sheen textures enabled in the application.
  24286. */
  24287. static get SheenTextureEnabled(): boolean;
  24288. static set SheenTextureEnabled(value: boolean);
  24289. private static _AnisotropicTextureEnabled;
  24290. /**
  24291. * Are anisotropic textures enabled in the application.
  24292. */
  24293. static get AnisotropicTextureEnabled(): boolean;
  24294. static set AnisotropicTextureEnabled(value: boolean);
  24295. private static _ThicknessTextureEnabled;
  24296. /**
  24297. * Are thickness textures enabled in the application.
  24298. */
  24299. static get ThicknessTextureEnabled(): boolean;
  24300. static set ThicknessTextureEnabled(value: boolean);
  24301. }
  24302. }
  24303. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24304. /** @hidden */
  24305. export var defaultFragmentDeclaration: {
  24306. name: string;
  24307. shader: string;
  24308. };
  24309. }
  24310. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24311. /** @hidden */
  24312. export var defaultUboDeclaration: {
  24313. name: string;
  24314. shader: string;
  24315. };
  24316. }
  24317. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24318. /** @hidden */
  24319. export var prePassDeclaration: {
  24320. name: string;
  24321. shader: string;
  24322. };
  24323. }
  24324. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24325. /** @hidden */
  24326. export var lightFragmentDeclaration: {
  24327. name: string;
  24328. shader: string;
  24329. };
  24330. }
  24331. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24332. /** @hidden */
  24333. export var lightUboDeclaration: {
  24334. name: string;
  24335. shader: string;
  24336. };
  24337. }
  24338. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24339. /** @hidden */
  24340. export var lightsFragmentFunctions: {
  24341. name: string;
  24342. shader: string;
  24343. };
  24344. }
  24345. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24346. /** @hidden */
  24347. export var shadowsFragmentFunctions: {
  24348. name: string;
  24349. shader: string;
  24350. };
  24351. }
  24352. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24353. /** @hidden */
  24354. export var fresnelFunction: {
  24355. name: string;
  24356. shader: string;
  24357. };
  24358. }
  24359. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24360. /** @hidden */
  24361. export var bumpFragmentMainFunctions: {
  24362. name: string;
  24363. shader: string;
  24364. };
  24365. }
  24366. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24367. /** @hidden */
  24368. export var bumpFragmentFunctions: {
  24369. name: string;
  24370. shader: string;
  24371. };
  24372. }
  24373. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24374. /** @hidden */
  24375. export var logDepthDeclaration: {
  24376. name: string;
  24377. shader: string;
  24378. };
  24379. }
  24380. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24381. /** @hidden */
  24382. export var bumpFragment: {
  24383. name: string;
  24384. shader: string;
  24385. };
  24386. }
  24387. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24388. /** @hidden */
  24389. export var depthPrePass: {
  24390. name: string;
  24391. shader: string;
  24392. };
  24393. }
  24394. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24395. /** @hidden */
  24396. export var lightFragment: {
  24397. name: string;
  24398. shader: string;
  24399. };
  24400. }
  24401. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24402. /** @hidden */
  24403. export var logDepthFragment: {
  24404. name: string;
  24405. shader: string;
  24406. };
  24407. }
  24408. declare module "babylonjs/Shaders/default.fragment" {
  24409. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24410. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24411. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24412. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24413. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24414. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24415. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24416. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24417. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24418. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24419. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24420. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24421. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24422. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24423. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24424. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24425. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24426. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24427. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24428. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24429. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24430. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24431. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24432. /** @hidden */
  24433. export var defaultPixelShader: {
  24434. name: string;
  24435. shader: string;
  24436. };
  24437. }
  24438. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24439. /** @hidden */
  24440. export var defaultVertexDeclaration: {
  24441. name: string;
  24442. shader: string;
  24443. };
  24444. }
  24445. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24446. /** @hidden */
  24447. export var prePassVertexDeclaration: {
  24448. name: string;
  24449. shader: string;
  24450. };
  24451. }
  24452. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24453. /** @hidden */
  24454. export var bumpVertexDeclaration: {
  24455. name: string;
  24456. shader: string;
  24457. };
  24458. }
  24459. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24460. /** @hidden */
  24461. export var prePassVertex: {
  24462. name: string;
  24463. shader: string;
  24464. };
  24465. }
  24466. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24467. /** @hidden */
  24468. export var bumpVertex: {
  24469. name: string;
  24470. shader: string;
  24471. };
  24472. }
  24473. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24474. /** @hidden */
  24475. export var fogVertex: {
  24476. name: string;
  24477. shader: string;
  24478. };
  24479. }
  24480. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24481. /** @hidden */
  24482. export var shadowsVertex: {
  24483. name: string;
  24484. shader: string;
  24485. };
  24486. }
  24487. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24488. /** @hidden */
  24489. export var pointCloudVertex: {
  24490. name: string;
  24491. shader: string;
  24492. };
  24493. }
  24494. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24495. /** @hidden */
  24496. export var logDepthVertex: {
  24497. name: string;
  24498. shader: string;
  24499. };
  24500. }
  24501. declare module "babylonjs/Shaders/default.vertex" {
  24502. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24503. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24504. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24505. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24506. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24507. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24508. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24509. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24510. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24511. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24512. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24514. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24515. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24516. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24517. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24518. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24519. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24520. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24521. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24522. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24523. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24524. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24525. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24526. /** @hidden */
  24527. export var defaultVertexShader: {
  24528. name: string;
  24529. shader: string;
  24530. };
  24531. }
  24532. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24533. import { Nullable } from "babylonjs/types";
  24534. import { Scene } from "babylonjs/scene";
  24535. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24536. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24537. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24538. /**
  24539. * @hidden
  24540. */
  24541. export interface IMaterialDetailMapDefines {
  24542. DETAIL: boolean;
  24543. DETAILDIRECTUV: number;
  24544. DETAIL_NORMALBLENDMETHOD: number;
  24545. /** @hidden */
  24546. _areTexturesDirty: boolean;
  24547. }
  24548. /**
  24549. * Define the code related to the detail map parameters of a material
  24550. *
  24551. * Inspired from:
  24552. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  24553. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24554. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24555. */
  24556. export class DetailMapConfiguration {
  24557. private _texture;
  24558. /**
  24559. * The detail texture of the material.
  24560. */
  24561. texture: Nullable<BaseTexture>;
  24562. /**
  24563. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24564. * Bigger values mean stronger blending
  24565. */
  24566. diffuseBlendLevel: number;
  24567. /**
  24568. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24569. * Bigger values mean stronger blending. Only used with PBR materials
  24570. */
  24571. roughnessBlendLevel: number;
  24572. /**
  24573. * Defines how strong the bump effect from the detail map is
  24574. * Bigger values mean stronger effect
  24575. */
  24576. bumpLevel: number;
  24577. private _normalBlendMethod;
  24578. /**
  24579. * The method used to blend the bump and detail normals together
  24580. */
  24581. normalBlendMethod: number;
  24582. private _isEnabled;
  24583. /**
  24584. * Enable or disable the detail map on this material
  24585. */
  24586. isEnabled: boolean;
  24587. /** @hidden */
  24588. private _internalMarkAllSubMeshesAsTexturesDirty;
  24589. /** @hidden */
  24590. _markAllSubMeshesAsTexturesDirty(): void;
  24591. /**
  24592. * Instantiate a new detail map
  24593. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24594. */
  24595. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24596. /**
  24597. * Gets whether the submesh is ready to be used or not.
  24598. * @param defines the list of "defines" to update.
  24599. * @param scene defines the scene the material belongs to.
  24600. * @returns - boolean indicating that the submesh is ready or not.
  24601. */
  24602. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24603. /**
  24604. * Update the defines for detail map usage
  24605. * @param defines the list of "defines" to update.
  24606. * @param scene defines the scene the material belongs to.
  24607. */
  24608. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24609. /**
  24610. * Binds the material data.
  24611. * @param uniformBuffer defines the Uniform buffer to fill in.
  24612. * @param scene defines the scene the material belongs to.
  24613. * @param isFrozen defines whether the material is frozen or not.
  24614. */
  24615. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24616. /**
  24617. * Checks to see if a texture is used in the material.
  24618. * @param texture - Base texture to use.
  24619. * @returns - Boolean specifying if a texture is used in the material.
  24620. */
  24621. hasTexture(texture: BaseTexture): boolean;
  24622. /**
  24623. * Returns an array of the actively used textures.
  24624. * @param activeTextures Array of BaseTextures
  24625. */
  24626. getActiveTextures(activeTextures: BaseTexture[]): void;
  24627. /**
  24628. * Returns the animatable textures.
  24629. * @param animatables Array of animatable textures.
  24630. */
  24631. getAnimatables(animatables: IAnimatable[]): void;
  24632. /**
  24633. * Disposes the resources of the material.
  24634. * @param forceDisposeTextures - Forces the disposal of all textures.
  24635. */
  24636. dispose(forceDisposeTextures?: boolean): void;
  24637. /**
  24638. * Get the current class name useful for serialization or dynamic coding.
  24639. * @returns "DetailMap"
  24640. */
  24641. getClassName(): string;
  24642. /**
  24643. * Add the required uniforms to the current list.
  24644. * @param uniforms defines the current uniform list.
  24645. */
  24646. static AddUniforms(uniforms: string[]): void;
  24647. /**
  24648. * Add the required samplers to the current list.
  24649. * @param samplers defines the current sampler list.
  24650. */
  24651. static AddSamplers(samplers: string[]): void;
  24652. /**
  24653. * Add the required uniforms to the current buffer.
  24654. * @param uniformBuffer defines the current uniform buffer.
  24655. */
  24656. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24657. /**
  24658. * Makes a duplicate of the current instance into another one.
  24659. * @param detailMap define the instance where to copy the info
  24660. */
  24661. copyTo(detailMap: DetailMapConfiguration): void;
  24662. /**
  24663. * Serializes this detail map instance
  24664. * @returns - An object with the serialized instance.
  24665. */
  24666. serialize(): any;
  24667. /**
  24668. * Parses a detail map setting from a serialized object.
  24669. * @param source - Serialized object.
  24670. * @param scene Defines the scene we are parsing for
  24671. * @param rootUrl Defines the rootUrl to load from
  24672. */
  24673. parse(source: any, scene: Scene, rootUrl: string): void;
  24674. }
  24675. }
  24676. declare module "babylonjs/Materials/standardMaterial" {
  24677. import { SmartArray } from "babylonjs/Misc/smartArray";
  24678. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24679. import { Nullable } from "babylonjs/types";
  24680. import { Scene } from "babylonjs/scene";
  24681. import { Matrix } from "babylonjs/Maths/math.vector";
  24682. import { Color3 } from "babylonjs/Maths/math.color";
  24683. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24685. import { Mesh } from "babylonjs/Meshes/mesh";
  24686. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24687. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24688. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24689. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24690. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24691. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24692. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24693. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24694. import "babylonjs/Shaders/default.fragment";
  24695. import "babylonjs/Shaders/default.vertex";
  24696. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24697. /** @hidden */
  24698. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24699. MAINUV1: boolean;
  24700. MAINUV2: boolean;
  24701. DIFFUSE: boolean;
  24702. DIFFUSEDIRECTUV: number;
  24703. DETAIL: boolean;
  24704. DETAILDIRECTUV: number;
  24705. DETAIL_NORMALBLENDMETHOD: number;
  24706. AMBIENT: boolean;
  24707. AMBIENTDIRECTUV: number;
  24708. OPACITY: boolean;
  24709. OPACITYDIRECTUV: number;
  24710. OPACITYRGB: boolean;
  24711. REFLECTION: boolean;
  24712. EMISSIVE: boolean;
  24713. EMISSIVEDIRECTUV: number;
  24714. SPECULAR: boolean;
  24715. SPECULARDIRECTUV: number;
  24716. BUMP: boolean;
  24717. BUMPDIRECTUV: number;
  24718. PARALLAX: boolean;
  24719. PARALLAXOCCLUSION: boolean;
  24720. SPECULAROVERALPHA: boolean;
  24721. CLIPPLANE: boolean;
  24722. CLIPPLANE2: boolean;
  24723. CLIPPLANE3: boolean;
  24724. CLIPPLANE4: boolean;
  24725. CLIPPLANE5: boolean;
  24726. CLIPPLANE6: boolean;
  24727. ALPHATEST: boolean;
  24728. DEPTHPREPASS: boolean;
  24729. ALPHAFROMDIFFUSE: boolean;
  24730. POINTSIZE: boolean;
  24731. FOG: boolean;
  24732. SPECULARTERM: boolean;
  24733. DIFFUSEFRESNEL: boolean;
  24734. OPACITYFRESNEL: boolean;
  24735. REFLECTIONFRESNEL: boolean;
  24736. REFRACTIONFRESNEL: boolean;
  24737. EMISSIVEFRESNEL: boolean;
  24738. FRESNEL: boolean;
  24739. NORMAL: boolean;
  24740. UV1: boolean;
  24741. UV2: boolean;
  24742. VERTEXCOLOR: boolean;
  24743. VERTEXALPHA: boolean;
  24744. NUM_BONE_INFLUENCERS: number;
  24745. BonesPerMesh: number;
  24746. BONETEXTURE: boolean;
  24747. BONES_VELOCITY_ENABLED: boolean;
  24748. INSTANCES: boolean;
  24749. THIN_INSTANCES: boolean;
  24750. GLOSSINESS: boolean;
  24751. ROUGHNESS: boolean;
  24752. EMISSIVEASILLUMINATION: boolean;
  24753. LINKEMISSIVEWITHDIFFUSE: boolean;
  24754. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24755. LIGHTMAP: boolean;
  24756. LIGHTMAPDIRECTUV: number;
  24757. OBJECTSPACE_NORMALMAP: boolean;
  24758. USELIGHTMAPASSHADOWMAP: boolean;
  24759. REFLECTIONMAP_3D: boolean;
  24760. REFLECTIONMAP_SPHERICAL: boolean;
  24761. REFLECTIONMAP_PLANAR: boolean;
  24762. REFLECTIONMAP_CUBIC: boolean;
  24763. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24764. REFLECTIONMAP_PROJECTION: boolean;
  24765. REFLECTIONMAP_SKYBOX: boolean;
  24766. REFLECTIONMAP_EXPLICIT: boolean;
  24767. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24768. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24769. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24770. INVERTCUBICMAP: boolean;
  24771. LOGARITHMICDEPTH: boolean;
  24772. REFRACTION: boolean;
  24773. REFRACTIONMAP_3D: boolean;
  24774. REFLECTIONOVERALPHA: boolean;
  24775. TWOSIDEDLIGHTING: boolean;
  24776. SHADOWFLOAT: boolean;
  24777. MORPHTARGETS: boolean;
  24778. MORPHTARGETS_NORMAL: boolean;
  24779. MORPHTARGETS_TANGENT: boolean;
  24780. MORPHTARGETS_UV: boolean;
  24781. NUM_MORPH_INFLUENCERS: number;
  24782. NONUNIFORMSCALING: boolean;
  24783. PREMULTIPLYALPHA: boolean;
  24784. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24785. ALPHABLEND: boolean;
  24786. PREPASS: boolean;
  24787. PREPASS_IRRADIANCE: boolean;
  24788. PREPASS_IRRADIANCE_INDEX: number;
  24789. PREPASS_ALBEDO: boolean;
  24790. PREPASS_ALBEDO_INDEX: number;
  24791. PREPASS_DEPTHNORMAL: boolean;
  24792. PREPASS_DEPTHNORMAL_INDEX: number;
  24793. PREPASS_POSITION: boolean;
  24794. PREPASS_POSITION_INDEX: number;
  24795. PREPASS_VELOCITY: boolean;
  24796. PREPASS_VELOCITY_INDEX: number;
  24797. PREPASS_REFLECTIVITY: boolean;
  24798. PREPASS_REFLECTIVITY_INDEX: number;
  24799. SCENE_MRT_COUNT: number;
  24800. RGBDLIGHTMAP: boolean;
  24801. RGBDREFLECTION: boolean;
  24802. RGBDREFRACTION: boolean;
  24803. IMAGEPROCESSING: boolean;
  24804. VIGNETTE: boolean;
  24805. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24806. VIGNETTEBLENDMODEOPAQUE: boolean;
  24807. TONEMAPPING: boolean;
  24808. TONEMAPPING_ACES: boolean;
  24809. CONTRAST: boolean;
  24810. COLORCURVES: boolean;
  24811. COLORGRADING: boolean;
  24812. COLORGRADING3D: boolean;
  24813. SAMPLER3DGREENDEPTH: boolean;
  24814. SAMPLER3DBGRMAP: boolean;
  24815. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24816. MULTIVIEW: boolean;
  24817. /**
  24818. * If the reflection texture on this material is in linear color space
  24819. * @hidden
  24820. */
  24821. IS_REFLECTION_LINEAR: boolean;
  24822. /**
  24823. * If the refraction texture on this material is in linear color space
  24824. * @hidden
  24825. */
  24826. IS_REFRACTION_LINEAR: boolean;
  24827. EXPOSURE: boolean;
  24828. constructor();
  24829. setReflectionMode(modeToEnable: string): void;
  24830. }
  24831. /**
  24832. * This is the default material used in Babylon. It is the best trade off between quality
  24833. * and performances.
  24834. * @see https://doc.babylonjs.com/babylon101/materials
  24835. */
  24836. export class StandardMaterial extends PushMaterial {
  24837. private _diffuseTexture;
  24838. /**
  24839. * The basic texture of the material as viewed under a light.
  24840. */
  24841. diffuseTexture: Nullable<BaseTexture>;
  24842. private _ambientTexture;
  24843. /**
  24844. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24845. */
  24846. ambientTexture: Nullable<BaseTexture>;
  24847. private _opacityTexture;
  24848. /**
  24849. * Define the transparency of the material from a texture.
  24850. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24851. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24852. */
  24853. opacityTexture: Nullable<BaseTexture>;
  24854. private _reflectionTexture;
  24855. /**
  24856. * Define the texture used to display the reflection.
  24857. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24858. */
  24859. reflectionTexture: Nullable<BaseTexture>;
  24860. private _emissiveTexture;
  24861. /**
  24862. * Define texture of the material as if self lit.
  24863. * This will be mixed in the final result even in the absence of light.
  24864. */
  24865. emissiveTexture: Nullable<BaseTexture>;
  24866. private _specularTexture;
  24867. /**
  24868. * Define how the color and intensity of the highlight given by the light in the material.
  24869. */
  24870. specularTexture: Nullable<BaseTexture>;
  24871. private _bumpTexture;
  24872. /**
  24873. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24874. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  24875. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24876. */
  24877. bumpTexture: Nullable<BaseTexture>;
  24878. private _lightmapTexture;
  24879. /**
  24880. * Complex lighting can be computationally expensive to compute at runtime.
  24881. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24882. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24883. */
  24884. lightmapTexture: Nullable<BaseTexture>;
  24885. private _refractionTexture;
  24886. /**
  24887. * Define the texture used to display the refraction.
  24888. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24889. */
  24890. refractionTexture: Nullable<BaseTexture>;
  24891. /**
  24892. * The color of the material lit by the environmental background lighting.
  24893. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24894. */
  24895. ambientColor: Color3;
  24896. /**
  24897. * The basic color of the material as viewed under a light.
  24898. */
  24899. diffuseColor: Color3;
  24900. /**
  24901. * Define how the color and intensity of the highlight given by the light in the material.
  24902. */
  24903. specularColor: Color3;
  24904. /**
  24905. * Define the color of the material as if self lit.
  24906. * This will be mixed in the final result even in the absence of light.
  24907. */
  24908. emissiveColor: Color3;
  24909. /**
  24910. * Defines how sharp are the highlights in the material.
  24911. * The bigger the value the sharper giving a more glossy feeling to the result.
  24912. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24913. */
  24914. specularPower: number;
  24915. private _useAlphaFromDiffuseTexture;
  24916. /**
  24917. * Does the transparency come from the diffuse texture alpha channel.
  24918. */
  24919. useAlphaFromDiffuseTexture: boolean;
  24920. private _useEmissiveAsIllumination;
  24921. /**
  24922. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24923. */
  24924. useEmissiveAsIllumination: boolean;
  24925. private _linkEmissiveWithDiffuse;
  24926. /**
  24927. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24928. * the emissive level when the final color is close to one.
  24929. */
  24930. linkEmissiveWithDiffuse: boolean;
  24931. private _useSpecularOverAlpha;
  24932. /**
  24933. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24934. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24935. */
  24936. useSpecularOverAlpha: boolean;
  24937. private _useReflectionOverAlpha;
  24938. /**
  24939. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24940. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24941. */
  24942. useReflectionOverAlpha: boolean;
  24943. private _disableLighting;
  24944. /**
  24945. * Does lights from the scene impacts this material.
  24946. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24947. */
  24948. disableLighting: boolean;
  24949. private _useObjectSpaceNormalMap;
  24950. /**
  24951. * Allows using an object space normal map (instead of tangent space).
  24952. */
  24953. useObjectSpaceNormalMap: boolean;
  24954. private _useParallax;
  24955. /**
  24956. * Is parallax enabled or not.
  24957. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24958. */
  24959. useParallax: boolean;
  24960. private _useParallaxOcclusion;
  24961. /**
  24962. * Is parallax occlusion enabled or not.
  24963. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24964. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24965. */
  24966. useParallaxOcclusion: boolean;
  24967. /**
  24968. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  24969. */
  24970. parallaxScaleBias: number;
  24971. private _roughness;
  24972. /**
  24973. * Helps to define how blurry the reflections should appears in the material.
  24974. */
  24975. roughness: number;
  24976. /**
  24977. * In case of refraction, define the value of the index of refraction.
  24978. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24979. */
  24980. indexOfRefraction: number;
  24981. /**
  24982. * Invert the refraction texture alongside the y axis.
  24983. * It can be useful with procedural textures or probe for instance.
  24984. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24985. */
  24986. invertRefractionY: boolean;
  24987. /**
  24988. * Defines the alpha limits in alpha test mode.
  24989. */
  24990. alphaCutOff: number;
  24991. private _useLightmapAsShadowmap;
  24992. /**
  24993. * In case of light mapping, define whether the map contains light or shadow informations.
  24994. */
  24995. useLightmapAsShadowmap: boolean;
  24996. private _diffuseFresnelParameters;
  24997. /**
  24998. * Define the diffuse fresnel parameters of the material.
  24999. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25000. */
  25001. diffuseFresnelParameters: FresnelParameters;
  25002. private _opacityFresnelParameters;
  25003. /**
  25004. * Define the opacity fresnel parameters of the material.
  25005. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25006. */
  25007. opacityFresnelParameters: FresnelParameters;
  25008. private _reflectionFresnelParameters;
  25009. /**
  25010. * Define the reflection fresnel parameters of the material.
  25011. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25012. */
  25013. reflectionFresnelParameters: FresnelParameters;
  25014. private _refractionFresnelParameters;
  25015. /**
  25016. * Define the refraction fresnel parameters of the material.
  25017. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25018. */
  25019. refractionFresnelParameters: FresnelParameters;
  25020. private _emissiveFresnelParameters;
  25021. /**
  25022. * Define the emissive fresnel parameters of the material.
  25023. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25024. */
  25025. emissiveFresnelParameters: FresnelParameters;
  25026. private _useReflectionFresnelFromSpecular;
  25027. /**
  25028. * If true automatically deducts the fresnels values from the material specularity.
  25029. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25030. */
  25031. useReflectionFresnelFromSpecular: boolean;
  25032. private _useGlossinessFromSpecularMapAlpha;
  25033. /**
  25034. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25035. */
  25036. useGlossinessFromSpecularMapAlpha: boolean;
  25037. private _maxSimultaneousLights;
  25038. /**
  25039. * Defines the maximum number of lights that can be used in the material
  25040. */
  25041. maxSimultaneousLights: number;
  25042. private _invertNormalMapX;
  25043. /**
  25044. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25045. */
  25046. invertNormalMapX: boolean;
  25047. private _invertNormalMapY;
  25048. /**
  25049. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25050. */
  25051. invertNormalMapY: boolean;
  25052. private _twoSidedLighting;
  25053. /**
  25054. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25055. */
  25056. twoSidedLighting: boolean;
  25057. /**
  25058. * Default configuration related to image processing available in the standard Material.
  25059. */
  25060. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25061. /**
  25062. * Gets the image processing configuration used either in this material.
  25063. */
  25064. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25065. /**
  25066. * Sets the Default image processing configuration used either in the this material.
  25067. *
  25068. * If sets to null, the scene one is in use.
  25069. */
  25070. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25071. /**
  25072. * Keep track of the image processing observer to allow dispose and replace.
  25073. */
  25074. private _imageProcessingObserver;
  25075. /**
  25076. * Attaches a new image processing configuration to the Standard Material.
  25077. * @param configuration
  25078. */
  25079. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25080. /**
  25081. * Defines additionnal PrePass parameters for the material.
  25082. */
  25083. readonly prePassConfiguration: PrePassConfiguration;
  25084. /**
  25085. * Gets wether the color curves effect is enabled.
  25086. */
  25087. get cameraColorCurvesEnabled(): boolean;
  25088. /**
  25089. * Sets wether the color curves effect is enabled.
  25090. */
  25091. set cameraColorCurvesEnabled(value: boolean);
  25092. /**
  25093. * Gets wether the color grading effect is enabled.
  25094. */
  25095. get cameraColorGradingEnabled(): boolean;
  25096. /**
  25097. * Gets wether the color grading effect is enabled.
  25098. */
  25099. set cameraColorGradingEnabled(value: boolean);
  25100. /**
  25101. * Gets wether tonemapping is enabled or not.
  25102. */
  25103. get cameraToneMappingEnabled(): boolean;
  25104. /**
  25105. * Sets wether tonemapping is enabled or not
  25106. */
  25107. set cameraToneMappingEnabled(value: boolean);
  25108. /**
  25109. * The camera exposure used on this material.
  25110. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25111. * This corresponds to a photographic exposure.
  25112. */
  25113. get cameraExposure(): number;
  25114. /**
  25115. * The camera exposure used on this material.
  25116. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25117. * This corresponds to a photographic exposure.
  25118. */
  25119. set cameraExposure(value: number);
  25120. /**
  25121. * Gets The camera contrast used on this material.
  25122. */
  25123. get cameraContrast(): number;
  25124. /**
  25125. * Sets The camera contrast used on this material.
  25126. */
  25127. set cameraContrast(value: number);
  25128. /**
  25129. * Gets the Color Grading 2D Lookup Texture.
  25130. */
  25131. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25132. /**
  25133. * Sets the Color Grading 2D Lookup Texture.
  25134. */
  25135. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25136. /**
  25137. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25138. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25139. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  25140. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25141. */
  25142. get cameraColorCurves(): Nullable<ColorCurves>;
  25143. /**
  25144. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25145. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25146. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  25147. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25148. */
  25149. set cameraColorCurves(value: Nullable<ColorCurves>);
  25150. /**
  25151. * Can this material render to several textures at once
  25152. */
  25153. get canRenderToMRT(): boolean;
  25154. /**
  25155. * Defines the detail map parameters for the material.
  25156. */
  25157. readonly detailMap: DetailMapConfiguration;
  25158. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25159. protected _worldViewProjectionMatrix: Matrix;
  25160. protected _globalAmbientColor: Color3;
  25161. protected _useLogarithmicDepth: boolean;
  25162. protected _rebuildInParallel: boolean;
  25163. /**
  25164. * Instantiates a new standard material.
  25165. * This is the default material used in Babylon. It is the best trade off between quality
  25166. * and performances.
  25167. * @see https://doc.babylonjs.com/babylon101/materials
  25168. * @param name Define the name of the material in the scene
  25169. * @param scene Define the scene the material belong to
  25170. */
  25171. constructor(name: string, scene: Scene);
  25172. /**
  25173. * Gets a boolean indicating that current material needs to register RTT
  25174. */
  25175. get hasRenderTargetTextures(): boolean;
  25176. /**
  25177. * Gets the current class name of the material e.g. "StandardMaterial"
  25178. * Mainly use in serialization.
  25179. * @returns the class name
  25180. */
  25181. getClassName(): string;
  25182. /**
  25183. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25184. * You can try switching to logarithmic depth.
  25185. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25186. */
  25187. get useLogarithmicDepth(): boolean;
  25188. set useLogarithmicDepth(value: boolean);
  25189. /**
  25190. * Specifies if the material will require alpha blending
  25191. * @returns a boolean specifying if alpha blending is needed
  25192. */
  25193. needAlphaBlending(): boolean;
  25194. /**
  25195. * Specifies if this material should be rendered in alpha test mode
  25196. * @returns a boolean specifying if an alpha test is needed.
  25197. */
  25198. needAlphaTesting(): boolean;
  25199. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25200. /**
  25201. * Get the texture used for alpha test purpose.
  25202. * @returns the diffuse texture in case of the standard material.
  25203. */
  25204. getAlphaTestTexture(): Nullable<BaseTexture>;
  25205. /**
  25206. * Get if the submesh is ready to be used and all its information available.
  25207. * Child classes can use it to update shaders
  25208. * @param mesh defines the mesh to check
  25209. * @param subMesh defines which submesh to check
  25210. * @param useInstances specifies that instances should be used
  25211. * @returns a boolean indicating that the submesh is ready or not
  25212. */
  25213. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25214. /**
  25215. * Builds the material UBO layouts.
  25216. * Used internally during the effect preparation.
  25217. */
  25218. buildUniformLayout(): void;
  25219. /**
  25220. * Unbinds the material from the mesh
  25221. */
  25222. unbind(): void;
  25223. /**
  25224. * Binds the submesh to this material by preparing the effect and shader to draw
  25225. * @param world defines the world transformation matrix
  25226. * @param mesh defines the mesh containing the submesh
  25227. * @param subMesh defines the submesh to bind the material to
  25228. */
  25229. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25230. /**
  25231. * Get the list of animatables in the material.
  25232. * @returns the list of animatables object used in the material
  25233. */
  25234. getAnimatables(): IAnimatable[];
  25235. /**
  25236. * Gets the active textures from the material
  25237. * @returns an array of textures
  25238. */
  25239. getActiveTextures(): BaseTexture[];
  25240. /**
  25241. * Specifies if the material uses a texture
  25242. * @param texture defines the texture to check against the material
  25243. * @returns a boolean specifying if the material uses the texture
  25244. */
  25245. hasTexture(texture: BaseTexture): boolean;
  25246. /**
  25247. * Disposes the material
  25248. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25249. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25250. */
  25251. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25252. /**
  25253. * Makes a duplicate of the material, and gives it a new name
  25254. * @param name defines the new name for the duplicated material
  25255. * @returns the cloned material
  25256. */
  25257. clone(name: string): StandardMaterial;
  25258. /**
  25259. * Serializes this material in a JSON representation
  25260. * @returns the serialized material object
  25261. */
  25262. serialize(): any;
  25263. /**
  25264. * Creates a standard material from parsed material data
  25265. * @param source defines the JSON representation of the material
  25266. * @param scene defines the hosting scene
  25267. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25268. * @returns a new standard material
  25269. */
  25270. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25271. /**
  25272. * Are diffuse textures enabled in the application.
  25273. */
  25274. static get DiffuseTextureEnabled(): boolean;
  25275. static set DiffuseTextureEnabled(value: boolean);
  25276. /**
  25277. * Are detail textures enabled in the application.
  25278. */
  25279. static get DetailTextureEnabled(): boolean;
  25280. static set DetailTextureEnabled(value: boolean);
  25281. /**
  25282. * Are ambient textures enabled in the application.
  25283. */
  25284. static get AmbientTextureEnabled(): boolean;
  25285. static set AmbientTextureEnabled(value: boolean);
  25286. /**
  25287. * Are opacity textures enabled in the application.
  25288. */
  25289. static get OpacityTextureEnabled(): boolean;
  25290. static set OpacityTextureEnabled(value: boolean);
  25291. /**
  25292. * Are reflection textures enabled in the application.
  25293. */
  25294. static get ReflectionTextureEnabled(): boolean;
  25295. static set ReflectionTextureEnabled(value: boolean);
  25296. /**
  25297. * Are emissive textures enabled in the application.
  25298. */
  25299. static get EmissiveTextureEnabled(): boolean;
  25300. static set EmissiveTextureEnabled(value: boolean);
  25301. /**
  25302. * Are specular textures enabled in the application.
  25303. */
  25304. static get SpecularTextureEnabled(): boolean;
  25305. static set SpecularTextureEnabled(value: boolean);
  25306. /**
  25307. * Are bump textures enabled in the application.
  25308. */
  25309. static get BumpTextureEnabled(): boolean;
  25310. static set BumpTextureEnabled(value: boolean);
  25311. /**
  25312. * Are lightmap textures enabled in the application.
  25313. */
  25314. static get LightmapTextureEnabled(): boolean;
  25315. static set LightmapTextureEnabled(value: boolean);
  25316. /**
  25317. * Are refraction textures enabled in the application.
  25318. */
  25319. static get RefractionTextureEnabled(): boolean;
  25320. static set RefractionTextureEnabled(value: boolean);
  25321. /**
  25322. * Are color grading textures enabled in the application.
  25323. */
  25324. static get ColorGradingTextureEnabled(): boolean;
  25325. static set ColorGradingTextureEnabled(value: boolean);
  25326. /**
  25327. * Are fresnels enabled in the application.
  25328. */
  25329. static get FresnelEnabled(): boolean;
  25330. static set FresnelEnabled(value: boolean);
  25331. }
  25332. }
  25333. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25334. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25335. /** @hidden */
  25336. export var rgbdDecodePixelShader: {
  25337. name: string;
  25338. shader: string;
  25339. };
  25340. }
  25341. declare module "babylonjs/Misc/rgbdTextureTools" {
  25342. import "babylonjs/Shaders/rgbdDecode.fragment";
  25343. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25344. import { Texture } from "babylonjs/Materials/Textures/texture";
  25345. /**
  25346. * Class used to host RGBD texture specific utilities
  25347. */
  25348. export class RGBDTextureTools {
  25349. /**
  25350. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25351. * @param texture the texture to expand.
  25352. */
  25353. static ExpandRGBDTexture(texture: Texture): void;
  25354. }
  25355. }
  25356. declare module "babylonjs/Misc/brdfTextureTools" {
  25357. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25358. import { Scene } from "babylonjs/scene";
  25359. /**
  25360. * Class used to host texture specific utilities
  25361. */
  25362. export class BRDFTextureTools {
  25363. /**
  25364. * Prevents texture cache collision
  25365. */
  25366. private static _instanceNumber;
  25367. /**
  25368. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25369. * @param scene defines the hosting scene
  25370. * @returns the environment BRDF texture
  25371. */
  25372. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25373. private static _environmentBRDFBase64Texture;
  25374. }
  25375. }
  25376. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25377. import { Nullable } from "babylonjs/types";
  25378. import { Color3 } from "babylonjs/Maths/math.color";
  25379. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25380. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25381. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25382. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25384. import { Engine } from "babylonjs/Engines/engine";
  25385. import { Scene } from "babylonjs/scene";
  25386. /**
  25387. * @hidden
  25388. */
  25389. export interface IMaterialClearCoatDefines {
  25390. CLEARCOAT: boolean;
  25391. CLEARCOAT_DEFAULTIOR: boolean;
  25392. CLEARCOAT_TEXTURE: boolean;
  25393. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  25394. CLEARCOAT_TEXTUREDIRECTUV: number;
  25395. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  25396. CLEARCOAT_BUMP: boolean;
  25397. CLEARCOAT_BUMPDIRECTUV: number;
  25398. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25399. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25400. CLEARCOAT_REMAP_F0: boolean;
  25401. CLEARCOAT_TINT: boolean;
  25402. CLEARCOAT_TINT_TEXTURE: boolean;
  25403. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25404. /** @hidden */
  25405. _areTexturesDirty: boolean;
  25406. }
  25407. /**
  25408. * Define the code related to the clear coat parameters of the pbr material.
  25409. */
  25410. export class PBRClearCoatConfiguration {
  25411. /**
  25412. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25413. * The default fits with a polyurethane material.
  25414. */
  25415. private static readonly _DefaultIndexOfRefraction;
  25416. private _isEnabled;
  25417. /**
  25418. * Defines if the clear coat is enabled in the material.
  25419. */
  25420. isEnabled: boolean;
  25421. /**
  25422. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25423. */
  25424. intensity: number;
  25425. /**
  25426. * Defines the clear coat layer roughness.
  25427. */
  25428. roughness: number;
  25429. private _indexOfRefraction;
  25430. /**
  25431. * Defines the index of refraction of the clear coat.
  25432. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25433. * The default fits with a polyurethane material.
  25434. * Changing the default value is more performance intensive.
  25435. */
  25436. indexOfRefraction: number;
  25437. private _texture;
  25438. /**
  25439. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  25440. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  25441. * if textureRoughness is not empty, else no texture roughness is used
  25442. */
  25443. texture: Nullable<BaseTexture>;
  25444. private _useRoughnessFromMainTexture;
  25445. /**
  25446. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  25447. * If false, the green channel from textureRoughness is used for roughness
  25448. */
  25449. useRoughnessFromMainTexture: boolean;
  25450. private _textureRoughness;
  25451. /**
  25452. * Stores the clear coat roughness in a texture (green channel)
  25453. * Not used if useRoughnessFromMainTexture is true
  25454. */
  25455. textureRoughness: Nullable<BaseTexture>;
  25456. private _remapF0OnInterfaceChange;
  25457. /**
  25458. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25459. */
  25460. remapF0OnInterfaceChange: boolean;
  25461. private _bumpTexture;
  25462. /**
  25463. * Define the clear coat specific bump texture.
  25464. */
  25465. bumpTexture: Nullable<BaseTexture>;
  25466. private _isTintEnabled;
  25467. /**
  25468. * Defines if the clear coat tint is enabled in the material.
  25469. */
  25470. isTintEnabled: boolean;
  25471. /**
  25472. * Defines the clear coat tint of the material.
  25473. * This is only use if tint is enabled
  25474. */
  25475. tintColor: Color3;
  25476. /**
  25477. * Defines the distance at which the tint color should be found in the
  25478. * clear coat media.
  25479. * This is only use if tint is enabled
  25480. */
  25481. tintColorAtDistance: number;
  25482. /**
  25483. * Defines the clear coat layer thickness.
  25484. * This is only use if tint is enabled
  25485. */
  25486. tintThickness: number;
  25487. private _tintTexture;
  25488. /**
  25489. * Stores the clear tint values in a texture.
  25490. * rgb is tint
  25491. * a is a thickness factor
  25492. */
  25493. tintTexture: Nullable<BaseTexture>;
  25494. /** @hidden */
  25495. private _internalMarkAllSubMeshesAsTexturesDirty;
  25496. /** @hidden */
  25497. _markAllSubMeshesAsTexturesDirty(): void;
  25498. /**
  25499. * Instantiate a new istance of clear coat configuration.
  25500. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25501. */
  25502. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25503. /**
  25504. * Gets wehter the submesh is ready to be used or not.
  25505. * @param defines the list of "defines" to update.
  25506. * @param scene defines the scene the material belongs to.
  25507. * @param engine defines the engine the material belongs to.
  25508. * @param disableBumpMap defines wether the material disables bump or not.
  25509. * @returns - boolean indicating that the submesh is ready or not.
  25510. */
  25511. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25512. /**
  25513. * Checks to see if a texture is used in the material.
  25514. * @param defines the list of "defines" to update.
  25515. * @param scene defines the scene to the material belongs to.
  25516. */
  25517. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25518. /**
  25519. * Binds the material data.
  25520. * @param uniformBuffer defines the Uniform buffer to fill in.
  25521. * @param scene defines the scene the material belongs to.
  25522. * @param engine defines the engine the material belongs to.
  25523. * @param disableBumpMap defines wether the material disables bump or not.
  25524. * @param isFrozen defines wether the material is frozen or not.
  25525. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25526. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25527. * @param subMesh the submesh to bind data for
  25528. */
  25529. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  25530. /**
  25531. * Checks to see if a texture is used in the material.
  25532. * @param texture - Base texture to use.
  25533. * @returns - Boolean specifying if a texture is used in the material.
  25534. */
  25535. hasTexture(texture: BaseTexture): boolean;
  25536. /**
  25537. * Returns an array of the actively used textures.
  25538. * @param activeTextures Array of BaseTextures
  25539. */
  25540. getActiveTextures(activeTextures: BaseTexture[]): void;
  25541. /**
  25542. * Returns the animatable textures.
  25543. * @param animatables Array of animatable textures.
  25544. */
  25545. getAnimatables(animatables: IAnimatable[]): void;
  25546. /**
  25547. * Disposes the resources of the material.
  25548. * @param forceDisposeTextures - Forces the disposal of all textures.
  25549. */
  25550. dispose(forceDisposeTextures?: boolean): void;
  25551. /**
  25552. * Get the current class name of the texture useful for serialization or dynamic coding.
  25553. * @returns "PBRClearCoatConfiguration"
  25554. */
  25555. getClassName(): string;
  25556. /**
  25557. * Add fallbacks to the effect fallbacks list.
  25558. * @param defines defines the Base texture to use.
  25559. * @param fallbacks defines the current fallback list.
  25560. * @param currentRank defines the current fallback rank.
  25561. * @returns the new fallback rank.
  25562. */
  25563. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25564. /**
  25565. * Add the required uniforms to the current list.
  25566. * @param uniforms defines the current uniform list.
  25567. */
  25568. static AddUniforms(uniforms: string[]): void;
  25569. /**
  25570. * Add the required samplers to the current list.
  25571. * @param samplers defines the current sampler list.
  25572. */
  25573. static AddSamplers(samplers: string[]): void;
  25574. /**
  25575. * Add the required uniforms to the current buffer.
  25576. * @param uniformBuffer defines the current uniform buffer.
  25577. */
  25578. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25579. /**
  25580. * Makes a duplicate of the current configuration into another one.
  25581. * @param clearCoatConfiguration define the config where to copy the info
  25582. */
  25583. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25584. /**
  25585. * Serializes this clear coat configuration.
  25586. * @returns - An object with the serialized config.
  25587. */
  25588. serialize(): any;
  25589. /**
  25590. * Parses a anisotropy Configuration from a serialized object.
  25591. * @param source - Serialized object.
  25592. * @param scene Defines the scene we are parsing for
  25593. * @param rootUrl Defines the rootUrl to load from
  25594. */
  25595. parse(source: any, scene: Scene, rootUrl: string): void;
  25596. }
  25597. }
  25598. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25599. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25601. import { Vector2 } from "babylonjs/Maths/math.vector";
  25602. import { Scene } from "babylonjs/scene";
  25603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25604. import { Nullable } from "babylonjs/types";
  25605. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25606. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25607. /**
  25608. * @hidden
  25609. */
  25610. export interface IMaterialAnisotropicDefines {
  25611. ANISOTROPIC: boolean;
  25612. ANISOTROPIC_TEXTURE: boolean;
  25613. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25614. MAINUV1: boolean;
  25615. _areTexturesDirty: boolean;
  25616. _needUVs: boolean;
  25617. }
  25618. /**
  25619. * Define the code related to the anisotropic parameters of the pbr material.
  25620. */
  25621. export class PBRAnisotropicConfiguration {
  25622. private _isEnabled;
  25623. /**
  25624. * Defines if the anisotropy is enabled in the material.
  25625. */
  25626. isEnabled: boolean;
  25627. /**
  25628. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25629. */
  25630. intensity: number;
  25631. /**
  25632. * Defines if the effect is along the tangents, bitangents or in between.
  25633. * By default, the effect is "strectching" the highlights along the tangents.
  25634. */
  25635. direction: Vector2;
  25636. private _texture;
  25637. /**
  25638. * Stores the anisotropy values in a texture.
  25639. * rg is direction (like normal from -1 to 1)
  25640. * b is a intensity
  25641. */
  25642. texture: Nullable<BaseTexture>;
  25643. /** @hidden */
  25644. private _internalMarkAllSubMeshesAsTexturesDirty;
  25645. /** @hidden */
  25646. _markAllSubMeshesAsTexturesDirty(): void;
  25647. /**
  25648. * Instantiate a new istance of anisotropy configuration.
  25649. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25650. */
  25651. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25652. /**
  25653. * Specifies that the submesh is ready to be used.
  25654. * @param defines the list of "defines" to update.
  25655. * @param scene defines the scene the material belongs to.
  25656. * @returns - boolean indicating that the submesh is ready or not.
  25657. */
  25658. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25659. /**
  25660. * Checks to see if a texture is used in the material.
  25661. * @param defines the list of "defines" to update.
  25662. * @param mesh the mesh we are preparing the defines for.
  25663. * @param scene defines the scene the material belongs to.
  25664. */
  25665. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25666. /**
  25667. * Binds the material data.
  25668. * @param uniformBuffer defines the Uniform buffer to fill in.
  25669. * @param scene defines the scene the material belongs to.
  25670. * @param isFrozen defines wether the material is frozen or not.
  25671. */
  25672. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25673. /**
  25674. * Checks to see if a texture is used in the material.
  25675. * @param texture - Base texture to use.
  25676. * @returns - Boolean specifying if a texture is used in the material.
  25677. */
  25678. hasTexture(texture: BaseTexture): boolean;
  25679. /**
  25680. * Returns an array of the actively used textures.
  25681. * @param activeTextures Array of BaseTextures
  25682. */
  25683. getActiveTextures(activeTextures: BaseTexture[]): void;
  25684. /**
  25685. * Returns the animatable textures.
  25686. * @param animatables Array of animatable textures.
  25687. */
  25688. getAnimatables(animatables: IAnimatable[]): void;
  25689. /**
  25690. * Disposes the resources of the material.
  25691. * @param forceDisposeTextures - Forces the disposal of all textures.
  25692. */
  25693. dispose(forceDisposeTextures?: boolean): void;
  25694. /**
  25695. * Get the current class name of the texture useful for serialization or dynamic coding.
  25696. * @returns "PBRAnisotropicConfiguration"
  25697. */
  25698. getClassName(): string;
  25699. /**
  25700. * Add fallbacks to the effect fallbacks list.
  25701. * @param defines defines the Base texture to use.
  25702. * @param fallbacks defines the current fallback list.
  25703. * @param currentRank defines the current fallback rank.
  25704. * @returns the new fallback rank.
  25705. */
  25706. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25707. /**
  25708. * Add the required uniforms to the current list.
  25709. * @param uniforms defines the current uniform list.
  25710. */
  25711. static AddUniforms(uniforms: string[]): void;
  25712. /**
  25713. * Add the required uniforms to the current buffer.
  25714. * @param uniformBuffer defines the current uniform buffer.
  25715. */
  25716. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25717. /**
  25718. * Add the required samplers to the current list.
  25719. * @param samplers defines the current sampler list.
  25720. */
  25721. static AddSamplers(samplers: string[]): void;
  25722. /**
  25723. * Makes a duplicate of the current configuration into another one.
  25724. * @param anisotropicConfiguration define the config where to copy the info
  25725. */
  25726. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25727. /**
  25728. * Serializes this anisotropy configuration.
  25729. * @returns - An object with the serialized config.
  25730. */
  25731. serialize(): any;
  25732. /**
  25733. * Parses a anisotropy Configuration from a serialized object.
  25734. * @param source - Serialized object.
  25735. * @param scene Defines the scene we are parsing for
  25736. * @param rootUrl Defines the rootUrl to load from
  25737. */
  25738. parse(source: any, scene: Scene, rootUrl: string): void;
  25739. }
  25740. }
  25741. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  25742. import { Scene } from "babylonjs/scene";
  25743. /**
  25744. * @hidden
  25745. */
  25746. export interface IMaterialBRDFDefines {
  25747. BRDF_V_HEIGHT_CORRELATED: boolean;
  25748. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25749. SPHERICAL_HARMONICS: boolean;
  25750. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25751. /** @hidden */
  25752. _areMiscDirty: boolean;
  25753. }
  25754. /**
  25755. * Define the code related to the BRDF parameters of the pbr material.
  25756. */
  25757. export class PBRBRDFConfiguration {
  25758. /**
  25759. * Default value used for the energy conservation.
  25760. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25761. */
  25762. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25763. /**
  25764. * Default value used for the Smith Visibility Height Correlated mode.
  25765. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25766. */
  25767. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25768. /**
  25769. * Default value used for the IBL diffuse part.
  25770. * This can help switching back to the polynomials mode globally which is a tiny bit
  25771. * less GPU intensive at the drawback of a lower quality.
  25772. */
  25773. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25774. /**
  25775. * Default value used for activating energy conservation for the specular workflow.
  25776. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25777. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25778. */
  25779. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25780. private _useEnergyConservation;
  25781. /**
  25782. * Defines if the material uses energy conservation.
  25783. */
  25784. useEnergyConservation: boolean;
  25785. private _useSmithVisibilityHeightCorrelated;
  25786. /**
  25787. * LEGACY Mode set to false
  25788. * Defines if the material uses height smith correlated visibility term.
  25789. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25790. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25791. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25792. * Not relying on height correlated will also disable energy conservation.
  25793. */
  25794. useSmithVisibilityHeightCorrelated: boolean;
  25795. private _useSphericalHarmonics;
  25796. /**
  25797. * LEGACY Mode set to false
  25798. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25799. * diffuse part of the IBL.
  25800. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25801. * to the ground truth.
  25802. */
  25803. useSphericalHarmonics: boolean;
  25804. private _useSpecularGlossinessInputEnergyConservation;
  25805. /**
  25806. * Defines if the material uses energy conservation, when the specular workflow is active.
  25807. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25808. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25809. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25810. */
  25811. useSpecularGlossinessInputEnergyConservation: boolean;
  25812. /** @hidden */
  25813. private _internalMarkAllSubMeshesAsMiscDirty;
  25814. /** @hidden */
  25815. _markAllSubMeshesAsMiscDirty(): void;
  25816. /**
  25817. * Instantiate a new istance of clear coat configuration.
  25818. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25819. */
  25820. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25821. /**
  25822. * Checks to see if a texture is used in the material.
  25823. * @param defines the list of "defines" to update.
  25824. */
  25825. prepareDefines(defines: IMaterialBRDFDefines): void;
  25826. /**
  25827. * Get the current class name of the texture useful for serialization or dynamic coding.
  25828. * @returns "PBRClearCoatConfiguration"
  25829. */
  25830. getClassName(): string;
  25831. /**
  25832. * Makes a duplicate of the current configuration into another one.
  25833. * @param brdfConfiguration define the config where to copy the info
  25834. */
  25835. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25836. /**
  25837. * Serializes this BRDF configuration.
  25838. * @returns - An object with the serialized config.
  25839. */
  25840. serialize(): any;
  25841. /**
  25842. * Parses a anisotropy Configuration from a serialized object.
  25843. * @param source - Serialized object.
  25844. * @param scene Defines the scene we are parsing for
  25845. * @param rootUrl Defines the rootUrl to load from
  25846. */
  25847. parse(source: any, scene: Scene, rootUrl: string): void;
  25848. }
  25849. }
  25850. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  25851. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25852. import { Color3 } from "babylonjs/Maths/math.color";
  25853. import { Scene } from "babylonjs/scene";
  25854. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25855. import { Nullable } from "babylonjs/types";
  25856. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25857. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25858. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25859. /**
  25860. * @hidden
  25861. */
  25862. export interface IMaterialSheenDefines {
  25863. SHEEN: boolean;
  25864. SHEEN_TEXTURE: boolean;
  25865. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25866. SHEEN_TEXTUREDIRECTUV: number;
  25867. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25868. SHEEN_LINKWITHALBEDO: boolean;
  25869. SHEEN_ROUGHNESS: boolean;
  25870. SHEEN_ALBEDOSCALING: boolean;
  25871. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25872. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25873. /** @hidden */
  25874. _areTexturesDirty: boolean;
  25875. }
  25876. /**
  25877. * Define the code related to the Sheen parameters of the pbr material.
  25878. */
  25879. export class PBRSheenConfiguration {
  25880. private _isEnabled;
  25881. /**
  25882. * Defines if the material uses sheen.
  25883. */
  25884. isEnabled: boolean;
  25885. private _linkSheenWithAlbedo;
  25886. /**
  25887. * Defines if the sheen is linked to the sheen color.
  25888. */
  25889. linkSheenWithAlbedo: boolean;
  25890. /**
  25891. * Defines the sheen intensity.
  25892. */
  25893. intensity: number;
  25894. /**
  25895. * Defines the sheen color.
  25896. */
  25897. color: Color3;
  25898. private _texture;
  25899. /**
  25900. * Stores the sheen tint values in a texture.
  25901. * rgb is tint
  25902. * 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)
  25903. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25904. */
  25905. texture: Nullable<BaseTexture>;
  25906. private _useRoughnessFromMainTexture;
  25907. /**
  25908. * Indicates that the alpha channel of the texture property will be used for roughness.
  25909. * Has no effect if the roughness (and texture!) property is not defined
  25910. */
  25911. useRoughnessFromMainTexture: boolean;
  25912. private _roughness;
  25913. /**
  25914. * Defines the sheen roughness.
  25915. * It is not taken into account if linkSheenWithAlbedo is true.
  25916. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25917. */
  25918. roughness: Nullable<number>;
  25919. private _textureRoughness;
  25920. /**
  25921. * Stores the sheen roughness in a texture.
  25922. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25923. */
  25924. textureRoughness: Nullable<BaseTexture>;
  25925. private _albedoScaling;
  25926. /**
  25927. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25928. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25929. * making it easier to setup and tweak the effect
  25930. */
  25931. albedoScaling: boolean;
  25932. /** @hidden */
  25933. private _internalMarkAllSubMeshesAsTexturesDirty;
  25934. /** @hidden */
  25935. _markAllSubMeshesAsTexturesDirty(): void;
  25936. /**
  25937. * Instantiate a new istance of clear coat configuration.
  25938. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25939. */
  25940. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25941. /**
  25942. * Specifies that the submesh is ready to be used.
  25943. * @param defines the list of "defines" to update.
  25944. * @param scene defines the scene the material belongs to.
  25945. * @returns - boolean indicating that the submesh is ready or not.
  25946. */
  25947. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25948. /**
  25949. * Checks to see if a texture is used in the material.
  25950. * @param defines the list of "defines" to update.
  25951. * @param scene defines the scene the material belongs to.
  25952. */
  25953. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25954. /**
  25955. * Binds the material data.
  25956. * @param uniformBuffer defines the Uniform buffer to fill in.
  25957. * @param scene defines the scene the material belongs to.
  25958. * @param isFrozen defines wether the material is frozen or not.
  25959. * @param subMesh the submesh to bind data for
  25960. */
  25961. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25962. /**
  25963. * Checks to see if a texture is used in the material.
  25964. * @param texture - Base texture to use.
  25965. * @returns - Boolean specifying if a texture is used in the material.
  25966. */
  25967. hasTexture(texture: BaseTexture): boolean;
  25968. /**
  25969. * Returns an array of the actively used textures.
  25970. * @param activeTextures Array of BaseTextures
  25971. */
  25972. getActiveTextures(activeTextures: BaseTexture[]): void;
  25973. /**
  25974. * Returns the animatable textures.
  25975. * @param animatables Array of animatable textures.
  25976. */
  25977. getAnimatables(animatables: IAnimatable[]): void;
  25978. /**
  25979. * Disposes the resources of the material.
  25980. * @param forceDisposeTextures - Forces the disposal of all textures.
  25981. */
  25982. dispose(forceDisposeTextures?: boolean): void;
  25983. /**
  25984. * Get the current class name of the texture useful for serialization or dynamic coding.
  25985. * @returns "PBRSheenConfiguration"
  25986. */
  25987. getClassName(): string;
  25988. /**
  25989. * Add fallbacks to the effect fallbacks list.
  25990. * @param defines defines the Base texture to use.
  25991. * @param fallbacks defines the current fallback list.
  25992. * @param currentRank defines the current fallback rank.
  25993. * @returns the new fallback rank.
  25994. */
  25995. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25996. /**
  25997. * Add the required uniforms to the current list.
  25998. * @param uniforms defines the current uniform list.
  25999. */
  26000. static AddUniforms(uniforms: string[]): void;
  26001. /**
  26002. * Add the required uniforms to the current buffer.
  26003. * @param uniformBuffer defines the current uniform buffer.
  26004. */
  26005. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26006. /**
  26007. * Add the required samplers to the current list.
  26008. * @param samplers defines the current sampler list.
  26009. */
  26010. static AddSamplers(samplers: string[]): void;
  26011. /**
  26012. * Makes a duplicate of the current configuration into another one.
  26013. * @param sheenConfiguration define the config where to copy the info
  26014. */
  26015. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  26016. /**
  26017. * Serializes this BRDF configuration.
  26018. * @returns - An object with the serialized config.
  26019. */
  26020. serialize(): any;
  26021. /**
  26022. * Parses a anisotropy Configuration from a serialized object.
  26023. * @param source - Serialized object.
  26024. * @param scene Defines the scene we are parsing for
  26025. * @param rootUrl Defines the rootUrl to load from
  26026. */
  26027. parse(source: any, scene: Scene, rootUrl: string): void;
  26028. }
  26029. }
  26030. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  26031. import { Nullable } from "babylonjs/types";
  26032. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26033. import { Color3 } from "babylonjs/Maths/math.color";
  26034. import { SmartArray } from "babylonjs/Misc/smartArray";
  26035. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26036. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26037. import { Effect } from "babylonjs/Materials/effect";
  26038. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26039. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26040. import { Engine } from "babylonjs/Engines/engine";
  26041. import { Scene } from "babylonjs/scene";
  26042. /**
  26043. * @hidden
  26044. */
  26045. export interface IMaterialSubSurfaceDefines {
  26046. SUBSURFACE: boolean;
  26047. SS_REFRACTION: boolean;
  26048. SS_TRANSLUCENCY: boolean;
  26049. SS_SCATTERING: boolean;
  26050. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26051. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26052. SS_REFRACTIONMAP_3D: boolean;
  26053. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26054. SS_LODINREFRACTIONALPHA: boolean;
  26055. SS_GAMMAREFRACTION: boolean;
  26056. SS_RGBDREFRACTION: boolean;
  26057. SS_LINEARSPECULARREFRACTION: boolean;
  26058. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26059. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26060. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26061. /** @hidden */
  26062. _areTexturesDirty: boolean;
  26063. }
  26064. /**
  26065. * Define the code related to the sub surface parameters of the pbr material.
  26066. */
  26067. export class PBRSubSurfaceConfiguration {
  26068. private _isRefractionEnabled;
  26069. /**
  26070. * Defines if the refraction is enabled in the material.
  26071. */
  26072. isRefractionEnabled: boolean;
  26073. private _isTranslucencyEnabled;
  26074. /**
  26075. * Defines if the translucency is enabled in the material.
  26076. */
  26077. isTranslucencyEnabled: boolean;
  26078. private _isScatteringEnabled;
  26079. /**
  26080. * Defines if the sub surface scattering is enabled in the material.
  26081. */
  26082. isScatteringEnabled: boolean;
  26083. private _scatteringDiffusionProfileIndex;
  26084. /**
  26085. * Diffusion profile for subsurface scattering.
  26086. * Useful for better scattering in the skins or foliages.
  26087. */
  26088. get scatteringDiffusionProfile(): Nullable<Color3>;
  26089. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26090. /**
  26091. * Defines the refraction intensity of the material.
  26092. * The refraction when enabled replaces the Diffuse part of the material.
  26093. * The intensity helps transitionning between diffuse and refraction.
  26094. */
  26095. refractionIntensity: number;
  26096. /**
  26097. * Defines the translucency intensity of the material.
  26098. * When translucency has been enabled, this defines how much of the "translucency"
  26099. * is addded to the diffuse part of the material.
  26100. */
  26101. translucencyIntensity: number;
  26102. /**
  26103. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26104. */
  26105. useAlbedoToTintRefraction: boolean;
  26106. private _thicknessTexture;
  26107. /**
  26108. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26109. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26110. * 0 would mean minimumThickness
  26111. * 1 would mean maximumThickness
  26112. * The other channels might be use as a mask to vary the different effects intensity.
  26113. */
  26114. thicknessTexture: Nullable<BaseTexture>;
  26115. private _refractionTexture;
  26116. /**
  26117. * Defines the texture to use for refraction.
  26118. */
  26119. refractionTexture: Nullable<BaseTexture>;
  26120. private _indexOfRefraction;
  26121. /**
  26122. * Index of refraction of the material base layer.
  26123. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26124. *
  26125. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26126. *
  26127. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26128. */
  26129. indexOfRefraction: number;
  26130. private _volumeIndexOfRefraction;
  26131. /**
  26132. * Index of refraction of the material's volume.
  26133. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26134. *
  26135. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26136. * the volume will use the same IOR as the surface.
  26137. */
  26138. get volumeIndexOfRefraction(): number;
  26139. set volumeIndexOfRefraction(value: number);
  26140. private _invertRefractionY;
  26141. /**
  26142. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26143. */
  26144. invertRefractionY: boolean;
  26145. private _linkRefractionWithTransparency;
  26146. /**
  26147. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26148. * Materials half opaque for instance using refraction could benefit from this control.
  26149. */
  26150. linkRefractionWithTransparency: boolean;
  26151. /**
  26152. * Defines the minimum thickness stored in the thickness map.
  26153. * If no thickness map is defined, this value will be used to simulate thickness.
  26154. */
  26155. minimumThickness: number;
  26156. /**
  26157. * Defines the maximum thickness stored in the thickness map.
  26158. */
  26159. maximumThickness: number;
  26160. /**
  26161. * Defines the volume tint of the material.
  26162. * This is used for both translucency and scattering.
  26163. */
  26164. tintColor: Color3;
  26165. /**
  26166. * Defines the distance at which the tint color should be found in the media.
  26167. * This is used for refraction only.
  26168. */
  26169. tintColorAtDistance: number;
  26170. /**
  26171. * Defines how far each channel transmit through the media.
  26172. * It is defined as a color to simplify it selection.
  26173. */
  26174. diffusionDistance: Color3;
  26175. private _useMaskFromThicknessTexture;
  26176. /**
  26177. * Stores the intensity of the different subsurface effects in the thickness texture.
  26178. * * the green channel is the translucency intensity.
  26179. * * the blue channel is the scattering intensity.
  26180. * * the alpha channel is the refraction intensity.
  26181. */
  26182. useMaskFromThicknessTexture: boolean;
  26183. private _scene;
  26184. /** @hidden */
  26185. private _internalMarkAllSubMeshesAsTexturesDirty;
  26186. private _internalMarkScenePrePassDirty;
  26187. /** @hidden */
  26188. _markAllSubMeshesAsTexturesDirty(): void;
  26189. /** @hidden */
  26190. _markScenePrePassDirty(): void;
  26191. /**
  26192. * Instantiate a new istance of sub surface configuration.
  26193. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26194. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26195. * @param scene The scene
  26196. */
  26197. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26198. /**
  26199. * Gets wehter the submesh is ready to be used or not.
  26200. * @param defines the list of "defines" to update.
  26201. * @param scene defines the scene the material belongs to.
  26202. * @returns - boolean indicating that the submesh is ready or not.
  26203. */
  26204. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26205. /**
  26206. * Checks to see if a texture is used in the material.
  26207. * @param defines the list of "defines" to update.
  26208. * @param scene defines the scene to the material belongs to.
  26209. */
  26210. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26211. /**
  26212. * Binds the material data.
  26213. * @param uniformBuffer defines the Uniform buffer to fill in.
  26214. * @param scene defines the scene the material belongs to.
  26215. * @param engine defines the engine the material belongs to.
  26216. * @param isFrozen defines whether the material is frozen or not.
  26217. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26218. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26219. */
  26220. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26221. /**
  26222. * Unbinds the material from the mesh.
  26223. * @param activeEffect defines the effect that should be unbound from.
  26224. * @returns true if unbound, otherwise false
  26225. */
  26226. unbind(activeEffect: Effect): boolean;
  26227. /**
  26228. * Returns the texture used for refraction or null if none is used.
  26229. * @param scene defines the scene the material belongs to.
  26230. * @returns - Refraction texture if present. If no refraction texture and refraction
  26231. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26232. */
  26233. private _getRefractionTexture;
  26234. /**
  26235. * Returns true if alpha blending should be disabled.
  26236. */
  26237. get disableAlphaBlending(): boolean;
  26238. /**
  26239. * Fills the list of render target textures.
  26240. * @param renderTargets the list of render targets to update
  26241. */
  26242. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26243. /**
  26244. * Checks to see if a texture is used in the material.
  26245. * @param texture - Base texture to use.
  26246. * @returns - Boolean specifying if a texture is used in the material.
  26247. */
  26248. hasTexture(texture: BaseTexture): boolean;
  26249. /**
  26250. * Gets a boolean indicating that current material needs to register RTT
  26251. * @returns true if this uses a render target otherwise false.
  26252. */
  26253. hasRenderTargetTextures(): boolean;
  26254. /**
  26255. * Returns an array of the actively used textures.
  26256. * @param activeTextures Array of BaseTextures
  26257. */
  26258. getActiveTextures(activeTextures: BaseTexture[]): void;
  26259. /**
  26260. * Returns the animatable textures.
  26261. * @param animatables Array of animatable textures.
  26262. */
  26263. getAnimatables(animatables: IAnimatable[]): void;
  26264. /**
  26265. * Disposes the resources of the material.
  26266. * @param forceDisposeTextures - Forces the disposal of all textures.
  26267. */
  26268. dispose(forceDisposeTextures?: boolean): void;
  26269. /**
  26270. * Get the current class name of the texture useful for serialization or dynamic coding.
  26271. * @returns "PBRSubSurfaceConfiguration"
  26272. */
  26273. getClassName(): string;
  26274. /**
  26275. * Add fallbacks to the effect fallbacks list.
  26276. * @param defines defines the Base texture to use.
  26277. * @param fallbacks defines the current fallback list.
  26278. * @param currentRank defines the current fallback rank.
  26279. * @returns the new fallback rank.
  26280. */
  26281. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26282. /**
  26283. * Add the required uniforms to the current list.
  26284. * @param uniforms defines the current uniform list.
  26285. */
  26286. static AddUniforms(uniforms: string[]): void;
  26287. /**
  26288. * Add the required samplers to the current list.
  26289. * @param samplers defines the current sampler list.
  26290. */
  26291. static AddSamplers(samplers: string[]): void;
  26292. /**
  26293. * Add the required uniforms to the current buffer.
  26294. * @param uniformBuffer defines the current uniform buffer.
  26295. */
  26296. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26297. /**
  26298. * Makes a duplicate of the current configuration into another one.
  26299. * @param configuration define the config where to copy the info
  26300. */
  26301. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26302. /**
  26303. * Serializes this Sub Surface configuration.
  26304. * @returns - An object with the serialized config.
  26305. */
  26306. serialize(): any;
  26307. /**
  26308. * Parses a anisotropy Configuration from a serialized object.
  26309. * @param source - Serialized object.
  26310. * @param scene Defines the scene we are parsing for
  26311. * @param rootUrl Defines the rootUrl to load from
  26312. */
  26313. parse(source: any, scene: Scene, rootUrl: string): void;
  26314. }
  26315. }
  26316. declare module "babylonjs/Maths/sphericalPolynomial" {
  26317. import { Vector3 } from "babylonjs/Maths/math.vector";
  26318. import { Color3 } from "babylonjs/Maths/math.color";
  26319. /**
  26320. * Class representing spherical harmonics coefficients to the 3rd degree
  26321. */
  26322. export class SphericalHarmonics {
  26323. /**
  26324. * Defines whether or not the harmonics have been prescaled for rendering.
  26325. */
  26326. preScaled: boolean;
  26327. /**
  26328. * The l0,0 coefficients of the spherical harmonics
  26329. */
  26330. l00: Vector3;
  26331. /**
  26332. * The l1,-1 coefficients of the spherical harmonics
  26333. */
  26334. l1_1: Vector3;
  26335. /**
  26336. * The l1,0 coefficients of the spherical harmonics
  26337. */
  26338. l10: Vector3;
  26339. /**
  26340. * The l1,1 coefficients of the spherical harmonics
  26341. */
  26342. l11: Vector3;
  26343. /**
  26344. * The l2,-2 coefficients of the spherical harmonics
  26345. */
  26346. l2_2: Vector3;
  26347. /**
  26348. * The l2,-1 coefficients of the spherical harmonics
  26349. */
  26350. l2_1: Vector3;
  26351. /**
  26352. * The l2,0 coefficients of the spherical harmonics
  26353. */
  26354. l20: Vector3;
  26355. /**
  26356. * The l2,1 coefficients of the spherical harmonics
  26357. */
  26358. l21: Vector3;
  26359. /**
  26360. * The l2,2 coefficients of the spherical harmonics
  26361. */
  26362. l22: Vector3;
  26363. /**
  26364. * Adds a light to the spherical harmonics
  26365. * @param direction the direction of the light
  26366. * @param color the color of the light
  26367. * @param deltaSolidAngle the delta solid angle of the light
  26368. */
  26369. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26370. /**
  26371. * Scales the spherical harmonics by the given amount
  26372. * @param scale the amount to scale
  26373. */
  26374. scaleInPlace(scale: number): void;
  26375. /**
  26376. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26377. *
  26378. * ```
  26379. * E_lm = A_l * L_lm
  26380. * ```
  26381. *
  26382. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26383. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26384. * the scaling factors are given in equation 9.
  26385. */
  26386. convertIncidentRadianceToIrradiance(): void;
  26387. /**
  26388. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26389. *
  26390. * ```
  26391. * L = (1/pi) * E * rho
  26392. * ```
  26393. *
  26394. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26395. */
  26396. convertIrradianceToLambertianRadiance(): void;
  26397. /**
  26398. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26399. * required operations at run time.
  26400. *
  26401. * This is simply done by scaling back the SH with Ylm constants parameter.
  26402. * The trigonometric part being applied by the shader at run time.
  26403. */
  26404. preScaleForRendering(): void;
  26405. /**
  26406. * Constructs a spherical harmonics from an array.
  26407. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26408. * @returns the spherical harmonics
  26409. */
  26410. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26411. /**
  26412. * Gets the spherical harmonics from polynomial
  26413. * @param polynomial the spherical polynomial
  26414. * @returns the spherical harmonics
  26415. */
  26416. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26417. }
  26418. /**
  26419. * Class representing spherical polynomial coefficients to the 3rd degree
  26420. */
  26421. export class SphericalPolynomial {
  26422. private _harmonics;
  26423. /**
  26424. * The spherical harmonics used to create the polynomials.
  26425. */
  26426. get preScaledHarmonics(): SphericalHarmonics;
  26427. /**
  26428. * The x coefficients of the spherical polynomial
  26429. */
  26430. x: Vector3;
  26431. /**
  26432. * The y coefficients of the spherical polynomial
  26433. */
  26434. y: Vector3;
  26435. /**
  26436. * The z coefficients of the spherical polynomial
  26437. */
  26438. z: Vector3;
  26439. /**
  26440. * The xx coefficients of the spherical polynomial
  26441. */
  26442. xx: Vector3;
  26443. /**
  26444. * The yy coefficients of the spherical polynomial
  26445. */
  26446. yy: Vector3;
  26447. /**
  26448. * The zz coefficients of the spherical polynomial
  26449. */
  26450. zz: Vector3;
  26451. /**
  26452. * The xy coefficients of the spherical polynomial
  26453. */
  26454. xy: Vector3;
  26455. /**
  26456. * The yz coefficients of the spherical polynomial
  26457. */
  26458. yz: Vector3;
  26459. /**
  26460. * The zx coefficients of the spherical polynomial
  26461. */
  26462. zx: Vector3;
  26463. /**
  26464. * Adds an ambient color to the spherical polynomial
  26465. * @param color the color to add
  26466. */
  26467. addAmbient(color: Color3): void;
  26468. /**
  26469. * Scales the spherical polynomial by the given amount
  26470. * @param scale the amount to scale
  26471. */
  26472. scaleInPlace(scale: number): void;
  26473. /**
  26474. * Gets the spherical polynomial from harmonics
  26475. * @param harmonics the spherical harmonics
  26476. * @returns the spherical polynomial
  26477. */
  26478. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26479. /**
  26480. * Constructs a spherical polynomial from an array.
  26481. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26482. * @returns the spherical polynomial
  26483. */
  26484. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26485. }
  26486. }
  26487. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26488. import { Nullable } from "babylonjs/types";
  26489. /**
  26490. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26491. */
  26492. export interface CubeMapInfo {
  26493. /**
  26494. * The pixel array for the front face.
  26495. * This is stored in format, left to right, up to down format.
  26496. */
  26497. front: Nullable<ArrayBufferView>;
  26498. /**
  26499. * The pixel array for the back face.
  26500. * This is stored in format, left to right, up to down format.
  26501. */
  26502. back: Nullable<ArrayBufferView>;
  26503. /**
  26504. * The pixel array for the left face.
  26505. * This is stored in format, left to right, up to down format.
  26506. */
  26507. left: Nullable<ArrayBufferView>;
  26508. /**
  26509. * The pixel array for the right face.
  26510. * This is stored in format, left to right, up to down format.
  26511. */
  26512. right: Nullable<ArrayBufferView>;
  26513. /**
  26514. * The pixel array for the up face.
  26515. * This is stored in format, left to right, up to down format.
  26516. */
  26517. up: Nullable<ArrayBufferView>;
  26518. /**
  26519. * The pixel array for the down face.
  26520. * This is stored in format, left to right, up to down format.
  26521. */
  26522. down: Nullable<ArrayBufferView>;
  26523. /**
  26524. * The size of the cubemap stored.
  26525. *
  26526. * Each faces will be size * size pixels.
  26527. */
  26528. size: number;
  26529. /**
  26530. * The format of the texture.
  26531. *
  26532. * RGBA, RGB.
  26533. */
  26534. format: number;
  26535. /**
  26536. * The type of the texture data.
  26537. *
  26538. * UNSIGNED_INT, FLOAT.
  26539. */
  26540. type: number;
  26541. /**
  26542. * Specifies whether the texture is in gamma space.
  26543. */
  26544. gammaSpace: boolean;
  26545. }
  26546. /**
  26547. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26548. */
  26549. export class PanoramaToCubeMapTools {
  26550. private static FACE_LEFT;
  26551. private static FACE_RIGHT;
  26552. private static FACE_FRONT;
  26553. private static FACE_BACK;
  26554. private static FACE_DOWN;
  26555. private static FACE_UP;
  26556. /**
  26557. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26558. *
  26559. * @param float32Array The source data.
  26560. * @param inputWidth The width of the input panorama.
  26561. * @param inputHeight The height of the input panorama.
  26562. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26563. * @return The cubemap data
  26564. */
  26565. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26566. private static CreateCubemapTexture;
  26567. private static CalcProjectionSpherical;
  26568. }
  26569. }
  26570. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26571. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26573. import { Nullable } from "babylonjs/types";
  26574. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26575. /**
  26576. * Helper class dealing with the extraction of spherical polynomial dataArray
  26577. * from a cube map.
  26578. */
  26579. export class CubeMapToSphericalPolynomialTools {
  26580. private static FileFaces;
  26581. /**
  26582. * Converts a texture to the according Spherical Polynomial data.
  26583. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26584. *
  26585. * @param texture The texture to extract the information from.
  26586. * @return The Spherical Polynomial data.
  26587. */
  26588. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26589. /**
  26590. * Converts a cubemap to the according Spherical Polynomial data.
  26591. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26592. *
  26593. * @param cubeInfo The Cube map to extract the information from.
  26594. * @return The Spherical Polynomial data.
  26595. */
  26596. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26597. }
  26598. }
  26599. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26600. import { Nullable } from "babylonjs/types";
  26601. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26602. module "babylonjs/Materials/Textures/baseTexture" {
  26603. interface BaseTexture {
  26604. /**
  26605. * Get the polynomial representation of the texture data.
  26606. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26607. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26608. */
  26609. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26610. }
  26611. }
  26612. }
  26613. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26614. /** @hidden */
  26615. export var pbrFragmentDeclaration: {
  26616. name: string;
  26617. shader: string;
  26618. };
  26619. }
  26620. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26621. /** @hidden */
  26622. export var pbrUboDeclaration: {
  26623. name: string;
  26624. shader: string;
  26625. };
  26626. }
  26627. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26628. /** @hidden */
  26629. export var pbrFragmentExtraDeclaration: {
  26630. name: string;
  26631. shader: string;
  26632. };
  26633. }
  26634. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26635. /** @hidden */
  26636. export var pbrFragmentSamplersDeclaration: {
  26637. name: string;
  26638. shader: string;
  26639. };
  26640. }
  26641. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26642. /** @hidden */
  26643. export var subSurfaceScatteringFunctions: {
  26644. name: string;
  26645. shader: string;
  26646. };
  26647. }
  26648. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26649. /** @hidden */
  26650. export var importanceSampling: {
  26651. name: string;
  26652. shader: string;
  26653. };
  26654. }
  26655. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26656. /** @hidden */
  26657. export var pbrHelperFunctions: {
  26658. name: string;
  26659. shader: string;
  26660. };
  26661. }
  26662. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26663. /** @hidden */
  26664. export var harmonicsFunctions: {
  26665. name: string;
  26666. shader: string;
  26667. };
  26668. }
  26669. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26670. /** @hidden */
  26671. export var pbrDirectLightingSetupFunctions: {
  26672. name: string;
  26673. shader: string;
  26674. };
  26675. }
  26676. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26677. /** @hidden */
  26678. export var pbrDirectLightingFalloffFunctions: {
  26679. name: string;
  26680. shader: string;
  26681. };
  26682. }
  26683. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26684. /** @hidden */
  26685. export var pbrBRDFFunctions: {
  26686. name: string;
  26687. shader: string;
  26688. };
  26689. }
  26690. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26691. /** @hidden */
  26692. export var hdrFilteringFunctions: {
  26693. name: string;
  26694. shader: string;
  26695. };
  26696. }
  26697. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  26698. /** @hidden */
  26699. export var pbrDirectLightingFunctions: {
  26700. name: string;
  26701. shader: string;
  26702. };
  26703. }
  26704. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  26705. /** @hidden */
  26706. export var pbrIBLFunctions: {
  26707. name: string;
  26708. shader: string;
  26709. };
  26710. }
  26711. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  26712. /** @hidden */
  26713. export var pbrBlockAlbedoOpacity: {
  26714. name: string;
  26715. shader: string;
  26716. };
  26717. }
  26718. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  26719. /** @hidden */
  26720. export var pbrBlockReflectivity: {
  26721. name: string;
  26722. shader: string;
  26723. };
  26724. }
  26725. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  26726. /** @hidden */
  26727. export var pbrBlockAmbientOcclusion: {
  26728. name: string;
  26729. shader: string;
  26730. };
  26731. }
  26732. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  26733. /** @hidden */
  26734. export var pbrBlockAlphaFresnel: {
  26735. name: string;
  26736. shader: string;
  26737. };
  26738. }
  26739. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  26740. /** @hidden */
  26741. export var pbrBlockAnisotropic: {
  26742. name: string;
  26743. shader: string;
  26744. };
  26745. }
  26746. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  26747. /** @hidden */
  26748. export var pbrBlockReflection: {
  26749. name: string;
  26750. shader: string;
  26751. };
  26752. }
  26753. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  26754. /** @hidden */
  26755. export var pbrBlockSheen: {
  26756. name: string;
  26757. shader: string;
  26758. };
  26759. }
  26760. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  26761. /** @hidden */
  26762. export var pbrBlockClearcoat: {
  26763. name: string;
  26764. shader: string;
  26765. };
  26766. }
  26767. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  26768. /** @hidden */
  26769. export var pbrBlockSubSurface: {
  26770. name: string;
  26771. shader: string;
  26772. };
  26773. }
  26774. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  26775. /** @hidden */
  26776. export var pbrBlockNormalGeometric: {
  26777. name: string;
  26778. shader: string;
  26779. };
  26780. }
  26781. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  26782. /** @hidden */
  26783. export var pbrBlockNormalFinal: {
  26784. name: string;
  26785. shader: string;
  26786. };
  26787. }
  26788. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  26789. /** @hidden */
  26790. export var pbrBlockLightmapInit: {
  26791. name: string;
  26792. shader: string;
  26793. };
  26794. }
  26795. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  26796. /** @hidden */
  26797. export var pbrBlockGeometryInfo: {
  26798. name: string;
  26799. shader: string;
  26800. };
  26801. }
  26802. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  26803. /** @hidden */
  26804. export var pbrBlockReflectance0: {
  26805. name: string;
  26806. shader: string;
  26807. };
  26808. }
  26809. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  26810. /** @hidden */
  26811. export var pbrBlockReflectance: {
  26812. name: string;
  26813. shader: string;
  26814. };
  26815. }
  26816. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  26817. /** @hidden */
  26818. export var pbrBlockDirectLighting: {
  26819. name: string;
  26820. shader: string;
  26821. };
  26822. }
  26823. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  26824. /** @hidden */
  26825. export var pbrBlockFinalLitComponents: {
  26826. name: string;
  26827. shader: string;
  26828. };
  26829. }
  26830. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  26831. /** @hidden */
  26832. export var pbrBlockFinalUnlitComponents: {
  26833. name: string;
  26834. shader: string;
  26835. };
  26836. }
  26837. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  26838. /** @hidden */
  26839. export var pbrBlockFinalColorComposition: {
  26840. name: string;
  26841. shader: string;
  26842. };
  26843. }
  26844. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  26845. /** @hidden */
  26846. export var pbrBlockImageProcessing: {
  26847. name: string;
  26848. shader: string;
  26849. };
  26850. }
  26851. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  26852. /** @hidden */
  26853. export var pbrDebug: {
  26854. name: string;
  26855. shader: string;
  26856. };
  26857. }
  26858. declare module "babylonjs/Shaders/pbr.fragment" {
  26859. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  26860. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  26861. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26862. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  26863. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26864. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26865. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  26866. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26867. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26868. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26869. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26870. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26871. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  26872. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  26873. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  26874. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26875. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26876. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26877. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  26878. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  26879. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  26880. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  26881. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  26882. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  26883. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  26884. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26885. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26886. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  26887. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  26888. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  26889. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  26890. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  26891. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  26892. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  26893. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  26894. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  26895. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26896. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  26897. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26898. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  26899. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26900. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  26901. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  26902. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  26903. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  26904. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  26905. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26906. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  26907. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  26908. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  26909. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26910. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26911. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  26912. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  26913. /** @hidden */
  26914. export var pbrPixelShader: {
  26915. name: string;
  26916. shader: string;
  26917. };
  26918. }
  26919. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  26920. /** @hidden */
  26921. export var pbrVertexDeclaration: {
  26922. name: string;
  26923. shader: string;
  26924. };
  26925. }
  26926. declare module "babylonjs/Shaders/pbr.vertex" {
  26927. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  26928. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26929. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26930. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26931. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26932. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  26933. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26934. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26935. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26936. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26937. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26938. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26939. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26940. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26941. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26943. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26944. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26945. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  26946. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26947. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26948. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26949. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26950. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26951. /** @hidden */
  26952. export var pbrVertexShader: {
  26953. name: string;
  26954. shader: string;
  26955. };
  26956. }
  26957. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  26958. import { Nullable } from "babylonjs/types";
  26959. import { Scene } from "babylonjs/scene";
  26960. import { Matrix } from "babylonjs/Maths/math.vector";
  26961. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26963. import { Mesh } from "babylonjs/Meshes/mesh";
  26964. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  26965. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  26966. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  26967. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  26968. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  26969. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  26970. import { Color3 } from "babylonjs/Maths/math.color";
  26971. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26972. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  26973. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26974. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26975. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26976. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26977. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  26978. import "babylonjs/Shaders/pbr.fragment";
  26979. import "babylonjs/Shaders/pbr.vertex";
  26980. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  26981. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  26982. /**
  26983. * Manages the defines for the PBR Material.
  26984. * @hidden
  26985. */
  26986. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  26987. PBR: boolean;
  26988. NUM_SAMPLES: string;
  26989. REALTIME_FILTERING: boolean;
  26990. MAINUV1: boolean;
  26991. MAINUV2: boolean;
  26992. UV1: boolean;
  26993. UV2: boolean;
  26994. ALBEDO: boolean;
  26995. GAMMAALBEDO: boolean;
  26996. ALBEDODIRECTUV: number;
  26997. VERTEXCOLOR: boolean;
  26998. DETAIL: boolean;
  26999. DETAILDIRECTUV: number;
  27000. DETAIL_NORMALBLENDMETHOD: number;
  27001. AMBIENT: boolean;
  27002. AMBIENTDIRECTUV: number;
  27003. AMBIENTINGRAYSCALE: boolean;
  27004. OPACITY: boolean;
  27005. VERTEXALPHA: boolean;
  27006. OPACITYDIRECTUV: number;
  27007. OPACITYRGB: boolean;
  27008. ALPHATEST: boolean;
  27009. DEPTHPREPASS: boolean;
  27010. ALPHABLEND: boolean;
  27011. ALPHAFROMALBEDO: boolean;
  27012. ALPHATESTVALUE: string;
  27013. SPECULAROVERALPHA: boolean;
  27014. RADIANCEOVERALPHA: boolean;
  27015. ALPHAFRESNEL: boolean;
  27016. LINEARALPHAFRESNEL: boolean;
  27017. PREMULTIPLYALPHA: boolean;
  27018. EMISSIVE: boolean;
  27019. EMISSIVEDIRECTUV: number;
  27020. REFLECTIVITY: boolean;
  27021. REFLECTIVITYDIRECTUV: number;
  27022. SPECULARTERM: boolean;
  27023. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  27024. MICROSURFACEAUTOMATIC: boolean;
  27025. LODBASEDMICROSFURACE: boolean;
  27026. MICROSURFACEMAP: boolean;
  27027. MICROSURFACEMAPDIRECTUV: number;
  27028. METALLICWORKFLOW: boolean;
  27029. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  27030. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  27031. METALLNESSSTOREINMETALMAPBLUE: boolean;
  27032. AOSTOREINMETALMAPRED: boolean;
  27033. METALLIC_REFLECTANCE: boolean;
  27034. METALLIC_REFLECTANCEDIRECTUV: number;
  27035. ENVIRONMENTBRDF: boolean;
  27036. ENVIRONMENTBRDF_RGBD: boolean;
  27037. NORMAL: boolean;
  27038. TANGENT: boolean;
  27039. BUMP: boolean;
  27040. BUMPDIRECTUV: number;
  27041. OBJECTSPACE_NORMALMAP: boolean;
  27042. PARALLAX: boolean;
  27043. PARALLAXOCCLUSION: boolean;
  27044. NORMALXYSCALE: boolean;
  27045. LIGHTMAP: boolean;
  27046. LIGHTMAPDIRECTUV: number;
  27047. USELIGHTMAPASSHADOWMAP: boolean;
  27048. GAMMALIGHTMAP: boolean;
  27049. RGBDLIGHTMAP: boolean;
  27050. REFLECTION: boolean;
  27051. REFLECTIONMAP_3D: boolean;
  27052. REFLECTIONMAP_SPHERICAL: boolean;
  27053. REFLECTIONMAP_PLANAR: boolean;
  27054. REFLECTIONMAP_CUBIC: boolean;
  27055. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27056. REFLECTIONMAP_PROJECTION: boolean;
  27057. REFLECTIONMAP_SKYBOX: boolean;
  27058. REFLECTIONMAP_EXPLICIT: boolean;
  27059. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27060. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27061. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27062. INVERTCUBICMAP: boolean;
  27063. USESPHERICALFROMREFLECTIONMAP: boolean;
  27064. USEIRRADIANCEMAP: boolean;
  27065. SPHERICAL_HARMONICS: boolean;
  27066. USESPHERICALINVERTEX: boolean;
  27067. REFLECTIONMAP_OPPOSITEZ: boolean;
  27068. LODINREFLECTIONALPHA: boolean;
  27069. GAMMAREFLECTION: boolean;
  27070. RGBDREFLECTION: boolean;
  27071. LINEARSPECULARREFLECTION: boolean;
  27072. RADIANCEOCCLUSION: boolean;
  27073. HORIZONOCCLUSION: boolean;
  27074. INSTANCES: boolean;
  27075. THIN_INSTANCES: boolean;
  27076. PREPASS: boolean;
  27077. PREPASS_IRRADIANCE: boolean;
  27078. PREPASS_IRRADIANCE_INDEX: number;
  27079. PREPASS_ALBEDO: boolean;
  27080. PREPASS_ALBEDO_INDEX: number;
  27081. PREPASS_DEPTHNORMAL: boolean;
  27082. PREPASS_DEPTHNORMAL_INDEX: number;
  27083. PREPASS_POSITION: boolean;
  27084. PREPASS_POSITION_INDEX: number;
  27085. PREPASS_VELOCITY: boolean;
  27086. PREPASS_VELOCITY_INDEX: number;
  27087. PREPASS_REFLECTIVITY: boolean;
  27088. PREPASS_REFLECTIVITY_INDEX: number;
  27089. SCENE_MRT_COUNT: number;
  27090. NUM_BONE_INFLUENCERS: number;
  27091. BonesPerMesh: number;
  27092. BONETEXTURE: boolean;
  27093. BONES_VELOCITY_ENABLED: boolean;
  27094. NONUNIFORMSCALING: boolean;
  27095. MORPHTARGETS: boolean;
  27096. MORPHTARGETS_NORMAL: boolean;
  27097. MORPHTARGETS_TANGENT: boolean;
  27098. MORPHTARGETS_UV: boolean;
  27099. NUM_MORPH_INFLUENCERS: number;
  27100. IMAGEPROCESSING: boolean;
  27101. VIGNETTE: boolean;
  27102. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27103. VIGNETTEBLENDMODEOPAQUE: boolean;
  27104. TONEMAPPING: boolean;
  27105. TONEMAPPING_ACES: boolean;
  27106. CONTRAST: boolean;
  27107. COLORCURVES: boolean;
  27108. COLORGRADING: boolean;
  27109. COLORGRADING3D: boolean;
  27110. SAMPLER3DGREENDEPTH: boolean;
  27111. SAMPLER3DBGRMAP: boolean;
  27112. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27113. EXPOSURE: boolean;
  27114. MULTIVIEW: boolean;
  27115. USEPHYSICALLIGHTFALLOFF: boolean;
  27116. USEGLTFLIGHTFALLOFF: boolean;
  27117. TWOSIDEDLIGHTING: boolean;
  27118. SHADOWFLOAT: boolean;
  27119. CLIPPLANE: boolean;
  27120. CLIPPLANE2: boolean;
  27121. CLIPPLANE3: boolean;
  27122. CLIPPLANE4: boolean;
  27123. CLIPPLANE5: boolean;
  27124. CLIPPLANE6: boolean;
  27125. POINTSIZE: boolean;
  27126. FOG: boolean;
  27127. LOGARITHMICDEPTH: boolean;
  27128. FORCENORMALFORWARD: boolean;
  27129. SPECULARAA: boolean;
  27130. CLEARCOAT: boolean;
  27131. CLEARCOAT_DEFAULTIOR: boolean;
  27132. CLEARCOAT_TEXTURE: boolean;
  27133. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  27134. CLEARCOAT_TEXTUREDIRECTUV: number;
  27135. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  27136. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27137. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27138. CLEARCOAT_BUMP: boolean;
  27139. CLEARCOAT_BUMPDIRECTUV: number;
  27140. CLEARCOAT_REMAP_F0: boolean;
  27141. CLEARCOAT_TINT: boolean;
  27142. CLEARCOAT_TINT_TEXTURE: boolean;
  27143. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27144. ANISOTROPIC: boolean;
  27145. ANISOTROPIC_TEXTURE: boolean;
  27146. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27147. BRDF_V_HEIGHT_CORRELATED: boolean;
  27148. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27149. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27150. SHEEN: boolean;
  27151. SHEEN_TEXTURE: boolean;
  27152. SHEEN_TEXTURE_ROUGHNESS: boolean;
  27153. SHEEN_TEXTUREDIRECTUV: number;
  27154. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  27155. SHEEN_LINKWITHALBEDO: boolean;
  27156. SHEEN_ROUGHNESS: boolean;
  27157. SHEEN_ALBEDOSCALING: boolean;
  27158. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27159. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27160. SUBSURFACE: boolean;
  27161. SS_REFRACTION: boolean;
  27162. SS_TRANSLUCENCY: boolean;
  27163. SS_SCATTERING: boolean;
  27164. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27165. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27166. SS_REFRACTIONMAP_3D: boolean;
  27167. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27168. SS_LODINREFRACTIONALPHA: boolean;
  27169. SS_GAMMAREFRACTION: boolean;
  27170. SS_RGBDREFRACTION: boolean;
  27171. SS_LINEARSPECULARREFRACTION: boolean;
  27172. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27173. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27174. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27175. UNLIT: boolean;
  27176. DEBUGMODE: number;
  27177. /**
  27178. * Initializes the PBR Material defines.
  27179. */
  27180. constructor();
  27181. /**
  27182. * Resets the PBR Material defines.
  27183. */
  27184. reset(): void;
  27185. }
  27186. /**
  27187. * The Physically based material base class of BJS.
  27188. *
  27189. * This offers the main features of a standard PBR material.
  27190. * For more information, please refer to the documentation :
  27191. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27192. */
  27193. export abstract class PBRBaseMaterial extends PushMaterial {
  27194. /**
  27195. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27196. */
  27197. static readonly PBRMATERIAL_OPAQUE: number;
  27198. /**
  27199. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27200. */
  27201. static readonly PBRMATERIAL_ALPHATEST: number;
  27202. /**
  27203. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27204. */
  27205. static readonly PBRMATERIAL_ALPHABLEND: number;
  27206. /**
  27207. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27208. * They are also discarded below the alpha cutoff threshold to improve performances.
  27209. */
  27210. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27211. /**
  27212. * Defines the default value of how much AO map is occluding the analytical lights
  27213. * (point spot...).
  27214. */
  27215. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27216. /**
  27217. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27218. */
  27219. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27220. /**
  27221. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27222. * to enhance interoperability with other engines.
  27223. */
  27224. static readonly LIGHTFALLOFF_GLTF: number;
  27225. /**
  27226. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27227. * to enhance interoperability with other materials.
  27228. */
  27229. static readonly LIGHTFALLOFF_STANDARD: number;
  27230. /**
  27231. * Intensity of the direct lights e.g. the four lights available in your scene.
  27232. * This impacts both the direct diffuse and specular highlights.
  27233. */
  27234. protected _directIntensity: number;
  27235. /**
  27236. * Intensity of the emissive part of the material.
  27237. * This helps controlling the emissive effect without modifying the emissive color.
  27238. */
  27239. protected _emissiveIntensity: number;
  27240. /**
  27241. * Intensity of the environment e.g. how much the environment will light the object
  27242. * either through harmonics for rough material or through the refelction for shiny ones.
  27243. */
  27244. protected _environmentIntensity: number;
  27245. /**
  27246. * This is a special control allowing the reduction of the specular highlights coming from the
  27247. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27248. */
  27249. protected _specularIntensity: number;
  27250. /**
  27251. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27252. */
  27253. private _lightingInfos;
  27254. /**
  27255. * Debug Control allowing disabling the bump map on this material.
  27256. */
  27257. protected _disableBumpMap: boolean;
  27258. /**
  27259. * AKA Diffuse Texture in standard nomenclature.
  27260. */
  27261. protected _albedoTexture: Nullable<BaseTexture>;
  27262. /**
  27263. * AKA Occlusion Texture in other nomenclature.
  27264. */
  27265. protected _ambientTexture: Nullable<BaseTexture>;
  27266. /**
  27267. * AKA Occlusion Texture Intensity in other nomenclature.
  27268. */
  27269. protected _ambientTextureStrength: number;
  27270. /**
  27271. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27272. * 1 means it completely occludes it
  27273. * 0 mean it has no impact
  27274. */
  27275. protected _ambientTextureImpactOnAnalyticalLights: number;
  27276. /**
  27277. * Stores the alpha values in a texture.
  27278. */
  27279. protected _opacityTexture: Nullable<BaseTexture>;
  27280. /**
  27281. * Stores the reflection values in a texture.
  27282. */
  27283. protected _reflectionTexture: Nullable<BaseTexture>;
  27284. /**
  27285. * Stores the emissive values in a texture.
  27286. */
  27287. protected _emissiveTexture: Nullable<BaseTexture>;
  27288. /**
  27289. * AKA Specular texture in other nomenclature.
  27290. */
  27291. protected _reflectivityTexture: Nullable<BaseTexture>;
  27292. /**
  27293. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27294. */
  27295. protected _metallicTexture: Nullable<BaseTexture>;
  27296. /**
  27297. * Specifies the metallic scalar of the metallic/roughness workflow.
  27298. * Can also be used to scale the metalness values of the metallic texture.
  27299. */
  27300. protected _metallic: Nullable<number>;
  27301. /**
  27302. * Specifies the roughness scalar of the metallic/roughness workflow.
  27303. * Can also be used to scale the roughness values of the metallic texture.
  27304. */
  27305. protected _roughness: Nullable<number>;
  27306. /**
  27307. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27308. * By default the indexOfrefraction is used to compute F0;
  27309. *
  27310. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27311. *
  27312. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27313. * F90 = metallicReflectanceColor;
  27314. */
  27315. protected _metallicF0Factor: number;
  27316. /**
  27317. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27318. * By default the F90 is always 1;
  27319. *
  27320. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27321. *
  27322. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27323. * F90 = metallicReflectanceColor;
  27324. */
  27325. protected _metallicReflectanceColor: Color3;
  27326. /**
  27327. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27328. * This is multiply against the scalar values defined in the material.
  27329. */
  27330. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27331. /**
  27332. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27333. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27334. */
  27335. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27336. /**
  27337. * Stores surface normal data used to displace a mesh in a texture.
  27338. */
  27339. protected _bumpTexture: Nullable<BaseTexture>;
  27340. /**
  27341. * Stores the pre-calculated light information of a mesh in a texture.
  27342. */
  27343. protected _lightmapTexture: Nullable<BaseTexture>;
  27344. /**
  27345. * The color of a material in ambient lighting.
  27346. */
  27347. protected _ambientColor: Color3;
  27348. /**
  27349. * AKA Diffuse Color in other nomenclature.
  27350. */
  27351. protected _albedoColor: Color3;
  27352. /**
  27353. * AKA Specular Color in other nomenclature.
  27354. */
  27355. protected _reflectivityColor: Color3;
  27356. /**
  27357. * The color applied when light is reflected from a material.
  27358. */
  27359. protected _reflectionColor: Color3;
  27360. /**
  27361. * The color applied when light is emitted from a material.
  27362. */
  27363. protected _emissiveColor: Color3;
  27364. /**
  27365. * AKA Glossiness in other nomenclature.
  27366. */
  27367. protected _microSurface: number;
  27368. /**
  27369. * Specifies that the material will use the light map as a show map.
  27370. */
  27371. protected _useLightmapAsShadowmap: boolean;
  27372. /**
  27373. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27374. * makes the reflect vector face the model (under horizon).
  27375. */
  27376. protected _useHorizonOcclusion: boolean;
  27377. /**
  27378. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27379. * too much the area relying on ambient texture to define their ambient occlusion.
  27380. */
  27381. protected _useRadianceOcclusion: boolean;
  27382. /**
  27383. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27384. */
  27385. protected _useAlphaFromAlbedoTexture: boolean;
  27386. /**
  27387. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27388. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27389. */
  27390. protected _useSpecularOverAlpha: boolean;
  27391. /**
  27392. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27393. */
  27394. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27395. /**
  27396. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27397. */
  27398. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27399. /**
  27400. * Specifies if the metallic texture contains the roughness information in its green channel.
  27401. */
  27402. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27403. /**
  27404. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27405. */
  27406. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27407. /**
  27408. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27409. */
  27410. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27411. /**
  27412. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27413. */
  27414. protected _useAmbientInGrayScale: boolean;
  27415. /**
  27416. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27417. * The material will try to infer what glossiness each pixel should be.
  27418. */
  27419. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27420. /**
  27421. * Defines the falloff type used in this material.
  27422. * It by default is Physical.
  27423. */
  27424. protected _lightFalloff: number;
  27425. /**
  27426. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27427. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27428. */
  27429. protected _useRadianceOverAlpha: boolean;
  27430. /**
  27431. * Allows using an object space normal map (instead of tangent space).
  27432. */
  27433. protected _useObjectSpaceNormalMap: boolean;
  27434. /**
  27435. * Allows using the bump map in parallax mode.
  27436. */
  27437. protected _useParallax: boolean;
  27438. /**
  27439. * Allows using the bump map in parallax occlusion mode.
  27440. */
  27441. protected _useParallaxOcclusion: boolean;
  27442. /**
  27443. * Controls the scale bias of the parallax mode.
  27444. */
  27445. protected _parallaxScaleBias: number;
  27446. /**
  27447. * If sets to true, disables all the lights affecting the material.
  27448. */
  27449. protected _disableLighting: boolean;
  27450. /**
  27451. * Number of Simultaneous lights allowed on the material.
  27452. */
  27453. protected _maxSimultaneousLights: number;
  27454. /**
  27455. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27456. */
  27457. protected _invertNormalMapX: boolean;
  27458. /**
  27459. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27460. */
  27461. protected _invertNormalMapY: boolean;
  27462. /**
  27463. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27464. */
  27465. protected _twoSidedLighting: boolean;
  27466. /**
  27467. * Defines the alpha limits in alpha test mode.
  27468. */
  27469. protected _alphaCutOff: number;
  27470. /**
  27471. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27472. */
  27473. protected _forceAlphaTest: boolean;
  27474. /**
  27475. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27476. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27477. */
  27478. protected _useAlphaFresnel: boolean;
  27479. /**
  27480. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27481. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27482. */
  27483. protected _useLinearAlphaFresnel: boolean;
  27484. /**
  27485. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27486. * from cos thetav and roughness:
  27487. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27488. */
  27489. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27490. /**
  27491. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27492. */
  27493. protected _forceIrradianceInFragment: boolean;
  27494. private _realTimeFiltering;
  27495. /**
  27496. * Enables realtime filtering on the texture.
  27497. */
  27498. get realTimeFiltering(): boolean;
  27499. set realTimeFiltering(b: boolean);
  27500. private _realTimeFilteringQuality;
  27501. /**
  27502. * Quality switch for realtime filtering
  27503. */
  27504. get realTimeFilteringQuality(): number;
  27505. set realTimeFilteringQuality(n: number);
  27506. /**
  27507. * Can this material render to several textures at once
  27508. */
  27509. get canRenderToMRT(): boolean;
  27510. /**
  27511. * Force normal to face away from face.
  27512. */
  27513. protected _forceNormalForward: boolean;
  27514. /**
  27515. * Enables specular anti aliasing in the PBR shader.
  27516. * It will both interacts on the Geometry for analytical and IBL lighting.
  27517. * It also prefilter the roughness map based on the bump values.
  27518. */
  27519. protected _enableSpecularAntiAliasing: boolean;
  27520. /**
  27521. * Default configuration related to image processing available in the PBR Material.
  27522. */
  27523. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27524. /**
  27525. * Keep track of the image processing observer to allow dispose and replace.
  27526. */
  27527. private _imageProcessingObserver;
  27528. /**
  27529. * Attaches a new image processing configuration to the PBR Material.
  27530. * @param configuration
  27531. */
  27532. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27533. /**
  27534. * Stores the available render targets.
  27535. */
  27536. private _renderTargets;
  27537. /**
  27538. * Sets the global ambient color for the material used in lighting calculations.
  27539. */
  27540. private _globalAmbientColor;
  27541. /**
  27542. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27543. */
  27544. private _useLogarithmicDepth;
  27545. /**
  27546. * If set to true, no lighting calculations will be applied.
  27547. */
  27548. private _unlit;
  27549. private _debugMode;
  27550. /**
  27551. * @hidden
  27552. * This is reserved for the inspector.
  27553. * Defines the material debug mode.
  27554. * It helps seeing only some components of the material while troubleshooting.
  27555. */
  27556. debugMode: number;
  27557. /**
  27558. * @hidden
  27559. * This is reserved for the inspector.
  27560. * Specify from where on screen the debug mode should start.
  27561. * The value goes from -1 (full screen) to 1 (not visible)
  27562. * It helps with side by side comparison against the final render
  27563. * This defaults to -1
  27564. */
  27565. private debugLimit;
  27566. /**
  27567. * @hidden
  27568. * This is reserved for the inspector.
  27569. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27570. * You can use the factor to better multiply the final value.
  27571. */
  27572. private debugFactor;
  27573. /**
  27574. * Defines the clear coat layer parameters for the material.
  27575. */
  27576. readonly clearCoat: PBRClearCoatConfiguration;
  27577. /**
  27578. * Defines the anisotropic parameters for the material.
  27579. */
  27580. readonly anisotropy: PBRAnisotropicConfiguration;
  27581. /**
  27582. * Defines the BRDF parameters for the material.
  27583. */
  27584. readonly brdf: PBRBRDFConfiguration;
  27585. /**
  27586. * Defines the Sheen parameters for the material.
  27587. */
  27588. readonly sheen: PBRSheenConfiguration;
  27589. /**
  27590. * Defines the SubSurface parameters for the material.
  27591. */
  27592. readonly subSurface: PBRSubSurfaceConfiguration;
  27593. /**
  27594. * Defines additionnal PrePass parameters for the material.
  27595. */
  27596. readonly prePassConfiguration: PrePassConfiguration;
  27597. /**
  27598. * Defines the detail map parameters for the material.
  27599. */
  27600. readonly detailMap: DetailMapConfiguration;
  27601. protected _rebuildInParallel: boolean;
  27602. /**
  27603. * Instantiates a new PBRMaterial instance.
  27604. *
  27605. * @param name The material name
  27606. * @param scene The scene the material will be use in.
  27607. */
  27608. constructor(name: string, scene: Scene);
  27609. /**
  27610. * Gets a boolean indicating that current material needs to register RTT
  27611. */
  27612. get hasRenderTargetTextures(): boolean;
  27613. /**
  27614. * Gets the name of the material class.
  27615. */
  27616. getClassName(): string;
  27617. /**
  27618. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27619. */
  27620. get useLogarithmicDepth(): boolean;
  27621. /**
  27622. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27623. */
  27624. set useLogarithmicDepth(value: boolean);
  27625. /**
  27626. * Returns true if alpha blending should be disabled.
  27627. */
  27628. protected get _disableAlphaBlending(): boolean;
  27629. /**
  27630. * Specifies whether or not this material should be rendered in alpha blend mode.
  27631. */
  27632. needAlphaBlending(): boolean;
  27633. /**
  27634. * Specifies whether or not this material should be rendered in alpha test mode.
  27635. */
  27636. needAlphaTesting(): boolean;
  27637. /**
  27638. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27639. */
  27640. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27641. /**
  27642. * Gets the texture used for the alpha test.
  27643. */
  27644. getAlphaTestTexture(): Nullable<BaseTexture>;
  27645. /**
  27646. * Specifies that the submesh is ready to be used.
  27647. * @param mesh - BJS mesh.
  27648. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27649. * @param useInstances - Specifies that instances should be used.
  27650. * @returns - boolean indicating that the submesh is ready or not.
  27651. */
  27652. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27653. /**
  27654. * Specifies if the material uses metallic roughness workflow.
  27655. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27656. */
  27657. isMetallicWorkflow(): boolean;
  27658. private _prepareEffect;
  27659. private _prepareDefines;
  27660. /**
  27661. * Force shader compilation
  27662. */
  27663. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27664. /**
  27665. * Initializes the uniform buffer layout for the shader.
  27666. */
  27667. buildUniformLayout(): void;
  27668. /**
  27669. * Unbinds the material from the mesh
  27670. */
  27671. unbind(): void;
  27672. /**
  27673. * Binds the submesh data.
  27674. * @param world - The world matrix.
  27675. * @param mesh - The BJS mesh.
  27676. * @param subMesh - A submesh of the BJS mesh.
  27677. */
  27678. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27679. /**
  27680. * Returns the animatable textures.
  27681. * @returns - Array of animatable textures.
  27682. */
  27683. getAnimatables(): IAnimatable[];
  27684. /**
  27685. * Returns the texture used for reflections.
  27686. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27687. */
  27688. private _getReflectionTexture;
  27689. /**
  27690. * Returns an array of the actively used textures.
  27691. * @returns - Array of BaseTextures
  27692. */
  27693. getActiveTextures(): BaseTexture[];
  27694. /**
  27695. * Checks to see if a texture is used in the material.
  27696. * @param texture - Base texture to use.
  27697. * @returns - Boolean specifying if a texture is used in the material.
  27698. */
  27699. hasTexture(texture: BaseTexture): boolean;
  27700. /**
  27701. * Sets the required values to the prepass renderer.
  27702. * @param prePassRenderer defines the prepass renderer to setup
  27703. */
  27704. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27705. /**
  27706. * Disposes the resources of the material.
  27707. * @param forceDisposeEffect - Forces the disposal of effects.
  27708. * @param forceDisposeTextures - Forces the disposal of all textures.
  27709. */
  27710. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27711. }
  27712. }
  27713. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  27714. import { Nullable } from "babylonjs/types";
  27715. import { Scene } from "babylonjs/scene";
  27716. import { Color3 } from "babylonjs/Maths/math.color";
  27717. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  27718. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27719. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27720. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  27721. /**
  27722. * The Physically based material of BJS.
  27723. *
  27724. * This offers the main features of a standard PBR material.
  27725. * For more information, please refer to the documentation :
  27726. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27727. */
  27728. export class PBRMaterial extends PBRBaseMaterial {
  27729. /**
  27730. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27731. */
  27732. static readonly PBRMATERIAL_OPAQUE: number;
  27733. /**
  27734. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27735. */
  27736. static readonly PBRMATERIAL_ALPHATEST: number;
  27737. /**
  27738. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27739. */
  27740. static readonly PBRMATERIAL_ALPHABLEND: number;
  27741. /**
  27742. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27743. * They are also discarded below the alpha cutoff threshold to improve performances.
  27744. */
  27745. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27746. /**
  27747. * Defines the default value of how much AO map is occluding the analytical lights
  27748. * (point spot...).
  27749. */
  27750. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27751. /**
  27752. * Intensity of the direct lights e.g. the four lights available in your scene.
  27753. * This impacts both the direct diffuse and specular highlights.
  27754. */
  27755. directIntensity: number;
  27756. /**
  27757. * Intensity of the emissive part of the material.
  27758. * This helps controlling the emissive effect without modifying the emissive color.
  27759. */
  27760. emissiveIntensity: number;
  27761. /**
  27762. * Intensity of the environment e.g. how much the environment will light the object
  27763. * either through harmonics for rough material or through the refelction for shiny ones.
  27764. */
  27765. environmentIntensity: number;
  27766. /**
  27767. * This is a special control allowing the reduction of the specular highlights coming from the
  27768. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27769. */
  27770. specularIntensity: number;
  27771. /**
  27772. * Debug Control allowing disabling the bump map on this material.
  27773. */
  27774. disableBumpMap: boolean;
  27775. /**
  27776. * AKA Diffuse Texture in standard nomenclature.
  27777. */
  27778. albedoTexture: BaseTexture;
  27779. /**
  27780. * AKA Occlusion Texture in other nomenclature.
  27781. */
  27782. ambientTexture: BaseTexture;
  27783. /**
  27784. * AKA Occlusion Texture Intensity in other nomenclature.
  27785. */
  27786. ambientTextureStrength: number;
  27787. /**
  27788. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27789. * 1 means it completely occludes it
  27790. * 0 mean it has no impact
  27791. */
  27792. ambientTextureImpactOnAnalyticalLights: number;
  27793. /**
  27794. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27795. */
  27796. opacityTexture: BaseTexture;
  27797. /**
  27798. * Stores the reflection values in a texture.
  27799. */
  27800. reflectionTexture: Nullable<BaseTexture>;
  27801. /**
  27802. * Stores the emissive values in a texture.
  27803. */
  27804. emissiveTexture: BaseTexture;
  27805. /**
  27806. * AKA Specular texture in other nomenclature.
  27807. */
  27808. reflectivityTexture: BaseTexture;
  27809. /**
  27810. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27811. */
  27812. metallicTexture: BaseTexture;
  27813. /**
  27814. * Specifies the metallic scalar of the metallic/roughness workflow.
  27815. * Can also be used to scale the metalness values of the metallic texture.
  27816. */
  27817. metallic: Nullable<number>;
  27818. /**
  27819. * Specifies the roughness scalar of the metallic/roughness workflow.
  27820. * Can also be used to scale the roughness values of the metallic texture.
  27821. */
  27822. roughness: Nullable<number>;
  27823. /**
  27824. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27825. * By default the indexOfrefraction is used to compute F0;
  27826. *
  27827. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27828. *
  27829. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27830. * F90 = metallicReflectanceColor;
  27831. */
  27832. metallicF0Factor: number;
  27833. /**
  27834. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27835. * By default the F90 is always 1;
  27836. *
  27837. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27838. *
  27839. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27840. * F90 = metallicReflectanceColor;
  27841. */
  27842. metallicReflectanceColor: Color3;
  27843. /**
  27844. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27845. * This is multiply against the scalar values defined in the material.
  27846. */
  27847. metallicReflectanceTexture: Nullable<BaseTexture>;
  27848. /**
  27849. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27850. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27851. */
  27852. microSurfaceTexture: BaseTexture;
  27853. /**
  27854. * Stores surface normal data used to displace a mesh in a texture.
  27855. */
  27856. bumpTexture: BaseTexture;
  27857. /**
  27858. * Stores the pre-calculated light information of a mesh in a texture.
  27859. */
  27860. lightmapTexture: BaseTexture;
  27861. /**
  27862. * Stores the refracted light information in a texture.
  27863. */
  27864. get refractionTexture(): Nullable<BaseTexture>;
  27865. set refractionTexture(value: Nullable<BaseTexture>);
  27866. /**
  27867. * The color of a material in ambient lighting.
  27868. */
  27869. ambientColor: Color3;
  27870. /**
  27871. * AKA Diffuse Color in other nomenclature.
  27872. */
  27873. albedoColor: Color3;
  27874. /**
  27875. * AKA Specular Color in other nomenclature.
  27876. */
  27877. reflectivityColor: Color3;
  27878. /**
  27879. * The color reflected from the material.
  27880. */
  27881. reflectionColor: Color3;
  27882. /**
  27883. * The color emitted from the material.
  27884. */
  27885. emissiveColor: Color3;
  27886. /**
  27887. * AKA Glossiness in other nomenclature.
  27888. */
  27889. microSurface: number;
  27890. /**
  27891. * Index of refraction of the material base layer.
  27892. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27893. *
  27894. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27895. *
  27896. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27897. */
  27898. get indexOfRefraction(): number;
  27899. set indexOfRefraction(value: number);
  27900. /**
  27901. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27902. */
  27903. get invertRefractionY(): boolean;
  27904. set invertRefractionY(value: boolean);
  27905. /**
  27906. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27907. * Materials half opaque for instance using refraction could benefit from this control.
  27908. */
  27909. get linkRefractionWithTransparency(): boolean;
  27910. set linkRefractionWithTransparency(value: boolean);
  27911. /**
  27912. * If true, the light map contains occlusion information instead of lighting info.
  27913. */
  27914. useLightmapAsShadowmap: boolean;
  27915. /**
  27916. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27917. */
  27918. useAlphaFromAlbedoTexture: boolean;
  27919. /**
  27920. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27921. */
  27922. forceAlphaTest: boolean;
  27923. /**
  27924. * Defines the alpha limits in alpha test mode.
  27925. */
  27926. alphaCutOff: number;
  27927. /**
  27928. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27929. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27930. */
  27931. useSpecularOverAlpha: boolean;
  27932. /**
  27933. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27934. */
  27935. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27936. /**
  27937. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27938. */
  27939. useRoughnessFromMetallicTextureAlpha: boolean;
  27940. /**
  27941. * Specifies if the metallic texture contains the roughness information in its green channel.
  27942. */
  27943. useRoughnessFromMetallicTextureGreen: boolean;
  27944. /**
  27945. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27946. */
  27947. useMetallnessFromMetallicTextureBlue: boolean;
  27948. /**
  27949. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27950. */
  27951. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27952. /**
  27953. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27954. */
  27955. useAmbientInGrayScale: boolean;
  27956. /**
  27957. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27958. * The material will try to infer what glossiness each pixel should be.
  27959. */
  27960. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27961. /**
  27962. * BJS is using an harcoded light falloff based on a manually sets up range.
  27963. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27964. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27965. */
  27966. get usePhysicalLightFalloff(): boolean;
  27967. /**
  27968. * BJS is using an harcoded light falloff based on a manually sets up range.
  27969. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27970. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27971. */
  27972. set usePhysicalLightFalloff(value: boolean);
  27973. /**
  27974. * In order to support the falloff compatibility with gltf, a special mode has been added
  27975. * to reproduce the gltf light falloff.
  27976. */
  27977. get useGLTFLightFalloff(): boolean;
  27978. /**
  27979. * In order to support the falloff compatibility with gltf, a special mode has been added
  27980. * to reproduce the gltf light falloff.
  27981. */
  27982. set useGLTFLightFalloff(value: boolean);
  27983. /**
  27984. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27985. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27986. */
  27987. useRadianceOverAlpha: boolean;
  27988. /**
  27989. * Allows using an object space normal map (instead of tangent space).
  27990. */
  27991. useObjectSpaceNormalMap: boolean;
  27992. /**
  27993. * Allows using the bump map in parallax mode.
  27994. */
  27995. useParallax: boolean;
  27996. /**
  27997. * Allows using the bump map in parallax occlusion mode.
  27998. */
  27999. useParallaxOcclusion: boolean;
  28000. /**
  28001. * Controls the scale bias of the parallax mode.
  28002. */
  28003. parallaxScaleBias: number;
  28004. /**
  28005. * If sets to true, disables all the lights affecting the material.
  28006. */
  28007. disableLighting: boolean;
  28008. /**
  28009. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  28010. */
  28011. forceIrradianceInFragment: boolean;
  28012. /**
  28013. * Number of Simultaneous lights allowed on the material.
  28014. */
  28015. maxSimultaneousLights: number;
  28016. /**
  28017. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28018. */
  28019. invertNormalMapX: boolean;
  28020. /**
  28021. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28022. */
  28023. invertNormalMapY: boolean;
  28024. /**
  28025. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28026. */
  28027. twoSidedLighting: boolean;
  28028. /**
  28029. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28030. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  28031. */
  28032. useAlphaFresnel: boolean;
  28033. /**
  28034. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28035. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  28036. */
  28037. useLinearAlphaFresnel: boolean;
  28038. /**
  28039. * Let user defines the brdf lookup texture used for IBL.
  28040. * A default 8bit version is embedded but you could point at :
  28041. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  28042. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  28043. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  28044. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  28045. */
  28046. environmentBRDFTexture: Nullable<BaseTexture>;
  28047. /**
  28048. * Force normal to face away from face.
  28049. */
  28050. forceNormalForward: boolean;
  28051. /**
  28052. * Enables specular anti aliasing in the PBR shader.
  28053. * It will both interacts on the Geometry for analytical and IBL lighting.
  28054. * It also prefilter the roughness map based on the bump values.
  28055. */
  28056. enableSpecularAntiAliasing: boolean;
  28057. /**
  28058. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28059. * makes the reflect vector face the model (under horizon).
  28060. */
  28061. useHorizonOcclusion: boolean;
  28062. /**
  28063. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28064. * too much the area relying on ambient texture to define their ambient occlusion.
  28065. */
  28066. useRadianceOcclusion: boolean;
  28067. /**
  28068. * If set to true, no lighting calculations will be applied.
  28069. */
  28070. unlit: boolean;
  28071. /**
  28072. * Gets the image processing configuration used either in this material.
  28073. */
  28074. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28075. /**
  28076. * Sets the Default image processing configuration used either in the this material.
  28077. *
  28078. * If sets to null, the scene one is in use.
  28079. */
  28080. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28081. /**
  28082. * Gets wether the color curves effect is enabled.
  28083. */
  28084. get cameraColorCurvesEnabled(): boolean;
  28085. /**
  28086. * Sets wether the color curves effect is enabled.
  28087. */
  28088. set cameraColorCurvesEnabled(value: boolean);
  28089. /**
  28090. * Gets wether the color grading effect is enabled.
  28091. */
  28092. get cameraColorGradingEnabled(): boolean;
  28093. /**
  28094. * Gets wether the color grading effect is enabled.
  28095. */
  28096. set cameraColorGradingEnabled(value: boolean);
  28097. /**
  28098. * Gets wether tonemapping is enabled or not.
  28099. */
  28100. get cameraToneMappingEnabled(): boolean;
  28101. /**
  28102. * Sets wether tonemapping is enabled or not
  28103. */
  28104. set cameraToneMappingEnabled(value: boolean);
  28105. /**
  28106. * The camera exposure used on this material.
  28107. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28108. * This corresponds to a photographic exposure.
  28109. */
  28110. get cameraExposure(): number;
  28111. /**
  28112. * The camera exposure used on this material.
  28113. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28114. * This corresponds to a photographic exposure.
  28115. */
  28116. set cameraExposure(value: number);
  28117. /**
  28118. * Gets The camera contrast used on this material.
  28119. */
  28120. get cameraContrast(): number;
  28121. /**
  28122. * Sets The camera contrast used on this material.
  28123. */
  28124. set cameraContrast(value: number);
  28125. /**
  28126. * Gets the Color Grading 2D Lookup Texture.
  28127. */
  28128. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28129. /**
  28130. * Sets the Color Grading 2D Lookup Texture.
  28131. */
  28132. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28133. /**
  28134. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28135. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28136. * 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;
  28137. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28138. */
  28139. get cameraColorCurves(): Nullable<ColorCurves>;
  28140. /**
  28141. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28142. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28143. * 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;
  28144. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28145. */
  28146. set cameraColorCurves(value: Nullable<ColorCurves>);
  28147. /**
  28148. * Instantiates a new PBRMaterial instance.
  28149. *
  28150. * @param name The material name
  28151. * @param scene The scene the material will be use in.
  28152. */
  28153. constructor(name: string, scene: Scene);
  28154. /**
  28155. * Returns the name of this material class.
  28156. */
  28157. getClassName(): string;
  28158. /**
  28159. * Makes a duplicate of the current material.
  28160. * @param name - name to use for the new material.
  28161. */
  28162. clone(name: string): PBRMaterial;
  28163. /**
  28164. * Serializes this PBR Material.
  28165. * @returns - An object with the serialized material.
  28166. */
  28167. serialize(): any;
  28168. /**
  28169. * Parses a PBR Material from a serialized object.
  28170. * @param source - Serialized object.
  28171. * @param scene - BJS scene instance.
  28172. * @param rootUrl - url for the scene object
  28173. * @returns - PBRMaterial
  28174. */
  28175. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28176. }
  28177. }
  28178. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28179. /** @hidden */
  28180. export var mrtFragmentDeclaration: {
  28181. name: string;
  28182. shader: string;
  28183. };
  28184. }
  28185. declare module "babylonjs/Shaders/geometry.fragment" {
  28186. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28187. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28188. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28189. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28190. /** @hidden */
  28191. export var geometryPixelShader: {
  28192. name: string;
  28193. shader: string;
  28194. };
  28195. }
  28196. declare module "babylonjs/Shaders/geometry.vertex" {
  28197. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28198. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28199. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28200. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28201. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28202. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28203. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28204. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28205. /** @hidden */
  28206. export var geometryVertexShader: {
  28207. name: string;
  28208. shader: string;
  28209. };
  28210. }
  28211. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28212. import { Matrix } from "babylonjs/Maths/math.vector";
  28213. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28214. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28215. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28216. import { Effect } from "babylonjs/Materials/effect";
  28217. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28218. import { Scene } from "babylonjs/scene";
  28219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28220. import { Nullable } from "babylonjs/types";
  28221. import "babylonjs/Shaders/geometry.fragment";
  28222. import "babylonjs/Shaders/geometry.vertex";
  28223. /** @hidden */
  28224. interface ISavedTransformationMatrix {
  28225. world: Matrix;
  28226. viewProjection: Matrix;
  28227. }
  28228. /**
  28229. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28230. */
  28231. export class GeometryBufferRenderer {
  28232. /**
  28233. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28234. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28235. */
  28236. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28237. /**
  28238. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28239. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28240. */
  28241. static readonly POSITION_TEXTURE_TYPE: number;
  28242. /**
  28243. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28244. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28245. */
  28246. static readonly VELOCITY_TEXTURE_TYPE: number;
  28247. /**
  28248. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28249. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28250. */
  28251. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28252. /**
  28253. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28254. * in order to compute objects velocities when enableVelocity is set to "true"
  28255. * @hidden
  28256. */
  28257. _previousTransformationMatrices: {
  28258. [index: number]: ISavedTransformationMatrix;
  28259. };
  28260. /**
  28261. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28262. * in order to compute objects velocities when enableVelocity is set to "true"
  28263. * @hidden
  28264. */
  28265. _previousBonesTransformationMatrices: {
  28266. [index: number]: Float32Array;
  28267. };
  28268. /**
  28269. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28270. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28271. */
  28272. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28273. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28274. renderTransparentMeshes: boolean;
  28275. private _scene;
  28276. private _resizeObserver;
  28277. private _multiRenderTarget;
  28278. private _ratio;
  28279. private _enablePosition;
  28280. private _enableVelocity;
  28281. private _enableReflectivity;
  28282. private _positionIndex;
  28283. private _velocityIndex;
  28284. private _reflectivityIndex;
  28285. private _depthNormalIndex;
  28286. private _linkedWithPrePass;
  28287. private _prePassRenderer;
  28288. private _attachments;
  28289. protected _effect: Effect;
  28290. protected _cachedDefines: string;
  28291. /**
  28292. * @hidden
  28293. * Sets up internal structures to share outputs with PrePassRenderer
  28294. * This method should only be called by the PrePassRenderer itself
  28295. */
  28296. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28297. /**
  28298. * @hidden
  28299. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28300. * This method should only be called by the PrePassRenderer itself
  28301. */
  28302. _unlinkPrePassRenderer(): void;
  28303. /**
  28304. * @hidden
  28305. * Resets the geometry buffer layout
  28306. */
  28307. _resetLayout(): void;
  28308. /**
  28309. * @hidden
  28310. * Replaces a texture in the geometry buffer renderer
  28311. * Useful when linking textures of the prepass renderer
  28312. */
  28313. _forceTextureType(geometryBufferType: number, index: number): void;
  28314. /**
  28315. * @hidden
  28316. * Sets texture attachments
  28317. * Useful when linking textures of the prepass renderer
  28318. */
  28319. _setAttachments(attachments: number[]): void;
  28320. /**
  28321. * @hidden
  28322. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28323. * Useful when linking textures of the prepass renderer
  28324. */
  28325. _linkInternalTexture(internalTexture: InternalTexture): void;
  28326. /**
  28327. * Gets the render list (meshes to be rendered) used in the G buffer.
  28328. */
  28329. get renderList(): Nullable<AbstractMesh[]>;
  28330. /**
  28331. * Set the render list (meshes to be rendered) used in the G buffer.
  28332. */
  28333. set renderList(meshes: Nullable<AbstractMesh[]>);
  28334. /**
  28335. * Gets wether or not G buffer are supported by the running hardware.
  28336. * This requires draw buffer supports
  28337. */
  28338. get isSupported(): boolean;
  28339. /**
  28340. * Returns the index of the given texture type in the G-Buffer textures array
  28341. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28342. * @returns the index of the given texture type in the G-Buffer textures array
  28343. */
  28344. getTextureIndex(textureType: number): number;
  28345. /**
  28346. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28347. */
  28348. get enablePosition(): boolean;
  28349. /**
  28350. * Sets whether or not objects positions are enabled for the G buffer.
  28351. */
  28352. set enablePosition(enable: boolean);
  28353. /**
  28354. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28355. */
  28356. get enableVelocity(): boolean;
  28357. /**
  28358. * Sets wether or not objects velocities are enabled for the G buffer.
  28359. */
  28360. set enableVelocity(enable: boolean);
  28361. /**
  28362. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28363. */
  28364. get enableReflectivity(): boolean;
  28365. /**
  28366. * Sets wether or not objects roughness are enabled for the G buffer.
  28367. */
  28368. set enableReflectivity(enable: boolean);
  28369. /**
  28370. * Gets the scene associated with the buffer.
  28371. */
  28372. get scene(): Scene;
  28373. /**
  28374. * Gets the ratio used by the buffer during its creation.
  28375. * How big is the buffer related to the main canvas.
  28376. */
  28377. get ratio(): number;
  28378. /** @hidden */
  28379. static _SceneComponentInitialization: (scene: Scene) => void;
  28380. /**
  28381. * Creates a new G Buffer for the scene
  28382. * @param scene The scene the buffer belongs to
  28383. * @param ratio How big is the buffer related to the main canvas.
  28384. */
  28385. constructor(scene: Scene, ratio?: number);
  28386. /**
  28387. * Checks wether everything is ready to render a submesh to the G buffer.
  28388. * @param subMesh the submesh to check readiness for
  28389. * @param useInstances is the mesh drawn using instance or not
  28390. * @returns true if ready otherwise false
  28391. */
  28392. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28393. /**
  28394. * Gets the current underlying G Buffer.
  28395. * @returns the buffer
  28396. */
  28397. getGBuffer(): MultiRenderTarget;
  28398. /**
  28399. * Gets the number of samples used to render the buffer (anti aliasing).
  28400. */
  28401. get samples(): number;
  28402. /**
  28403. * Sets the number of samples used to render the buffer (anti aliasing).
  28404. */
  28405. set samples(value: number);
  28406. /**
  28407. * Disposes the renderer and frees up associated resources.
  28408. */
  28409. dispose(): void;
  28410. private _assignRenderTargetIndices;
  28411. protected _createRenderTargets(): void;
  28412. private _copyBonesTransformationMatrices;
  28413. }
  28414. }
  28415. declare module "babylonjs/Rendering/prePassRenderer" {
  28416. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28417. import { Scene } from "babylonjs/scene";
  28418. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28419. import { Effect } from "babylonjs/Materials/effect";
  28420. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28422. import { Material } from "babylonjs/Materials/material";
  28423. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28424. /**
  28425. * Renders a pre pass of the scene
  28426. * This means every mesh in the scene will be rendered to a render target texture
  28427. * And then this texture will be composited to the rendering canvas with post processes
  28428. * It is necessary for effects like subsurface scattering or deferred shading
  28429. */
  28430. export class PrePassRenderer {
  28431. /** @hidden */
  28432. static _SceneComponentInitialization: (scene: Scene) => void;
  28433. private _textureFormats;
  28434. /**
  28435. * To save performance, we can excluded skinned meshes from the prepass
  28436. */
  28437. excludedSkinnedMesh: AbstractMesh[];
  28438. /**
  28439. * Force material to be excluded from the prepass
  28440. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28441. * and you don't want a material to show in the effect.
  28442. */
  28443. excludedMaterials: Material[];
  28444. private _textureIndices;
  28445. private _scene;
  28446. private _engine;
  28447. private _isDirty;
  28448. /**
  28449. * Number of textures in the multi render target texture where the scene is directly rendered
  28450. */
  28451. mrtCount: number;
  28452. /**
  28453. * The render target where the scene is directly rendered
  28454. */
  28455. prePassRT: MultiRenderTarget;
  28456. private _multiRenderAttachments;
  28457. private _defaultAttachments;
  28458. private _clearAttachments;
  28459. private _postProcesses;
  28460. private readonly _clearColor;
  28461. /**
  28462. * Image processing post process for composition
  28463. */
  28464. imageProcessingPostProcess: ImageProcessingPostProcess;
  28465. /**
  28466. * Configuration for prepass effects
  28467. */
  28468. private _effectConfigurations;
  28469. private _mrtFormats;
  28470. private _mrtLayout;
  28471. private _enabled;
  28472. /**
  28473. * Indicates if the prepass is enabled
  28474. */
  28475. get enabled(): boolean;
  28476. /**
  28477. * How many samples are used for MSAA of the scene render target
  28478. */
  28479. get samples(): number;
  28480. set samples(n: number);
  28481. private _geometryBuffer;
  28482. private _useGeometryBufferFallback;
  28483. /**
  28484. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28485. */
  28486. get useGeometryBufferFallback(): boolean;
  28487. set useGeometryBufferFallback(value: boolean);
  28488. /**
  28489. * Instanciates a prepass renderer
  28490. * @param scene The scene
  28491. */
  28492. constructor(scene: Scene);
  28493. private _initializeAttachments;
  28494. private _createCompositionEffect;
  28495. /**
  28496. * Indicates if rendering a prepass is supported
  28497. */
  28498. get isSupported(): boolean;
  28499. /**
  28500. * Sets the proper output textures to draw in the engine.
  28501. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28502. * @param subMesh Submesh on which the effect is applied
  28503. */
  28504. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28505. /**
  28506. * @hidden
  28507. */
  28508. _beforeCameraDraw(): void;
  28509. /**
  28510. * @hidden
  28511. */
  28512. _afterCameraDraw(): void;
  28513. private _checkRTSize;
  28514. private _bindFrameBuffer;
  28515. /**
  28516. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28517. */
  28518. clear(): void;
  28519. private _setState;
  28520. private _updateGeometryBufferLayout;
  28521. /**
  28522. * Adds an effect configuration to the prepass.
  28523. * If an effect has already been added, it won't add it twice and will return the configuration
  28524. * already present.
  28525. * @param cfg the effect configuration
  28526. * @return the effect configuration now used by the prepass
  28527. */
  28528. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28529. /**
  28530. * Returns the index of a texture in the multi render target texture array.
  28531. * @param type Texture type
  28532. * @return The index
  28533. */
  28534. getIndex(type: number): number;
  28535. private _enable;
  28536. private _disable;
  28537. private _resetLayout;
  28538. private _resetPostProcessChain;
  28539. private _bindPostProcessChain;
  28540. /**
  28541. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28542. */
  28543. markAsDirty(): void;
  28544. /**
  28545. * Enables a texture on the MultiRenderTarget for prepass
  28546. */
  28547. private _enableTextures;
  28548. private _update;
  28549. private _markAllMaterialsAsPrePassDirty;
  28550. /**
  28551. * Disposes the prepass renderer.
  28552. */
  28553. dispose(): void;
  28554. }
  28555. }
  28556. declare module "babylonjs/PostProcesses/postProcess" {
  28557. import { Nullable } from "babylonjs/types";
  28558. import { SmartArray } from "babylonjs/Misc/smartArray";
  28559. import { Observable } from "babylonjs/Misc/observable";
  28560. import { Vector2 } from "babylonjs/Maths/math.vector";
  28561. import { Camera } from "babylonjs/Cameras/camera";
  28562. import { Effect } from "babylonjs/Materials/effect";
  28563. import "babylonjs/Shaders/postprocess.vertex";
  28564. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28565. import { Engine } from "babylonjs/Engines/engine";
  28566. import { Color4 } from "babylonjs/Maths/math.color";
  28567. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28568. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28569. import { Scene } from "babylonjs/scene";
  28570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28571. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28572. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28573. /**
  28574. * Size options for a post process
  28575. */
  28576. export type PostProcessOptions = {
  28577. width: number;
  28578. height: number;
  28579. };
  28580. /**
  28581. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28582. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28583. */
  28584. export class PostProcess {
  28585. /**
  28586. * Gets or sets the unique id of the post process
  28587. */
  28588. uniqueId: number;
  28589. /** Name of the PostProcess. */
  28590. name: string;
  28591. /**
  28592. * Width of the texture to apply the post process on
  28593. */
  28594. width: number;
  28595. /**
  28596. * Height of the texture to apply the post process on
  28597. */
  28598. height: number;
  28599. /**
  28600. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28601. */
  28602. nodeMaterialSource: Nullable<NodeMaterial>;
  28603. /**
  28604. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28605. * @hidden
  28606. */
  28607. _outputTexture: Nullable<InternalTexture>;
  28608. /**
  28609. * Sampling mode used by the shader
  28610. * See https://doc.babylonjs.com/classes/3.1/texture
  28611. */
  28612. renderTargetSamplingMode: number;
  28613. /**
  28614. * Clear color to use when screen clearing
  28615. */
  28616. clearColor: Color4;
  28617. /**
  28618. * If the buffer needs to be cleared before applying the post process. (default: true)
  28619. * Should be set to false if shader will overwrite all previous pixels.
  28620. */
  28621. autoClear: boolean;
  28622. /**
  28623. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28624. */
  28625. alphaMode: number;
  28626. /**
  28627. * Sets the setAlphaBlendConstants of the babylon engine
  28628. */
  28629. alphaConstants: Color4;
  28630. /**
  28631. * Animations to be used for the post processing
  28632. */
  28633. animations: import("babylonjs/Animations/animation").Animation[];
  28634. /**
  28635. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28636. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28637. */
  28638. enablePixelPerfectMode: boolean;
  28639. /**
  28640. * Force the postprocess to be applied without taking in account viewport
  28641. */
  28642. forceFullscreenViewport: boolean;
  28643. /**
  28644. * List of inspectable custom properties (used by the Inspector)
  28645. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28646. */
  28647. inspectableCustomProperties: IInspectable[];
  28648. /**
  28649. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28650. *
  28651. * | Value | Type | Description |
  28652. * | ----- | ----------------------------------- | ----------- |
  28653. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28654. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28655. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28656. *
  28657. */
  28658. scaleMode: number;
  28659. /**
  28660. * Force textures to be a power of two (default: false)
  28661. */
  28662. alwaysForcePOT: boolean;
  28663. private _samples;
  28664. /**
  28665. * Number of sample textures (default: 1)
  28666. */
  28667. get samples(): number;
  28668. set samples(n: number);
  28669. /**
  28670. * Modify the scale of the post process to be the same as the viewport (default: false)
  28671. */
  28672. adaptScaleToCurrentViewport: boolean;
  28673. private _camera;
  28674. protected _scene: Scene;
  28675. private _engine;
  28676. private _options;
  28677. private _reusable;
  28678. private _textureType;
  28679. private _textureFormat;
  28680. /**
  28681. * Smart array of input and output textures for the post process.
  28682. * @hidden
  28683. */
  28684. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28685. /**
  28686. * The index in _textures that corresponds to the output texture.
  28687. * @hidden
  28688. */
  28689. _currentRenderTextureInd: number;
  28690. private _effect;
  28691. private _samplers;
  28692. private _fragmentUrl;
  28693. private _vertexUrl;
  28694. private _parameters;
  28695. private _scaleRatio;
  28696. protected _indexParameters: any;
  28697. private _shareOutputWithPostProcess;
  28698. private _texelSize;
  28699. private _forcedOutputTexture;
  28700. /**
  28701. * Prepass configuration in case this post process needs a texture from prepass
  28702. * @hidden
  28703. */
  28704. _prePassEffectConfiguration: PrePassEffectConfiguration;
  28705. /**
  28706. * Returns the fragment url or shader name used in the post process.
  28707. * @returns the fragment url or name in the shader store.
  28708. */
  28709. getEffectName(): string;
  28710. /**
  28711. * An event triggered when the postprocess is activated.
  28712. */
  28713. onActivateObservable: Observable<Camera>;
  28714. private _onActivateObserver;
  28715. /**
  28716. * A function that is added to the onActivateObservable
  28717. */
  28718. set onActivate(callback: Nullable<(camera: Camera) => void>);
  28719. /**
  28720. * An event triggered when the postprocess changes its size.
  28721. */
  28722. onSizeChangedObservable: Observable<PostProcess>;
  28723. private _onSizeChangedObserver;
  28724. /**
  28725. * A function that is added to the onSizeChangedObservable
  28726. */
  28727. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  28728. /**
  28729. * An event triggered when the postprocess applies its effect.
  28730. */
  28731. onApplyObservable: Observable<Effect>;
  28732. private _onApplyObserver;
  28733. /**
  28734. * A function that is added to the onApplyObservable
  28735. */
  28736. set onApply(callback: (effect: Effect) => void);
  28737. /**
  28738. * An event triggered before rendering the postprocess
  28739. */
  28740. onBeforeRenderObservable: Observable<Effect>;
  28741. private _onBeforeRenderObserver;
  28742. /**
  28743. * A function that is added to the onBeforeRenderObservable
  28744. */
  28745. set onBeforeRender(callback: (effect: Effect) => void);
  28746. /**
  28747. * An event triggered after rendering the postprocess
  28748. */
  28749. onAfterRenderObservable: Observable<Effect>;
  28750. private _onAfterRenderObserver;
  28751. /**
  28752. * A function that is added to the onAfterRenderObservable
  28753. */
  28754. set onAfterRender(callback: (efect: Effect) => void);
  28755. /**
  28756. * 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
  28757. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28758. */
  28759. get inputTexture(): InternalTexture;
  28760. set inputTexture(value: InternalTexture);
  28761. /**
  28762. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  28763. * the only way to unset it is to use this function to restore its internal state
  28764. */
  28765. restoreDefaultInputTexture(): void;
  28766. /**
  28767. * Gets the camera which post process is applied to.
  28768. * @returns The camera the post process is applied to.
  28769. */
  28770. getCamera(): Camera;
  28771. /**
  28772. * Gets the texel size of the postprocess.
  28773. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28774. */
  28775. get texelSize(): Vector2;
  28776. /**
  28777. * Creates a new instance PostProcess
  28778. * @param name The name of the PostProcess.
  28779. * @param fragmentUrl The url of the fragment shader to be used.
  28780. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28781. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28782. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28783. * @param camera The camera to apply the render pass to.
  28784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28785. * @param engine The engine which the post process will be applied. (default: current engine)
  28786. * @param reusable If the post process can be reused on the same frame. (default: false)
  28787. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28788. * @param textureType Type of textures used when performing the post process. (default: 0)
  28789. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28790. * @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
  28791. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  28792. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  28793. */
  28794. 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);
  28795. /**
  28796. * Gets a string identifying the name of the class
  28797. * @returns "PostProcess" string
  28798. */
  28799. getClassName(): string;
  28800. /**
  28801. * Gets the engine which this post process belongs to.
  28802. * @returns The engine the post process was enabled with.
  28803. */
  28804. getEngine(): Engine;
  28805. /**
  28806. * The effect that is created when initializing the post process.
  28807. * @returns The created effect corresponding the the postprocess.
  28808. */
  28809. getEffect(): Effect;
  28810. /**
  28811. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28812. * @param postProcess The post process to share the output with.
  28813. * @returns This post process.
  28814. */
  28815. shareOutputWith(postProcess: PostProcess): PostProcess;
  28816. /**
  28817. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28818. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28819. */
  28820. useOwnOutput(): void;
  28821. /**
  28822. * Updates the effect with the current post process compile time values and recompiles the shader.
  28823. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28824. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28825. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28826. * @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
  28827. * @param onCompiled Called when the shader has been compiled.
  28828. * @param onError Called if there is an error when compiling a shader.
  28829. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28830. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28831. */
  28832. 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;
  28833. /**
  28834. * The post process is reusable if it can be used multiple times within one frame.
  28835. * @returns If the post process is reusable
  28836. */
  28837. isReusable(): boolean;
  28838. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28839. markTextureDirty(): void;
  28840. /**
  28841. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28842. * 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.
  28843. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28844. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28845. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28846. * @returns The target texture that was bound to be written to.
  28847. */
  28848. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28849. /**
  28850. * If the post process is supported.
  28851. */
  28852. get isSupported(): boolean;
  28853. /**
  28854. * The aspect ratio of the output texture.
  28855. */
  28856. get aspectRatio(): number;
  28857. /**
  28858. * Get a value indicating if the post-process is ready to be used
  28859. * @returns true if the post-process is ready (shader is compiled)
  28860. */
  28861. isReady(): boolean;
  28862. /**
  28863. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28864. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28865. */
  28866. apply(): Nullable<Effect>;
  28867. private _disposeTextures;
  28868. /**
  28869. * Sets the required values to the prepass renderer.
  28870. * @param prePassRenderer defines the prepass renderer to setup.
  28871. * @returns true if the pre pass is needed.
  28872. */
  28873. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28874. /**
  28875. * Disposes the post process.
  28876. * @param camera The camera to dispose the post process on.
  28877. */
  28878. dispose(camera?: Camera): void;
  28879. /**
  28880. * Serializes the particle system to a JSON object
  28881. * @returns the JSON object
  28882. */
  28883. serialize(): any;
  28884. /**
  28885. * Creates a material from parsed material data
  28886. * @param parsedPostProcess defines parsed post process data
  28887. * @param scene defines the hosting scene
  28888. * @param rootUrl defines the root URL to use to load textures
  28889. * @returns a new post process
  28890. */
  28891. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28892. }
  28893. }
  28894. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  28895. /** @hidden */
  28896. export var kernelBlurVaryingDeclaration: {
  28897. name: string;
  28898. shader: string;
  28899. };
  28900. }
  28901. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  28902. /** @hidden */
  28903. export var kernelBlurFragment: {
  28904. name: string;
  28905. shader: string;
  28906. };
  28907. }
  28908. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  28909. /** @hidden */
  28910. export var kernelBlurFragment2: {
  28911. name: string;
  28912. shader: string;
  28913. };
  28914. }
  28915. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  28916. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28917. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28918. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  28919. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  28920. /** @hidden */
  28921. export var kernelBlurPixelShader: {
  28922. name: string;
  28923. shader: string;
  28924. };
  28925. }
  28926. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  28927. /** @hidden */
  28928. export var kernelBlurVertex: {
  28929. name: string;
  28930. shader: string;
  28931. };
  28932. }
  28933. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  28934. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28935. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  28936. /** @hidden */
  28937. export var kernelBlurVertexShader: {
  28938. name: string;
  28939. shader: string;
  28940. };
  28941. }
  28942. declare module "babylonjs/PostProcesses/blurPostProcess" {
  28943. import { Vector2 } from "babylonjs/Maths/math.vector";
  28944. import { Nullable } from "babylonjs/types";
  28945. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  28946. import { Camera } from "babylonjs/Cameras/camera";
  28947. import { Effect } from "babylonjs/Materials/effect";
  28948. import { Engine } from "babylonjs/Engines/engine";
  28949. import "babylonjs/Shaders/kernelBlur.fragment";
  28950. import "babylonjs/Shaders/kernelBlur.vertex";
  28951. import { Scene } from "babylonjs/scene";
  28952. /**
  28953. * The Blur Post Process which blurs an image based on a kernel and direction.
  28954. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28955. */
  28956. export class BlurPostProcess extends PostProcess {
  28957. private blockCompilation;
  28958. protected _kernel: number;
  28959. protected _idealKernel: number;
  28960. protected _packedFloat: boolean;
  28961. private _staticDefines;
  28962. /** The direction in which to blur the image. */
  28963. direction: Vector2;
  28964. /**
  28965. * Sets the length in pixels of the blur sample region
  28966. */
  28967. set kernel(v: number);
  28968. /**
  28969. * Gets the length in pixels of the blur sample region
  28970. */
  28971. get kernel(): number;
  28972. /**
  28973. * Sets wether or not the blur needs to unpack/repack floats
  28974. */
  28975. set packedFloat(v: boolean);
  28976. /**
  28977. * Gets wether or not the blur is unpacking/repacking floats
  28978. */
  28979. get packedFloat(): boolean;
  28980. /**
  28981. * Gets a string identifying the name of the class
  28982. * @returns "BlurPostProcess" string
  28983. */
  28984. getClassName(): string;
  28985. /**
  28986. * Creates a new instance BlurPostProcess
  28987. * @param name The name of the effect.
  28988. * @param direction The direction in which to blur the image.
  28989. * @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.
  28990. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28991. * @param camera The camera to apply the render pass to.
  28992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28993. * @param engine The engine which the post process will be applied. (default: current engine)
  28994. * @param reusable If the post process can be reused on the same frame. (default: false)
  28995. * @param textureType Type of textures used when performing the post process. (default: 0)
  28996. * @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)
  28997. */
  28998. 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);
  28999. /**
  29000. * Updates the effect with the current post process compile time values and recompiles the shader.
  29001. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29002. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29003. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29004. * @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
  29005. * @param onCompiled Called when the shader has been compiled.
  29006. * @param onError Called if there is an error when compiling a shader.
  29007. */
  29008. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29009. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29010. /**
  29011. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  29012. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  29013. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  29014. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  29015. * The gaps between physical kernels are compensated for in the weighting of the samples
  29016. * @param idealKernel Ideal blur kernel.
  29017. * @return Nearest best kernel.
  29018. */
  29019. protected _nearestBestKernel(idealKernel: number): number;
  29020. /**
  29021. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  29022. * @param x The point on the Gaussian distribution to sample.
  29023. * @return the value of the Gaussian function at x.
  29024. */
  29025. protected _gaussianWeight(x: number): number;
  29026. /**
  29027. * Generates a string that can be used as a floating point number in GLSL.
  29028. * @param x Value to print.
  29029. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  29030. * @return GLSL float string.
  29031. */
  29032. protected _glslFloat(x: number, decimalFigures?: number): string;
  29033. /** @hidden */
  29034. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  29035. }
  29036. }
  29037. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  29038. import { Scene } from "babylonjs/scene";
  29039. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29040. import { Plane } from "babylonjs/Maths/math.plane";
  29041. /**
  29042. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29043. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29044. * You can then easily use it as a reflectionTexture on a flat surface.
  29045. * In case the surface is not a plane, please consider relying on reflection probes.
  29046. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29047. */
  29048. export class MirrorTexture extends RenderTargetTexture {
  29049. private scene;
  29050. /**
  29051. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  29052. * 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.
  29053. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29054. */
  29055. mirrorPlane: Plane;
  29056. /**
  29057. * Define the blur ratio used to blur the reflection if needed.
  29058. */
  29059. set blurRatio(value: number);
  29060. get blurRatio(): number;
  29061. /**
  29062. * Define the adaptive blur kernel used to blur the reflection if needed.
  29063. * This will autocompute the closest best match for the `blurKernel`
  29064. */
  29065. set adaptiveBlurKernel(value: number);
  29066. /**
  29067. * Define the blur kernel used to blur the reflection if needed.
  29068. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29069. */
  29070. set blurKernel(value: number);
  29071. /**
  29072. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29073. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29074. */
  29075. set blurKernelX(value: number);
  29076. get blurKernelX(): number;
  29077. /**
  29078. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29079. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29080. */
  29081. set blurKernelY(value: number);
  29082. get blurKernelY(): number;
  29083. private _autoComputeBlurKernel;
  29084. protected _onRatioRescale(): void;
  29085. private _updateGammaSpace;
  29086. private _imageProcessingConfigChangeObserver;
  29087. private _transformMatrix;
  29088. private _mirrorMatrix;
  29089. private _savedViewMatrix;
  29090. private _blurX;
  29091. private _blurY;
  29092. private _adaptiveBlurKernel;
  29093. private _blurKernelX;
  29094. private _blurKernelY;
  29095. private _blurRatio;
  29096. /**
  29097. * Instantiates a Mirror Texture.
  29098. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29099. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29100. * You can then easily use it as a reflectionTexture on a flat surface.
  29101. * In case the surface is not a plane, please consider relying on reflection probes.
  29102. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29103. * @param name
  29104. * @param size
  29105. * @param scene
  29106. * @param generateMipMaps
  29107. * @param type
  29108. * @param samplingMode
  29109. * @param generateDepthBuffer
  29110. */
  29111. constructor(name: string, size: number | {
  29112. width: number;
  29113. height: number;
  29114. } | {
  29115. ratio: number;
  29116. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29117. private _preparePostProcesses;
  29118. /**
  29119. * Clone the mirror texture.
  29120. * @returns the cloned texture
  29121. */
  29122. clone(): MirrorTexture;
  29123. /**
  29124. * Serialize the texture to a JSON representation you could use in Parse later on
  29125. * @returns the serialized JSON representation
  29126. */
  29127. serialize(): any;
  29128. /**
  29129. * Dispose the texture and release its associated resources.
  29130. */
  29131. dispose(): void;
  29132. }
  29133. }
  29134. declare module "babylonjs/Materials/Textures/texture" {
  29135. import { Observable } from "babylonjs/Misc/observable";
  29136. import { Nullable } from "babylonjs/types";
  29137. import { Matrix } from "babylonjs/Maths/math.vector";
  29138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29139. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29140. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29141. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29142. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29143. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29144. import { Scene } from "babylonjs/scene";
  29145. /**
  29146. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29147. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29148. */
  29149. export class Texture extends BaseTexture {
  29150. /**
  29151. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29152. */
  29153. static SerializeBuffers: boolean;
  29154. /** @hidden */
  29155. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29156. /** @hidden */
  29157. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29158. /** @hidden */
  29159. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29160. /** nearest is mag = nearest and min = nearest and mip = linear */
  29161. static readonly NEAREST_SAMPLINGMODE: number;
  29162. /** nearest is mag = nearest and min = nearest and mip = linear */
  29163. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29164. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29165. static readonly BILINEAR_SAMPLINGMODE: number;
  29166. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29167. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29168. /** Trilinear is mag = linear and min = linear and mip = linear */
  29169. static readonly TRILINEAR_SAMPLINGMODE: number;
  29170. /** Trilinear is mag = linear and min = linear and mip = linear */
  29171. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29172. /** mag = nearest and min = nearest and mip = nearest */
  29173. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29174. /** mag = nearest and min = linear and mip = nearest */
  29175. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29176. /** mag = nearest and min = linear and mip = linear */
  29177. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29178. /** mag = nearest and min = linear and mip = none */
  29179. static readonly NEAREST_LINEAR: number;
  29180. /** mag = nearest and min = nearest and mip = none */
  29181. static readonly NEAREST_NEAREST: number;
  29182. /** mag = linear and min = nearest and mip = nearest */
  29183. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29184. /** mag = linear and min = nearest and mip = linear */
  29185. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29186. /** mag = linear and min = linear and mip = none */
  29187. static readonly LINEAR_LINEAR: number;
  29188. /** mag = linear and min = nearest and mip = none */
  29189. static readonly LINEAR_NEAREST: number;
  29190. /** Explicit coordinates mode */
  29191. static readonly EXPLICIT_MODE: number;
  29192. /** Spherical coordinates mode */
  29193. static readonly SPHERICAL_MODE: number;
  29194. /** Planar coordinates mode */
  29195. static readonly PLANAR_MODE: number;
  29196. /** Cubic coordinates mode */
  29197. static readonly CUBIC_MODE: number;
  29198. /** Projection coordinates mode */
  29199. static readonly PROJECTION_MODE: number;
  29200. /** Inverse Cubic coordinates mode */
  29201. static readonly SKYBOX_MODE: number;
  29202. /** Inverse Cubic coordinates mode */
  29203. static readonly INVCUBIC_MODE: number;
  29204. /** Equirectangular coordinates mode */
  29205. static readonly EQUIRECTANGULAR_MODE: number;
  29206. /** Equirectangular Fixed coordinates mode */
  29207. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29208. /** Equirectangular Fixed Mirrored coordinates mode */
  29209. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29210. /** Texture is not repeating outside of 0..1 UVs */
  29211. static readonly CLAMP_ADDRESSMODE: number;
  29212. /** Texture is repeating outside of 0..1 UVs */
  29213. static readonly WRAP_ADDRESSMODE: number;
  29214. /** Texture is repeating and mirrored */
  29215. static readonly MIRROR_ADDRESSMODE: number;
  29216. /**
  29217. * 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
  29218. */
  29219. static UseSerializedUrlIfAny: boolean;
  29220. /**
  29221. * Define the url of the texture.
  29222. */
  29223. url: Nullable<string>;
  29224. /**
  29225. * Define an offset on the texture to offset the u coordinates of the UVs
  29226. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29227. */
  29228. uOffset: number;
  29229. /**
  29230. * Define an offset on the texture to offset the v coordinates of the UVs
  29231. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29232. */
  29233. vOffset: number;
  29234. /**
  29235. * Define an offset on the texture to scale the u coordinates of the UVs
  29236. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29237. */
  29238. uScale: number;
  29239. /**
  29240. * Define an offset on the texture to scale the v coordinates of the UVs
  29241. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29242. */
  29243. vScale: number;
  29244. /**
  29245. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29246. * @see https://doc.babylonjs.com/how_to/more_materials
  29247. */
  29248. uAng: number;
  29249. /**
  29250. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29251. * @see https://doc.babylonjs.com/how_to/more_materials
  29252. */
  29253. vAng: number;
  29254. /**
  29255. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29256. * @see https://doc.babylonjs.com/how_to/more_materials
  29257. */
  29258. wAng: number;
  29259. /**
  29260. * Defines the center of rotation (U)
  29261. */
  29262. uRotationCenter: number;
  29263. /**
  29264. * Defines the center of rotation (V)
  29265. */
  29266. vRotationCenter: number;
  29267. /**
  29268. * Defines the center of rotation (W)
  29269. */
  29270. wRotationCenter: number;
  29271. /**
  29272. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29273. */
  29274. homogeneousRotationInUVTransform: boolean;
  29275. /**
  29276. * Are mip maps generated for this texture or not.
  29277. */
  29278. get noMipmap(): boolean;
  29279. /**
  29280. * List of inspectable custom properties (used by the Inspector)
  29281. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29282. */
  29283. inspectableCustomProperties: Nullable<IInspectable[]>;
  29284. private _noMipmap;
  29285. /** @hidden */
  29286. _invertY: boolean;
  29287. private _rowGenerationMatrix;
  29288. private _cachedTextureMatrix;
  29289. private _projectionModeMatrix;
  29290. private _t0;
  29291. private _t1;
  29292. private _t2;
  29293. private _cachedUOffset;
  29294. private _cachedVOffset;
  29295. private _cachedUScale;
  29296. private _cachedVScale;
  29297. private _cachedUAng;
  29298. private _cachedVAng;
  29299. private _cachedWAng;
  29300. private _cachedProjectionMatrixId;
  29301. private _cachedURotationCenter;
  29302. private _cachedVRotationCenter;
  29303. private _cachedWRotationCenter;
  29304. private _cachedHomogeneousRotationInUVTransform;
  29305. private _cachedCoordinatesMode;
  29306. /** @hidden */
  29307. protected _initialSamplingMode: number;
  29308. /** @hidden */
  29309. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29310. private _deleteBuffer;
  29311. protected _format: Nullable<number>;
  29312. private _delayedOnLoad;
  29313. private _delayedOnError;
  29314. private _mimeType?;
  29315. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29316. get mimeType(): string | undefined;
  29317. /**
  29318. * Observable triggered once the texture has been loaded.
  29319. */
  29320. onLoadObservable: Observable<Texture>;
  29321. protected _isBlocking: boolean;
  29322. /**
  29323. * Is the texture preventing material to render while loading.
  29324. * If false, a default texture will be used instead of the loading one during the preparation step.
  29325. */
  29326. set isBlocking(value: boolean);
  29327. get isBlocking(): boolean;
  29328. /**
  29329. * Get the current sampling mode associated with the texture.
  29330. */
  29331. get samplingMode(): number;
  29332. /**
  29333. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29334. */
  29335. get invertY(): boolean;
  29336. /**
  29337. * Instantiates a new texture.
  29338. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29339. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29340. * @param url defines the url of the picture to load as a texture
  29341. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29342. * @param noMipmap defines if the texture will require mip maps or not
  29343. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29344. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29345. * @param onLoad defines a callback triggered when the texture has been loaded
  29346. * @param onError defines a callback triggered when an error occurred during the loading session
  29347. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29348. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29349. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29350. * @param mimeType defines an optional mime type information
  29351. */
  29352. 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);
  29353. /**
  29354. * Update the url (and optional buffer) of this texture if url was null during construction.
  29355. * @param url the url of the texture
  29356. * @param buffer the buffer of the texture (defaults to null)
  29357. * @param onLoad callback called when the texture is loaded (defaults to null)
  29358. */
  29359. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29360. /**
  29361. * Finish the loading sequence of a texture flagged as delayed load.
  29362. * @hidden
  29363. */
  29364. delayLoad(): void;
  29365. private _prepareRowForTextureGeneration;
  29366. /**
  29367. * Checks if the texture has the same transform matrix than another texture
  29368. * @param texture texture to check against
  29369. * @returns true if the transforms are the same, else false
  29370. */
  29371. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  29372. /**
  29373. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29374. * @returns the transform matrix of the texture.
  29375. */
  29376. getTextureMatrix(uBase?: number): Matrix;
  29377. /**
  29378. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29379. * @returns The reflection texture transform
  29380. */
  29381. getReflectionTextureMatrix(): Matrix;
  29382. /**
  29383. * Clones the texture.
  29384. * @returns the cloned texture
  29385. */
  29386. clone(): Texture;
  29387. /**
  29388. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29389. * @returns The JSON representation of the texture
  29390. */
  29391. serialize(): any;
  29392. /**
  29393. * Get the current class name of the texture useful for serialization or dynamic coding.
  29394. * @returns "Texture"
  29395. */
  29396. getClassName(): string;
  29397. /**
  29398. * Dispose the texture and release its associated resources.
  29399. */
  29400. dispose(): void;
  29401. /**
  29402. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29403. * @param parsedTexture Define the JSON representation of the texture
  29404. * @param scene Define the scene the parsed texture should be instantiated in
  29405. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29406. * @returns The parsed texture if successful
  29407. */
  29408. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29409. /**
  29410. * Creates a texture from its base 64 representation.
  29411. * @param data Define the base64 payload without the data: prefix
  29412. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29413. * @param scene Define the scene the texture should belong to
  29414. * @param noMipmap Forces the texture to not create mip map information if true
  29415. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29416. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29417. * @param onLoad define a callback triggered when the texture has been loaded
  29418. * @param onError define a callback triggered when an error occurred during the loading session
  29419. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29420. * @returns the created texture
  29421. */
  29422. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29423. /**
  29424. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29425. * @param data Define the base64 payload without the data: prefix
  29426. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29427. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29428. * @param scene Define the scene the texture should belong to
  29429. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29430. * @param noMipmap Forces the texture to not create mip map information if true
  29431. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29432. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29433. * @param onLoad define a callback triggered when the texture has been loaded
  29434. * @param onError define a callback triggered when an error occurred during the loading session
  29435. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29436. * @returns the created texture
  29437. */
  29438. 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;
  29439. }
  29440. }
  29441. declare module "babylonjs/PostProcesses/postProcessManager" {
  29442. import { Nullable } from "babylonjs/types";
  29443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29444. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29445. import { Scene } from "babylonjs/scene";
  29446. /**
  29447. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29448. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29449. */
  29450. export class PostProcessManager {
  29451. private _scene;
  29452. private _indexBuffer;
  29453. private _vertexBuffers;
  29454. /**
  29455. * Creates a new instance PostProcess
  29456. * @param scene The scene that the post process is associated with.
  29457. */
  29458. constructor(scene: Scene);
  29459. private _prepareBuffers;
  29460. private _buildIndexBuffer;
  29461. /**
  29462. * Rebuilds the vertex buffers of the manager.
  29463. * @hidden
  29464. */
  29465. _rebuild(): void;
  29466. /**
  29467. * Prepares a frame to be run through a post process.
  29468. * @param sourceTexture The input texture to the post procesess. (default: null)
  29469. * @param postProcesses An array of post processes to be run. (default: null)
  29470. * @returns True if the post processes were able to be run.
  29471. * @hidden
  29472. */
  29473. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29474. /**
  29475. * Manually render a set of post processes to a texture.
  29476. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29477. * @param postProcesses An array of post processes to be run.
  29478. * @param targetTexture The target texture to render to.
  29479. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29480. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29481. * @param lodLevel defines which lod of the texture to render to
  29482. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29483. */
  29484. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29485. /**
  29486. * Finalize the result of the output of the postprocesses.
  29487. * @param doNotPresent If true the result will not be displayed to the screen.
  29488. * @param targetTexture The target texture to render to.
  29489. * @param faceIndex The index of the face to bind the target texture to.
  29490. * @param postProcesses The array of post processes to render.
  29491. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29492. * @hidden
  29493. */
  29494. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29495. /**
  29496. * Disposes of the post process manager.
  29497. */
  29498. dispose(): void;
  29499. }
  29500. }
  29501. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29502. import { Observable } from "babylonjs/Misc/observable";
  29503. import { SmartArray } from "babylonjs/Misc/smartArray";
  29504. import { Nullable, Immutable } from "babylonjs/types";
  29505. import { Camera } from "babylonjs/Cameras/camera";
  29506. import { Scene } from "babylonjs/scene";
  29507. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29508. import { Color4 } from "babylonjs/Maths/math.color";
  29509. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29511. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29513. import { Texture } from "babylonjs/Materials/Textures/texture";
  29514. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29515. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29516. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29517. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29518. import { Engine } from "babylonjs/Engines/engine";
  29519. /**
  29520. * This Helps creating a texture that will be created from a camera in your scene.
  29521. * It is basically a dynamic texture that could be used to create special effects for instance.
  29522. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29523. */
  29524. export class RenderTargetTexture extends Texture {
  29525. /**
  29526. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29527. */
  29528. static readonly REFRESHRATE_RENDER_ONCE: number;
  29529. /**
  29530. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29531. */
  29532. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29533. /**
  29534. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29535. * the central point of your effect and can save a lot of performances.
  29536. */
  29537. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29538. /**
  29539. * Use this predicate to dynamically define the list of mesh you want to render.
  29540. * If set, the renderList property will be overwritten.
  29541. */
  29542. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29543. private _renderList;
  29544. /**
  29545. * Use this list to define the list of mesh you want to render.
  29546. */
  29547. get renderList(): Nullable<Array<AbstractMesh>>;
  29548. set renderList(value: Nullable<Array<AbstractMesh>>);
  29549. /**
  29550. * Use this function to overload the renderList array at rendering time.
  29551. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29552. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29553. * the cube (if the RTT is a cube, else layerOrFace=0).
  29554. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29555. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29556. * hold dummy elements!
  29557. */
  29558. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29559. private _hookArray;
  29560. /**
  29561. * Define if particles should be rendered in your texture.
  29562. */
  29563. renderParticles: boolean;
  29564. /**
  29565. * Define if sprites should be rendered in your texture.
  29566. */
  29567. renderSprites: boolean;
  29568. /**
  29569. * Define the camera used to render the texture.
  29570. */
  29571. activeCamera: Nullable<Camera>;
  29572. /**
  29573. * Override the mesh isReady function with your own one.
  29574. */
  29575. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29576. /**
  29577. * Override the render function of the texture with your own one.
  29578. */
  29579. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29580. /**
  29581. * Define if camera post processes should be use while rendering the texture.
  29582. */
  29583. useCameraPostProcesses: boolean;
  29584. /**
  29585. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29586. */
  29587. ignoreCameraViewport: boolean;
  29588. private _postProcessManager;
  29589. private _postProcesses;
  29590. private _resizeObserver;
  29591. /**
  29592. * An event triggered when the texture is unbind.
  29593. */
  29594. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29595. /**
  29596. * An event triggered when the texture is unbind.
  29597. */
  29598. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29599. private _onAfterUnbindObserver;
  29600. /**
  29601. * Set a after unbind callback in the texture.
  29602. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29603. */
  29604. set onAfterUnbind(callback: () => void);
  29605. /**
  29606. * An event triggered before rendering the texture
  29607. */
  29608. onBeforeRenderObservable: Observable<number>;
  29609. private _onBeforeRenderObserver;
  29610. /**
  29611. * Set a before render callback in the texture.
  29612. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29613. */
  29614. set onBeforeRender(callback: (faceIndex: number) => void);
  29615. /**
  29616. * An event triggered after rendering the texture
  29617. */
  29618. onAfterRenderObservable: Observable<number>;
  29619. private _onAfterRenderObserver;
  29620. /**
  29621. * Set a after render callback in the texture.
  29622. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29623. */
  29624. set onAfterRender(callback: (faceIndex: number) => void);
  29625. /**
  29626. * An event triggered after the texture clear
  29627. */
  29628. onClearObservable: Observable<Engine>;
  29629. private _onClearObserver;
  29630. /**
  29631. * Set a clear callback in the texture.
  29632. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29633. */
  29634. set onClear(callback: (Engine: Engine) => void);
  29635. /**
  29636. * An event triggered when the texture is resized.
  29637. */
  29638. onResizeObservable: Observable<RenderTargetTexture>;
  29639. /**
  29640. * Define the clear color of the Render Target if it should be different from the scene.
  29641. */
  29642. clearColor: Color4;
  29643. protected _size: number | {
  29644. width: number;
  29645. height: number;
  29646. layers?: number;
  29647. };
  29648. protected _initialSizeParameter: number | {
  29649. width: number;
  29650. height: number;
  29651. } | {
  29652. ratio: number;
  29653. };
  29654. protected _sizeRatio: Nullable<number>;
  29655. /** @hidden */
  29656. _generateMipMaps: boolean;
  29657. protected _renderingManager: RenderingManager;
  29658. /** @hidden */
  29659. _waitingRenderList?: string[];
  29660. protected _doNotChangeAspectRatio: boolean;
  29661. protected _currentRefreshId: number;
  29662. protected _refreshRate: number;
  29663. protected _textureMatrix: Matrix;
  29664. protected _samples: number;
  29665. protected _renderTargetOptions: RenderTargetCreationOptions;
  29666. /**
  29667. * Gets render target creation options that were used.
  29668. */
  29669. get renderTargetOptions(): RenderTargetCreationOptions;
  29670. protected _onRatioRescale(): void;
  29671. /**
  29672. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29673. * It must define where the camera used to render the texture is set
  29674. */
  29675. boundingBoxPosition: Vector3;
  29676. private _boundingBoxSize;
  29677. /**
  29678. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29679. * When defined, the cubemap will switch to local mode
  29680. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29681. * @example https://www.babylonjs-playground.com/#RNASML
  29682. */
  29683. set boundingBoxSize(value: Vector3);
  29684. get boundingBoxSize(): Vector3;
  29685. /**
  29686. * In case the RTT has been created with a depth texture, get the associated
  29687. * depth texture.
  29688. * Otherwise, return null.
  29689. */
  29690. get depthStencilTexture(): Nullable<InternalTexture>;
  29691. /**
  29692. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  29693. * or used a shadow, depth texture...
  29694. * @param name The friendly name of the texture
  29695. * @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)
  29696. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  29697. * @param generateMipMaps True if mip maps need to be generated after render.
  29698. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  29699. * @param type The type of the buffer in the RTT (int, half float, float...)
  29700. * @param isCube True if a cube texture needs to be created
  29701. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  29702. * @param generateDepthBuffer True to generate a depth buffer
  29703. * @param generateStencilBuffer True to generate a stencil buffer
  29704. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  29705. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  29706. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29707. */
  29708. constructor(name: string, size: number | {
  29709. width: number;
  29710. height: number;
  29711. layers?: number;
  29712. } | {
  29713. ratio: number;
  29714. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  29715. /**
  29716. * Creates a depth stencil texture.
  29717. * This is only available in WebGL 2 or with the depth texture extension available.
  29718. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  29719. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  29720. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  29721. */
  29722. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  29723. private _processSizeParameter;
  29724. /**
  29725. * Define the number of samples to use in case of MSAA.
  29726. * It defaults to one meaning no MSAA has been enabled.
  29727. */
  29728. get samples(): number;
  29729. set samples(value: number);
  29730. /**
  29731. * Resets the refresh counter of the texture and start bak from scratch.
  29732. * Could be useful to regenerate the texture if it is setup to render only once.
  29733. */
  29734. resetRefreshCounter(): void;
  29735. /**
  29736. * Define the refresh rate of the texture or the rendering frequency.
  29737. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  29738. */
  29739. get refreshRate(): number;
  29740. set refreshRate(value: number);
  29741. /**
  29742. * Adds a post process to the render target rendering passes.
  29743. * @param postProcess define the post process to add
  29744. */
  29745. addPostProcess(postProcess: PostProcess): void;
  29746. /**
  29747. * Clear all the post processes attached to the render target
  29748. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  29749. */
  29750. clearPostProcesses(dispose?: boolean): void;
  29751. /**
  29752. * Remove one of the post process from the list of attached post processes to the texture
  29753. * @param postProcess define the post process to remove from the list
  29754. */
  29755. removePostProcess(postProcess: PostProcess): void;
  29756. /** @hidden */
  29757. _shouldRender(): boolean;
  29758. /**
  29759. * Gets the actual render size of the texture.
  29760. * @returns the width of the render size
  29761. */
  29762. getRenderSize(): number;
  29763. /**
  29764. * Gets the actual render width of the texture.
  29765. * @returns the width of the render size
  29766. */
  29767. getRenderWidth(): number;
  29768. /**
  29769. * Gets the actual render height of the texture.
  29770. * @returns the height of the render size
  29771. */
  29772. getRenderHeight(): number;
  29773. /**
  29774. * Gets the actual number of layers of the texture.
  29775. * @returns the number of layers
  29776. */
  29777. getRenderLayers(): number;
  29778. /**
  29779. * Get if the texture can be rescaled or not.
  29780. */
  29781. get canRescale(): boolean;
  29782. /**
  29783. * Resize the texture using a ratio.
  29784. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  29785. */
  29786. scale(ratio: number): void;
  29787. /**
  29788. * Get the texture reflection matrix used to rotate/transform the reflection.
  29789. * @returns the reflection matrix
  29790. */
  29791. getReflectionTextureMatrix(): Matrix;
  29792. /**
  29793. * Resize the texture to a new desired size.
  29794. * Be carrefull as it will recreate all the data in the new texture.
  29795. * @param size Define the new size. It can be:
  29796. * - a number for squared texture,
  29797. * - an object containing { width: number, height: number }
  29798. * - or an object containing a ratio { ratio: number }
  29799. */
  29800. resize(size: number | {
  29801. width: number;
  29802. height: number;
  29803. } | {
  29804. ratio: number;
  29805. }): void;
  29806. private _defaultRenderListPrepared;
  29807. /**
  29808. * Renders all the objects from the render list into the texture.
  29809. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  29810. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  29811. */
  29812. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  29813. private _bestReflectionRenderTargetDimension;
  29814. private _prepareRenderingManager;
  29815. /**
  29816. * @hidden
  29817. * @param faceIndex face index to bind to if this is a cubetexture
  29818. * @param layer defines the index of the texture to bind in the array
  29819. */
  29820. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  29821. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  29822. private renderToTarget;
  29823. /**
  29824. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29825. * This allowed control for front to back rendering or reversly depending of the special needs.
  29826. *
  29827. * @param renderingGroupId The rendering group id corresponding to its index
  29828. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29829. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29830. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29831. */
  29832. 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;
  29833. /**
  29834. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29835. *
  29836. * @param renderingGroupId The rendering group id corresponding to its index
  29837. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29838. */
  29839. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  29840. /**
  29841. * Clones the texture.
  29842. * @returns the cloned texture
  29843. */
  29844. clone(): RenderTargetTexture;
  29845. /**
  29846. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29847. * @returns The JSON representation of the texture
  29848. */
  29849. serialize(): any;
  29850. /**
  29851. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  29852. */
  29853. disposeFramebufferObjects(): void;
  29854. /**
  29855. * Dispose the texture and release its associated resources.
  29856. */
  29857. dispose(): void;
  29858. /** @hidden */
  29859. _rebuild(): void;
  29860. /**
  29861. * Clear the info related to rendering groups preventing retention point in material dispose.
  29862. */
  29863. freeRenderingGroups(): void;
  29864. /**
  29865. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29866. * @returns the view count
  29867. */
  29868. getViewCount(): number;
  29869. }
  29870. }
  29871. declare module "babylonjs/Misc/guid" {
  29872. /**
  29873. * Class used to manipulate GUIDs
  29874. */
  29875. export class GUID {
  29876. /**
  29877. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29878. * Be aware Math.random() could cause collisions, but:
  29879. * "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"
  29880. * @returns a pseudo random id
  29881. */
  29882. static RandomId(): string;
  29883. }
  29884. }
  29885. declare module "babylonjs/Materials/shadowDepthWrapper" {
  29886. import { Nullable } from "babylonjs/types";
  29887. import { Scene } from "babylonjs/scene";
  29888. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29889. import { Material } from "babylonjs/Materials/material";
  29890. import { Effect } from "babylonjs/Materials/effect";
  29891. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  29892. /**
  29893. * Options to be used when creating a shadow depth material
  29894. */
  29895. export interface IIOptionShadowDepthMaterial {
  29896. /** Variables in the vertex shader code that need to have their names remapped.
  29897. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29898. * "var_name" should be either: worldPos or vNormalW
  29899. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29900. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29901. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29902. */
  29903. remappedVariables?: string[];
  29904. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29905. standalone?: boolean;
  29906. }
  29907. /**
  29908. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29909. */
  29910. export class ShadowDepthWrapper {
  29911. private _scene;
  29912. private _options?;
  29913. private _baseMaterial;
  29914. private _onEffectCreatedObserver;
  29915. private _subMeshToEffect;
  29916. private _subMeshToDepthEffect;
  29917. private _meshes;
  29918. /** @hidden */
  29919. _matriceNames: any;
  29920. /** Gets the standalone status of the wrapper */
  29921. get standalone(): boolean;
  29922. /** Gets the base material the wrapper is built upon */
  29923. get baseMaterial(): Material;
  29924. /**
  29925. * Instantiate a new shadow depth wrapper.
  29926. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29927. * generate the shadow depth map. For more information, please refer to the documentation:
  29928. * https://doc.babylonjs.com/babylon101/shadows
  29929. * @param baseMaterial Material to wrap
  29930. * @param scene Define the scene the material belongs to
  29931. * @param options Options used to create the wrapper
  29932. */
  29933. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29934. /**
  29935. * Gets the effect to use to generate the depth map
  29936. * @param subMesh subMesh to get the effect for
  29937. * @param shadowGenerator shadow generator to get the effect for
  29938. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29939. */
  29940. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29941. /**
  29942. * Specifies that the submesh is ready to be used for depth rendering
  29943. * @param subMesh submesh to check
  29944. * @param defines the list of defines to take into account when checking the effect
  29945. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29946. * @param useInstances specifies that instances should be used
  29947. * @returns a boolean indicating that the submesh is ready or not
  29948. */
  29949. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29950. /**
  29951. * Disposes the resources
  29952. */
  29953. dispose(): void;
  29954. private _makeEffect;
  29955. }
  29956. }
  29957. declare module "babylonjs/Materials/material" {
  29958. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29959. import { SmartArray } from "babylonjs/Misc/smartArray";
  29960. import { Observable } from "babylonjs/Misc/observable";
  29961. import { Nullable } from "babylonjs/types";
  29962. import { Scene } from "babylonjs/scene";
  29963. import { Matrix } from "babylonjs/Maths/math.vector";
  29964. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29966. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29967. import { Effect } from "babylonjs/Materials/effect";
  29968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29969. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29970. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29971. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29972. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  29973. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  29974. import { Mesh } from "babylonjs/Meshes/mesh";
  29975. import { Animation } from "babylonjs/Animations/animation";
  29976. /**
  29977. * Options for compiling materials.
  29978. */
  29979. export interface IMaterialCompilationOptions {
  29980. /**
  29981. * Defines whether clip planes are enabled.
  29982. */
  29983. clipPlane: boolean;
  29984. /**
  29985. * Defines whether instances are enabled.
  29986. */
  29987. useInstances: boolean;
  29988. }
  29989. /**
  29990. * Options passed when calling customShaderNameResolve
  29991. */
  29992. export interface ICustomShaderNameResolveOptions {
  29993. /**
  29994. * 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
  29995. */
  29996. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29997. }
  29998. /**
  29999. * Base class for the main features of a material in Babylon.js
  30000. */
  30001. export class Material implements IAnimatable {
  30002. /**
  30003. * Returns the triangle fill mode
  30004. */
  30005. static readonly TriangleFillMode: number;
  30006. /**
  30007. * Returns the wireframe mode
  30008. */
  30009. static readonly WireFrameFillMode: number;
  30010. /**
  30011. * Returns the point fill mode
  30012. */
  30013. static readonly PointFillMode: number;
  30014. /**
  30015. * Returns the point list draw mode
  30016. */
  30017. static readonly PointListDrawMode: number;
  30018. /**
  30019. * Returns the line list draw mode
  30020. */
  30021. static readonly LineListDrawMode: number;
  30022. /**
  30023. * Returns the line loop draw mode
  30024. */
  30025. static readonly LineLoopDrawMode: number;
  30026. /**
  30027. * Returns the line strip draw mode
  30028. */
  30029. static readonly LineStripDrawMode: number;
  30030. /**
  30031. * Returns the triangle strip draw mode
  30032. */
  30033. static readonly TriangleStripDrawMode: number;
  30034. /**
  30035. * Returns the triangle fan draw mode
  30036. */
  30037. static readonly TriangleFanDrawMode: number;
  30038. /**
  30039. * Stores the clock-wise side orientation
  30040. */
  30041. static readonly ClockWiseSideOrientation: number;
  30042. /**
  30043. * Stores the counter clock-wise side orientation
  30044. */
  30045. static readonly CounterClockWiseSideOrientation: number;
  30046. /**
  30047. * The dirty texture flag value
  30048. */
  30049. static readonly TextureDirtyFlag: number;
  30050. /**
  30051. * The dirty light flag value
  30052. */
  30053. static readonly LightDirtyFlag: number;
  30054. /**
  30055. * The dirty fresnel flag value
  30056. */
  30057. static readonly FresnelDirtyFlag: number;
  30058. /**
  30059. * The dirty attribute flag value
  30060. */
  30061. static readonly AttributesDirtyFlag: number;
  30062. /**
  30063. * The dirty misc flag value
  30064. */
  30065. static readonly MiscDirtyFlag: number;
  30066. /**
  30067. * The dirty prepass flag value
  30068. */
  30069. static readonly PrePassDirtyFlag: number;
  30070. /**
  30071. * The all dirty flag value
  30072. */
  30073. static readonly AllDirtyFlag: number;
  30074. /**
  30075. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30076. */
  30077. static readonly MATERIAL_OPAQUE: number;
  30078. /**
  30079. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30080. */
  30081. static readonly MATERIAL_ALPHATEST: number;
  30082. /**
  30083. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30084. */
  30085. static readonly MATERIAL_ALPHABLEND: number;
  30086. /**
  30087. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30088. * They are also discarded below the alpha cutoff threshold to improve performances.
  30089. */
  30090. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30091. /**
  30092. * The Whiteout method is used to blend normals.
  30093. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30094. */
  30095. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30096. /**
  30097. * The Reoriented Normal Mapping method is used to blend normals.
  30098. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30099. */
  30100. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30101. /**
  30102. * Custom callback helping to override the default shader used in the material.
  30103. */
  30104. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30105. /**
  30106. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30107. */
  30108. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30109. /**
  30110. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30111. * This means that the material can keep using a previous shader while a new one is being compiled.
  30112. * This is mostly used when shader parallel compilation is supported (true by default)
  30113. */
  30114. allowShaderHotSwapping: boolean;
  30115. /**
  30116. * The ID of the material
  30117. */
  30118. id: string;
  30119. /**
  30120. * Gets or sets the unique id of the material
  30121. */
  30122. uniqueId: number;
  30123. /**
  30124. * The name of the material
  30125. */
  30126. name: string;
  30127. /**
  30128. * Gets or sets user defined metadata
  30129. */
  30130. metadata: any;
  30131. /**
  30132. * For internal use only. Please do not use.
  30133. */
  30134. reservedDataStore: any;
  30135. /**
  30136. * Specifies if the ready state should be checked on each call
  30137. */
  30138. checkReadyOnEveryCall: boolean;
  30139. /**
  30140. * Specifies if the ready state should be checked once
  30141. */
  30142. checkReadyOnlyOnce: boolean;
  30143. /**
  30144. * The state of the material
  30145. */
  30146. state: string;
  30147. /**
  30148. * If the material can be rendered to several textures with MRT extension
  30149. */
  30150. get canRenderToMRT(): boolean;
  30151. /**
  30152. * The alpha value of the material
  30153. */
  30154. protected _alpha: number;
  30155. /**
  30156. * List of inspectable custom properties (used by the Inspector)
  30157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30158. */
  30159. inspectableCustomProperties: IInspectable[];
  30160. /**
  30161. * Sets the alpha value of the material
  30162. */
  30163. set alpha(value: number);
  30164. /**
  30165. * Gets the alpha value of the material
  30166. */
  30167. get alpha(): number;
  30168. /**
  30169. * Specifies if back face culling is enabled
  30170. */
  30171. protected _backFaceCulling: boolean;
  30172. /**
  30173. * Sets the back-face culling state
  30174. */
  30175. set backFaceCulling(value: boolean);
  30176. /**
  30177. * Gets the back-face culling state
  30178. */
  30179. get backFaceCulling(): boolean;
  30180. /**
  30181. * Stores the value for side orientation
  30182. */
  30183. sideOrientation: number;
  30184. /**
  30185. * Callback triggered when the material is compiled
  30186. */
  30187. onCompiled: Nullable<(effect: Effect) => void>;
  30188. /**
  30189. * Callback triggered when an error occurs
  30190. */
  30191. onError: Nullable<(effect: Effect, errors: string) => void>;
  30192. /**
  30193. * Callback triggered to get the render target textures
  30194. */
  30195. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30196. /**
  30197. * Gets a boolean indicating that current material needs to register RTT
  30198. */
  30199. get hasRenderTargetTextures(): boolean;
  30200. /**
  30201. * Specifies if the material should be serialized
  30202. */
  30203. doNotSerialize: boolean;
  30204. /**
  30205. * @hidden
  30206. */
  30207. _storeEffectOnSubMeshes: boolean;
  30208. /**
  30209. * Stores the animations for the material
  30210. */
  30211. animations: Nullable<Array<Animation>>;
  30212. /**
  30213. * An event triggered when the material is disposed
  30214. */
  30215. onDisposeObservable: Observable<Material>;
  30216. /**
  30217. * An observer which watches for dispose events
  30218. */
  30219. private _onDisposeObserver;
  30220. private _onUnBindObservable;
  30221. /**
  30222. * Called during a dispose event
  30223. */
  30224. set onDispose(callback: () => void);
  30225. private _onBindObservable;
  30226. /**
  30227. * An event triggered when the material is bound
  30228. */
  30229. get onBindObservable(): Observable<AbstractMesh>;
  30230. /**
  30231. * An observer which watches for bind events
  30232. */
  30233. private _onBindObserver;
  30234. /**
  30235. * Called during a bind event
  30236. */
  30237. set onBind(callback: (Mesh: AbstractMesh) => void);
  30238. /**
  30239. * An event triggered when the material is unbound
  30240. */
  30241. get onUnBindObservable(): Observable<Material>;
  30242. protected _onEffectCreatedObservable: Nullable<Observable<{
  30243. effect: Effect;
  30244. subMesh: Nullable<SubMesh>;
  30245. }>>;
  30246. /**
  30247. * An event triggered when the effect is (re)created
  30248. */
  30249. get onEffectCreatedObservable(): Observable<{
  30250. effect: Effect;
  30251. subMesh: Nullable<SubMesh>;
  30252. }>;
  30253. /**
  30254. * Stores the value of the alpha mode
  30255. */
  30256. private _alphaMode;
  30257. /**
  30258. * Sets the value of the alpha mode.
  30259. *
  30260. * | Value | Type | Description |
  30261. * | --- | --- | --- |
  30262. * | 0 | ALPHA_DISABLE | |
  30263. * | 1 | ALPHA_ADD | |
  30264. * | 2 | ALPHA_COMBINE | |
  30265. * | 3 | ALPHA_SUBTRACT | |
  30266. * | 4 | ALPHA_MULTIPLY | |
  30267. * | 5 | ALPHA_MAXIMIZED | |
  30268. * | 6 | ALPHA_ONEONE | |
  30269. * | 7 | ALPHA_PREMULTIPLIED | |
  30270. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30271. * | 9 | ALPHA_INTERPOLATE | |
  30272. * | 10 | ALPHA_SCREENMODE | |
  30273. *
  30274. */
  30275. set alphaMode(value: number);
  30276. /**
  30277. * Gets the value of the alpha mode
  30278. */
  30279. get alphaMode(): number;
  30280. /**
  30281. * Stores the state of the need depth pre-pass value
  30282. */
  30283. private _needDepthPrePass;
  30284. /**
  30285. * Sets the need depth pre-pass value
  30286. */
  30287. set needDepthPrePass(value: boolean);
  30288. /**
  30289. * Gets the depth pre-pass value
  30290. */
  30291. get needDepthPrePass(): boolean;
  30292. /**
  30293. * Specifies if depth writing should be disabled
  30294. */
  30295. disableDepthWrite: boolean;
  30296. /**
  30297. * Specifies if color writing should be disabled
  30298. */
  30299. disableColorWrite: boolean;
  30300. /**
  30301. * Specifies if depth writing should be forced
  30302. */
  30303. forceDepthWrite: boolean;
  30304. /**
  30305. * Specifies the depth function that should be used. 0 means the default engine function
  30306. */
  30307. depthFunction: number;
  30308. /**
  30309. * Specifies if there should be a separate pass for culling
  30310. */
  30311. separateCullingPass: boolean;
  30312. /**
  30313. * Stores the state specifing if fog should be enabled
  30314. */
  30315. private _fogEnabled;
  30316. /**
  30317. * Sets the state for enabling fog
  30318. */
  30319. set fogEnabled(value: boolean);
  30320. /**
  30321. * Gets the value of the fog enabled state
  30322. */
  30323. get fogEnabled(): boolean;
  30324. /**
  30325. * Stores the size of points
  30326. */
  30327. pointSize: number;
  30328. /**
  30329. * Stores the z offset value
  30330. */
  30331. zOffset: number;
  30332. get wireframe(): boolean;
  30333. /**
  30334. * Sets the state of wireframe mode
  30335. */
  30336. set wireframe(value: boolean);
  30337. /**
  30338. * Gets the value specifying if point clouds are enabled
  30339. */
  30340. get pointsCloud(): boolean;
  30341. /**
  30342. * Sets the state of point cloud mode
  30343. */
  30344. set pointsCloud(value: boolean);
  30345. /**
  30346. * Gets the material fill mode
  30347. */
  30348. get fillMode(): number;
  30349. /**
  30350. * Sets the material fill mode
  30351. */
  30352. set fillMode(value: number);
  30353. /**
  30354. * @hidden
  30355. * Stores the effects for the material
  30356. */
  30357. _effect: Nullable<Effect>;
  30358. /**
  30359. * Specifies if uniform buffers should be used
  30360. */
  30361. private _useUBO;
  30362. /**
  30363. * Stores a reference to the scene
  30364. */
  30365. private _scene;
  30366. /**
  30367. * Stores the fill mode state
  30368. */
  30369. private _fillMode;
  30370. /**
  30371. * Specifies if the depth write state should be cached
  30372. */
  30373. private _cachedDepthWriteState;
  30374. /**
  30375. * Specifies if the color write state should be cached
  30376. */
  30377. private _cachedColorWriteState;
  30378. /**
  30379. * Specifies if the depth function state should be cached
  30380. */
  30381. private _cachedDepthFunctionState;
  30382. /**
  30383. * Stores the uniform buffer
  30384. */
  30385. protected _uniformBuffer: UniformBuffer;
  30386. /** @hidden */
  30387. _indexInSceneMaterialArray: number;
  30388. /** @hidden */
  30389. meshMap: Nullable<{
  30390. [id: string]: AbstractMesh | undefined;
  30391. }>;
  30392. /**
  30393. * Creates a material instance
  30394. * @param name defines the name of the material
  30395. * @param scene defines the scene to reference
  30396. * @param doNotAdd specifies if the material should be added to the scene
  30397. */
  30398. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30399. /**
  30400. * Returns a string representation of the current material
  30401. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30402. * @returns a string with material information
  30403. */
  30404. toString(fullDetails?: boolean): string;
  30405. /**
  30406. * Gets the class name of the material
  30407. * @returns a string with the class name of the material
  30408. */
  30409. getClassName(): string;
  30410. /**
  30411. * Specifies if updates for the material been locked
  30412. */
  30413. get isFrozen(): boolean;
  30414. /**
  30415. * Locks updates for the material
  30416. */
  30417. freeze(): void;
  30418. /**
  30419. * Unlocks updates for the material
  30420. */
  30421. unfreeze(): void;
  30422. /**
  30423. * Specifies if the material is ready to be used
  30424. * @param mesh defines the mesh to check
  30425. * @param useInstances specifies if instances should be used
  30426. * @returns a boolean indicating if the material is ready to be used
  30427. */
  30428. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30429. /**
  30430. * Specifies that the submesh is ready to be used
  30431. * @param mesh defines the mesh to check
  30432. * @param subMesh defines which submesh to check
  30433. * @param useInstances specifies that instances should be used
  30434. * @returns a boolean indicating that the submesh is ready or not
  30435. */
  30436. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30437. /**
  30438. * Returns the material effect
  30439. * @returns the effect associated with the material
  30440. */
  30441. getEffect(): Nullable<Effect>;
  30442. /**
  30443. * Returns the current scene
  30444. * @returns a Scene
  30445. */
  30446. getScene(): Scene;
  30447. /**
  30448. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30449. */
  30450. protected _forceAlphaTest: boolean;
  30451. /**
  30452. * The transparency mode of the material.
  30453. */
  30454. protected _transparencyMode: Nullable<number>;
  30455. /**
  30456. * Gets the current transparency mode.
  30457. */
  30458. get transparencyMode(): Nullable<number>;
  30459. /**
  30460. * Sets the transparency mode of the material.
  30461. *
  30462. * | Value | Type | Description |
  30463. * | ----- | ----------------------------------- | ----------- |
  30464. * | 0 | OPAQUE | |
  30465. * | 1 | ALPHATEST | |
  30466. * | 2 | ALPHABLEND | |
  30467. * | 3 | ALPHATESTANDBLEND | |
  30468. *
  30469. */
  30470. set transparencyMode(value: Nullable<number>);
  30471. /**
  30472. * Returns true if alpha blending should be disabled.
  30473. */
  30474. protected get _disableAlphaBlending(): boolean;
  30475. /**
  30476. * Specifies whether or not this material should be rendered in alpha blend mode.
  30477. * @returns a boolean specifying if alpha blending is needed
  30478. */
  30479. needAlphaBlending(): boolean;
  30480. /**
  30481. * Specifies if the mesh will require alpha blending
  30482. * @param mesh defines the mesh to check
  30483. * @returns a boolean specifying if alpha blending is needed for the mesh
  30484. */
  30485. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30486. /**
  30487. * Specifies whether or not this material should be rendered in alpha test mode.
  30488. * @returns a boolean specifying if an alpha test is needed.
  30489. */
  30490. needAlphaTesting(): boolean;
  30491. /**
  30492. * Specifies if material alpha testing should be turned on for the mesh
  30493. * @param mesh defines the mesh to check
  30494. */
  30495. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30496. /**
  30497. * Gets the texture used for the alpha test
  30498. * @returns the texture to use for alpha testing
  30499. */
  30500. getAlphaTestTexture(): Nullable<BaseTexture>;
  30501. /**
  30502. * Marks the material to indicate that it needs to be re-calculated
  30503. */
  30504. markDirty(): void;
  30505. /** @hidden */
  30506. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30507. /**
  30508. * Binds the material to the mesh
  30509. * @param world defines the world transformation matrix
  30510. * @param mesh defines the mesh to bind the material to
  30511. */
  30512. bind(world: Matrix, mesh?: Mesh): void;
  30513. /**
  30514. * Binds the submesh to the material
  30515. * @param world defines the world transformation matrix
  30516. * @param mesh defines the mesh containing the submesh
  30517. * @param subMesh defines the submesh to bind the material to
  30518. */
  30519. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30520. /**
  30521. * Binds the world matrix to the material
  30522. * @param world defines the world transformation matrix
  30523. */
  30524. bindOnlyWorldMatrix(world: Matrix): void;
  30525. /**
  30526. * Binds the scene's uniform buffer to the effect.
  30527. * @param effect defines the effect to bind to the scene uniform buffer
  30528. * @param sceneUbo defines the uniform buffer storing scene data
  30529. */
  30530. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30531. /**
  30532. * Binds the view matrix to the effect
  30533. * @param effect defines the effect to bind the view matrix to
  30534. */
  30535. bindView(effect: Effect): void;
  30536. /**
  30537. * Binds the view projection matrix to the effect
  30538. * @param effect defines the effect to bind the view projection matrix to
  30539. */
  30540. bindViewProjection(effect: Effect): void;
  30541. /**
  30542. * Processes to execute after binding the material to a mesh
  30543. * @param mesh defines the rendered mesh
  30544. */
  30545. protected _afterBind(mesh?: Mesh): void;
  30546. /**
  30547. * Unbinds the material from the mesh
  30548. */
  30549. unbind(): void;
  30550. /**
  30551. * Gets the active textures from the material
  30552. * @returns an array of textures
  30553. */
  30554. getActiveTextures(): BaseTexture[];
  30555. /**
  30556. * Specifies if the material uses a texture
  30557. * @param texture defines the texture to check against the material
  30558. * @returns a boolean specifying if the material uses the texture
  30559. */
  30560. hasTexture(texture: BaseTexture): boolean;
  30561. /**
  30562. * Makes a duplicate of the material, and gives it a new name
  30563. * @param name defines the new name for the duplicated material
  30564. * @returns the cloned material
  30565. */
  30566. clone(name: string): Nullable<Material>;
  30567. /**
  30568. * Gets the meshes bound to the material
  30569. * @returns an array of meshes bound to the material
  30570. */
  30571. getBindedMeshes(): AbstractMesh[];
  30572. /**
  30573. * Force shader compilation
  30574. * @param mesh defines the mesh associated with this material
  30575. * @param onCompiled defines a function to execute once the material is compiled
  30576. * @param options defines the options to configure the compilation
  30577. * @param onError defines a function to execute if the material fails compiling
  30578. */
  30579. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30580. /**
  30581. * Force shader compilation
  30582. * @param mesh defines the mesh that will use this material
  30583. * @param options defines additional options for compiling the shaders
  30584. * @returns a promise that resolves when the compilation completes
  30585. */
  30586. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30587. private static readonly _AllDirtyCallBack;
  30588. private static readonly _ImageProcessingDirtyCallBack;
  30589. private static readonly _TextureDirtyCallBack;
  30590. private static readonly _FresnelDirtyCallBack;
  30591. private static readonly _MiscDirtyCallBack;
  30592. private static readonly _PrePassDirtyCallBack;
  30593. private static readonly _LightsDirtyCallBack;
  30594. private static readonly _AttributeDirtyCallBack;
  30595. private static _FresnelAndMiscDirtyCallBack;
  30596. private static _TextureAndMiscDirtyCallBack;
  30597. private static readonly _DirtyCallbackArray;
  30598. private static readonly _RunDirtyCallBacks;
  30599. /**
  30600. * Marks a define in the material to indicate that it needs to be re-computed
  30601. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30602. */
  30603. markAsDirty(flag: number): void;
  30604. /**
  30605. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30606. * @param func defines a function which checks material defines against the submeshes
  30607. */
  30608. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30609. /**
  30610. * Indicates that the scene should check if the rendering now needs a prepass
  30611. */
  30612. protected _markScenePrePassDirty(): void;
  30613. /**
  30614. * Indicates that we need to re-calculated for all submeshes
  30615. */
  30616. protected _markAllSubMeshesAsAllDirty(): void;
  30617. /**
  30618. * Indicates that image processing needs to be re-calculated for all submeshes
  30619. */
  30620. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30621. /**
  30622. * Indicates that textures need to be re-calculated for all submeshes
  30623. */
  30624. protected _markAllSubMeshesAsTexturesDirty(): void;
  30625. /**
  30626. * Indicates that fresnel needs to be re-calculated for all submeshes
  30627. */
  30628. protected _markAllSubMeshesAsFresnelDirty(): void;
  30629. /**
  30630. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30631. */
  30632. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30633. /**
  30634. * Indicates that lights need to be re-calculated for all submeshes
  30635. */
  30636. protected _markAllSubMeshesAsLightsDirty(): void;
  30637. /**
  30638. * Indicates that attributes need to be re-calculated for all submeshes
  30639. */
  30640. protected _markAllSubMeshesAsAttributesDirty(): void;
  30641. /**
  30642. * Indicates that misc needs to be re-calculated for all submeshes
  30643. */
  30644. protected _markAllSubMeshesAsMiscDirty(): void;
  30645. /**
  30646. * Indicates that prepass needs to be re-calculated for all submeshes
  30647. */
  30648. protected _markAllSubMeshesAsPrePassDirty(): void;
  30649. /**
  30650. * Indicates that textures and misc need to be re-calculated for all submeshes
  30651. */
  30652. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30653. /**
  30654. * Sets the required values to the prepass renderer.
  30655. * @param prePassRenderer defines the prepass renderer to setup.
  30656. * @returns true if the pre pass is needed.
  30657. */
  30658. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30659. /**
  30660. * Disposes the material
  30661. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30662. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30663. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30664. */
  30665. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30666. /** @hidden */
  30667. private releaseVertexArrayObject;
  30668. /**
  30669. * Serializes this material
  30670. * @returns the serialized material object
  30671. */
  30672. serialize(): any;
  30673. /**
  30674. * Creates a material from parsed material data
  30675. * @param parsedMaterial defines parsed material data
  30676. * @param scene defines the hosting scene
  30677. * @param rootUrl defines the root URL to use to load textures
  30678. * @returns a new material
  30679. */
  30680. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30681. }
  30682. }
  30683. declare module "babylonjs/Materials/multiMaterial" {
  30684. import { Nullable } from "babylonjs/types";
  30685. import { Scene } from "babylonjs/scene";
  30686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30687. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30688. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30689. import { Material } from "babylonjs/Materials/material";
  30690. /**
  30691. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30692. * separate meshes. This can be use to improve performances.
  30693. * @see https://doc.babylonjs.com/how_to/multi_materials
  30694. */
  30695. export class MultiMaterial extends Material {
  30696. private _subMaterials;
  30697. /**
  30698. * Gets or Sets the list of Materials used within the multi material.
  30699. * They need to be ordered according to the submeshes order in the associated mesh
  30700. */
  30701. get subMaterials(): Nullable<Material>[];
  30702. set subMaterials(value: Nullable<Material>[]);
  30703. /**
  30704. * Function used to align with Node.getChildren()
  30705. * @returns the list of Materials used within the multi material
  30706. */
  30707. getChildren(): Nullable<Material>[];
  30708. /**
  30709. * Instantiates a new Multi Material
  30710. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30711. * separate meshes. This can be use to improve performances.
  30712. * @see https://doc.babylonjs.com/how_to/multi_materials
  30713. * @param name Define the name in the scene
  30714. * @param scene Define the scene the material belongs to
  30715. */
  30716. constructor(name: string, scene: Scene);
  30717. private _hookArray;
  30718. /**
  30719. * Get one of the submaterial by its index in the submaterials array
  30720. * @param index The index to look the sub material at
  30721. * @returns The Material if the index has been defined
  30722. */
  30723. getSubMaterial(index: number): Nullable<Material>;
  30724. /**
  30725. * Get the list of active textures for the whole sub materials list.
  30726. * @returns All the textures that will be used during the rendering
  30727. */
  30728. getActiveTextures(): BaseTexture[];
  30729. /**
  30730. * Gets the current class name of the material e.g. "MultiMaterial"
  30731. * Mainly use in serialization.
  30732. * @returns the class name
  30733. */
  30734. getClassName(): string;
  30735. /**
  30736. * Checks if the material is ready to render the requested sub mesh
  30737. * @param mesh Define the mesh the submesh belongs to
  30738. * @param subMesh Define the sub mesh to look readyness for
  30739. * @param useInstances Define whether or not the material is used with instances
  30740. * @returns true if ready, otherwise false
  30741. */
  30742. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30743. /**
  30744. * Clones the current material and its related sub materials
  30745. * @param name Define the name of the newly cloned material
  30746. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30747. * @returns the cloned material
  30748. */
  30749. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30750. /**
  30751. * Serializes the materials into a JSON representation.
  30752. * @returns the JSON representation
  30753. */
  30754. serialize(): any;
  30755. /**
  30756. * Dispose the material and release its associated resources
  30757. * @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)
  30758. * @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)
  30759. * @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)
  30760. */
  30761. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30762. /**
  30763. * Creates a MultiMaterial from parsed MultiMaterial data.
  30764. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30765. * @param scene defines the hosting scene
  30766. * @returns a new MultiMaterial
  30767. */
  30768. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30769. }
  30770. }
  30771. declare module "babylonjs/Meshes/subMesh" {
  30772. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  30773. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30774. import { Engine } from "babylonjs/Engines/engine";
  30775. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  30776. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  30777. import { Effect } from "babylonjs/Materials/effect";
  30778. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30779. import { Plane } from "babylonjs/Maths/math.plane";
  30780. import { Collider } from "babylonjs/Collisions/collider";
  30781. import { Material } from "babylonjs/Materials/material";
  30782. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30784. import { Mesh } from "babylonjs/Meshes/mesh";
  30785. import { Ray } from "babylonjs/Culling/ray";
  30786. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  30787. /**
  30788. * Defines a subdivision inside a mesh
  30789. */
  30790. export class SubMesh implements ICullable {
  30791. /** the material index to use */
  30792. materialIndex: number;
  30793. /** vertex index start */
  30794. verticesStart: number;
  30795. /** vertices count */
  30796. verticesCount: number;
  30797. /** index start */
  30798. indexStart: number;
  30799. /** indices count */
  30800. indexCount: number;
  30801. /** @hidden */
  30802. _materialDefines: Nullable<MaterialDefines>;
  30803. /** @hidden */
  30804. _materialEffect: Nullable<Effect>;
  30805. /** @hidden */
  30806. _effectOverride: Nullable<Effect>;
  30807. /**
  30808. * Gets material defines used by the effect associated to the sub mesh
  30809. */
  30810. get materialDefines(): Nullable<MaterialDefines>;
  30811. /**
  30812. * Sets material defines used by the effect associated to the sub mesh
  30813. */
  30814. set materialDefines(defines: Nullable<MaterialDefines>);
  30815. /**
  30816. * Gets associated effect
  30817. */
  30818. get effect(): Nullable<Effect>;
  30819. /**
  30820. * Sets associated effect (effect used to render this submesh)
  30821. * @param effect defines the effect to associate with
  30822. * @param defines defines the set of defines used to compile this effect
  30823. */
  30824. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30825. /** @hidden */
  30826. _linesIndexCount: number;
  30827. private _mesh;
  30828. private _renderingMesh;
  30829. private _boundingInfo;
  30830. private _linesIndexBuffer;
  30831. /** @hidden */
  30832. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30833. /** @hidden */
  30834. _trianglePlanes: Plane[];
  30835. /** @hidden */
  30836. _lastColliderTransformMatrix: Nullable<Matrix>;
  30837. /** @hidden */
  30838. _renderId: number;
  30839. /** @hidden */
  30840. _alphaIndex: number;
  30841. /** @hidden */
  30842. _distanceToCamera: number;
  30843. /** @hidden */
  30844. _id: number;
  30845. private _currentMaterial;
  30846. /**
  30847. * Add a new submesh to a mesh
  30848. * @param materialIndex defines the material index to use
  30849. * @param verticesStart defines vertex index start
  30850. * @param verticesCount defines vertices count
  30851. * @param indexStart defines index start
  30852. * @param indexCount defines indices count
  30853. * @param mesh defines the parent mesh
  30854. * @param renderingMesh defines an optional rendering mesh
  30855. * @param createBoundingBox defines if bounding box should be created for this submesh
  30856. * @returns the new submesh
  30857. */
  30858. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30859. /**
  30860. * Creates a new submesh
  30861. * @param materialIndex defines the material index to use
  30862. * @param verticesStart defines vertex index start
  30863. * @param verticesCount defines vertices count
  30864. * @param indexStart defines index start
  30865. * @param indexCount defines indices count
  30866. * @param mesh defines the parent mesh
  30867. * @param renderingMesh defines an optional rendering mesh
  30868. * @param createBoundingBox defines if bounding box should be created for this submesh
  30869. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30870. */
  30871. constructor(
  30872. /** the material index to use */
  30873. materialIndex: number,
  30874. /** vertex index start */
  30875. verticesStart: number,
  30876. /** vertices count */
  30877. verticesCount: number,
  30878. /** index start */
  30879. indexStart: number,
  30880. /** indices count */
  30881. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30882. /**
  30883. * Returns true if this submesh covers the entire parent mesh
  30884. * @ignorenaming
  30885. */
  30886. get IsGlobal(): boolean;
  30887. /**
  30888. * Returns the submesh BoudingInfo object
  30889. * @returns current bounding info (or mesh's one if the submesh is global)
  30890. */
  30891. getBoundingInfo(): BoundingInfo;
  30892. /**
  30893. * Sets the submesh BoundingInfo
  30894. * @param boundingInfo defines the new bounding info to use
  30895. * @returns the SubMesh
  30896. */
  30897. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30898. /**
  30899. * Returns the mesh of the current submesh
  30900. * @return the parent mesh
  30901. */
  30902. getMesh(): AbstractMesh;
  30903. /**
  30904. * Returns the rendering mesh of the submesh
  30905. * @returns the rendering mesh (could be different from parent mesh)
  30906. */
  30907. getRenderingMesh(): Mesh;
  30908. /**
  30909. * Returns the replacement mesh of the submesh
  30910. * @returns the replacement mesh (could be different from parent mesh)
  30911. */
  30912. getReplacementMesh(): Nullable<AbstractMesh>;
  30913. /**
  30914. * Returns the effective mesh of the submesh
  30915. * @returns the effective mesh (could be different from parent mesh)
  30916. */
  30917. getEffectiveMesh(): AbstractMesh;
  30918. /**
  30919. * Returns the submesh material
  30920. * @returns null or the current material
  30921. */
  30922. getMaterial(): Nullable<Material>;
  30923. private _IsMultiMaterial;
  30924. /**
  30925. * Sets a new updated BoundingInfo object to the submesh
  30926. * @param data defines an optional position array to use to determine the bounding info
  30927. * @returns the SubMesh
  30928. */
  30929. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30930. /** @hidden */
  30931. _checkCollision(collider: Collider): boolean;
  30932. /**
  30933. * Updates the submesh BoundingInfo
  30934. * @param world defines the world matrix to use to update the bounding info
  30935. * @returns the submesh
  30936. */
  30937. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30938. /**
  30939. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30940. * @param frustumPlanes defines the frustum planes
  30941. * @returns true if the submesh is intersecting with the frustum
  30942. */
  30943. isInFrustum(frustumPlanes: Plane[]): boolean;
  30944. /**
  30945. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30946. * @param frustumPlanes defines the frustum planes
  30947. * @returns true if the submesh is inside the frustum
  30948. */
  30949. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30950. /**
  30951. * Renders the submesh
  30952. * @param enableAlphaMode defines if alpha needs to be used
  30953. * @returns the submesh
  30954. */
  30955. render(enableAlphaMode: boolean): SubMesh;
  30956. /**
  30957. * @hidden
  30958. */
  30959. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30960. /**
  30961. * Checks if the submesh intersects with a ray
  30962. * @param ray defines the ray to test
  30963. * @returns true is the passed ray intersects the submesh bounding box
  30964. */
  30965. canIntersects(ray: Ray): boolean;
  30966. /**
  30967. * Intersects current submesh with a ray
  30968. * @param ray defines the ray to test
  30969. * @param positions defines mesh's positions array
  30970. * @param indices defines mesh's indices array
  30971. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30972. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30973. * @returns intersection info or null if no intersection
  30974. */
  30975. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30976. /** @hidden */
  30977. private _intersectLines;
  30978. /** @hidden */
  30979. private _intersectUnIndexedLines;
  30980. /** @hidden */
  30981. private _intersectTriangles;
  30982. /** @hidden */
  30983. private _intersectUnIndexedTriangles;
  30984. /** @hidden */
  30985. _rebuild(): void;
  30986. /**
  30987. * Creates a new submesh from the passed mesh
  30988. * @param newMesh defines the new hosting mesh
  30989. * @param newRenderingMesh defines an optional rendering mesh
  30990. * @returns the new submesh
  30991. */
  30992. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30993. /**
  30994. * Release associated resources
  30995. */
  30996. dispose(): void;
  30997. /**
  30998. * Gets the class name
  30999. * @returns the string "SubMesh".
  31000. */
  31001. getClassName(): string;
  31002. /**
  31003. * Creates a new submesh from indices data
  31004. * @param materialIndex the index of the main mesh material
  31005. * @param startIndex the index where to start the copy in the mesh indices array
  31006. * @param indexCount the number of indices to copy then from the startIndex
  31007. * @param mesh the main mesh to create the submesh from
  31008. * @param renderingMesh the optional rendering mesh
  31009. * @returns a new submesh
  31010. */
  31011. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31012. }
  31013. }
  31014. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31015. /**
  31016. * Class used to represent data loading progression
  31017. */
  31018. export class SceneLoaderFlags {
  31019. private static _ForceFullSceneLoadingForIncremental;
  31020. private static _ShowLoadingScreen;
  31021. private static _CleanBoneMatrixWeights;
  31022. private static _loggingLevel;
  31023. /**
  31024. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31025. */
  31026. static get ForceFullSceneLoadingForIncremental(): boolean;
  31027. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31028. /**
  31029. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31030. */
  31031. static get ShowLoadingScreen(): boolean;
  31032. static set ShowLoadingScreen(value: boolean);
  31033. /**
  31034. * Defines the current logging level (while loading the scene)
  31035. * @ignorenaming
  31036. */
  31037. static get loggingLevel(): number;
  31038. static set loggingLevel(value: number);
  31039. /**
  31040. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31041. */
  31042. static get CleanBoneMatrixWeights(): boolean;
  31043. static set CleanBoneMatrixWeights(value: boolean);
  31044. }
  31045. }
  31046. declare module "babylonjs/Meshes/geometry" {
  31047. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31048. import { Scene } from "babylonjs/scene";
  31049. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31050. import { Engine } from "babylonjs/Engines/engine";
  31051. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31052. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31053. import { Effect } from "babylonjs/Materials/effect";
  31054. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31055. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31056. import { Mesh } from "babylonjs/Meshes/mesh";
  31057. /**
  31058. * Class used to store geometry data (vertex buffers + index buffer)
  31059. */
  31060. export class Geometry implements IGetSetVerticesData {
  31061. /**
  31062. * Gets or sets the ID of the geometry
  31063. */
  31064. id: string;
  31065. /**
  31066. * Gets or sets the unique ID of the geometry
  31067. */
  31068. uniqueId: number;
  31069. /**
  31070. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31071. */
  31072. delayLoadState: number;
  31073. /**
  31074. * Gets the file containing the data to load when running in delay load state
  31075. */
  31076. delayLoadingFile: Nullable<string>;
  31077. /**
  31078. * Callback called when the geometry is updated
  31079. */
  31080. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31081. private _scene;
  31082. private _engine;
  31083. private _meshes;
  31084. private _totalVertices;
  31085. /** @hidden */
  31086. _indices: IndicesArray;
  31087. /** @hidden */
  31088. _vertexBuffers: {
  31089. [key: string]: VertexBuffer;
  31090. };
  31091. private _isDisposed;
  31092. private _extend;
  31093. private _boundingBias;
  31094. /** @hidden */
  31095. _delayInfo: Array<string>;
  31096. private _indexBuffer;
  31097. private _indexBufferIsUpdatable;
  31098. /** @hidden */
  31099. _boundingInfo: Nullable<BoundingInfo>;
  31100. /** @hidden */
  31101. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31102. /** @hidden */
  31103. _softwareSkinningFrameId: number;
  31104. private _vertexArrayObjects;
  31105. private _updatable;
  31106. /** @hidden */
  31107. _positions: Nullable<Vector3[]>;
  31108. /**
  31109. * 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
  31110. */
  31111. get boundingBias(): Vector2;
  31112. /**
  31113. * 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
  31114. */
  31115. set boundingBias(value: Vector2);
  31116. /**
  31117. * Static function used to attach a new empty geometry to a mesh
  31118. * @param mesh defines the mesh to attach the geometry to
  31119. * @returns the new Geometry
  31120. */
  31121. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31122. /** Get the list of meshes using this geometry */
  31123. get meshes(): Mesh[];
  31124. /**
  31125. * 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
  31126. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31127. */
  31128. useBoundingInfoFromGeometry: boolean;
  31129. /**
  31130. * Creates a new geometry
  31131. * @param id defines the unique ID
  31132. * @param scene defines the hosting scene
  31133. * @param vertexData defines the VertexData used to get geometry data
  31134. * @param updatable defines if geometry must be updatable (false by default)
  31135. * @param mesh defines the mesh that will be associated with the geometry
  31136. */
  31137. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31138. /**
  31139. * Gets the current extend of the geometry
  31140. */
  31141. get extend(): {
  31142. minimum: Vector3;
  31143. maximum: Vector3;
  31144. };
  31145. /**
  31146. * Gets the hosting scene
  31147. * @returns the hosting Scene
  31148. */
  31149. getScene(): Scene;
  31150. /**
  31151. * Gets the hosting engine
  31152. * @returns the hosting Engine
  31153. */
  31154. getEngine(): Engine;
  31155. /**
  31156. * Defines if the geometry is ready to use
  31157. * @returns true if the geometry is ready to be used
  31158. */
  31159. isReady(): boolean;
  31160. /**
  31161. * Gets a value indicating that the geometry should not be serialized
  31162. */
  31163. get doNotSerialize(): boolean;
  31164. /** @hidden */
  31165. _rebuild(): void;
  31166. /**
  31167. * Affects all geometry data in one call
  31168. * @param vertexData defines the geometry data
  31169. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31170. */
  31171. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31172. /**
  31173. * Set specific vertex data
  31174. * @param kind defines the data kind (Position, normal, etc...)
  31175. * @param data defines the vertex data to use
  31176. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31177. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31178. */
  31179. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31180. /**
  31181. * Removes a specific vertex data
  31182. * @param kind defines the data kind (Position, normal, etc...)
  31183. */
  31184. removeVerticesData(kind: string): void;
  31185. /**
  31186. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31187. * @param buffer defines the vertex buffer to use
  31188. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31189. */
  31190. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31191. /**
  31192. * Update a specific vertex buffer
  31193. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31194. * It will do nothing if the buffer is not updatable
  31195. * @param kind defines the data kind (Position, normal, etc...)
  31196. * @param data defines the data to use
  31197. * @param offset defines the offset in the target buffer where to store the data
  31198. * @param useBytes set to true if the offset is in bytes
  31199. */
  31200. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31201. /**
  31202. * Update a specific vertex buffer
  31203. * This function will create a new buffer if the current one is not updatable
  31204. * @param kind defines the data kind (Position, normal, etc...)
  31205. * @param data defines the data to use
  31206. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31207. */
  31208. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31209. private _updateBoundingInfo;
  31210. /** @hidden */
  31211. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31212. /**
  31213. * Gets total number of vertices
  31214. * @returns the total number of vertices
  31215. */
  31216. getTotalVertices(): number;
  31217. /**
  31218. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31219. * @param kind defines the data kind (Position, normal, etc...)
  31220. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31221. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31222. * @returns a float array containing vertex data
  31223. */
  31224. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31225. /**
  31226. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31227. * @param kind defines the data kind (Position, normal, etc...)
  31228. * @returns true if the vertex buffer with the specified kind is updatable
  31229. */
  31230. isVertexBufferUpdatable(kind: string): boolean;
  31231. /**
  31232. * Gets a specific vertex buffer
  31233. * @param kind defines the data kind (Position, normal, etc...)
  31234. * @returns a VertexBuffer
  31235. */
  31236. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31237. /**
  31238. * Returns all vertex buffers
  31239. * @return an object holding all vertex buffers indexed by kind
  31240. */
  31241. getVertexBuffers(): Nullable<{
  31242. [key: string]: VertexBuffer;
  31243. }>;
  31244. /**
  31245. * Gets a boolean indicating if specific vertex buffer is present
  31246. * @param kind defines the data kind (Position, normal, etc...)
  31247. * @returns true if data is present
  31248. */
  31249. isVerticesDataPresent(kind: string): boolean;
  31250. /**
  31251. * Gets a list of all attached data kinds (Position, normal, etc...)
  31252. * @returns a list of string containing all kinds
  31253. */
  31254. getVerticesDataKinds(): string[];
  31255. /**
  31256. * Update index buffer
  31257. * @param indices defines the indices to store in the index buffer
  31258. * @param offset defines the offset in the target buffer where to store the data
  31259. * @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)
  31260. */
  31261. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31262. /**
  31263. * Creates a new index buffer
  31264. * @param indices defines the indices to store in the index buffer
  31265. * @param totalVertices defines the total number of vertices (could be null)
  31266. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31267. */
  31268. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31269. /**
  31270. * Return the total number of indices
  31271. * @returns the total number of indices
  31272. */
  31273. getTotalIndices(): number;
  31274. /**
  31275. * Gets the index buffer array
  31276. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31277. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31278. * @returns the index buffer array
  31279. */
  31280. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31281. /**
  31282. * Gets the index buffer
  31283. * @return the index buffer
  31284. */
  31285. getIndexBuffer(): Nullable<DataBuffer>;
  31286. /** @hidden */
  31287. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31288. /**
  31289. * Release the associated resources for a specific mesh
  31290. * @param mesh defines the source mesh
  31291. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31292. */
  31293. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31294. /**
  31295. * Apply current geometry to a given mesh
  31296. * @param mesh defines the mesh to apply geometry to
  31297. */
  31298. applyToMesh(mesh: Mesh): void;
  31299. private _updateExtend;
  31300. private _applyToMesh;
  31301. private notifyUpdate;
  31302. /**
  31303. * Load the geometry if it was flagged as delay loaded
  31304. * @param scene defines the hosting scene
  31305. * @param onLoaded defines a callback called when the geometry is loaded
  31306. */
  31307. load(scene: Scene, onLoaded?: () => void): void;
  31308. private _queueLoad;
  31309. /**
  31310. * Invert the geometry to move from a right handed system to a left handed one.
  31311. */
  31312. toLeftHanded(): void;
  31313. /** @hidden */
  31314. _resetPointsArrayCache(): void;
  31315. /** @hidden */
  31316. _generatePointsArray(): boolean;
  31317. /**
  31318. * Gets a value indicating if the geometry is disposed
  31319. * @returns true if the geometry was disposed
  31320. */
  31321. isDisposed(): boolean;
  31322. private _disposeVertexArrayObjects;
  31323. /**
  31324. * Free all associated resources
  31325. */
  31326. dispose(): void;
  31327. /**
  31328. * Clone the current geometry into a new geometry
  31329. * @param id defines the unique ID of the new geometry
  31330. * @returns a new geometry object
  31331. */
  31332. copy(id: string): Geometry;
  31333. /**
  31334. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31335. * @return a JSON representation of the current geometry data (without the vertices data)
  31336. */
  31337. serialize(): any;
  31338. private toNumberArray;
  31339. /**
  31340. * Serialize all vertices data into a JSON oject
  31341. * @returns a JSON representation of the current geometry data
  31342. */
  31343. serializeVerticeData(): any;
  31344. /**
  31345. * Extracts a clone of a mesh geometry
  31346. * @param mesh defines the source mesh
  31347. * @param id defines the unique ID of the new geometry object
  31348. * @returns the new geometry object
  31349. */
  31350. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31351. /**
  31352. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31353. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31354. * Be aware Math.random() could cause collisions, but:
  31355. * "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"
  31356. * @returns a string containing a new GUID
  31357. */
  31358. static RandomId(): string;
  31359. /** @hidden */
  31360. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31361. private static _CleanMatricesWeights;
  31362. /**
  31363. * Create a new geometry from persisted data (Using .babylon file format)
  31364. * @param parsedVertexData defines the persisted data
  31365. * @param scene defines the hosting scene
  31366. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31367. * @returns the new geometry object
  31368. */
  31369. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31370. }
  31371. }
  31372. declare module "babylonjs/Meshes/mesh.vertexData" {
  31373. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31374. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31375. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31376. import { Geometry } from "babylonjs/Meshes/geometry";
  31377. import { Mesh } from "babylonjs/Meshes/mesh";
  31378. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31379. /**
  31380. * Define an interface for all classes that will get and set the data on vertices
  31381. */
  31382. export interface IGetSetVerticesData {
  31383. /**
  31384. * Gets a boolean indicating if specific vertex data is present
  31385. * @param kind defines the vertex data kind to use
  31386. * @returns true is data kind is present
  31387. */
  31388. isVerticesDataPresent(kind: string): boolean;
  31389. /**
  31390. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31391. * @param kind defines the data kind (Position, normal, etc...)
  31392. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31393. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31394. * @returns a float array containing vertex data
  31395. */
  31396. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31397. /**
  31398. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31399. * @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.
  31400. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31401. * @returns the indices array or an empty array if the mesh has no geometry
  31402. */
  31403. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31404. /**
  31405. * Set specific vertex data
  31406. * @param kind defines the data kind (Position, normal, etc...)
  31407. * @param data defines the vertex data to use
  31408. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31409. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31410. */
  31411. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31412. /**
  31413. * Update a specific associated vertex buffer
  31414. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31415. * - VertexBuffer.PositionKind
  31416. * - VertexBuffer.UVKind
  31417. * - VertexBuffer.UV2Kind
  31418. * - VertexBuffer.UV3Kind
  31419. * - VertexBuffer.UV4Kind
  31420. * - VertexBuffer.UV5Kind
  31421. * - VertexBuffer.UV6Kind
  31422. * - VertexBuffer.ColorKind
  31423. * - VertexBuffer.MatricesIndicesKind
  31424. * - VertexBuffer.MatricesIndicesExtraKind
  31425. * - VertexBuffer.MatricesWeightsKind
  31426. * - VertexBuffer.MatricesWeightsExtraKind
  31427. * @param data defines the data source
  31428. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31429. * @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)
  31430. */
  31431. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31432. /**
  31433. * Creates a new index buffer
  31434. * @param indices defines the indices to store in the index buffer
  31435. * @param totalVertices defines the total number of vertices (could be null)
  31436. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31437. */
  31438. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31439. }
  31440. /**
  31441. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31442. */
  31443. export class VertexData {
  31444. /**
  31445. * Mesh side orientation : usually the external or front surface
  31446. */
  31447. static readonly FRONTSIDE: number;
  31448. /**
  31449. * Mesh side orientation : usually the internal or back surface
  31450. */
  31451. static readonly BACKSIDE: number;
  31452. /**
  31453. * Mesh side orientation : both internal and external or front and back surfaces
  31454. */
  31455. static readonly DOUBLESIDE: number;
  31456. /**
  31457. * Mesh side orientation : by default, `FRONTSIDE`
  31458. */
  31459. static readonly DEFAULTSIDE: number;
  31460. /**
  31461. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31462. */
  31463. positions: Nullable<FloatArray>;
  31464. /**
  31465. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31466. */
  31467. normals: Nullable<FloatArray>;
  31468. /**
  31469. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31470. */
  31471. tangents: Nullable<FloatArray>;
  31472. /**
  31473. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31474. */
  31475. uvs: Nullable<FloatArray>;
  31476. /**
  31477. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31478. */
  31479. uvs2: Nullable<FloatArray>;
  31480. /**
  31481. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31482. */
  31483. uvs3: Nullable<FloatArray>;
  31484. /**
  31485. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31486. */
  31487. uvs4: Nullable<FloatArray>;
  31488. /**
  31489. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31490. */
  31491. uvs5: Nullable<FloatArray>;
  31492. /**
  31493. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31494. */
  31495. uvs6: Nullable<FloatArray>;
  31496. /**
  31497. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31498. */
  31499. colors: Nullable<FloatArray>;
  31500. /**
  31501. * 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).
  31502. */
  31503. matricesIndices: Nullable<FloatArray>;
  31504. /**
  31505. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31506. */
  31507. matricesWeights: Nullable<FloatArray>;
  31508. /**
  31509. * An array extending the number of possible indices
  31510. */
  31511. matricesIndicesExtra: Nullable<FloatArray>;
  31512. /**
  31513. * An array extending the number of possible weights when the number of indices is extended
  31514. */
  31515. matricesWeightsExtra: Nullable<FloatArray>;
  31516. /**
  31517. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31518. */
  31519. indices: Nullable<IndicesArray>;
  31520. /**
  31521. * Uses the passed data array to set the set the values for the specified kind of data
  31522. * @param data a linear array of floating numbers
  31523. * @param kind the type of data that is being set, eg positions, colors etc
  31524. */
  31525. set(data: FloatArray, kind: string): void;
  31526. /**
  31527. * Associates the vertexData to the passed Mesh.
  31528. * Sets it as updatable or not (default `false`)
  31529. * @param mesh the mesh the vertexData is applied to
  31530. * @param updatable when used and having the value true allows new data to update the vertexData
  31531. * @returns the VertexData
  31532. */
  31533. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31534. /**
  31535. * Associates the vertexData to the passed Geometry.
  31536. * Sets it as updatable or not (default `false`)
  31537. * @param geometry the geometry the vertexData is applied to
  31538. * @param updatable when used and having the value true allows new data to update the vertexData
  31539. * @returns VertexData
  31540. */
  31541. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31542. /**
  31543. * Updates the associated mesh
  31544. * @param mesh the mesh to be updated
  31545. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31546. * @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
  31547. * @returns VertexData
  31548. */
  31549. updateMesh(mesh: Mesh): VertexData;
  31550. /**
  31551. * Updates the associated geometry
  31552. * @param geometry the geometry to be updated
  31553. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31554. * @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
  31555. * @returns VertexData.
  31556. */
  31557. updateGeometry(geometry: Geometry): VertexData;
  31558. private _applyTo;
  31559. private _update;
  31560. /**
  31561. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31562. * @param matrix the transforming matrix
  31563. * @returns the VertexData
  31564. */
  31565. transform(matrix: Matrix): VertexData;
  31566. /**
  31567. * Merges the passed VertexData into the current one
  31568. * @param other the VertexData to be merged into the current one
  31569. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31570. * @returns the modified VertexData
  31571. */
  31572. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31573. private _mergeElement;
  31574. private _validate;
  31575. /**
  31576. * Serializes the VertexData
  31577. * @returns a serialized object
  31578. */
  31579. serialize(): any;
  31580. /**
  31581. * Extracts the vertexData from a mesh
  31582. * @param mesh the mesh from which to extract the VertexData
  31583. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31584. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31585. * @returns the object VertexData associated to the passed mesh
  31586. */
  31587. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31588. /**
  31589. * Extracts the vertexData from the geometry
  31590. * @param geometry the geometry from which to extract the VertexData
  31591. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31592. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31593. * @returns the object VertexData associated to the passed mesh
  31594. */
  31595. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31596. private static _ExtractFrom;
  31597. /**
  31598. * Creates the VertexData for a Ribbon
  31599. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31600. * * pathArray array of paths, each of which an array of successive Vector3
  31601. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31602. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31603. * * 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
  31604. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31605. * * 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)
  31606. * * 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)
  31607. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31608. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31609. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31610. * @returns the VertexData of the ribbon
  31611. */
  31612. static CreateRibbon(options: {
  31613. pathArray: Vector3[][];
  31614. closeArray?: boolean;
  31615. closePath?: boolean;
  31616. offset?: number;
  31617. sideOrientation?: number;
  31618. frontUVs?: Vector4;
  31619. backUVs?: Vector4;
  31620. invertUV?: boolean;
  31621. uvs?: Vector2[];
  31622. colors?: Color4[];
  31623. }): VertexData;
  31624. /**
  31625. * Creates the VertexData for a box
  31626. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31627. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31628. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31629. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31630. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31631. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31632. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31634. * * 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)
  31635. * * 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)
  31636. * @returns the VertexData of the box
  31637. */
  31638. static CreateBox(options: {
  31639. size?: number;
  31640. width?: number;
  31641. height?: number;
  31642. depth?: number;
  31643. faceUV?: Vector4[];
  31644. faceColors?: Color4[];
  31645. sideOrientation?: number;
  31646. frontUVs?: Vector4;
  31647. backUVs?: Vector4;
  31648. }): VertexData;
  31649. /**
  31650. * Creates the VertexData for a tiled box
  31651. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31652. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31653. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31654. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31656. * @returns the VertexData of the box
  31657. */
  31658. static CreateTiledBox(options: {
  31659. pattern?: number;
  31660. width?: number;
  31661. height?: number;
  31662. depth?: number;
  31663. tileSize?: number;
  31664. tileWidth?: number;
  31665. tileHeight?: number;
  31666. alignHorizontal?: number;
  31667. alignVertical?: number;
  31668. faceUV?: Vector4[];
  31669. faceColors?: Color4[];
  31670. sideOrientation?: number;
  31671. }): VertexData;
  31672. /**
  31673. * Creates the VertexData for a tiled plane
  31674. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31675. * * pattern a limited pattern arrangement depending on the number
  31676. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31677. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31678. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  31679. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31680. * * 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)
  31681. * * 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)
  31682. * @returns the VertexData of the tiled plane
  31683. */
  31684. static CreateTiledPlane(options: {
  31685. pattern?: number;
  31686. tileSize?: number;
  31687. tileWidth?: number;
  31688. tileHeight?: number;
  31689. size?: number;
  31690. width?: number;
  31691. height?: number;
  31692. alignHorizontal?: number;
  31693. alignVertical?: number;
  31694. sideOrientation?: number;
  31695. frontUVs?: Vector4;
  31696. backUVs?: Vector4;
  31697. }): VertexData;
  31698. /**
  31699. * Creates the VertexData for an ellipsoid, defaults to a sphere
  31700. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31701. * * segments sets the number of horizontal strips optional, default 32
  31702. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  31703. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  31704. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  31705. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  31706. * * 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
  31707. * * 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
  31708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31709. * * 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)
  31710. * * 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)
  31711. * @returns the VertexData of the ellipsoid
  31712. */
  31713. static CreateSphere(options: {
  31714. segments?: number;
  31715. diameter?: number;
  31716. diameterX?: number;
  31717. diameterY?: number;
  31718. diameterZ?: number;
  31719. arc?: number;
  31720. slice?: number;
  31721. sideOrientation?: number;
  31722. frontUVs?: Vector4;
  31723. backUVs?: Vector4;
  31724. }): VertexData;
  31725. /**
  31726. * Creates the VertexData for a cylinder, cone or prism
  31727. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31728. * * height sets the height (y direction) of the cylinder, optional, default 2
  31729. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  31730. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  31731. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  31732. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31733. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  31734. * * 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
  31735. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31736. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31737. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  31738. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  31739. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31740. * * 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)
  31741. * * 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)
  31742. * @returns the VertexData of the cylinder, cone or prism
  31743. */
  31744. static CreateCylinder(options: {
  31745. height?: number;
  31746. diameterTop?: number;
  31747. diameterBottom?: number;
  31748. diameter?: number;
  31749. tessellation?: number;
  31750. subdivisions?: number;
  31751. arc?: number;
  31752. faceColors?: Color4[];
  31753. faceUV?: Vector4[];
  31754. hasRings?: boolean;
  31755. enclose?: boolean;
  31756. sideOrientation?: number;
  31757. frontUVs?: Vector4;
  31758. backUVs?: Vector4;
  31759. }): VertexData;
  31760. /**
  31761. * Creates the VertexData for a torus
  31762. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31763. * * diameter the diameter of the torus, optional default 1
  31764. * * thickness the diameter of the tube forming the torus, optional default 0.5
  31765. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31766. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31767. * * 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)
  31768. * * 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)
  31769. * @returns the VertexData of the torus
  31770. */
  31771. static CreateTorus(options: {
  31772. diameter?: number;
  31773. thickness?: number;
  31774. tessellation?: number;
  31775. sideOrientation?: number;
  31776. frontUVs?: Vector4;
  31777. backUVs?: Vector4;
  31778. }): VertexData;
  31779. /**
  31780. * Creates the VertexData of the LineSystem
  31781. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  31782. * - lines an array of lines, each line being an array of successive Vector3
  31783. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  31784. * @returns the VertexData of the LineSystem
  31785. */
  31786. static CreateLineSystem(options: {
  31787. lines: Vector3[][];
  31788. colors?: Nullable<Color4[][]>;
  31789. }): VertexData;
  31790. /**
  31791. * Create the VertexData for a DashedLines
  31792. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  31793. * - points an array successive Vector3
  31794. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  31795. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  31796. * - dashNb the intended total number of dashes, optional, default 200
  31797. * @returns the VertexData for the DashedLines
  31798. */
  31799. static CreateDashedLines(options: {
  31800. points: Vector3[];
  31801. dashSize?: number;
  31802. gapSize?: number;
  31803. dashNb?: number;
  31804. }): VertexData;
  31805. /**
  31806. * Creates the VertexData for a Ground
  31807. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31808. * - width the width (x direction) of the ground, optional, default 1
  31809. * - height the height (z direction) of the ground, optional, default 1
  31810. * - subdivisions the number of subdivisions per side, optional, default 1
  31811. * @returns the VertexData of the Ground
  31812. */
  31813. static CreateGround(options: {
  31814. width?: number;
  31815. height?: number;
  31816. subdivisions?: number;
  31817. subdivisionsX?: number;
  31818. subdivisionsY?: number;
  31819. }): VertexData;
  31820. /**
  31821. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  31822. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31823. * * xmin the ground minimum X coordinate, optional, default -1
  31824. * * zmin the ground minimum Z coordinate, optional, default -1
  31825. * * xmax the ground maximum X coordinate, optional, default 1
  31826. * * zmax the ground maximum Z coordinate, optional, default 1
  31827. * * 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}
  31828. * * 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}
  31829. * @returns the VertexData of the TiledGround
  31830. */
  31831. static CreateTiledGround(options: {
  31832. xmin: number;
  31833. zmin: number;
  31834. xmax: number;
  31835. zmax: number;
  31836. subdivisions?: {
  31837. w: number;
  31838. h: number;
  31839. };
  31840. precision?: {
  31841. w: number;
  31842. h: number;
  31843. };
  31844. }): VertexData;
  31845. /**
  31846. * Creates the VertexData of the Ground designed from a heightmap
  31847. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  31848. * * width the width (x direction) of the ground
  31849. * * height the height (z direction) of the ground
  31850. * * subdivisions the number of subdivisions per side
  31851. * * minHeight the minimum altitude on the ground, optional, default 0
  31852. * * maxHeight the maximum altitude on the ground, optional default 1
  31853. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  31854. * * buffer the array holding the image color data
  31855. * * bufferWidth the width of image
  31856. * * bufferHeight the height of image
  31857. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  31858. * @returns the VertexData of the Ground designed from a heightmap
  31859. */
  31860. static CreateGroundFromHeightMap(options: {
  31861. width: number;
  31862. height: number;
  31863. subdivisions: number;
  31864. minHeight: number;
  31865. maxHeight: number;
  31866. colorFilter: Color3;
  31867. buffer: Uint8Array;
  31868. bufferWidth: number;
  31869. bufferHeight: number;
  31870. alphaFilter: number;
  31871. }): VertexData;
  31872. /**
  31873. * Creates the VertexData for a Plane
  31874. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  31875. * * size sets the width and height of the plane to the value of size, optional default 1
  31876. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  31877. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  31878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31879. * * 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)
  31880. * * 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)
  31881. * @returns the VertexData of the box
  31882. */
  31883. static CreatePlane(options: {
  31884. size?: number;
  31885. width?: number;
  31886. height?: number;
  31887. sideOrientation?: number;
  31888. frontUVs?: Vector4;
  31889. backUVs?: Vector4;
  31890. }): VertexData;
  31891. /**
  31892. * Creates the VertexData of the Disc or regular Polygon
  31893. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  31894. * * radius the radius of the disc, optional default 0.5
  31895. * * tessellation the number of polygon sides, optional, default 64
  31896. * * 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
  31897. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31898. * * 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)
  31899. * * 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)
  31900. * @returns the VertexData of the box
  31901. */
  31902. static CreateDisc(options: {
  31903. radius?: number;
  31904. tessellation?: number;
  31905. arc?: number;
  31906. sideOrientation?: number;
  31907. frontUVs?: Vector4;
  31908. backUVs?: Vector4;
  31909. }): VertexData;
  31910. /**
  31911. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  31912. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  31913. * @param polygon a mesh built from polygonTriangulation.build()
  31914. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31915. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31916. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31917. * @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)
  31918. * @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)
  31919. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31920. * @returns the VertexData of the Polygon
  31921. */
  31922. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31923. /**
  31924. * Creates the VertexData of the IcoSphere
  31925. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31926. * * radius the radius of the IcoSphere, optional default 1
  31927. * * radiusX allows stretching in the x direction, optional, default radius
  31928. * * radiusY allows stretching in the y direction, optional, default radius
  31929. * * radiusZ allows stretching in the z direction, optional, default radius
  31930. * * flat when true creates a flat shaded mesh, optional, default true
  31931. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31932. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31933. * * 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)
  31934. * * 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)
  31935. * @returns the VertexData of the IcoSphere
  31936. */
  31937. static CreateIcoSphere(options: {
  31938. radius?: number;
  31939. radiusX?: number;
  31940. radiusY?: number;
  31941. radiusZ?: number;
  31942. flat?: boolean;
  31943. subdivisions?: number;
  31944. sideOrientation?: number;
  31945. frontUVs?: Vector4;
  31946. backUVs?: Vector4;
  31947. }): VertexData;
  31948. /**
  31949. * Creates the VertexData for a Polyhedron
  31950. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31951. * * type provided types are:
  31952. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31953. * * 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)
  31954. * * size the size of the IcoSphere, optional default 1
  31955. * * sizeX allows stretching in the x direction, optional, default size
  31956. * * sizeY allows stretching in the y direction, optional, default size
  31957. * * sizeZ allows stretching in the z direction, optional, default size
  31958. * * 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
  31959. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31960. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31961. * * flat when true creates a flat shaded mesh, optional, default true
  31962. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31964. * * 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)
  31965. * * 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)
  31966. * @returns the VertexData of the Polyhedron
  31967. */
  31968. static CreatePolyhedron(options: {
  31969. type?: number;
  31970. size?: number;
  31971. sizeX?: number;
  31972. sizeY?: number;
  31973. sizeZ?: number;
  31974. custom?: any;
  31975. faceUV?: Vector4[];
  31976. faceColors?: Color4[];
  31977. flat?: boolean;
  31978. sideOrientation?: number;
  31979. frontUVs?: Vector4;
  31980. backUVs?: Vector4;
  31981. }): VertexData;
  31982. /**
  31983. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  31984. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  31985. * @returns the VertexData of the Capsule
  31986. */
  31987. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  31988. /**
  31989. * Creates the VertexData for a TorusKnot
  31990. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  31991. * * radius the radius of the torus knot, optional, default 2
  31992. * * tube the thickness of the tube, optional, default 0.5
  31993. * * radialSegments the number of sides on each tube segments, optional, default 32
  31994. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  31995. * * p the number of windings around the z axis, optional, default 2
  31996. * * q the number of windings around the x axis, optional, default 3
  31997. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31998. * * 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)
  31999. * * 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)
  32000. * @returns the VertexData of the Torus Knot
  32001. */
  32002. static CreateTorusKnot(options: {
  32003. radius?: number;
  32004. tube?: number;
  32005. radialSegments?: number;
  32006. tubularSegments?: number;
  32007. p?: number;
  32008. q?: number;
  32009. sideOrientation?: number;
  32010. frontUVs?: Vector4;
  32011. backUVs?: Vector4;
  32012. }): VertexData;
  32013. /**
  32014. * Compute normals for given positions and indices
  32015. * @param positions an array of vertex positions, [...., x, y, z, ......]
  32016. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  32017. * @param normals an array of vertex normals, [...., x, y, z, ......]
  32018. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  32019. * * facetNormals : optional array of facet normals (vector3)
  32020. * * facetPositions : optional array of facet positions (vector3)
  32021. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  32022. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  32023. * * bInfo : optional bounding info, required for facetPartitioning computation
  32024. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  32025. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  32026. * * useRightHandedSystem: optional boolean to for right handed system computation
  32027. * * depthSort : optional boolean to enable the facet depth sort computation
  32028. * * distanceTo : optional Vector3 to compute the facet depth from this location
  32029. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  32030. */
  32031. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  32032. facetNormals?: any;
  32033. facetPositions?: any;
  32034. facetPartitioning?: any;
  32035. ratio?: number;
  32036. bInfo?: any;
  32037. bbSize?: Vector3;
  32038. subDiv?: any;
  32039. useRightHandedSystem?: boolean;
  32040. depthSort?: boolean;
  32041. distanceTo?: Vector3;
  32042. depthSortedFacets?: any;
  32043. }): void;
  32044. /** @hidden */
  32045. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  32046. /**
  32047. * Applies VertexData created from the imported parameters to the geometry
  32048. * @param parsedVertexData the parsed data from an imported file
  32049. * @param geometry the geometry to apply the VertexData to
  32050. */
  32051. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  32052. }
  32053. }
  32054. declare module "babylonjs/Morph/morphTarget" {
  32055. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32056. import { Observable } from "babylonjs/Misc/observable";
  32057. import { Nullable, FloatArray } from "babylonjs/types";
  32058. import { Scene } from "babylonjs/scene";
  32059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32060. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32061. /**
  32062. * Defines a target to use with MorphTargetManager
  32063. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32064. */
  32065. export class MorphTarget implements IAnimatable {
  32066. /** defines the name of the target */
  32067. name: string;
  32068. /**
  32069. * Gets or sets the list of animations
  32070. */
  32071. animations: import("babylonjs/Animations/animation").Animation[];
  32072. private _scene;
  32073. private _positions;
  32074. private _normals;
  32075. private _tangents;
  32076. private _uvs;
  32077. private _influence;
  32078. private _uniqueId;
  32079. /**
  32080. * Observable raised when the influence changes
  32081. */
  32082. onInfluenceChanged: Observable<boolean>;
  32083. /** @hidden */
  32084. _onDataLayoutChanged: Observable<void>;
  32085. /**
  32086. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32087. */
  32088. get influence(): number;
  32089. set influence(influence: number);
  32090. /**
  32091. * Gets or sets the id of the morph Target
  32092. */
  32093. id: string;
  32094. private _animationPropertiesOverride;
  32095. /**
  32096. * Gets or sets the animation properties override
  32097. */
  32098. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32099. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32100. /**
  32101. * Creates a new MorphTarget
  32102. * @param name defines the name of the target
  32103. * @param influence defines the influence to use
  32104. * @param scene defines the scene the morphtarget belongs to
  32105. */
  32106. constructor(
  32107. /** defines the name of the target */
  32108. name: string, influence?: number, scene?: Nullable<Scene>);
  32109. /**
  32110. * Gets the unique ID of this manager
  32111. */
  32112. get uniqueId(): number;
  32113. /**
  32114. * Gets a boolean defining if the target contains position data
  32115. */
  32116. get hasPositions(): boolean;
  32117. /**
  32118. * Gets a boolean defining if the target contains normal data
  32119. */
  32120. get hasNormals(): boolean;
  32121. /**
  32122. * Gets a boolean defining if the target contains tangent data
  32123. */
  32124. get hasTangents(): boolean;
  32125. /**
  32126. * Gets a boolean defining if the target contains texture coordinates data
  32127. */
  32128. get hasUVs(): boolean;
  32129. /**
  32130. * Affects position data to this target
  32131. * @param data defines the position data to use
  32132. */
  32133. setPositions(data: Nullable<FloatArray>): void;
  32134. /**
  32135. * Gets the position data stored in this target
  32136. * @returns a FloatArray containing the position data (or null if not present)
  32137. */
  32138. getPositions(): Nullable<FloatArray>;
  32139. /**
  32140. * Affects normal data to this target
  32141. * @param data defines the normal data to use
  32142. */
  32143. setNormals(data: Nullable<FloatArray>): void;
  32144. /**
  32145. * Gets the normal data stored in this target
  32146. * @returns a FloatArray containing the normal data (or null if not present)
  32147. */
  32148. getNormals(): Nullable<FloatArray>;
  32149. /**
  32150. * Affects tangent data to this target
  32151. * @param data defines the tangent data to use
  32152. */
  32153. setTangents(data: Nullable<FloatArray>): void;
  32154. /**
  32155. * Gets the tangent data stored in this target
  32156. * @returns a FloatArray containing the tangent data (or null if not present)
  32157. */
  32158. getTangents(): Nullable<FloatArray>;
  32159. /**
  32160. * Affects texture coordinates data to this target
  32161. * @param data defines the texture coordinates data to use
  32162. */
  32163. setUVs(data: Nullable<FloatArray>): void;
  32164. /**
  32165. * Gets the texture coordinates data stored in this target
  32166. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32167. */
  32168. getUVs(): Nullable<FloatArray>;
  32169. /**
  32170. * Clone the current target
  32171. * @returns a new MorphTarget
  32172. */
  32173. clone(): MorphTarget;
  32174. /**
  32175. * Serializes the current target into a Serialization object
  32176. * @returns the serialized object
  32177. */
  32178. serialize(): any;
  32179. /**
  32180. * Returns the string "MorphTarget"
  32181. * @returns "MorphTarget"
  32182. */
  32183. getClassName(): string;
  32184. /**
  32185. * Creates a new target from serialized data
  32186. * @param serializationObject defines the serialized data to use
  32187. * @returns a new MorphTarget
  32188. */
  32189. static Parse(serializationObject: any): MorphTarget;
  32190. /**
  32191. * Creates a MorphTarget from mesh data
  32192. * @param mesh defines the source mesh
  32193. * @param name defines the name to use for the new target
  32194. * @param influence defines the influence to attach to the target
  32195. * @returns a new MorphTarget
  32196. */
  32197. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32198. }
  32199. }
  32200. declare module "babylonjs/Morph/morphTargetManager" {
  32201. import { Nullable } from "babylonjs/types";
  32202. import { Scene } from "babylonjs/scene";
  32203. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32204. /**
  32205. * This class is used to deform meshes using morphing between different targets
  32206. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32207. */
  32208. export class MorphTargetManager {
  32209. private _targets;
  32210. private _targetInfluenceChangedObservers;
  32211. private _targetDataLayoutChangedObservers;
  32212. private _activeTargets;
  32213. private _scene;
  32214. private _influences;
  32215. private _supportsNormals;
  32216. private _supportsTangents;
  32217. private _supportsUVs;
  32218. private _vertexCount;
  32219. private _uniqueId;
  32220. private _tempInfluences;
  32221. /**
  32222. * Gets or sets a boolean indicating if normals must be morphed
  32223. */
  32224. enableNormalMorphing: boolean;
  32225. /**
  32226. * Gets or sets a boolean indicating if tangents must be morphed
  32227. */
  32228. enableTangentMorphing: boolean;
  32229. /**
  32230. * Gets or sets a boolean indicating if UV must be morphed
  32231. */
  32232. enableUVMorphing: boolean;
  32233. /**
  32234. * Creates a new MorphTargetManager
  32235. * @param scene defines the current scene
  32236. */
  32237. constructor(scene?: Nullable<Scene>);
  32238. /**
  32239. * Gets the unique ID of this manager
  32240. */
  32241. get uniqueId(): number;
  32242. /**
  32243. * Gets the number of vertices handled by this manager
  32244. */
  32245. get vertexCount(): number;
  32246. /**
  32247. * Gets a boolean indicating if this manager supports morphing of normals
  32248. */
  32249. get supportsNormals(): boolean;
  32250. /**
  32251. * Gets a boolean indicating if this manager supports morphing of tangents
  32252. */
  32253. get supportsTangents(): boolean;
  32254. /**
  32255. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32256. */
  32257. get supportsUVs(): boolean;
  32258. /**
  32259. * Gets the number of targets stored in this manager
  32260. */
  32261. get numTargets(): number;
  32262. /**
  32263. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32264. */
  32265. get numInfluencers(): number;
  32266. /**
  32267. * Gets the list of influences (one per target)
  32268. */
  32269. get influences(): Float32Array;
  32270. /**
  32271. * Gets the active target at specified index. An active target is a target with an influence > 0
  32272. * @param index defines the index to check
  32273. * @returns the requested target
  32274. */
  32275. getActiveTarget(index: number): MorphTarget;
  32276. /**
  32277. * Gets the target at specified index
  32278. * @param index defines the index to check
  32279. * @returns the requested target
  32280. */
  32281. getTarget(index: number): MorphTarget;
  32282. /**
  32283. * Add a new target to this manager
  32284. * @param target defines the target to add
  32285. */
  32286. addTarget(target: MorphTarget): void;
  32287. /**
  32288. * Removes a target from the manager
  32289. * @param target defines the target to remove
  32290. */
  32291. removeTarget(target: MorphTarget): void;
  32292. /**
  32293. * Clone the current manager
  32294. * @returns a new MorphTargetManager
  32295. */
  32296. clone(): MorphTargetManager;
  32297. /**
  32298. * Serializes the current manager into a Serialization object
  32299. * @returns the serialized object
  32300. */
  32301. serialize(): any;
  32302. private _syncActiveTargets;
  32303. /**
  32304. * Syncrhonize the targets with all the meshes using this morph target manager
  32305. */
  32306. synchronize(): void;
  32307. /**
  32308. * Creates a new MorphTargetManager from serialized data
  32309. * @param serializationObject defines the serialized data
  32310. * @param scene defines the hosting scene
  32311. * @returns the new MorphTargetManager
  32312. */
  32313. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32314. }
  32315. }
  32316. declare module "babylonjs/Meshes/meshLODLevel" {
  32317. import { Mesh } from "babylonjs/Meshes/mesh";
  32318. import { Nullable } from "babylonjs/types";
  32319. /**
  32320. * Class used to represent a specific level of detail of a mesh
  32321. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32322. */
  32323. export class MeshLODLevel {
  32324. /** Defines the distance where this level should start being displayed */
  32325. distance: number;
  32326. /** Defines the mesh to use to render this level */
  32327. mesh: Nullable<Mesh>;
  32328. /**
  32329. * Creates a new LOD level
  32330. * @param distance defines the distance where this level should star being displayed
  32331. * @param mesh defines the mesh to use to render this level
  32332. */
  32333. constructor(
  32334. /** Defines the distance where this level should start being displayed */
  32335. distance: number,
  32336. /** Defines the mesh to use to render this level */
  32337. mesh: Nullable<Mesh>);
  32338. }
  32339. }
  32340. declare module "babylonjs/Misc/canvasGenerator" {
  32341. /**
  32342. * Helper class used to generate a canvas to manipulate images
  32343. */
  32344. export class CanvasGenerator {
  32345. /**
  32346. * Create a new canvas (or offscreen canvas depending on the context)
  32347. * @param width defines the expected width
  32348. * @param height defines the expected height
  32349. * @return a new canvas or offscreen canvas
  32350. */
  32351. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32352. }
  32353. }
  32354. declare module "babylonjs/Meshes/groundMesh" {
  32355. import { Scene } from "babylonjs/scene";
  32356. import { Vector3 } from "babylonjs/Maths/math.vector";
  32357. import { Mesh } from "babylonjs/Meshes/mesh";
  32358. /**
  32359. * Mesh representing the gorund
  32360. */
  32361. export class GroundMesh extends Mesh {
  32362. /** If octree should be generated */
  32363. generateOctree: boolean;
  32364. private _heightQuads;
  32365. /** @hidden */
  32366. _subdivisionsX: number;
  32367. /** @hidden */
  32368. _subdivisionsY: number;
  32369. /** @hidden */
  32370. _width: number;
  32371. /** @hidden */
  32372. _height: number;
  32373. /** @hidden */
  32374. _minX: number;
  32375. /** @hidden */
  32376. _maxX: number;
  32377. /** @hidden */
  32378. _minZ: number;
  32379. /** @hidden */
  32380. _maxZ: number;
  32381. constructor(name: string, scene: Scene);
  32382. /**
  32383. * "GroundMesh"
  32384. * @returns "GroundMesh"
  32385. */
  32386. getClassName(): string;
  32387. /**
  32388. * The minimum of x and y subdivisions
  32389. */
  32390. get subdivisions(): number;
  32391. /**
  32392. * X subdivisions
  32393. */
  32394. get subdivisionsX(): number;
  32395. /**
  32396. * Y subdivisions
  32397. */
  32398. get subdivisionsY(): number;
  32399. /**
  32400. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32401. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32402. * @param chunksCount the number of subdivisions for x and y
  32403. * @param octreeBlocksSize (Default: 32)
  32404. */
  32405. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32406. /**
  32407. * Returns a height (y) value in the Worl system :
  32408. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32409. * @param x x coordinate
  32410. * @param z z coordinate
  32411. * @returns the ground y position if (x, z) are outside the ground surface.
  32412. */
  32413. getHeightAtCoordinates(x: number, z: number): number;
  32414. /**
  32415. * Returns a normalized vector (Vector3) orthogonal to the ground
  32416. * at the ground coordinates (x, z) expressed in the World system.
  32417. * @param x x coordinate
  32418. * @param z z coordinate
  32419. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32420. */
  32421. getNormalAtCoordinates(x: number, z: number): Vector3;
  32422. /**
  32423. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32424. * at the ground coordinates (x, z) expressed in the World system.
  32425. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32426. * @param x x coordinate
  32427. * @param z z coordinate
  32428. * @param ref vector to store the result
  32429. * @returns the GroundMesh.
  32430. */
  32431. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32432. /**
  32433. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32434. * if the ground has been updated.
  32435. * This can be used in the render loop.
  32436. * @returns the GroundMesh.
  32437. */
  32438. updateCoordinateHeights(): GroundMesh;
  32439. private _getFacetAt;
  32440. private _initHeightQuads;
  32441. private _computeHeightQuads;
  32442. /**
  32443. * Serializes this ground mesh
  32444. * @param serializationObject object to write serialization to
  32445. */
  32446. serialize(serializationObject: any): void;
  32447. /**
  32448. * Parses a serialized ground mesh
  32449. * @param parsedMesh the serialized mesh
  32450. * @param scene the scene to create the ground mesh in
  32451. * @returns the created ground mesh
  32452. */
  32453. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32454. }
  32455. }
  32456. declare module "babylonjs/Physics/physicsJoint" {
  32457. import { Vector3 } from "babylonjs/Maths/math.vector";
  32458. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32459. /**
  32460. * Interface for Physics-Joint data
  32461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32462. */
  32463. export interface PhysicsJointData {
  32464. /**
  32465. * The main pivot of the joint
  32466. */
  32467. mainPivot?: Vector3;
  32468. /**
  32469. * The connected pivot of the joint
  32470. */
  32471. connectedPivot?: Vector3;
  32472. /**
  32473. * The main axis of the joint
  32474. */
  32475. mainAxis?: Vector3;
  32476. /**
  32477. * The connected axis of the joint
  32478. */
  32479. connectedAxis?: Vector3;
  32480. /**
  32481. * The collision of the joint
  32482. */
  32483. collision?: boolean;
  32484. /**
  32485. * Native Oimo/Cannon/Energy data
  32486. */
  32487. nativeParams?: any;
  32488. }
  32489. /**
  32490. * This is a holder class for the physics joint created by the physics plugin
  32491. * It holds a set of functions to control the underlying joint
  32492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32493. */
  32494. export class PhysicsJoint {
  32495. /**
  32496. * The type of the physics joint
  32497. */
  32498. type: number;
  32499. /**
  32500. * The data for the physics joint
  32501. */
  32502. jointData: PhysicsJointData;
  32503. private _physicsJoint;
  32504. protected _physicsPlugin: IPhysicsEnginePlugin;
  32505. /**
  32506. * Initializes the physics joint
  32507. * @param type The type of the physics joint
  32508. * @param jointData The data for the physics joint
  32509. */
  32510. constructor(
  32511. /**
  32512. * The type of the physics joint
  32513. */
  32514. type: number,
  32515. /**
  32516. * The data for the physics joint
  32517. */
  32518. jointData: PhysicsJointData);
  32519. /**
  32520. * Gets the physics joint
  32521. */
  32522. get physicsJoint(): any;
  32523. /**
  32524. * Sets the physics joint
  32525. */
  32526. set physicsJoint(newJoint: any);
  32527. /**
  32528. * Sets the physics plugin
  32529. */
  32530. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32531. /**
  32532. * Execute a function that is physics-plugin specific.
  32533. * @param {Function} func the function that will be executed.
  32534. * It accepts two parameters: the physics world and the physics joint
  32535. */
  32536. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32537. /**
  32538. * Distance-Joint type
  32539. */
  32540. static DistanceJoint: number;
  32541. /**
  32542. * Hinge-Joint type
  32543. */
  32544. static HingeJoint: number;
  32545. /**
  32546. * Ball-and-Socket joint type
  32547. */
  32548. static BallAndSocketJoint: number;
  32549. /**
  32550. * Wheel-Joint type
  32551. */
  32552. static WheelJoint: number;
  32553. /**
  32554. * Slider-Joint type
  32555. */
  32556. static SliderJoint: number;
  32557. /**
  32558. * Prismatic-Joint type
  32559. */
  32560. static PrismaticJoint: number;
  32561. /**
  32562. * Universal-Joint type
  32563. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32564. */
  32565. static UniversalJoint: number;
  32566. /**
  32567. * Hinge-Joint 2 type
  32568. */
  32569. static Hinge2Joint: number;
  32570. /**
  32571. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32572. */
  32573. static PointToPointJoint: number;
  32574. /**
  32575. * Spring-Joint type
  32576. */
  32577. static SpringJoint: number;
  32578. /**
  32579. * Lock-Joint type
  32580. */
  32581. static LockJoint: number;
  32582. }
  32583. /**
  32584. * A class representing a physics distance joint
  32585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32586. */
  32587. export class DistanceJoint extends PhysicsJoint {
  32588. /**
  32589. *
  32590. * @param jointData The data for the Distance-Joint
  32591. */
  32592. constructor(jointData: DistanceJointData);
  32593. /**
  32594. * Update the predefined distance.
  32595. * @param maxDistance The maximum preferred distance
  32596. * @param minDistance The minimum preferred distance
  32597. */
  32598. updateDistance(maxDistance: number, minDistance?: number): void;
  32599. }
  32600. /**
  32601. * Represents a Motor-Enabled Joint
  32602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32603. */
  32604. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32605. /**
  32606. * Initializes the Motor-Enabled Joint
  32607. * @param type The type of the joint
  32608. * @param jointData The physica joint data for the joint
  32609. */
  32610. constructor(type: number, jointData: PhysicsJointData);
  32611. /**
  32612. * Set the motor values.
  32613. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32614. * @param force the force to apply
  32615. * @param maxForce max force for this motor.
  32616. */
  32617. setMotor(force?: number, maxForce?: number): void;
  32618. /**
  32619. * Set the motor's limits.
  32620. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32621. * @param upperLimit The upper limit of the motor
  32622. * @param lowerLimit The lower limit of the motor
  32623. */
  32624. setLimit(upperLimit: number, lowerLimit?: number): void;
  32625. }
  32626. /**
  32627. * This class represents a single physics Hinge-Joint
  32628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32629. */
  32630. export class HingeJoint extends MotorEnabledJoint {
  32631. /**
  32632. * Initializes the Hinge-Joint
  32633. * @param jointData The joint data for the Hinge-Joint
  32634. */
  32635. constructor(jointData: PhysicsJointData);
  32636. /**
  32637. * Set the motor values.
  32638. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32639. * @param {number} force the force to apply
  32640. * @param {number} maxForce max force for this motor.
  32641. */
  32642. setMotor(force?: number, maxForce?: number): void;
  32643. /**
  32644. * Set the motor's limits.
  32645. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32646. * @param upperLimit The upper limit of the motor
  32647. * @param lowerLimit The lower limit of the motor
  32648. */
  32649. setLimit(upperLimit: number, lowerLimit?: number): void;
  32650. }
  32651. /**
  32652. * This class represents a dual hinge physics joint (same as wheel joint)
  32653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32654. */
  32655. export class Hinge2Joint extends MotorEnabledJoint {
  32656. /**
  32657. * Initializes the Hinge2-Joint
  32658. * @param jointData The joint data for the Hinge2-Joint
  32659. */
  32660. constructor(jointData: PhysicsJointData);
  32661. /**
  32662. * Set the motor values.
  32663. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32664. * @param {number} targetSpeed the speed the motor is to reach
  32665. * @param {number} maxForce max force for this motor.
  32666. * @param {motorIndex} the motor's index, 0 or 1.
  32667. */
  32668. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32669. /**
  32670. * Set the motor limits.
  32671. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32672. * @param {number} upperLimit the upper limit
  32673. * @param {number} lowerLimit lower limit
  32674. * @param {motorIndex} the motor's index, 0 or 1.
  32675. */
  32676. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32677. }
  32678. /**
  32679. * Interface for a motor enabled joint
  32680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32681. */
  32682. export interface IMotorEnabledJoint {
  32683. /**
  32684. * Physics joint
  32685. */
  32686. physicsJoint: any;
  32687. /**
  32688. * Sets the motor of the motor-enabled joint
  32689. * @param force The force of the motor
  32690. * @param maxForce The maximum force of the motor
  32691. * @param motorIndex The index of the motor
  32692. */
  32693. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32694. /**
  32695. * Sets the limit of the motor
  32696. * @param upperLimit The upper limit of the motor
  32697. * @param lowerLimit The lower limit of the motor
  32698. * @param motorIndex The index of the motor
  32699. */
  32700. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32701. }
  32702. /**
  32703. * Joint data for a Distance-Joint
  32704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32705. */
  32706. export interface DistanceJointData extends PhysicsJointData {
  32707. /**
  32708. * Max distance the 2 joint objects can be apart
  32709. */
  32710. maxDistance: number;
  32711. }
  32712. /**
  32713. * Joint data from a spring joint
  32714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32715. */
  32716. export interface SpringJointData extends PhysicsJointData {
  32717. /**
  32718. * Length of the spring
  32719. */
  32720. length: number;
  32721. /**
  32722. * Stiffness of the spring
  32723. */
  32724. stiffness: number;
  32725. /**
  32726. * Damping of the spring
  32727. */
  32728. damping: number;
  32729. /** this callback will be called when applying the force to the impostors. */
  32730. forceApplicationCallback: () => void;
  32731. }
  32732. }
  32733. declare module "babylonjs/Physics/physicsRaycastResult" {
  32734. import { Vector3 } from "babylonjs/Maths/math.vector";
  32735. /**
  32736. * Holds the data for the raycast result
  32737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32738. */
  32739. export class PhysicsRaycastResult {
  32740. private _hasHit;
  32741. private _hitDistance;
  32742. private _hitNormalWorld;
  32743. private _hitPointWorld;
  32744. private _rayFromWorld;
  32745. private _rayToWorld;
  32746. /**
  32747. * Gets if there was a hit
  32748. */
  32749. get hasHit(): boolean;
  32750. /**
  32751. * Gets the distance from the hit
  32752. */
  32753. get hitDistance(): number;
  32754. /**
  32755. * Gets the hit normal/direction in the world
  32756. */
  32757. get hitNormalWorld(): Vector3;
  32758. /**
  32759. * Gets the hit point in the world
  32760. */
  32761. get hitPointWorld(): Vector3;
  32762. /**
  32763. * Gets the ray "start point" of the ray in the world
  32764. */
  32765. get rayFromWorld(): Vector3;
  32766. /**
  32767. * Gets the ray "end point" of the ray in the world
  32768. */
  32769. get rayToWorld(): Vector3;
  32770. /**
  32771. * Sets the hit data (normal & point in world space)
  32772. * @param hitNormalWorld defines the normal in world space
  32773. * @param hitPointWorld defines the point in world space
  32774. */
  32775. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32776. /**
  32777. * Sets the distance from the start point to the hit point
  32778. * @param distance
  32779. */
  32780. setHitDistance(distance: number): void;
  32781. /**
  32782. * Calculates the distance manually
  32783. */
  32784. calculateHitDistance(): void;
  32785. /**
  32786. * Resets all the values to default
  32787. * @param from The from point on world space
  32788. * @param to The to point on world space
  32789. */
  32790. reset(from?: Vector3, to?: Vector3): void;
  32791. }
  32792. /**
  32793. * Interface for the size containing width and height
  32794. */
  32795. interface IXYZ {
  32796. /**
  32797. * X
  32798. */
  32799. x: number;
  32800. /**
  32801. * Y
  32802. */
  32803. y: number;
  32804. /**
  32805. * Z
  32806. */
  32807. z: number;
  32808. }
  32809. }
  32810. declare module "babylonjs/Physics/IPhysicsEngine" {
  32811. import { Nullable } from "babylonjs/types";
  32812. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32814. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32815. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32816. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32817. /**
  32818. * Interface used to describe a physics joint
  32819. */
  32820. export interface PhysicsImpostorJoint {
  32821. /** Defines the main impostor to which the joint is linked */
  32822. mainImpostor: PhysicsImpostor;
  32823. /** Defines the impostor that is connected to the main impostor using this joint */
  32824. connectedImpostor: PhysicsImpostor;
  32825. /** Defines the joint itself */
  32826. joint: PhysicsJoint;
  32827. }
  32828. /** @hidden */
  32829. export interface IPhysicsEnginePlugin {
  32830. world: any;
  32831. name: string;
  32832. setGravity(gravity: Vector3): void;
  32833. setTimeStep(timeStep: number): void;
  32834. getTimeStep(): number;
  32835. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32836. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32837. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32838. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32839. removePhysicsBody(impostor: PhysicsImpostor): void;
  32840. generateJoint(joint: PhysicsImpostorJoint): void;
  32841. removeJoint(joint: PhysicsImpostorJoint): void;
  32842. isSupported(): boolean;
  32843. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32844. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32845. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32846. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32847. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32848. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32849. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32850. getBodyMass(impostor: PhysicsImpostor): number;
  32851. getBodyFriction(impostor: PhysicsImpostor): number;
  32852. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32853. getBodyRestitution(impostor: PhysicsImpostor): number;
  32854. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32855. getBodyPressure?(impostor: PhysicsImpostor): number;
  32856. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32857. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32858. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32859. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32860. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32861. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32862. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32863. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32864. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32865. sleepBody(impostor: PhysicsImpostor): void;
  32866. wakeUpBody(impostor: PhysicsImpostor): void;
  32867. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32868. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32869. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32870. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32871. getRadius(impostor: PhysicsImpostor): number;
  32872. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32873. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32874. dispose(): void;
  32875. }
  32876. /**
  32877. * Interface used to define a physics engine
  32878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32879. */
  32880. export interface IPhysicsEngine {
  32881. /**
  32882. * Gets the gravity vector used by the simulation
  32883. */
  32884. gravity: Vector3;
  32885. /**
  32886. * Sets the gravity vector used by the simulation
  32887. * @param gravity defines the gravity vector to use
  32888. */
  32889. setGravity(gravity: Vector3): void;
  32890. /**
  32891. * Set the time step of the physics engine.
  32892. * Default is 1/60.
  32893. * To slow it down, enter 1/600 for example.
  32894. * To speed it up, 1/30
  32895. * @param newTimeStep the new timestep to apply to this world.
  32896. */
  32897. setTimeStep(newTimeStep: number): void;
  32898. /**
  32899. * Get the time step of the physics engine.
  32900. * @returns the current time step
  32901. */
  32902. getTimeStep(): number;
  32903. /**
  32904. * Set the sub time step of the physics engine.
  32905. * Default is 0 meaning there is no sub steps
  32906. * To increase physics resolution precision, set a small value (like 1 ms)
  32907. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32908. */
  32909. setSubTimeStep(subTimeStep: number): void;
  32910. /**
  32911. * Get the sub time step of the physics engine.
  32912. * @returns the current sub time step
  32913. */
  32914. getSubTimeStep(): number;
  32915. /**
  32916. * Release all resources
  32917. */
  32918. dispose(): void;
  32919. /**
  32920. * Gets the name of the current physics plugin
  32921. * @returns the name of the plugin
  32922. */
  32923. getPhysicsPluginName(): string;
  32924. /**
  32925. * Adding a new impostor for the impostor tracking.
  32926. * This will be done by the impostor itself.
  32927. * @param impostor the impostor to add
  32928. */
  32929. addImpostor(impostor: PhysicsImpostor): void;
  32930. /**
  32931. * Remove an impostor from the engine.
  32932. * This impostor and its mesh will not longer be updated by the physics engine.
  32933. * @param impostor the impostor to remove
  32934. */
  32935. removeImpostor(impostor: PhysicsImpostor): void;
  32936. /**
  32937. * Add a joint to the physics engine
  32938. * @param mainImpostor defines the main impostor to which the joint is added.
  32939. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32940. * @param joint defines the joint that will connect both impostors.
  32941. */
  32942. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32943. /**
  32944. * Removes a joint from the simulation
  32945. * @param mainImpostor defines the impostor used with the joint
  32946. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32947. * @param joint defines the joint to remove
  32948. */
  32949. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32950. /**
  32951. * Gets the current plugin used to run the simulation
  32952. * @returns current plugin
  32953. */
  32954. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32955. /**
  32956. * Gets the list of physic impostors
  32957. * @returns an array of PhysicsImpostor
  32958. */
  32959. getImpostors(): Array<PhysicsImpostor>;
  32960. /**
  32961. * Gets the impostor for a physics enabled object
  32962. * @param object defines the object impersonated by the impostor
  32963. * @returns the PhysicsImpostor or null if not found
  32964. */
  32965. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32966. /**
  32967. * Gets the impostor for a physics body object
  32968. * @param body defines physics body used by the impostor
  32969. * @returns the PhysicsImpostor or null if not found
  32970. */
  32971. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32972. /**
  32973. * Does a raycast in the physics world
  32974. * @param from when should the ray start?
  32975. * @param to when should the ray end?
  32976. * @returns PhysicsRaycastResult
  32977. */
  32978. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32979. /**
  32980. * Called by the scene. No need to call it.
  32981. * @param delta defines the timespam between frames
  32982. */
  32983. _step(delta: number): void;
  32984. }
  32985. }
  32986. declare module "babylonjs/Physics/physicsImpostor" {
  32987. import { Nullable, IndicesArray } from "babylonjs/types";
  32988. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  32989. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32991. import { Scene } from "babylonjs/scene";
  32992. import { Bone } from "babylonjs/Bones/bone";
  32993. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32994. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  32995. import { Space } from "babylonjs/Maths/math.axis";
  32996. /**
  32997. * The interface for the physics imposter parameters
  32998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32999. */
  33000. export interface PhysicsImpostorParameters {
  33001. /**
  33002. * The mass of the physics imposter
  33003. */
  33004. mass: number;
  33005. /**
  33006. * The friction of the physics imposter
  33007. */
  33008. friction?: number;
  33009. /**
  33010. * The coefficient of restitution of the physics imposter
  33011. */
  33012. restitution?: number;
  33013. /**
  33014. * The native options of the physics imposter
  33015. */
  33016. nativeOptions?: any;
  33017. /**
  33018. * Specifies if the parent should be ignored
  33019. */
  33020. ignoreParent?: boolean;
  33021. /**
  33022. * Specifies if bi-directional transformations should be disabled
  33023. */
  33024. disableBidirectionalTransformation?: boolean;
  33025. /**
  33026. * The pressure inside the physics imposter, soft object only
  33027. */
  33028. pressure?: number;
  33029. /**
  33030. * The stiffness the physics imposter, soft object only
  33031. */
  33032. stiffness?: number;
  33033. /**
  33034. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33035. */
  33036. velocityIterations?: number;
  33037. /**
  33038. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33039. */
  33040. positionIterations?: number;
  33041. /**
  33042. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33043. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33044. * Add to fix multiple points
  33045. */
  33046. fixedPoints?: number;
  33047. /**
  33048. * The collision margin around a soft object
  33049. */
  33050. margin?: number;
  33051. /**
  33052. * The collision margin around a soft object
  33053. */
  33054. damping?: number;
  33055. /**
  33056. * The path for a rope based on an extrusion
  33057. */
  33058. path?: any;
  33059. /**
  33060. * The shape of an extrusion used for a rope based on an extrusion
  33061. */
  33062. shape?: any;
  33063. }
  33064. /**
  33065. * Interface for a physics-enabled object
  33066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33067. */
  33068. export interface IPhysicsEnabledObject {
  33069. /**
  33070. * The position of the physics-enabled object
  33071. */
  33072. position: Vector3;
  33073. /**
  33074. * The rotation of the physics-enabled object
  33075. */
  33076. rotationQuaternion: Nullable<Quaternion>;
  33077. /**
  33078. * The scale of the physics-enabled object
  33079. */
  33080. scaling: Vector3;
  33081. /**
  33082. * The rotation of the physics-enabled object
  33083. */
  33084. rotation?: Vector3;
  33085. /**
  33086. * The parent of the physics-enabled object
  33087. */
  33088. parent?: any;
  33089. /**
  33090. * The bounding info of the physics-enabled object
  33091. * @returns The bounding info of the physics-enabled object
  33092. */
  33093. getBoundingInfo(): BoundingInfo;
  33094. /**
  33095. * Computes the world matrix
  33096. * @param force Specifies if the world matrix should be computed by force
  33097. * @returns A world matrix
  33098. */
  33099. computeWorldMatrix(force: boolean): Matrix;
  33100. /**
  33101. * Gets the world matrix
  33102. * @returns A world matrix
  33103. */
  33104. getWorldMatrix?(): Matrix;
  33105. /**
  33106. * Gets the child meshes
  33107. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33108. * @returns An array of abstract meshes
  33109. */
  33110. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33111. /**
  33112. * Gets the vertex data
  33113. * @param kind The type of vertex data
  33114. * @returns A nullable array of numbers, or a float32 array
  33115. */
  33116. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33117. /**
  33118. * Gets the indices from the mesh
  33119. * @returns A nullable array of index arrays
  33120. */
  33121. getIndices?(): Nullable<IndicesArray>;
  33122. /**
  33123. * Gets the scene from the mesh
  33124. * @returns the indices array or null
  33125. */
  33126. getScene?(): Scene;
  33127. /**
  33128. * Gets the absolute position from the mesh
  33129. * @returns the absolute position
  33130. */
  33131. getAbsolutePosition(): Vector3;
  33132. /**
  33133. * Gets the absolute pivot point from the mesh
  33134. * @returns the absolute pivot point
  33135. */
  33136. getAbsolutePivotPoint(): Vector3;
  33137. /**
  33138. * Rotates the mesh
  33139. * @param axis The axis of rotation
  33140. * @param amount The amount of rotation
  33141. * @param space The space of the rotation
  33142. * @returns The rotation transform node
  33143. */
  33144. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33145. /**
  33146. * Translates the mesh
  33147. * @param axis The axis of translation
  33148. * @param distance The distance of translation
  33149. * @param space The space of the translation
  33150. * @returns The transform node
  33151. */
  33152. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33153. /**
  33154. * Sets the absolute position of the mesh
  33155. * @param absolutePosition The absolute position of the mesh
  33156. * @returns The transform node
  33157. */
  33158. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33159. /**
  33160. * Gets the class name of the mesh
  33161. * @returns The class name
  33162. */
  33163. getClassName(): string;
  33164. }
  33165. /**
  33166. * Represents a physics imposter
  33167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33168. */
  33169. export class PhysicsImpostor {
  33170. /**
  33171. * The physics-enabled object used as the physics imposter
  33172. */
  33173. object: IPhysicsEnabledObject;
  33174. /**
  33175. * The type of the physics imposter
  33176. */
  33177. type: number;
  33178. private _options;
  33179. private _scene?;
  33180. /**
  33181. * The default object size of the imposter
  33182. */
  33183. static DEFAULT_OBJECT_SIZE: Vector3;
  33184. /**
  33185. * The identity quaternion of the imposter
  33186. */
  33187. static IDENTITY_QUATERNION: Quaternion;
  33188. /** @hidden */
  33189. _pluginData: any;
  33190. private _physicsEngine;
  33191. private _physicsBody;
  33192. private _bodyUpdateRequired;
  33193. private _onBeforePhysicsStepCallbacks;
  33194. private _onAfterPhysicsStepCallbacks;
  33195. /** @hidden */
  33196. _onPhysicsCollideCallbacks: Array<{
  33197. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  33198. otherImpostors: Array<PhysicsImpostor>;
  33199. }>;
  33200. private _deltaPosition;
  33201. private _deltaRotation;
  33202. private _deltaRotationConjugated;
  33203. /** @hidden */
  33204. _isFromLine: boolean;
  33205. private _parent;
  33206. private _isDisposed;
  33207. private static _tmpVecs;
  33208. private static _tmpQuat;
  33209. /**
  33210. * Specifies if the physics imposter is disposed
  33211. */
  33212. get isDisposed(): boolean;
  33213. /**
  33214. * Gets the mass of the physics imposter
  33215. */
  33216. get mass(): number;
  33217. set mass(value: number);
  33218. /**
  33219. * Gets the coefficient of friction
  33220. */
  33221. get friction(): number;
  33222. /**
  33223. * Sets the coefficient of friction
  33224. */
  33225. set friction(value: number);
  33226. /**
  33227. * Gets the coefficient of restitution
  33228. */
  33229. get restitution(): number;
  33230. /**
  33231. * Sets the coefficient of restitution
  33232. */
  33233. set restitution(value: number);
  33234. /**
  33235. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33236. */
  33237. get pressure(): number;
  33238. /**
  33239. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33240. */
  33241. set pressure(value: number);
  33242. /**
  33243. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33244. */
  33245. get stiffness(): number;
  33246. /**
  33247. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33248. */
  33249. set stiffness(value: number);
  33250. /**
  33251. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33252. */
  33253. get velocityIterations(): number;
  33254. /**
  33255. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33256. */
  33257. set velocityIterations(value: number);
  33258. /**
  33259. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33260. */
  33261. get positionIterations(): number;
  33262. /**
  33263. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33264. */
  33265. set positionIterations(value: number);
  33266. /**
  33267. * The unique id of the physics imposter
  33268. * set by the physics engine when adding this impostor to the array
  33269. */
  33270. uniqueId: number;
  33271. /**
  33272. * @hidden
  33273. */
  33274. soft: boolean;
  33275. /**
  33276. * @hidden
  33277. */
  33278. segments: number;
  33279. private _joints;
  33280. /**
  33281. * Initializes the physics imposter
  33282. * @param object The physics-enabled object used as the physics imposter
  33283. * @param type The type of the physics imposter
  33284. * @param _options The options for the physics imposter
  33285. * @param _scene The Babylon scene
  33286. */
  33287. constructor(
  33288. /**
  33289. * The physics-enabled object used as the physics imposter
  33290. */
  33291. object: IPhysicsEnabledObject,
  33292. /**
  33293. * The type of the physics imposter
  33294. */
  33295. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33296. /**
  33297. * This function will completly initialize this impostor.
  33298. * It will create a new body - but only if this mesh has no parent.
  33299. * If it has, this impostor will not be used other than to define the impostor
  33300. * of the child mesh.
  33301. * @hidden
  33302. */
  33303. _init(): void;
  33304. private _getPhysicsParent;
  33305. /**
  33306. * Should a new body be generated.
  33307. * @returns boolean specifying if body initialization is required
  33308. */
  33309. isBodyInitRequired(): boolean;
  33310. /**
  33311. * Sets the updated scaling
  33312. * @param updated Specifies if the scaling is updated
  33313. */
  33314. setScalingUpdated(): void;
  33315. /**
  33316. * Force a regeneration of this or the parent's impostor's body.
  33317. * Use under cautious - This will remove all joints already implemented.
  33318. */
  33319. forceUpdate(): void;
  33320. /**
  33321. * Gets the body that holds this impostor. Either its own, or its parent.
  33322. */
  33323. get physicsBody(): any;
  33324. /**
  33325. * Get the parent of the physics imposter
  33326. * @returns Physics imposter or null
  33327. */
  33328. get parent(): Nullable<PhysicsImpostor>;
  33329. /**
  33330. * Sets the parent of the physics imposter
  33331. */
  33332. set parent(value: Nullable<PhysicsImpostor>);
  33333. /**
  33334. * Set the physics body. Used mainly by the physics engine/plugin
  33335. */
  33336. set physicsBody(physicsBody: any);
  33337. /**
  33338. * Resets the update flags
  33339. */
  33340. resetUpdateFlags(): void;
  33341. /**
  33342. * Gets the object extend size
  33343. * @returns the object extend size
  33344. */
  33345. getObjectExtendSize(): Vector3;
  33346. /**
  33347. * Gets the object center
  33348. * @returns The object center
  33349. */
  33350. getObjectCenter(): Vector3;
  33351. /**
  33352. * Get a specific parameter from the options parameters
  33353. * @param paramName The object parameter name
  33354. * @returns The object parameter
  33355. */
  33356. getParam(paramName: string): any;
  33357. /**
  33358. * Sets a specific parameter in the options given to the physics plugin
  33359. * @param paramName The parameter name
  33360. * @param value The value of the parameter
  33361. */
  33362. setParam(paramName: string, value: number): void;
  33363. /**
  33364. * Specifically change the body's mass option. Won't recreate the physics body object
  33365. * @param mass The mass of the physics imposter
  33366. */
  33367. setMass(mass: number): void;
  33368. /**
  33369. * Gets the linear velocity
  33370. * @returns linear velocity or null
  33371. */
  33372. getLinearVelocity(): Nullable<Vector3>;
  33373. /**
  33374. * Sets the linear velocity
  33375. * @param velocity linear velocity or null
  33376. */
  33377. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33378. /**
  33379. * Gets the angular velocity
  33380. * @returns angular velocity or null
  33381. */
  33382. getAngularVelocity(): Nullable<Vector3>;
  33383. /**
  33384. * Sets the angular velocity
  33385. * @param velocity The velocity or null
  33386. */
  33387. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33388. /**
  33389. * Execute a function with the physics plugin native code
  33390. * Provide a function the will have two variables - the world object and the physics body object
  33391. * @param func The function to execute with the physics plugin native code
  33392. */
  33393. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33394. /**
  33395. * Register a function that will be executed before the physics world is stepping forward
  33396. * @param func The function to execute before the physics world is stepped forward
  33397. */
  33398. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33399. /**
  33400. * Unregister a function that will be executed before the physics world is stepping forward
  33401. * @param func The function to execute before the physics world is stepped forward
  33402. */
  33403. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33404. /**
  33405. * Register a function that will be executed after the physics step
  33406. * @param func The function to execute after physics step
  33407. */
  33408. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33409. /**
  33410. * Unregisters a function that will be executed after the physics step
  33411. * @param func The function to execute after physics step
  33412. */
  33413. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33414. /**
  33415. * register a function that will be executed when this impostor collides against a different body
  33416. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33417. * @param func Callback that is executed on collision
  33418. */
  33419. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33420. /**
  33421. * Unregisters the physics imposter on contact
  33422. * @param collideAgainst The physics object to collide against
  33423. * @param func Callback to execute on collision
  33424. */
  33425. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33426. private _tmpQuat;
  33427. private _tmpQuat2;
  33428. /**
  33429. * Get the parent rotation
  33430. * @returns The parent rotation
  33431. */
  33432. getParentsRotation(): Quaternion;
  33433. /**
  33434. * this function is executed by the physics engine.
  33435. */
  33436. beforeStep: () => void;
  33437. /**
  33438. * this function is executed by the physics engine
  33439. */
  33440. afterStep: () => void;
  33441. /**
  33442. * Legacy collision detection event support
  33443. */
  33444. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33445. /**
  33446. * event and body object due to cannon's event-based architecture.
  33447. */
  33448. onCollide: (e: {
  33449. body: any;
  33450. }) => void;
  33451. /**
  33452. * Apply a force
  33453. * @param force The force to apply
  33454. * @param contactPoint The contact point for the force
  33455. * @returns The physics imposter
  33456. */
  33457. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33458. /**
  33459. * Apply an impulse
  33460. * @param force The impulse force
  33461. * @param contactPoint The contact point for the impulse force
  33462. * @returns The physics imposter
  33463. */
  33464. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33465. /**
  33466. * A help function to create a joint
  33467. * @param otherImpostor A physics imposter used to create a joint
  33468. * @param jointType The type of joint
  33469. * @param jointData The data for the joint
  33470. * @returns The physics imposter
  33471. */
  33472. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33473. /**
  33474. * Add a joint to this impostor with a different impostor
  33475. * @param otherImpostor A physics imposter used to add a joint
  33476. * @param joint The joint to add
  33477. * @returns The physics imposter
  33478. */
  33479. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33480. /**
  33481. * Add an anchor to a cloth impostor
  33482. * @param otherImpostor rigid impostor to anchor to
  33483. * @param width ratio across width from 0 to 1
  33484. * @param height ratio up height from 0 to 1
  33485. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33486. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33487. * @returns impostor the soft imposter
  33488. */
  33489. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33490. /**
  33491. * Add a hook to a rope impostor
  33492. * @param otherImpostor rigid impostor to anchor to
  33493. * @param length ratio across rope from 0 to 1
  33494. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33495. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33496. * @returns impostor the rope imposter
  33497. */
  33498. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33499. /**
  33500. * Will keep this body still, in a sleep mode.
  33501. * @returns the physics imposter
  33502. */
  33503. sleep(): PhysicsImpostor;
  33504. /**
  33505. * Wake the body up.
  33506. * @returns The physics imposter
  33507. */
  33508. wakeUp(): PhysicsImpostor;
  33509. /**
  33510. * Clones the physics imposter
  33511. * @param newObject The physics imposter clones to this physics-enabled object
  33512. * @returns A nullable physics imposter
  33513. */
  33514. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33515. /**
  33516. * Disposes the physics imposter
  33517. */
  33518. dispose(): void;
  33519. /**
  33520. * Sets the delta position
  33521. * @param position The delta position amount
  33522. */
  33523. setDeltaPosition(position: Vector3): void;
  33524. /**
  33525. * Sets the delta rotation
  33526. * @param rotation The delta rotation amount
  33527. */
  33528. setDeltaRotation(rotation: Quaternion): void;
  33529. /**
  33530. * Gets the box size of the physics imposter and stores the result in the input parameter
  33531. * @param result Stores the box size
  33532. * @returns The physics imposter
  33533. */
  33534. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33535. /**
  33536. * Gets the radius of the physics imposter
  33537. * @returns Radius of the physics imposter
  33538. */
  33539. getRadius(): number;
  33540. /**
  33541. * Sync a bone with this impostor
  33542. * @param bone The bone to sync to the impostor.
  33543. * @param boneMesh The mesh that the bone is influencing.
  33544. * @param jointPivot The pivot of the joint / bone in local space.
  33545. * @param distToJoint Optional distance from the impostor to the joint.
  33546. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33547. */
  33548. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33549. /**
  33550. * Sync impostor to a bone
  33551. * @param bone The bone that the impostor will be synced to.
  33552. * @param boneMesh The mesh that the bone is influencing.
  33553. * @param jointPivot The pivot of the joint / bone in local space.
  33554. * @param distToJoint Optional distance from the impostor to the joint.
  33555. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33556. * @param boneAxis Optional vector3 axis the bone is aligned with
  33557. */
  33558. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33559. /**
  33560. * No-Imposter type
  33561. */
  33562. static NoImpostor: number;
  33563. /**
  33564. * Sphere-Imposter type
  33565. */
  33566. static SphereImpostor: number;
  33567. /**
  33568. * Box-Imposter type
  33569. */
  33570. static BoxImpostor: number;
  33571. /**
  33572. * Plane-Imposter type
  33573. */
  33574. static PlaneImpostor: number;
  33575. /**
  33576. * Mesh-imposter type
  33577. */
  33578. static MeshImpostor: number;
  33579. /**
  33580. * Capsule-Impostor type (Ammo.js plugin only)
  33581. */
  33582. static CapsuleImpostor: number;
  33583. /**
  33584. * Cylinder-Imposter type
  33585. */
  33586. static CylinderImpostor: number;
  33587. /**
  33588. * Particle-Imposter type
  33589. */
  33590. static ParticleImpostor: number;
  33591. /**
  33592. * Heightmap-Imposter type
  33593. */
  33594. static HeightmapImpostor: number;
  33595. /**
  33596. * ConvexHull-Impostor type (Ammo.js plugin only)
  33597. */
  33598. static ConvexHullImpostor: number;
  33599. /**
  33600. * Custom-Imposter type (Ammo.js plugin only)
  33601. */
  33602. static CustomImpostor: number;
  33603. /**
  33604. * Rope-Imposter type
  33605. */
  33606. static RopeImpostor: number;
  33607. /**
  33608. * Cloth-Imposter type
  33609. */
  33610. static ClothImpostor: number;
  33611. /**
  33612. * Softbody-Imposter type
  33613. */
  33614. static SoftbodyImpostor: number;
  33615. }
  33616. }
  33617. declare module "babylonjs/Meshes/mesh" {
  33618. import { Observable } from "babylonjs/Misc/observable";
  33619. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33620. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33621. import { Camera } from "babylonjs/Cameras/camera";
  33622. import { Scene } from "babylonjs/scene";
  33623. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33624. import { Color4 } from "babylonjs/Maths/math.color";
  33625. import { Engine } from "babylonjs/Engines/engine";
  33626. import { Node } from "babylonjs/node";
  33627. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33628. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33629. import { Buffer } from "babylonjs/Meshes/buffer";
  33630. import { Geometry } from "babylonjs/Meshes/geometry";
  33631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33632. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33633. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33634. import { Effect } from "babylonjs/Materials/effect";
  33635. import { Material } from "babylonjs/Materials/material";
  33636. import { Skeleton } from "babylonjs/Bones/skeleton";
  33637. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33638. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33639. import { Path3D } from "babylonjs/Maths/math.path";
  33640. import { Plane } from "babylonjs/Maths/math.plane";
  33641. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33642. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33643. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33644. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33645. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33646. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33647. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33648. /**
  33649. * @hidden
  33650. **/
  33651. export class _CreationDataStorage {
  33652. closePath?: boolean;
  33653. closeArray?: boolean;
  33654. idx: number[];
  33655. dashSize: number;
  33656. gapSize: number;
  33657. path3D: Path3D;
  33658. pathArray: Vector3[][];
  33659. arc: number;
  33660. radius: number;
  33661. cap: number;
  33662. tessellation: number;
  33663. }
  33664. /**
  33665. * @hidden
  33666. **/
  33667. class _InstanceDataStorage {
  33668. visibleInstances: any;
  33669. batchCache: _InstancesBatch;
  33670. instancesBufferSize: number;
  33671. instancesBuffer: Nullable<Buffer>;
  33672. instancesData: Float32Array;
  33673. overridenInstanceCount: number;
  33674. isFrozen: boolean;
  33675. previousBatch: Nullable<_InstancesBatch>;
  33676. hardwareInstancedRendering: boolean;
  33677. sideOrientation: number;
  33678. manualUpdate: boolean;
  33679. previousRenderId: number;
  33680. }
  33681. /**
  33682. * @hidden
  33683. **/
  33684. export class _InstancesBatch {
  33685. mustReturn: boolean;
  33686. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33687. renderSelf: boolean[];
  33688. hardwareInstancedRendering: boolean[];
  33689. }
  33690. /**
  33691. * @hidden
  33692. **/
  33693. class _ThinInstanceDataStorage {
  33694. instancesCount: number;
  33695. matrixBuffer: Nullable<Buffer>;
  33696. matrixBufferSize: number;
  33697. matrixData: Nullable<Float32Array>;
  33698. boundingVectors: Array<Vector3>;
  33699. worldMatrices: Nullable<Matrix[]>;
  33700. }
  33701. /**
  33702. * Class used to represent renderable models
  33703. */
  33704. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33705. /**
  33706. * Mesh side orientation : usually the external or front surface
  33707. */
  33708. static readonly FRONTSIDE: number;
  33709. /**
  33710. * Mesh side orientation : usually the internal or back surface
  33711. */
  33712. static readonly BACKSIDE: number;
  33713. /**
  33714. * Mesh side orientation : both internal and external or front and back surfaces
  33715. */
  33716. static readonly DOUBLESIDE: number;
  33717. /**
  33718. * Mesh side orientation : by default, `FRONTSIDE`
  33719. */
  33720. static readonly DEFAULTSIDE: number;
  33721. /**
  33722. * Mesh cap setting : no cap
  33723. */
  33724. static readonly NO_CAP: number;
  33725. /**
  33726. * Mesh cap setting : one cap at the beginning of the mesh
  33727. */
  33728. static readonly CAP_START: number;
  33729. /**
  33730. * Mesh cap setting : one cap at the end of the mesh
  33731. */
  33732. static readonly CAP_END: number;
  33733. /**
  33734. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33735. */
  33736. static readonly CAP_ALL: number;
  33737. /**
  33738. * Mesh pattern setting : no flip or rotate
  33739. */
  33740. static readonly NO_FLIP: number;
  33741. /**
  33742. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33743. */
  33744. static readonly FLIP_TILE: number;
  33745. /**
  33746. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33747. */
  33748. static readonly ROTATE_TILE: number;
  33749. /**
  33750. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33751. */
  33752. static readonly FLIP_ROW: number;
  33753. /**
  33754. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33755. */
  33756. static readonly ROTATE_ROW: number;
  33757. /**
  33758. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33759. */
  33760. static readonly FLIP_N_ROTATE_TILE: number;
  33761. /**
  33762. * Mesh pattern setting : rotate pattern and rotate
  33763. */
  33764. static readonly FLIP_N_ROTATE_ROW: number;
  33765. /**
  33766. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33767. */
  33768. static readonly CENTER: number;
  33769. /**
  33770. * Mesh tile positioning : part tiles on left
  33771. */
  33772. static readonly LEFT: number;
  33773. /**
  33774. * Mesh tile positioning : part tiles on right
  33775. */
  33776. static readonly RIGHT: number;
  33777. /**
  33778. * Mesh tile positioning : part tiles on top
  33779. */
  33780. static readonly TOP: number;
  33781. /**
  33782. * Mesh tile positioning : part tiles on bottom
  33783. */
  33784. static readonly BOTTOM: number;
  33785. /**
  33786. * Gets the default side orientation.
  33787. * @param orientation the orientation to value to attempt to get
  33788. * @returns the default orientation
  33789. * @hidden
  33790. */
  33791. static _GetDefaultSideOrientation(orientation?: number): number;
  33792. private _internalMeshDataInfo;
  33793. get computeBonesUsingShaders(): boolean;
  33794. set computeBonesUsingShaders(value: boolean);
  33795. /**
  33796. * An event triggered before rendering the mesh
  33797. */
  33798. get onBeforeRenderObservable(): Observable<Mesh>;
  33799. /**
  33800. * An event triggered before binding the mesh
  33801. */
  33802. get onBeforeBindObservable(): Observable<Mesh>;
  33803. /**
  33804. * An event triggered after rendering the mesh
  33805. */
  33806. get onAfterRenderObservable(): Observable<Mesh>;
  33807. /**
  33808. * An event triggered before drawing the mesh
  33809. */
  33810. get onBeforeDrawObservable(): Observable<Mesh>;
  33811. private _onBeforeDrawObserver;
  33812. /**
  33813. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33814. */
  33815. set onBeforeDraw(callback: () => void);
  33816. get hasInstances(): boolean;
  33817. get hasThinInstances(): boolean;
  33818. /**
  33819. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33820. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33821. */
  33822. delayLoadState: number;
  33823. /**
  33824. * Gets the list of instances created from this mesh
  33825. * it is not supposed to be modified manually.
  33826. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33827. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33828. */
  33829. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33830. /**
  33831. * Gets the file containing delay loading data for this mesh
  33832. */
  33833. delayLoadingFile: string;
  33834. /** @hidden */
  33835. _binaryInfo: any;
  33836. /**
  33837. * User defined function used to change how LOD level selection is done
  33838. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33839. */
  33840. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33841. /**
  33842. * Gets or sets the morph target manager
  33843. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33844. */
  33845. get morphTargetManager(): Nullable<MorphTargetManager>;
  33846. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33847. /** @hidden */
  33848. _creationDataStorage: Nullable<_CreationDataStorage>;
  33849. /** @hidden */
  33850. _geometry: Nullable<Geometry>;
  33851. /** @hidden */
  33852. _delayInfo: Array<string>;
  33853. /** @hidden */
  33854. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33855. /** @hidden */
  33856. _instanceDataStorage: _InstanceDataStorage;
  33857. /** @hidden */
  33858. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33859. private _effectiveMaterial;
  33860. /** @hidden */
  33861. _shouldGenerateFlatShading: boolean;
  33862. /** @hidden */
  33863. _originalBuilderSideOrientation: number;
  33864. /**
  33865. * Use this property to change the original side orientation defined at construction time
  33866. */
  33867. overrideMaterialSideOrientation: Nullable<number>;
  33868. /**
  33869. * Gets the source mesh (the one used to clone this one from)
  33870. */
  33871. get source(): Nullable<Mesh>;
  33872. /**
  33873. * Gets the list of clones of this mesh
  33874. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33875. * Note that useClonedMeshMap=true is the default setting
  33876. */
  33877. get cloneMeshMap(): Nullable<{
  33878. [id: string]: Mesh | undefined;
  33879. }>;
  33880. /**
  33881. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33882. */
  33883. get isUnIndexed(): boolean;
  33884. set isUnIndexed(value: boolean);
  33885. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33886. get worldMatrixInstancedBuffer(): Float32Array;
  33887. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33888. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33889. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33890. /**
  33891. * @constructor
  33892. * @param name The value used by scene.getMeshByName() to do a lookup.
  33893. * @param scene The scene to add this mesh to.
  33894. * @param parent The parent of this mesh, if it has one
  33895. * @param source An optional Mesh from which geometry is shared, cloned.
  33896. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33897. * When false, achieved by calling a clone(), also passing False.
  33898. * This will make creation of children, recursive.
  33899. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33900. */
  33901. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33902. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33903. doNotInstantiate: boolean;
  33904. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33905. /**
  33906. * Gets the class name
  33907. * @returns the string "Mesh".
  33908. */
  33909. getClassName(): string;
  33910. /** @hidden */
  33911. get _isMesh(): boolean;
  33912. /**
  33913. * Returns a description of this mesh
  33914. * @param fullDetails define if full details about this mesh must be used
  33915. * @returns a descriptive string representing this mesh
  33916. */
  33917. toString(fullDetails?: boolean): string;
  33918. /** @hidden */
  33919. _unBindEffect(): void;
  33920. /**
  33921. * Gets a boolean indicating if this mesh has LOD
  33922. */
  33923. get hasLODLevels(): boolean;
  33924. /**
  33925. * Gets the list of MeshLODLevel associated with the current mesh
  33926. * @returns an array of MeshLODLevel
  33927. */
  33928. getLODLevels(): MeshLODLevel[];
  33929. private _sortLODLevels;
  33930. /**
  33931. * Add a mesh as LOD level triggered at the given distance.
  33932. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33933. * @param distance The distance from the center of the object to show this level
  33934. * @param mesh The mesh to be added as LOD level (can be null)
  33935. * @return This mesh (for chaining)
  33936. */
  33937. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33938. /**
  33939. * Returns the LOD level mesh at the passed distance or null if not found.
  33940. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33941. * @param distance The distance from the center of the object to show this level
  33942. * @returns a Mesh or `null`
  33943. */
  33944. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33945. /**
  33946. * Remove a mesh from the LOD array
  33947. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33948. * @param mesh defines the mesh to be removed
  33949. * @return This mesh (for chaining)
  33950. */
  33951. removeLODLevel(mesh: Mesh): Mesh;
  33952. /**
  33953. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33954. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33955. * @param camera defines the camera to use to compute distance
  33956. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33957. * @return This mesh (for chaining)
  33958. */
  33959. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33960. /**
  33961. * Gets the mesh internal Geometry object
  33962. */
  33963. get geometry(): Nullable<Geometry>;
  33964. /**
  33965. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33966. * @returns the total number of vertices
  33967. */
  33968. getTotalVertices(): number;
  33969. /**
  33970. * Returns the content of an associated vertex buffer
  33971. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33972. * - VertexBuffer.PositionKind
  33973. * - VertexBuffer.UVKind
  33974. * - VertexBuffer.UV2Kind
  33975. * - VertexBuffer.UV3Kind
  33976. * - VertexBuffer.UV4Kind
  33977. * - VertexBuffer.UV5Kind
  33978. * - VertexBuffer.UV6Kind
  33979. * - VertexBuffer.ColorKind
  33980. * - VertexBuffer.MatricesIndicesKind
  33981. * - VertexBuffer.MatricesIndicesExtraKind
  33982. * - VertexBuffer.MatricesWeightsKind
  33983. * - VertexBuffer.MatricesWeightsExtraKind
  33984. * @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
  33985. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33986. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33987. */
  33988. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33989. /**
  33990. * Returns the mesh VertexBuffer object from the requested `kind`
  33991. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33992. * - VertexBuffer.PositionKind
  33993. * - VertexBuffer.NormalKind
  33994. * - VertexBuffer.UVKind
  33995. * - VertexBuffer.UV2Kind
  33996. * - VertexBuffer.UV3Kind
  33997. * - VertexBuffer.UV4Kind
  33998. * - VertexBuffer.UV5Kind
  33999. * - VertexBuffer.UV6Kind
  34000. * - VertexBuffer.ColorKind
  34001. * - VertexBuffer.MatricesIndicesKind
  34002. * - VertexBuffer.MatricesIndicesExtraKind
  34003. * - VertexBuffer.MatricesWeightsKind
  34004. * - VertexBuffer.MatricesWeightsExtraKind
  34005. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34006. */
  34007. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34008. /**
  34009. * Tests if a specific vertex buffer is associated with this mesh
  34010. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34011. * - VertexBuffer.PositionKind
  34012. * - VertexBuffer.NormalKind
  34013. * - VertexBuffer.UVKind
  34014. * - VertexBuffer.UV2Kind
  34015. * - VertexBuffer.UV3Kind
  34016. * - VertexBuffer.UV4Kind
  34017. * - VertexBuffer.UV5Kind
  34018. * - VertexBuffer.UV6Kind
  34019. * - VertexBuffer.ColorKind
  34020. * - VertexBuffer.MatricesIndicesKind
  34021. * - VertexBuffer.MatricesIndicesExtraKind
  34022. * - VertexBuffer.MatricesWeightsKind
  34023. * - VertexBuffer.MatricesWeightsExtraKind
  34024. * @returns a boolean
  34025. */
  34026. isVerticesDataPresent(kind: string): boolean;
  34027. /**
  34028. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34029. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34030. * - VertexBuffer.PositionKind
  34031. * - VertexBuffer.UVKind
  34032. * - VertexBuffer.UV2Kind
  34033. * - VertexBuffer.UV3Kind
  34034. * - VertexBuffer.UV4Kind
  34035. * - VertexBuffer.UV5Kind
  34036. * - VertexBuffer.UV6Kind
  34037. * - VertexBuffer.ColorKind
  34038. * - VertexBuffer.MatricesIndicesKind
  34039. * - VertexBuffer.MatricesIndicesExtraKind
  34040. * - VertexBuffer.MatricesWeightsKind
  34041. * - VertexBuffer.MatricesWeightsExtraKind
  34042. * @returns a boolean
  34043. */
  34044. isVertexBufferUpdatable(kind: string): boolean;
  34045. /**
  34046. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34047. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34048. * - VertexBuffer.PositionKind
  34049. * - VertexBuffer.NormalKind
  34050. * - VertexBuffer.UVKind
  34051. * - VertexBuffer.UV2Kind
  34052. * - VertexBuffer.UV3Kind
  34053. * - VertexBuffer.UV4Kind
  34054. * - VertexBuffer.UV5Kind
  34055. * - VertexBuffer.UV6Kind
  34056. * - VertexBuffer.ColorKind
  34057. * - VertexBuffer.MatricesIndicesKind
  34058. * - VertexBuffer.MatricesIndicesExtraKind
  34059. * - VertexBuffer.MatricesWeightsKind
  34060. * - VertexBuffer.MatricesWeightsExtraKind
  34061. * @returns an array of strings
  34062. */
  34063. getVerticesDataKinds(): string[];
  34064. /**
  34065. * Returns a positive integer : the total number of indices in this mesh geometry.
  34066. * @returns the numner of indices or zero if the mesh has no geometry.
  34067. */
  34068. getTotalIndices(): number;
  34069. /**
  34070. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34071. * @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.
  34072. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34073. * @returns the indices array or an empty array if the mesh has no geometry
  34074. */
  34075. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34076. get isBlocked(): boolean;
  34077. /**
  34078. * Determine if the current mesh is ready to be rendered
  34079. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34080. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34081. * @returns true if all associated assets are ready (material, textures, shaders)
  34082. */
  34083. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34084. /**
  34085. * 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.
  34086. */
  34087. get areNormalsFrozen(): boolean;
  34088. /**
  34089. * 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.
  34090. * @returns the current mesh
  34091. */
  34092. freezeNormals(): Mesh;
  34093. /**
  34094. * 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
  34095. * @returns the current mesh
  34096. */
  34097. unfreezeNormals(): Mesh;
  34098. /**
  34099. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34100. */
  34101. set overridenInstanceCount(count: number);
  34102. /** @hidden */
  34103. _preActivate(): Mesh;
  34104. /** @hidden */
  34105. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34106. /** @hidden */
  34107. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34108. protected _afterComputeWorldMatrix(): void;
  34109. /** @hidden */
  34110. _postActivate(): void;
  34111. /**
  34112. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34113. * This means the mesh underlying bounding box and sphere are recomputed.
  34114. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34115. * @returns the current mesh
  34116. */
  34117. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34118. /** @hidden */
  34119. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34120. /**
  34121. * This function will subdivide the mesh into multiple submeshes
  34122. * @param count defines the expected number of submeshes
  34123. */
  34124. subdivide(count: number): void;
  34125. /**
  34126. * Copy a FloatArray into a specific associated vertex buffer
  34127. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34128. * - VertexBuffer.PositionKind
  34129. * - VertexBuffer.UVKind
  34130. * - VertexBuffer.UV2Kind
  34131. * - VertexBuffer.UV3Kind
  34132. * - VertexBuffer.UV4Kind
  34133. * - VertexBuffer.UV5Kind
  34134. * - VertexBuffer.UV6Kind
  34135. * - VertexBuffer.ColorKind
  34136. * - VertexBuffer.MatricesIndicesKind
  34137. * - VertexBuffer.MatricesIndicesExtraKind
  34138. * - VertexBuffer.MatricesWeightsKind
  34139. * - VertexBuffer.MatricesWeightsExtraKind
  34140. * @param data defines the data source
  34141. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34142. * @param stride defines the data stride size (can be null)
  34143. * @returns the current mesh
  34144. */
  34145. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34146. /**
  34147. * Delete a vertex buffer associated with this mesh
  34148. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34149. * - VertexBuffer.PositionKind
  34150. * - VertexBuffer.UVKind
  34151. * - VertexBuffer.UV2Kind
  34152. * - VertexBuffer.UV3Kind
  34153. * - VertexBuffer.UV4Kind
  34154. * - VertexBuffer.UV5Kind
  34155. * - VertexBuffer.UV6Kind
  34156. * - VertexBuffer.ColorKind
  34157. * - VertexBuffer.MatricesIndicesKind
  34158. * - VertexBuffer.MatricesIndicesExtraKind
  34159. * - VertexBuffer.MatricesWeightsKind
  34160. * - VertexBuffer.MatricesWeightsExtraKind
  34161. */
  34162. removeVerticesData(kind: string): void;
  34163. /**
  34164. * Flags an associated vertex buffer as updatable
  34165. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34166. * - VertexBuffer.PositionKind
  34167. * - VertexBuffer.UVKind
  34168. * - VertexBuffer.UV2Kind
  34169. * - VertexBuffer.UV3Kind
  34170. * - VertexBuffer.UV4Kind
  34171. * - VertexBuffer.UV5Kind
  34172. * - VertexBuffer.UV6Kind
  34173. * - VertexBuffer.ColorKind
  34174. * - VertexBuffer.MatricesIndicesKind
  34175. * - VertexBuffer.MatricesIndicesExtraKind
  34176. * - VertexBuffer.MatricesWeightsKind
  34177. * - VertexBuffer.MatricesWeightsExtraKind
  34178. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34179. */
  34180. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34181. /**
  34182. * Sets the mesh global Vertex Buffer
  34183. * @param buffer defines the buffer to use
  34184. * @returns the current mesh
  34185. */
  34186. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34187. /**
  34188. * Update a specific associated vertex buffer
  34189. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34190. * - VertexBuffer.PositionKind
  34191. * - VertexBuffer.UVKind
  34192. * - VertexBuffer.UV2Kind
  34193. * - VertexBuffer.UV3Kind
  34194. * - VertexBuffer.UV4Kind
  34195. * - VertexBuffer.UV5Kind
  34196. * - VertexBuffer.UV6Kind
  34197. * - VertexBuffer.ColorKind
  34198. * - VertexBuffer.MatricesIndicesKind
  34199. * - VertexBuffer.MatricesIndicesExtraKind
  34200. * - VertexBuffer.MatricesWeightsKind
  34201. * - VertexBuffer.MatricesWeightsExtraKind
  34202. * @param data defines the data source
  34203. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34204. * @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)
  34205. * @returns the current mesh
  34206. */
  34207. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34208. /**
  34209. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34210. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34211. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34212. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34213. * @returns the current mesh
  34214. */
  34215. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34216. /**
  34217. * Creates a un-shared specific occurence of the geometry for the mesh.
  34218. * @returns the current mesh
  34219. */
  34220. makeGeometryUnique(): Mesh;
  34221. /**
  34222. * Set the index buffer of this mesh
  34223. * @param indices defines the source data
  34224. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34225. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34226. * @returns the current mesh
  34227. */
  34228. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34229. /**
  34230. * Update the current index buffer
  34231. * @param indices defines the source data
  34232. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34233. * @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)
  34234. * @returns the current mesh
  34235. */
  34236. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34237. /**
  34238. * Invert the geometry to move from a right handed system to a left handed one.
  34239. * @returns the current mesh
  34240. */
  34241. toLeftHanded(): Mesh;
  34242. /** @hidden */
  34243. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34244. /** @hidden */
  34245. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34246. /**
  34247. * Registers for this mesh a javascript function called just before the rendering process
  34248. * @param func defines the function to call before rendering this mesh
  34249. * @returns the current mesh
  34250. */
  34251. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34252. /**
  34253. * Disposes a previously registered javascript function called before the rendering
  34254. * @param func defines the function to remove
  34255. * @returns the current mesh
  34256. */
  34257. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34258. /**
  34259. * Registers for this mesh a javascript function called just after the rendering is complete
  34260. * @param func defines the function to call after rendering this mesh
  34261. * @returns the current mesh
  34262. */
  34263. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34264. /**
  34265. * Disposes a previously registered javascript function called after the rendering.
  34266. * @param func defines the function to remove
  34267. * @returns the current mesh
  34268. */
  34269. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34270. /** @hidden */
  34271. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34272. /** @hidden */
  34273. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34274. /** @hidden */
  34275. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34276. /** @hidden */
  34277. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34278. /** @hidden */
  34279. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34280. /** @hidden */
  34281. _rebuild(): void;
  34282. /** @hidden */
  34283. _freeze(): void;
  34284. /** @hidden */
  34285. _unFreeze(): void;
  34286. /**
  34287. * 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
  34288. * @param subMesh defines the subMesh to render
  34289. * @param enableAlphaMode defines if alpha mode can be changed
  34290. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34291. * @returns the current mesh
  34292. */
  34293. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34294. private _onBeforeDraw;
  34295. /**
  34296. * Renormalize the mesh and patch it up if there are no weights
  34297. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34298. * However in the case of zero weights then we set just a single influence to 1.
  34299. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34300. */
  34301. cleanMatrixWeights(): void;
  34302. private normalizeSkinFourWeights;
  34303. private normalizeSkinWeightsAndExtra;
  34304. /**
  34305. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34306. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34307. * the user know there was an issue with importing the mesh
  34308. * @returns a validation object with skinned, valid and report string
  34309. */
  34310. validateSkinning(): {
  34311. skinned: boolean;
  34312. valid: boolean;
  34313. report: string;
  34314. };
  34315. /** @hidden */
  34316. _checkDelayState(): Mesh;
  34317. private _queueLoad;
  34318. /**
  34319. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34320. * A mesh is in the frustum if its bounding box intersects the frustum
  34321. * @param frustumPlanes defines the frustum to test
  34322. * @returns true if the mesh is in the frustum planes
  34323. */
  34324. isInFrustum(frustumPlanes: Plane[]): boolean;
  34325. /**
  34326. * Sets the mesh material by the material or multiMaterial `id` property
  34327. * @param id is a string identifying the material or the multiMaterial
  34328. * @returns the current mesh
  34329. */
  34330. setMaterialByID(id: string): Mesh;
  34331. /**
  34332. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34333. * @returns an array of IAnimatable
  34334. */
  34335. getAnimatables(): IAnimatable[];
  34336. /**
  34337. * Modifies the mesh geometry according to the passed transformation matrix.
  34338. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34339. * The mesh normals are modified using the same transformation.
  34340. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34341. * @param transform defines the transform matrix to use
  34342. * @see https://doc.babylonjs.com/resources/baking_transformations
  34343. * @returns the current mesh
  34344. */
  34345. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34346. /**
  34347. * Modifies the mesh geometry according to its own current World Matrix.
  34348. * The mesh World Matrix is then reset.
  34349. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34350. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34351. * @see https://doc.babylonjs.com/resources/baking_transformations
  34352. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34353. * @returns the current mesh
  34354. */
  34355. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34356. /** @hidden */
  34357. get _positions(): Nullable<Vector3[]>;
  34358. /** @hidden */
  34359. _resetPointsArrayCache(): Mesh;
  34360. /** @hidden */
  34361. _generatePointsArray(): boolean;
  34362. /**
  34363. * Returns a new Mesh object generated from the current mesh properties.
  34364. * This method must not get confused with createInstance()
  34365. * @param name is a string, the name given to the new mesh
  34366. * @param newParent can be any Node object (default `null`)
  34367. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34368. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34369. * @returns a new mesh
  34370. */
  34371. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34372. /**
  34373. * Releases resources associated with this mesh.
  34374. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34375. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34376. */
  34377. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34378. /** @hidden */
  34379. _disposeInstanceSpecificData(): void;
  34380. /** @hidden */
  34381. _disposeThinInstanceSpecificData(): void;
  34382. /**
  34383. * Modifies the mesh geometry according to a displacement map.
  34384. * 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.
  34385. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34386. * @param url is a string, the URL from the image file is to be downloaded.
  34387. * @param minHeight is the lower limit of the displacement.
  34388. * @param maxHeight is the upper limit of the displacement.
  34389. * @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.
  34390. * @param uvOffset is an optional vector2 used to offset UV.
  34391. * @param uvScale is an optional vector2 used to scale UV.
  34392. * @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.
  34393. * @returns the Mesh.
  34394. */
  34395. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34396. /**
  34397. * Modifies the mesh geometry according to a displacementMap buffer.
  34398. * 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.
  34399. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34400. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34401. * @param heightMapWidth is the width of the buffer image.
  34402. * @param heightMapHeight is the height of the buffer image.
  34403. * @param minHeight is the lower limit of the displacement.
  34404. * @param maxHeight is the upper limit of the displacement.
  34405. * @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.
  34406. * @param uvOffset is an optional vector2 used to offset UV.
  34407. * @param uvScale is an optional vector2 used to scale UV.
  34408. * @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.
  34409. * @returns the Mesh.
  34410. */
  34411. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34412. /**
  34413. * Modify the mesh to get a flat shading rendering.
  34414. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34415. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34416. * @returns current mesh
  34417. */
  34418. convertToFlatShadedMesh(): Mesh;
  34419. /**
  34420. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34421. * In other words, more vertices, no more indices and a single bigger VBO.
  34422. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34423. * @returns current mesh
  34424. */
  34425. convertToUnIndexedMesh(): Mesh;
  34426. /**
  34427. * Inverses facet orientations.
  34428. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34429. * @param flipNormals will also inverts the normals
  34430. * @returns current mesh
  34431. */
  34432. flipFaces(flipNormals?: boolean): Mesh;
  34433. /**
  34434. * Increase the number of facets and hence vertices in a mesh
  34435. * Vertex normals are interpolated from existing vertex normals
  34436. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34437. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34438. */
  34439. increaseVertices(numberPerEdge: number): void;
  34440. /**
  34441. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34442. * This will undo any application of covertToFlatShadedMesh
  34443. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34444. */
  34445. forceSharedVertices(): void;
  34446. /** @hidden */
  34447. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34448. /** @hidden */
  34449. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34450. /**
  34451. * Creates a new InstancedMesh object from the mesh model.
  34452. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34453. * @param name defines the name of the new instance
  34454. * @returns a new InstancedMesh
  34455. */
  34456. createInstance(name: string): InstancedMesh;
  34457. /**
  34458. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34459. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34460. * @returns the current mesh
  34461. */
  34462. synchronizeInstances(): Mesh;
  34463. /**
  34464. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34465. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34466. * This should be used together with the simplification to avoid disappearing triangles.
  34467. * @param successCallback an optional success callback to be called after the optimization finished.
  34468. * @returns the current mesh
  34469. */
  34470. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34471. /**
  34472. * Serialize current mesh
  34473. * @param serializationObject defines the object which will receive the serialization data
  34474. */
  34475. serialize(serializationObject: any): void;
  34476. /** @hidden */
  34477. _syncGeometryWithMorphTargetManager(): void;
  34478. /** @hidden */
  34479. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34480. /**
  34481. * Returns a new Mesh object parsed from the source provided.
  34482. * @param parsedMesh is the source
  34483. * @param scene defines the hosting scene
  34484. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34485. * @returns a new Mesh
  34486. */
  34487. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34488. /**
  34489. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34491. * @param name defines the name of the mesh to create
  34492. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34493. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34494. * @param closePath creates a seam between the first and the last points of each path of the path array
  34495. * @param offset is taken in account only if the `pathArray` is containing a single path
  34496. * @param scene defines the hosting scene
  34497. * @param updatable defines if the mesh must be flagged as updatable
  34498. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34499. * @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)
  34500. * @returns a new Mesh
  34501. */
  34502. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34503. /**
  34504. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34505. * @param name defines the name of the mesh to create
  34506. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34507. * @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
  34508. * @param scene defines the hosting scene
  34509. * @param updatable defines if the mesh must be flagged as updatable
  34510. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34511. * @returns a new Mesh
  34512. */
  34513. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34514. /**
  34515. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34516. * @param name defines the name of the mesh to create
  34517. * @param size sets the size (float) of each box side (default 1)
  34518. * @param scene defines the hosting scene
  34519. * @param updatable defines if the mesh must be flagged as updatable
  34520. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34521. * @returns a new Mesh
  34522. */
  34523. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34524. /**
  34525. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34526. * @param name defines the name of the mesh to create
  34527. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34528. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34529. * @param scene defines the hosting scene
  34530. * @param updatable defines if the mesh must be flagged as updatable
  34531. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34532. * @returns a new Mesh
  34533. */
  34534. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34535. /**
  34536. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34537. * @param name defines the name of the mesh to create
  34538. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34539. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34540. * @param scene defines the hosting scene
  34541. * @returns a new Mesh
  34542. */
  34543. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34544. /**
  34545. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34546. * @param name defines the name of the mesh to create
  34547. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34548. * @param diameterTop set the top cap diameter (floats, default 1)
  34549. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34550. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34551. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34552. * @param scene defines the hosting scene
  34553. * @param updatable defines if the mesh must be flagged as updatable
  34554. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34555. * @returns a new Mesh
  34556. */
  34557. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34558. /**
  34559. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34560. * @param name defines the name of the mesh to create
  34561. * @param diameter sets the diameter size (float) of the torus (default 1)
  34562. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34563. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34564. * @param scene defines the hosting scene
  34565. * @param updatable defines if the mesh must be flagged as updatable
  34566. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34567. * @returns a new Mesh
  34568. */
  34569. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34570. /**
  34571. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34572. * @param name defines the name of the mesh to create
  34573. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34574. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34575. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34576. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34577. * @param p the number of windings on X axis (positive integers, default 2)
  34578. * @param q the number of windings on Y axis (positive integers, default 3)
  34579. * @param scene defines the hosting scene
  34580. * @param updatable defines if the mesh must be flagged as updatable
  34581. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34582. * @returns a new Mesh
  34583. */
  34584. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34585. /**
  34586. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34587. * @param name defines the name of the mesh to create
  34588. * @param points is an array successive Vector3
  34589. * @param scene defines the hosting scene
  34590. * @param updatable defines if the mesh must be flagged as updatable
  34591. * @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).
  34592. * @returns a new Mesh
  34593. */
  34594. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34595. /**
  34596. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34597. * @param name defines the name of the mesh to create
  34598. * @param points is an array successive Vector3
  34599. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34600. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34601. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34602. * @param scene defines the hosting scene
  34603. * @param updatable defines if the mesh must be flagged as updatable
  34604. * @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)
  34605. * @returns a new Mesh
  34606. */
  34607. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34608. /**
  34609. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34610. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34611. * 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.
  34612. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34613. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34614. * Remember you can only change the shape positions, not their number when updating a polygon.
  34615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34616. * @param name defines the name of the mesh to create
  34617. * @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
  34618. * @param scene defines the hosting scene
  34619. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34620. * @param updatable defines if the mesh must be flagged as updatable
  34621. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34622. * @param earcutInjection can be used to inject your own earcut reference
  34623. * @returns a new Mesh
  34624. */
  34625. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34626. /**
  34627. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34629. * @param name defines the name of the mesh to create
  34630. * @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
  34631. * @param depth defines the height of extrusion
  34632. * @param scene defines the hosting scene
  34633. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34634. * @param updatable defines if the mesh must be flagged as updatable
  34635. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34636. * @param earcutInjection can be used to inject your own earcut reference
  34637. * @returns a new Mesh
  34638. */
  34639. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34640. /**
  34641. * Creates an extruded shape mesh.
  34642. * 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
  34643. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34645. * @param name defines the name of the mesh to create
  34646. * @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
  34647. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34648. * @param scale is the value to scale the shape
  34649. * @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
  34650. * @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
  34651. * @param scene defines the hosting scene
  34652. * @param updatable defines if the mesh must be flagged as updatable
  34653. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34654. * @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)
  34655. * @returns a new Mesh
  34656. */
  34657. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34658. /**
  34659. * Creates an custom extruded shape mesh.
  34660. * The custom extrusion is a parametric shape.
  34661. * It has no predefined shape. Its final shape will depend on the input parameters.
  34662. * Please consider using the same method from the MeshBuilder class instead
  34663. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34664. * @param name defines the name of the mesh to create
  34665. * @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
  34666. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34667. * @param scaleFunction is a custom Javascript function called on each path point
  34668. * @param rotationFunction is a custom Javascript function called on each path point
  34669. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34670. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34671. * @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
  34672. * @param scene defines the hosting scene
  34673. * @param updatable defines if the mesh must be flagged as updatable
  34674. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34675. * @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)
  34676. * @returns a new Mesh
  34677. */
  34678. 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;
  34679. /**
  34680. * Creates lathe mesh.
  34681. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34682. * Please consider using the same method from the MeshBuilder class instead
  34683. * @param name defines the name of the mesh to create
  34684. * @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
  34685. * @param radius is the radius value of the lathe
  34686. * @param tessellation is the side number of the lathe.
  34687. * @param scene defines the hosting scene
  34688. * @param updatable defines if the mesh must be flagged as updatable
  34689. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34690. * @returns a new Mesh
  34691. */
  34692. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34693. /**
  34694. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34695. * @param name defines the name of the mesh to create
  34696. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34697. * @param scene defines the hosting scene
  34698. * @param updatable defines if the mesh must be flagged as updatable
  34699. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34700. * @returns a new Mesh
  34701. */
  34702. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34703. /**
  34704. * Creates a ground mesh.
  34705. * Please consider using the same method from the MeshBuilder class instead
  34706. * @param name defines the name of the mesh to create
  34707. * @param width set the width of the ground
  34708. * @param height set the height of the ground
  34709. * @param subdivisions sets the number of subdivisions per side
  34710. * @param scene defines the hosting scene
  34711. * @param updatable defines if the mesh must be flagged as updatable
  34712. * @returns a new Mesh
  34713. */
  34714. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34715. /**
  34716. * Creates a tiled ground mesh.
  34717. * Please consider using the same method from the MeshBuilder class instead
  34718. * @param name defines the name of the mesh to create
  34719. * @param xmin set the ground minimum X coordinate
  34720. * @param zmin set the ground minimum Y coordinate
  34721. * @param xmax set the ground maximum X coordinate
  34722. * @param zmax set the ground maximum Z coordinate
  34723. * @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
  34724. * @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
  34725. * @param scene defines the hosting scene
  34726. * @param updatable defines if the mesh must be flagged as updatable
  34727. * @returns a new Mesh
  34728. */
  34729. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34730. w: number;
  34731. h: number;
  34732. }, precision: {
  34733. w: number;
  34734. h: number;
  34735. }, scene: Scene, updatable?: boolean): Mesh;
  34736. /**
  34737. * Creates a ground mesh from a height map.
  34738. * Please consider using the same method from the MeshBuilder class instead
  34739. * @see https://doc.babylonjs.com/babylon101/height_map
  34740. * @param name defines the name of the mesh to create
  34741. * @param url sets the URL of the height map image resource
  34742. * @param width set the ground width size
  34743. * @param height set the ground height size
  34744. * @param subdivisions sets the number of subdivision per side
  34745. * @param minHeight is the minimum altitude on the ground
  34746. * @param maxHeight is the maximum altitude on the ground
  34747. * @param scene defines the hosting scene
  34748. * @param updatable defines if the mesh must be flagged as updatable
  34749. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34750. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34751. * @returns a new Mesh
  34752. */
  34753. 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;
  34754. /**
  34755. * Creates a tube mesh.
  34756. * The tube is a parametric shape.
  34757. * It has no predefined shape. Its final shape will depend on the input parameters.
  34758. * Please consider using the same method from the MeshBuilder class instead
  34759. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34760. * @param name defines the name of the mesh to create
  34761. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34762. * @param radius sets the tube radius size
  34763. * @param tessellation is the number of sides on the tubular surface
  34764. * @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
  34765. * @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
  34766. * @param scene defines the hosting scene
  34767. * @param updatable defines if the mesh must be flagged as updatable
  34768. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34769. * @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)
  34770. * @returns a new Mesh
  34771. */
  34772. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34773. (i: number, distance: number): number;
  34774. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34775. /**
  34776. * Creates a polyhedron mesh.
  34777. * Please consider using the same method from the MeshBuilder class instead.
  34778. * * 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
  34779. * * The parameter `size` (positive float, default 1) sets the polygon size
  34780. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34781. * * 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`
  34782. * * 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
  34783. * * 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)`)
  34784. * * 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
  34785. * * 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
  34786. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34789. * @param name defines the name of the mesh to create
  34790. * @param options defines the options used to create the mesh
  34791. * @param scene defines the hosting scene
  34792. * @returns a new Mesh
  34793. */
  34794. static CreatePolyhedron(name: string, options: {
  34795. type?: number;
  34796. size?: number;
  34797. sizeX?: number;
  34798. sizeY?: number;
  34799. sizeZ?: number;
  34800. custom?: any;
  34801. faceUV?: Vector4[];
  34802. faceColors?: Color4[];
  34803. updatable?: boolean;
  34804. sideOrientation?: number;
  34805. }, scene: Scene): Mesh;
  34806. /**
  34807. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34808. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34809. * * 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`)
  34810. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34811. * * 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
  34812. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34815. * @param name defines the name of the mesh
  34816. * @param options defines the options used to create the mesh
  34817. * @param scene defines the hosting scene
  34818. * @returns a new Mesh
  34819. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34820. */
  34821. static CreateIcoSphere(name: string, options: {
  34822. radius?: number;
  34823. flat?: boolean;
  34824. subdivisions?: number;
  34825. sideOrientation?: number;
  34826. updatable?: boolean;
  34827. }, scene: Scene): Mesh;
  34828. /**
  34829. * Creates a decal mesh.
  34830. * Please consider using the same method from the MeshBuilder class instead.
  34831. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34832. * @param name defines the name of the mesh
  34833. * @param sourceMesh defines the mesh receiving the decal
  34834. * @param position sets the position of the decal in world coordinates
  34835. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34836. * @param size sets the decal scaling
  34837. * @param angle sets the angle to rotate the decal
  34838. * @returns a new Mesh
  34839. */
  34840. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34841. /** Creates a Capsule Mesh
  34842. * @param name defines the name of the mesh.
  34843. * @param options the constructors options used to shape the mesh.
  34844. * @param scene defines the scene the mesh is scoped to.
  34845. * @returns the capsule mesh
  34846. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34847. */
  34848. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34849. /**
  34850. * Prepare internal position array for software CPU skinning
  34851. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34852. */
  34853. setPositionsForCPUSkinning(): Float32Array;
  34854. /**
  34855. * Prepare internal normal array for software CPU skinning
  34856. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34857. */
  34858. setNormalsForCPUSkinning(): Float32Array;
  34859. /**
  34860. * Updates the vertex buffer by applying transformation from the bones
  34861. * @param skeleton defines the skeleton to apply to current mesh
  34862. * @returns the current mesh
  34863. */
  34864. applySkeleton(skeleton: Skeleton): Mesh;
  34865. /**
  34866. * 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
  34867. * @param meshes defines the list of meshes to scan
  34868. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34869. */
  34870. static MinMax(meshes: AbstractMesh[]): {
  34871. min: Vector3;
  34872. max: Vector3;
  34873. };
  34874. /**
  34875. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34876. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34877. * @returns a vector3
  34878. */
  34879. static Center(meshesOrMinMaxVector: {
  34880. min: Vector3;
  34881. max: Vector3;
  34882. } | AbstractMesh[]): Vector3;
  34883. /**
  34884. * Merge the array of meshes into a single mesh for performance reasons.
  34885. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34886. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34887. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34888. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34889. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34890. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34891. * @returns a new mesh
  34892. */
  34893. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34894. /** @hidden */
  34895. addInstance(instance: InstancedMesh): void;
  34896. /** @hidden */
  34897. removeInstance(instance: InstancedMesh): void;
  34898. }
  34899. }
  34900. declare module "babylonjs/Cameras/camera" {
  34901. import { SmartArray } from "babylonjs/Misc/smartArray";
  34902. import { Observable } from "babylonjs/Misc/observable";
  34903. import { Nullable } from "babylonjs/types";
  34904. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34905. import { Scene } from "babylonjs/scene";
  34906. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  34907. import { Node } from "babylonjs/node";
  34908. import { Mesh } from "babylonjs/Meshes/mesh";
  34909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34910. import { ICullable } from "babylonjs/Culling/boundingInfo";
  34911. import { Viewport } from "babylonjs/Maths/math.viewport";
  34912. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34913. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34914. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  34915. import { Ray } from "babylonjs/Culling/ray";
  34916. /**
  34917. * This is the base class of all the camera used in the application.
  34918. * @see https://doc.babylonjs.com/features/cameras
  34919. */
  34920. export class Camera extends Node {
  34921. /** @hidden */
  34922. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  34923. /**
  34924. * This is the default projection mode used by the cameras.
  34925. * It helps recreating a feeling of perspective and better appreciate depth.
  34926. * This is the best way to simulate real life cameras.
  34927. */
  34928. static readonly PERSPECTIVE_CAMERA: number;
  34929. /**
  34930. * This helps creating camera with an orthographic mode.
  34931. * 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.
  34932. */
  34933. static readonly ORTHOGRAPHIC_CAMERA: number;
  34934. /**
  34935. * This is the default FOV mode for perspective cameras.
  34936. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  34937. */
  34938. static readonly FOVMODE_VERTICAL_FIXED: number;
  34939. /**
  34940. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  34941. */
  34942. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  34943. /**
  34944. * This specifies ther is no need for a camera rig.
  34945. * Basically only one eye is rendered corresponding to the camera.
  34946. */
  34947. static readonly RIG_MODE_NONE: number;
  34948. /**
  34949. * Simulates a camera Rig with one blue eye and one red eye.
  34950. * This can be use with 3d blue and red glasses.
  34951. */
  34952. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  34953. /**
  34954. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  34955. */
  34956. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  34957. /**
  34958. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  34959. */
  34960. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  34961. /**
  34962. * Defines that both eyes of the camera will be rendered over under each other.
  34963. */
  34964. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  34965. /**
  34966. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  34967. */
  34968. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  34969. /**
  34970. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  34971. */
  34972. static readonly RIG_MODE_VR: number;
  34973. /**
  34974. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  34975. */
  34976. static readonly RIG_MODE_WEBVR: number;
  34977. /**
  34978. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  34979. */
  34980. static readonly RIG_MODE_CUSTOM: number;
  34981. /**
  34982. * Defines if by default attaching controls should prevent the default javascript event to continue.
  34983. */
  34984. static ForceAttachControlToAlwaysPreventDefault: boolean;
  34985. /**
  34986. * Define the input manager associated with the camera.
  34987. */
  34988. inputs: CameraInputsManager<Camera>;
  34989. /** @hidden */
  34990. _position: Vector3;
  34991. /**
  34992. * Define the current local position of the camera in the scene
  34993. */
  34994. get position(): Vector3;
  34995. set position(newPosition: Vector3);
  34996. protected _upVector: Vector3;
  34997. /**
  34998. * The vector the camera should consider as up.
  34999. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  35000. */
  35001. set upVector(vec: Vector3);
  35002. get upVector(): Vector3;
  35003. /**
  35004. * Define the current limit on the left side for an orthographic camera
  35005. * In scene unit
  35006. */
  35007. orthoLeft: Nullable<number>;
  35008. /**
  35009. * Define the current limit on the right side for an orthographic camera
  35010. * In scene unit
  35011. */
  35012. orthoRight: Nullable<number>;
  35013. /**
  35014. * Define the current limit on the bottom side for an orthographic camera
  35015. * In scene unit
  35016. */
  35017. orthoBottom: Nullable<number>;
  35018. /**
  35019. * Define the current limit on the top side for an orthographic camera
  35020. * In scene unit
  35021. */
  35022. orthoTop: Nullable<number>;
  35023. /**
  35024. * Field Of View is set in Radians. (default is 0.8)
  35025. */
  35026. fov: number;
  35027. /**
  35028. * Define the minimum distance the camera can see from.
  35029. * This is important to note that the depth buffer are not infinite and the closer it starts
  35030. * the more your scene might encounter depth fighting issue.
  35031. */
  35032. minZ: number;
  35033. /**
  35034. * Define the maximum distance the camera can see to.
  35035. * This is important to note that the depth buffer are not infinite and the further it end
  35036. * the more your scene might encounter depth fighting issue.
  35037. */
  35038. maxZ: number;
  35039. /**
  35040. * Define the default inertia of the camera.
  35041. * This helps giving a smooth feeling to the camera movement.
  35042. */
  35043. inertia: number;
  35044. /**
  35045. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  35046. */
  35047. mode: number;
  35048. /**
  35049. * Define whether the camera is intermediate.
  35050. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  35051. */
  35052. isIntermediate: boolean;
  35053. /**
  35054. * Define the viewport of the camera.
  35055. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  35056. */
  35057. viewport: Viewport;
  35058. /**
  35059. * Restricts the camera to viewing objects with the same layerMask.
  35060. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  35061. */
  35062. layerMask: number;
  35063. /**
  35064. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35065. */
  35066. fovMode: number;
  35067. /**
  35068. * Rig mode of the camera.
  35069. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35070. * This is normally controlled byt the camera themselves as internal use.
  35071. */
  35072. cameraRigMode: number;
  35073. /**
  35074. * Defines the distance between both "eyes" in case of a RIG
  35075. */
  35076. interaxialDistance: number;
  35077. /**
  35078. * Defines if stereoscopic rendering is done side by side or over under.
  35079. */
  35080. isStereoscopicSideBySide: boolean;
  35081. /**
  35082. * 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
  35083. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35084. * else in the scene. (Eg. security camera)
  35085. *
  35086. * 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)
  35087. */
  35088. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35089. /**
  35090. * When set, the camera will render to this render target instead of the default canvas
  35091. *
  35092. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35093. */
  35094. outputRenderTarget: Nullable<RenderTargetTexture>;
  35095. /**
  35096. * Observable triggered when the camera view matrix has changed.
  35097. */
  35098. onViewMatrixChangedObservable: Observable<Camera>;
  35099. /**
  35100. * Observable triggered when the camera Projection matrix has changed.
  35101. */
  35102. onProjectionMatrixChangedObservable: Observable<Camera>;
  35103. /**
  35104. * Observable triggered when the inputs have been processed.
  35105. */
  35106. onAfterCheckInputsObservable: Observable<Camera>;
  35107. /**
  35108. * Observable triggered when reset has been called and applied to the camera.
  35109. */
  35110. onRestoreStateObservable: Observable<Camera>;
  35111. /**
  35112. * Is this camera a part of a rig system?
  35113. */
  35114. isRigCamera: boolean;
  35115. /**
  35116. * If isRigCamera set to true this will be set with the parent camera.
  35117. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35118. */
  35119. rigParent?: Camera;
  35120. /** @hidden */
  35121. _cameraRigParams: any;
  35122. /** @hidden */
  35123. _rigCameras: Camera[];
  35124. /** @hidden */
  35125. _rigPostProcess: Nullable<PostProcess>;
  35126. protected _webvrViewMatrix: Matrix;
  35127. /** @hidden */
  35128. _skipRendering: boolean;
  35129. /** @hidden */
  35130. _projectionMatrix: Matrix;
  35131. /** @hidden */
  35132. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35133. /** @hidden */
  35134. _activeMeshes: SmartArray<AbstractMesh>;
  35135. protected _globalPosition: Vector3;
  35136. /** @hidden */
  35137. _computedViewMatrix: Matrix;
  35138. private _doNotComputeProjectionMatrix;
  35139. private _transformMatrix;
  35140. private _frustumPlanes;
  35141. private _refreshFrustumPlanes;
  35142. private _storedFov;
  35143. private _stateStored;
  35144. /**
  35145. * Instantiates a new camera object.
  35146. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35147. * @see https://doc.babylonjs.com/features/cameras
  35148. * @param name Defines the name of the camera in the scene
  35149. * @param position Defines the position of the camera
  35150. * @param scene Defines the scene the camera belongs too
  35151. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35152. */
  35153. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35154. /**
  35155. * Store current camera state (fov, position, etc..)
  35156. * @returns the camera
  35157. */
  35158. storeState(): Camera;
  35159. /**
  35160. * Restores the camera state values if it has been stored. You must call storeState() first
  35161. */
  35162. protected _restoreStateValues(): boolean;
  35163. /**
  35164. * Restored camera state. You must call storeState() first.
  35165. * @returns true if restored and false otherwise
  35166. */
  35167. restoreState(): boolean;
  35168. /**
  35169. * Gets the class name of the camera.
  35170. * @returns the class name
  35171. */
  35172. getClassName(): string;
  35173. /** @hidden */
  35174. readonly _isCamera: boolean;
  35175. /**
  35176. * Gets a string representation of the camera useful for debug purpose.
  35177. * @param fullDetails Defines that a more verboe level of logging is required
  35178. * @returns the string representation
  35179. */
  35180. toString(fullDetails?: boolean): string;
  35181. /**
  35182. * Gets the current world space position of the camera.
  35183. */
  35184. get globalPosition(): Vector3;
  35185. /**
  35186. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35187. * @returns the active meshe list
  35188. */
  35189. getActiveMeshes(): SmartArray<AbstractMesh>;
  35190. /**
  35191. * Check whether a mesh is part of the current active mesh list of the camera
  35192. * @param mesh Defines the mesh to check
  35193. * @returns true if active, false otherwise
  35194. */
  35195. isActiveMesh(mesh: Mesh): boolean;
  35196. /**
  35197. * Is this camera ready to be used/rendered
  35198. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35199. * @return true if the camera is ready
  35200. */
  35201. isReady(completeCheck?: boolean): boolean;
  35202. /** @hidden */
  35203. _initCache(): void;
  35204. /** @hidden */
  35205. _updateCache(ignoreParentClass?: boolean): void;
  35206. /** @hidden */
  35207. _isSynchronized(): boolean;
  35208. /** @hidden */
  35209. _isSynchronizedViewMatrix(): boolean;
  35210. /** @hidden */
  35211. _isSynchronizedProjectionMatrix(): boolean;
  35212. /**
  35213. * Attach the input controls to a specific dom element to get the input from.
  35214. * @param element Defines the element the controls should be listened from
  35215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35216. */
  35217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35218. /**
  35219. * Detach the current controls from the specified dom element.
  35220. * @param element Defines the element to stop listening the inputs from
  35221. */
  35222. detachControl(element: HTMLElement): void;
  35223. /**
  35224. * Update the camera state according to the different inputs gathered during the frame.
  35225. */
  35226. update(): void;
  35227. /** @hidden */
  35228. _checkInputs(): void;
  35229. /** @hidden */
  35230. get rigCameras(): Camera[];
  35231. /**
  35232. * Gets the post process used by the rig cameras
  35233. */
  35234. get rigPostProcess(): Nullable<PostProcess>;
  35235. /**
  35236. * Internal, gets the first post proces.
  35237. * @returns the first post process to be run on this camera.
  35238. */
  35239. _getFirstPostProcess(): Nullable<PostProcess>;
  35240. private _cascadePostProcessesToRigCams;
  35241. /**
  35242. * Attach a post process to the camera.
  35243. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35244. * @param postProcess The post process to attach to the camera
  35245. * @param insertAt The position of the post process in case several of them are in use in the scene
  35246. * @returns the position the post process has been inserted at
  35247. */
  35248. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35249. /**
  35250. * Detach a post process to the camera.
  35251. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35252. * @param postProcess The post process to detach from the camera
  35253. */
  35254. detachPostProcess(postProcess: PostProcess): void;
  35255. /**
  35256. * Gets the current world matrix of the camera
  35257. */
  35258. getWorldMatrix(): Matrix;
  35259. /** @hidden */
  35260. _getViewMatrix(): Matrix;
  35261. /**
  35262. * Gets the current view matrix of the camera.
  35263. * @param force forces the camera to recompute the matrix without looking at the cached state
  35264. * @returns the view matrix
  35265. */
  35266. getViewMatrix(force?: boolean): Matrix;
  35267. /**
  35268. * Freeze the projection matrix.
  35269. * It will prevent the cache check of the camera projection compute and can speed up perf
  35270. * if no parameter of the camera are meant to change
  35271. * @param projection Defines manually a projection if necessary
  35272. */
  35273. freezeProjectionMatrix(projection?: Matrix): void;
  35274. /**
  35275. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35276. */
  35277. unfreezeProjectionMatrix(): void;
  35278. /**
  35279. * Gets the current projection matrix of the camera.
  35280. * @param force forces the camera to recompute the matrix without looking at the cached state
  35281. * @returns the projection matrix
  35282. */
  35283. getProjectionMatrix(force?: boolean): Matrix;
  35284. /**
  35285. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35286. * @returns a Matrix
  35287. */
  35288. getTransformationMatrix(): Matrix;
  35289. private _updateFrustumPlanes;
  35290. /**
  35291. * Checks if a cullable object (mesh...) is in the camera frustum
  35292. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35293. * @param target The object to check
  35294. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35295. * @returns true if the object is in frustum otherwise false
  35296. */
  35297. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35298. /**
  35299. * Checks if a cullable object (mesh...) is in the camera frustum
  35300. * Unlike isInFrustum this cheks the full bounding box
  35301. * @param target The object to check
  35302. * @returns true if the object is in frustum otherwise false
  35303. */
  35304. isCompletelyInFrustum(target: ICullable): boolean;
  35305. /**
  35306. * Gets a ray in the forward direction from the camera.
  35307. * @param length Defines the length of the ray to create
  35308. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35309. * @param origin Defines the start point of the ray which defaults to the camera position
  35310. * @returns the forward ray
  35311. */
  35312. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35313. /**
  35314. * Gets a ray in the forward direction from the camera.
  35315. * @param refRay the ray to (re)use when setting the values
  35316. * @param length Defines the length of the ray to create
  35317. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35318. * @param origin Defines the start point of the ray which defaults to the camera position
  35319. * @returns the forward ray
  35320. */
  35321. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35322. /**
  35323. * Releases resources associated with this node.
  35324. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35325. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35326. */
  35327. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35328. /** @hidden */
  35329. _isLeftCamera: boolean;
  35330. /**
  35331. * Gets the left camera of a rig setup in case of Rigged Camera
  35332. */
  35333. get isLeftCamera(): boolean;
  35334. /** @hidden */
  35335. _isRightCamera: boolean;
  35336. /**
  35337. * Gets the right camera of a rig setup in case of Rigged Camera
  35338. */
  35339. get isRightCamera(): boolean;
  35340. /**
  35341. * Gets the left camera of a rig setup in case of Rigged Camera
  35342. */
  35343. get leftCamera(): Nullable<FreeCamera>;
  35344. /**
  35345. * Gets the right camera of a rig setup in case of Rigged Camera
  35346. */
  35347. get rightCamera(): Nullable<FreeCamera>;
  35348. /**
  35349. * Gets the left camera target of a rig setup in case of Rigged Camera
  35350. * @returns the target position
  35351. */
  35352. getLeftTarget(): Nullable<Vector3>;
  35353. /**
  35354. * Gets the right camera target of a rig setup in case of Rigged Camera
  35355. * @returns the target position
  35356. */
  35357. getRightTarget(): Nullable<Vector3>;
  35358. /**
  35359. * @hidden
  35360. */
  35361. setCameraRigMode(mode: number, rigParams: any): void;
  35362. /** @hidden */
  35363. static _setStereoscopicRigMode(camera: Camera): void;
  35364. /** @hidden */
  35365. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35366. /** @hidden */
  35367. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35368. /** @hidden */
  35369. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35370. /** @hidden */
  35371. _getVRProjectionMatrix(): Matrix;
  35372. protected _updateCameraRotationMatrix(): void;
  35373. protected _updateWebVRCameraRotationMatrix(): void;
  35374. /**
  35375. * This function MUST be overwritten by the different WebVR cameras available.
  35376. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35377. * @hidden
  35378. */
  35379. _getWebVRProjectionMatrix(): Matrix;
  35380. /**
  35381. * This function MUST be overwritten by the different WebVR cameras available.
  35382. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35383. * @hidden
  35384. */
  35385. _getWebVRViewMatrix(): Matrix;
  35386. /** @hidden */
  35387. setCameraRigParameter(name: string, value: any): void;
  35388. /**
  35389. * needs to be overridden by children so sub has required properties to be copied
  35390. * @hidden
  35391. */
  35392. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35393. /**
  35394. * May need to be overridden by children
  35395. * @hidden
  35396. */
  35397. _updateRigCameras(): void;
  35398. /** @hidden */
  35399. _setupInputs(): void;
  35400. /**
  35401. * Serialiaze the camera setup to a json represention
  35402. * @returns the JSON representation
  35403. */
  35404. serialize(): any;
  35405. /**
  35406. * Clones the current camera.
  35407. * @param name The cloned camera name
  35408. * @returns the cloned camera
  35409. */
  35410. clone(name: string): Camera;
  35411. /**
  35412. * Gets the direction of the camera relative to a given local axis.
  35413. * @param localAxis Defines the reference axis to provide a relative direction.
  35414. * @return the direction
  35415. */
  35416. getDirection(localAxis: Vector3): Vector3;
  35417. /**
  35418. * Returns the current camera absolute rotation
  35419. */
  35420. get absoluteRotation(): Quaternion;
  35421. /**
  35422. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35423. * @param localAxis Defines the reference axis to provide a relative direction.
  35424. * @param result Defines the vector to store the result in
  35425. */
  35426. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35427. /**
  35428. * Gets a camera constructor for a given camera type
  35429. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35430. * @param name The name of the camera the result will be able to instantiate
  35431. * @param scene The scene the result will construct the camera in
  35432. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35433. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35434. * @returns a factory method to construc the camera
  35435. */
  35436. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35437. /**
  35438. * Compute the world matrix of the camera.
  35439. * @returns the camera world matrix
  35440. */
  35441. computeWorldMatrix(): Matrix;
  35442. /**
  35443. * Parse a JSON and creates the camera from the parsed information
  35444. * @param parsedCamera The JSON to parse
  35445. * @param scene The scene to instantiate the camera in
  35446. * @returns the newly constructed camera
  35447. */
  35448. static Parse(parsedCamera: any, scene: Scene): Camera;
  35449. }
  35450. }
  35451. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35452. import { Nullable } from "babylonjs/types";
  35453. import { Scene } from "babylonjs/scene";
  35454. import { Vector4 } from "babylonjs/Maths/math.vector";
  35455. import { Mesh } from "babylonjs/Meshes/mesh";
  35456. /**
  35457. * Class containing static functions to help procedurally build meshes
  35458. */
  35459. export class DiscBuilder {
  35460. /**
  35461. * Creates a plane polygonal mesh. By default, this is a disc
  35462. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35463. * * 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
  35464. * * 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
  35465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35468. * @param name defines the name of the mesh
  35469. * @param options defines the options used to create the mesh
  35470. * @param scene defines the hosting scene
  35471. * @returns the plane polygonal mesh
  35472. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35473. */
  35474. static CreateDisc(name: string, options: {
  35475. radius?: number;
  35476. tessellation?: number;
  35477. arc?: number;
  35478. updatable?: boolean;
  35479. sideOrientation?: number;
  35480. frontUVs?: Vector4;
  35481. backUVs?: Vector4;
  35482. }, scene?: Nullable<Scene>): Mesh;
  35483. }
  35484. }
  35485. declare module "babylonjs/Particles/solidParticleSystem" {
  35486. import { Nullable } from "babylonjs/types";
  35487. import { Mesh } from "babylonjs/Meshes/mesh";
  35488. import { Scene, IDisposable } from "babylonjs/scene";
  35489. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35490. import { Material } from "babylonjs/Materials/material";
  35491. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35492. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35493. /**
  35494. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35495. *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.
  35496. * The SPS is also a particle system. It provides some methods to manage the particles.
  35497. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35498. *
  35499. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35500. */
  35501. export class SolidParticleSystem implements IDisposable {
  35502. /**
  35503. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35504. * Example : var p = SPS.particles[i];
  35505. */
  35506. particles: SolidParticle[];
  35507. /**
  35508. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35509. */
  35510. nbParticles: number;
  35511. /**
  35512. * If the particles must ever face the camera (default false). Useful for planar particles.
  35513. */
  35514. billboard: boolean;
  35515. /**
  35516. * Recompute normals when adding a shape
  35517. */
  35518. recomputeNormals: boolean;
  35519. /**
  35520. * This a counter ofr your own usage. It's not set by any SPS functions.
  35521. */
  35522. counter: number;
  35523. /**
  35524. * The SPS name. This name is also given to the underlying mesh.
  35525. */
  35526. name: string;
  35527. /**
  35528. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35529. */
  35530. mesh: Mesh;
  35531. /**
  35532. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35533. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35534. */
  35535. vars: any;
  35536. /**
  35537. * This array is populated when the SPS is set as 'pickable'.
  35538. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35539. * Each element of this array is an object `{idx: int, faceId: int}`.
  35540. * `idx` is the picked particle index in the `SPS.particles` array
  35541. * `faceId` is the picked face index counted within this particle.
  35542. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35543. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35544. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35545. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35546. */
  35547. pickedParticles: {
  35548. idx: number;
  35549. faceId: number;
  35550. }[];
  35551. /**
  35552. * This array is populated when the SPS is set as 'pickable'
  35553. * Each key of this array is a submesh index.
  35554. * Each element of this array is a second array defined like this :
  35555. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35556. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35557. * `idx` is the picked particle index in the `SPS.particles` array
  35558. * `faceId` is the picked face index counted within this particle.
  35559. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35560. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35561. */
  35562. pickedBySubMesh: {
  35563. idx: number;
  35564. faceId: number;
  35565. }[][];
  35566. /**
  35567. * This array is populated when `enableDepthSort` is set to true.
  35568. * Each element of this array is an instance of the class DepthSortedParticle.
  35569. */
  35570. depthSortedParticles: DepthSortedParticle[];
  35571. /**
  35572. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35573. * @hidden
  35574. */
  35575. _bSphereOnly: boolean;
  35576. /**
  35577. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35578. * @hidden
  35579. */
  35580. _bSphereRadiusFactor: number;
  35581. private _scene;
  35582. private _positions;
  35583. private _indices;
  35584. private _normals;
  35585. private _colors;
  35586. private _uvs;
  35587. private _indices32;
  35588. private _positions32;
  35589. private _normals32;
  35590. private _fixedNormal32;
  35591. private _colors32;
  35592. private _uvs32;
  35593. private _index;
  35594. private _updatable;
  35595. private _pickable;
  35596. private _isVisibilityBoxLocked;
  35597. private _alwaysVisible;
  35598. private _depthSort;
  35599. private _expandable;
  35600. private _shapeCounter;
  35601. private _copy;
  35602. private _color;
  35603. private _computeParticleColor;
  35604. private _computeParticleTexture;
  35605. private _computeParticleRotation;
  35606. private _computeParticleVertex;
  35607. private _computeBoundingBox;
  35608. private _depthSortParticles;
  35609. private _camera;
  35610. private _mustUnrotateFixedNormals;
  35611. private _particlesIntersect;
  35612. private _needs32Bits;
  35613. private _isNotBuilt;
  35614. private _lastParticleId;
  35615. private _idxOfId;
  35616. private _multimaterialEnabled;
  35617. private _useModelMaterial;
  35618. private _indicesByMaterial;
  35619. private _materialIndexes;
  35620. private _depthSortFunction;
  35621. private _materialSortFunction;
  35622. private _materials;
  35623. private _multimaterial;
  35624. private _materialIndexesById;
  35625. private _defaultMaterial;
  35626. private _autoUpdateSubMeshes;
  35627. private _tmpVertex;
  35628. /**
  35629. * Creates a SPS (Solid Particle System) object.
  35630. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35631. * @param scene (Scene) is the scene in which the SPS is added.
  35632. * @param options defines the options of the sps e.g.
  35633. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35634. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35635. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35636. * * 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.
  35637. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35638. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35639. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35640. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35641. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35642. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35643. */
  35644. constructor(name: string, scene: Scene, options?: {
  35645. updatable?: boolean;
  35646. isPickable?: boolean;
  35647. enableDepthSort?: boolean;
  35648. particleIntersection?: boolean;
  35649. boundingSphereOnly?: boolean;
  35650. bSphereRadiusFactor?: number;
  35651. expandable?: boolean;
  35652. useModelMaterial?: boolean;
  35653. enableMultiMaterial?: boolean;
  35654. });
  35655. /**
  35656. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35657. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35658. * @returns the created mesh
  35659. */
  35660. buildMesh(): Mesh;
  35661. /**
  35662. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35663. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35664. * Thus the particles generated from `digest()` have their property `position` set yet.
  35665. * @param mesh ( Mesh ) is the mesh to be digested
  35666. * @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
  35667. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35668. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35669. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35670. * @returns the current SPS
  35671. */
  35672. digest(mesh: Mesh, options?: {
  35673. facetNb?: number;
  35674. number?: number;
  35675. delta?: number;
  35676. storage?: [];
  35677. }): SolidParticleSystem;
  35678. /**
  35679. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35680. * @hidden
  35681. */
  35682. private _unrotateFixedNormals;
  35683. /**
  35684. * Resets the temporary working copy particle
  35685. * @hidden
  35686. */
  35687. private _resetCopy;
  35688. /**
  35689. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35690. * @param p the current index in the positions array to be updated
  35691. * @param ind the current index in the indices array
  35692. * @param shape a Vector3 array, the shape geometry
  35693. * @param positions the positions array to be updated
  35694. * @param meshInd the shape indices array
  35695. * @param indices the indices array to be updated
  35696. * @param meshUV the shape uv array
  35697. * @param uvs the uv array to be updated
  35698. * @param meshCol the shape color array
  35699. * @param colors the color array to be updated
  35700. * @param meshNor the shape normals array
  35701. * @param normals the normals array to be updated
  35702. * @param idx the particle index
  35703. * @param idxInShape the particle index in its shape
  35704. * @param options the addShape() method passed options
  35705. * @model the particle model
  35706. * @hidden
  35707. */
  35708. private _meshBuilder;
  35709. /**
  35710. * Returns a shape Vector3 array from positions float array
  35711. * @param positions float array
  35712. * @returns a vector3 array
  35713. * @hidden
  35714. */
  35715. private _posToShape;
  35716. /**
  35717. * Returns a shapeUV array from a float uvs (array deep copy)
  35718. * @param uvs as a float array
  35719. * @returns a shapeUV array
  35720. * @hidden
  35721. */
  35722. private _uvsToShapeUV;
  35723. /**
  35724. * Adds a new particle object in the particles array
  35725. * @param idx particle index in particles array
  35726. * @param id particle id
  35727. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35728. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35729. * @param model particle ModelShape object
  35730. * @param shapeId model shape identifier
  35731. * @param idxInShape index of the particle in the current model
  35732. * @param bInfo model bounding info object
  35733. * @param storage target storage array, if any
  35734. * @hidden
  35735. */
  35736. private _addParticle;
  35737. /**
  35738. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35739. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35740. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35741. * @param nb (positive integer) the number of particles to be created from this model
  35742. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35743. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35744. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35745. * @returns the number of shapes in the system
  35746. */
  35747. addShape(mesh: Mesh, nb: number, options?: {
  35748. positionFunction?: any;
  35749. vertexFunction?: any;
  35750. storage?: [];
  35751. }): number;
  35752. /**
  35753. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35754. * @hidden
  35755. */
  35756. private _rebuildParticle;
  35757. /**
  35758. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35759. * @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.
  35760. * @returns the SPS.
  35761. */
  35762. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35763. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35764. * Returns an array with the removed particles.
  35765. * 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.
  35766. * The SPS can't be empty so at least one particle needs to remain in place.
  35767. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35768. * @param start index of the first particle to remove
  35769. * @param end index of the last particle to remove (included)
  35770. * @returns an array populated with the removed particles
  35771. */
  35772. removeParticles(start: number, end: number): SolidParticle[];
  35773. /**
  35774. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35775. * @param solidParticleArray an array populated with Solid Particles objects
  35776. * @returns the SPS
  35777. */
  35778. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35779. /**
  35780. * Creates a new particle and modifies the SPS mesh geometry :
  35781. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35782. * - calls _addParticle() to populate the particle array
  35783. * factorized code from addShape() and insertParticlesFromArray()
  35784. * @param idx particle index in the particles array
  35785. * @param i particle index in its shape
  35786. * @param modelShape particle ModelShape object
  35787. * @param shape shape vertex array
  35788. * @param meshInd shape indices array
  35789. * @param meshUV shape uv array
  35790. * @param meshCol shape color array
  35791. * @param meshNor shape normals array
  35792. * @param bbInfo shape bounding info
  35793. * @param storage target particle storage
  35794. * @options addShape() passed options
  35795. * @hidden
  35796. */
  35797. private _insertNewParticle;
  35798. /**
  35799. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35800. * This method calls `updateParticle()` for each particle of the SPS.
  35801. * For an animated SPS, it is usually called within the render loop.
  35802. * 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.
  35803. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35804. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35805. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35806. * @returns the SPS.
  35807. */
  35808. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35809. /**
  35810. * Disposes the SPS.
  35811. */
  35812. dispose(): void;
  35813. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35814. * idx is the particle index in the SPS
  35815. * faceId is the picked face index counted within this particle.
  35816. * Returns null if the pickInfo can't identify a picked particle.
  35817. * @param pickingInfo (PickingInfo object)
  35818. * @returns {idx: number, faceId: number} or null
  35819. */
  35820. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35821. idx: number;
  35822. faceId: number;
  35823. }>;
  35824. /**
  35825. * Returns a SolidParticle object from its identifier : particle.id
  35826. * @param id (integer) the particle Id
  35827. * @returns the searched particle or null if not found in the SPS.
  35828. */
  35829. getParticleById(id: number): Nullable<SolidParticle>;
  35830. /**
  35831. * Returns a new array populated with the particles having the passed shapeId.
  35832. * @param shapeId (integer) the shape identifier
  35833. * @returns a new solid particle array
  35834. */
  35835. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35836. /**
  35837. * Populates the passed array "ref" with the particles having the passed shapeId.
  35838. * @param shapeId the shape identifier
  35839. * @returns the SPS
  35840. * @param ref
  35841. */
  35842. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35843. /**
  35844. * Computes the required SubMeshes according the materials assigned to the particles.
  35845. * @returns the solid particle system.
  35846. * Does nothing if called before the SPS mesh is built.
  35847. */
  35848. computeSubMeshes(): SolidParticleSystem;
  35849. /**
  35850. * Sorts the solid particles by material when MultiMaterial is enabled.
  35851. * Updates the indices32 array.
  35852. * Updates the indicesByMaterial array.
  35853. * Updates the mesh indices array.
  35854. * @returns the SPS
  35855. * @hidden
  35856. */
  35857. private _sortParticlesByMaterial;
  35858. /**
  35859. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35860. * @hidden
  35861. */
  35862. private _setMaterialIndexesById;
  35863. /**
  35864. * Returns an array with unique values of Materials from the passed array
  35865. * @param array the material array to be checked and filtered
  35866. * @hidden
  35867. */
  35868. private _filterUniqueMaterialId;
  35869. /**
  35870. * Sets a new Standard Material as _defaultMaterial if not already set.
  35871. * @hidden
  35872. */
  35873. private _setDefaultMaterial;
  35874. /**
  35875. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35876. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35877. * @returns the SPS.
  35878. */
  35879. refreshVisibleSize(): SolidParticleSystem;
  35880. /**
  35881. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35882. * @param size the size (float) of the visibility box
  35883. * note : this doesn't lock the SPS mesh bounding box.
  35884. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35885. */
  35886. setVisibilityBox(size: number): void;
  35887. /**
  35888. * Gets whether the SPS as always visible or not
  35889. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35890. */
  35891. get isAlwaysVisible(): boolean;
  35892. /**
  35893. * Sets the SPS as always visible or not
  35894. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35895. */
  35896. set isAlwaysVisible(val: boolean);
  35897. /**
  35898. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35899. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35900. */
  35901. set isVisibilityBoxLocked(val: boolean);
  35902. /**
  35903. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35904. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35905. */
  35906. get isVisibilityBoxLocked(): boolean;
  35907. /**
  35908. * Tells to `setParticles()` to compute the particle rotations or not.
  35909. * Default value : true. The SPS is faster when it's set to false.
  35910. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35911. */
  35912. set computeParticleRotation(val: boolean);
  35913. /**
  35914. * Tells to `setParticles()` to compute the particle colors or not.
  35915. * Default value : true. The SPS is faster when it's set to false.
  35916. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35917. */
  35918. set computeParticleColor(val: boolean);
  35919. set computeParticleTexture(val: boolean);
  35920. /**
  35921. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35922. * Default value : false. The SPS is faster when it's set to false.
  35923. * Note : the particle custom vertex positions aren't stored values.
  35924. */
  35925. set computeParticleVertex(val: boolean);
  35926. /**
  35927. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35928. */
  35929. set computeBoundingBox(val: boolean);
  35930. /**
  35931. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35932. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35933. * Default : `true`
  35934. */
  35935. set depthSortParticles(val: boolean);
  35936. /**
  35937. * Gets if `setParticles()` computes the particle rotations or not.
  35938. * Default value : true. The SPS is faster when it's set to false.
  35939. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35940. */
  35941. get computeParticleRotation(): boolean;
  35942. /**
  35943. * Gets if `setParticles()` computes the particle colors or not.
  35944. * Default value : true. The SPS is faster when it's set to false.
  35945. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35946. */
  35947. get computeParticleColor(): boolean;
  35948. /**
  35949. * Gets if `setParticles()` computes the particle textures or not.
  35950. * Default value : true. The SPS is faster when it's set to false.
  35951. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35952. */
  35953. get computeParticleTexture(): boolean;
  35954. /**
  35955. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35956. * Default value : false. The SPS is faster when it's set to false.
  35957. * Note : the particle custom vertex positions aren't stored values.
  35958. */
  35959. get computeParticleVertex(): boolean;
  35960. /**
  35961. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35962. */
  35963. get computeBoundingBox(): boolean;
  35964. /**
  35965. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35966. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35967. * Default : `true`
  35968. */
  35969. get depthSortParticles(): boolean;
  35970. /**
  35971. * Gets if the SPS is created as expandable at construction time.
  35972. * Default : `false`
  35973. */
  35974. get expandable(): boolean;
  35975. /**
  35976. * Gets if the SPS supports the Multi Materials
  35977. */
  35978. get multimaterialEnabled(): boolean;
  35979. /**
  35980. * Gets if the SPS uses the model materials for its own multimaterial.
  35981. */
  35982. get useModelMaterial(): boolean;
  35983. /**
  35984. * The SPS used material array.
  35985. */
  35986. get materials(): Material[];
  35987. /**
  35988. * Sets the SPS MultiMaterial from the passed materials.
  35989. * Note : the passed array is internally copied and not used then by reference.
  35990. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35991. */
  35992. setMultiMaterial(materials: Material[]): void;
  35993. /**
  35994. * The SPS computed multimaterial object
  35995. */
  35996. get multimaterial(): MultiMaterial;
  35997. set multimaterial(mm: MultiMaterial);
  35998. /**
  35999. * If the subMeshes must be updated on the next call to setParticles()
  36000. */
  36001. get autoUpdateSubMeshes(): boolean;
  36002. set autoUpdateSubMeshes(val: boolean);
  36003. /**
  36004. * This function does nothing. It may be overwritten to set all the particle first values.
  36005. * The SPS doesn't call this function, you may have to call it by your own.
  36006. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36007. */
  36008. initParticles(): void;
  36009. /**
  36010. * This function does nothing. It may be overwritten to recycle a particle.
  36011. * The SPS doesn't call this function, you may have to call it by your own.
  36012. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36013. * @param particle The particle to recycle
  36014. * @returns the recycled particle
  36015. */
  36016. recycleParticle(particle: SolidParticle): SolidParticle;
  36017. /**
  36018. * Updates a particle : this function should be overwritten by the user.
  36019. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36020. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36021. * @example : just set a particle position or velocity and recycle conditions
  36022. * @param particle The particle to update
  36023. * @returns the updated particle
  36024. */
  36025. updateParticle(particle: SolidParticle): SolidParticle;
  36026. /**
  36027. * Updates a vertex of a particle : it can be overwritten by the user.
  36028. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36029. * @param particle the current particle
  36030. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36031. * @param pt the index of the current vertex in the particle shape
  36032. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36033. * @example : just set a vertex particle position or color
  36034. * @returns the sps
  36035. */
  36036. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36037. /**
  36038. * This will be called before any other treatment by `setParticles()` and 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. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36045. /**
  36046. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36047. * This will be passed three parameters.
  36048. * This does nothing and may be overwritten by the user.
  36049. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36050. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36051. * @param update the boolean update value actually passed to setParticles()
  36052. */
  36053. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36054. }
  36055. }
  36056. declare module "babylonjs/Particles/solidParticle" {
  36057. import { Nullable } from "babylonjs/types";
  36058. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36059. import { Color4 } from "babylonjs/Maths/math.color";
  36060. import { Mesh } from "babylonjs/Meshes/mesh";
  36061. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36062. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36063. import { Plane } from "babylonjs/Maths/math.plane";
  36064. import { Material } from "babylonjs/Materials/material";
  36065. /**
  36066. * Represents one particle of a solid particle system.
  36067. */
  36068. export class SolidParticle {
  36069. /**
  36070. * particle global index
  36071. */
  36072. idx: number;
  36073. /**
  36074. * particle identifier
  36075. */
  36076. id: number;
  36077. /**
  36078. * The color of the particle
  36079. */
  36080. color: Nullable<Color4>;
  36081. /**
  36082. * The world space position of the particle.
  36083. */
  36084. position: Vector3;
  36085. /**
  36086. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36087. */
  36088. rotation: Vector3;
  36089. /**
  36090. * The world space rotation quaternion of the particle.
  36091. */
  36092. rotationQuaternion: Nullable<Quaternion>;
  36093. /**
  36094. * The scaling of the particle.
  36095. */
  36096. scaling: Vector3;
  36097. /**
  36098. * The uvs of the particle.
  36099. */
  36100. uvs: Vector4;
  36101. /**
  36102. * The current speed of the particle.
  36103. */
  36104. velocity: Vector3;
  36105. /**
  36106. * The pivot point in the particle local space.
  36107. */
  36108. pivot: Vector3;
  36109. /**
  36110. * Must the particle be translated from its pivot point in its local space ?
  36111. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36112. * Default : false
  36113. */
  36114. translateFromPivot: boolean;
  36115. /**
  36116. * Is the particle active or not ?
  36117. */
  36118. alive: boolean;
  36119. /**
  36120. * Is the particle visible or not ?
  36121. */
  36122. isVisible: boolean;
  36123. /**
  36124. * Index of this particle in the global "positions" array (Internal use)
  36125. * @hidden
  36126. */
  36127. _pos: number;
  36128. /**
  36129. * @hidden Index of this particle in the global "indices" array (Internal use)
  36130. */
  36131. _ind: number;
  36132. /**
  36133. * @hidden ModelShape of this particle (Internal use)
  36134. */
  36135. _model: ModelShape;
  36136. /**
  36137. * ModelShape id of this particle
  36138. */
  36139. shapeId: number;
  36140. /**
  36141. * Index of the particle in its shape id
  36142. */
  36143. idxInShape: number;
  36144. /**
  36145. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36146. */
  36147. _modelBoundingInfo: BoundingInfo;
  36148. /**
  36149. * @hidden Particle BoundingInfo object (Internal use)
  36150. */
  36151. _boundingInfo: BoundingInfo;
  36152. /**
  36153. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36154. */
  36155. _sps: SolidParticleSystem;
  36156. /**
  36157. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36158. */
  36159. _stillInvisible: boolean;
  36160. /**
  36161. * @hidden Last computed particle rotation matrix
  36162. */
  36163. _rotationMatrix: number[];
  36164. /**
  36165. * Parent particle Id, if any.
  36166. * Default null.
  36167. */
  36168. parentId: Nullable<number>;
  36169. /**
  36170. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36171. */
  36172. materialIndex: Nullable<number>;
  36173. /**
  36174. * Custom object or properties.
  36175. */
  36176. props: Nullable<any>;
  36177. /**
  36178. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36179. * The possible values are :
  36180. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36181. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36182. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36183. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36184. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36185. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36186. * */
  36187. cullingStrategy: number;
  36188. /**
  36189. * @hidden Internal global position in the SPS.
  36190. */
  36191. _globalPosition: Vector3;
  36192. /**
  36193. * Creates a Solid Particle object.
  36194. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36195. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36196. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36197. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36198. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36199. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36200. * @param shapeId (integer) is the model shape identifier in the SPS.
  36201. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36202. * @param sps defines the sps it is associated to
  36203. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36204. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36205. */
  36206. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36207. /**
  36208. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36209. * @param target the particle target
  36210. * @returns the current particle
  36211. */
  36212. copyToRef(target: SolidParticle): SolidParticle;
  36213. /**
  36214. * Legacy support, changed scale to scaling
  36215. */
  36216. get scale(): Vector3;
  36217. /**
  36218. * Legacy support, changed scale to scaling
  36219. */
  36220. set scale(scale: Vector3);
  36221. /**
  36222. * Legacy support, changed quaternion to rotationQuaternion
  36223. */
  36224. get quaternion(): Nullable<Quaternion>;
  36225. /**
  36226. * Legacy support, changed quaternion to rotationQuaternion
  36227. */
  36228. set quaternion(q: Nullable<Quaternion>);
  36229. /**
  36230. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36231. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36232. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36233. * @returns true if it intersects
  36234. */
  36235. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36236. /**
  36237. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36238. * A particle is in the frustum if its bounding box intersects the frustum
  36239. * @param frustumPlanes defines the frustum to test
  36240. * @returns true if the particle is in the frustum planes
  36241. */
  36242. isInFrustum(frustumPlanes: Plane[]): boolean;
  36243. /**
  36244. * get the rotation matrix of the particle
  36245. * @hidden
  36246. */
  36247. getRotationMatrix(m: Matrix): void;
  36248. }
  36249. /**
  36250. * Represents the shape of the model used by one particle of a solid particle system.
  36251. * SPS internal tool, don't use it manually.
  36252. */
  36253. export class ModelShape {
  36254. /**
  36255. * The shape id
  36256. * @hidden
  36257. */
  36258. shapeID: number;
  36259. /**
  36260. * flat array of model positions (internal use)
  36261. * @hidden
  36262. */
  36263. _shape: Vector3[];
  36264. /**
  36265. * flat array of model UVs (internal use)
  36266. * @hidden
  36267. */
  36268. _shapeUV: number[];
  36269. /**
  36270. * color array of the model
  36271. * @hidden
  36272. */
  36273. _shapeColors: number[];
  36274. /**
  36275. * indices array of the model
  36276. * @hidden
  36277. */
  36278. _indices: number[];
  36279. /**
  36280. * normals array of the model
  36281. * @hidden
  36282. */
  36283. _normals: number[];
  36284. /**
  36285. * length of the shape in the model indices array (internal use)
  36286. * @hidden
  36287. */
  36288. _indicesLength: number;
  36289. /**
  36290. * Custom position function (internal use)
  36291. * @hidden
  36292. */
  36293. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36294. /**
  36295. * Custom vertex function (internal use)
  36296. * @hidden
  36297. */
  36298. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36299. /**
  36300. * Model material (internal use)
  36301. * @hidden
  36302. */
  36303. _material: Nullable<Material>;
  36304. /**
  36305. * 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.
  36306. * SPS internal tool, don't use it manually.
  36307. * @hidden
  36308. */
  36309. 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>);
  36310. }
  36311. /**
  36312. * Represents a Depth Sorted Particle in the solid particle system.
  36313. * @hidden
  36314. */
  36315. export class DepthSortedParticle {
  36316. /**
  36317. * Particle index
  36318. */
  36319. idx: number;
  36320. /**
  36321. * Index of the particle in the "indices" array
  36322. */
  36323. ind: number;
  36324. /**
  36325. * Length of the particle shape in the "indices" array
  36326. */
  36327. indicesLength: number;
  36328. /**
  36329. * Squared distance from the particle to the camera
  36330. */
  36331. sqDistance: number;
  36332. /**
  36333. * Material index when used with MultiMaterials
  36334. */
  36335. materialIndex: number;
  36336. /**
  36337. * Creates a new sorted particle
  36338. * @param materialIndex
  36339. */
  36340. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36341. }
  36342. /**
  36343. * Represents a solid particle vertex
  36344. */
  36345. export class SolidParticleVertex {
  36346. /**
  36347. * Vertex position
  36348. */
  36349. position: Vector3;
  36350. /**
  36351. * Vertex color
  36352. */
  36353. color: Color4;
  36354. /**
  36355. * Vertex UV
  36356. */
  36357. uv: Vector2;
  36358. /**
  36359. * Creates a new solid particle vertex
  36360. */
  36361. constructor();
  36362. /** Vertex x coordinate */
  36363. get x(): number;
  36364. set x(val: number);
  36365. /** Vertex y coordinate */
  36366. get y(): number;
  36367. set y(val: number);
  36368. /** Vertex z coordinate */
  36369. get z(): number;
  36370. set z(val: number);
  36371. }
  36372. }
  36373. declare module "babylonjs/Collisions/meshCollisionData" {
  36374. import { Collider } from "babylonjs/Collisions/collider";
  36375. import { Vector3 } from "babylonjs/Maths/math.vector";
  36376. import { Nullable } from "babylonjs/types";
  36377. import { Observer } from "babylonjs/Misc/observable";
  36378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36379. /**
  36380. * @hidden
  36381. */
  36382. export class _MeshCollisionData {
  36383. _checkCollisions: boolean;
  36384. _collisionMask: number;
  36385. _collisionGroup: number;
  36386. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36387. _collider: Nullable<Collider>;
  36388. _oldPositionForCollisions: Vector3;
  36389. _diffPositionForCollisions: Vector3;
  36390. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36391. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36392. _collisionResponse: boolean;
  36393. }
  36394. }
  36395. declare module "babylonjs/Meshes/abstractMesh" {
  36396. import { Observable } from "babylonjs/Misc/observable";
  36397. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36398. import { Camera } from "babylonjs/Cameras/camera";
  36399. import { Scene, IDisposable } from "babylonjs/scene";
  36400. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36401. import { Node } from "babylonjs/node";
  36402. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36403. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36404. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36405. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36406. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36407. import { Material } from "babylonjs/Materials/material";
  36408. import { Light } from "babylonjs/Lights/light";
  36409. import { Skeleton } from "babylonjs/Bones/skeleton";
  36410. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36411. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36412. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36413. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36414. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36415. import { Plane } from "babylonjs/Maths/math.plane";
  36416. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36417. import { Ray } from "babylonjs/Culling/ray";
  36418. import { Collider } from "babylonjs/Collisions/collider";
  36419. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36420. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36421. /** @hidden */
  36422. class _FacetDataStorage {
  36423. facetPositions: Vector3[];
  36424. facetNormals: Vector3[];
  36425. facetPartitioning: number[][];
  36426. facetNb: number;
  36427. partitioningSubdivisions: number;
  36428. partitioningBBoxRatio: number;
  36429. facetDataEnabled: boolean;
  36430. facetParameters: any;
  36431. bbSize: Vector3;
  36432. subDiv: {
  36433. max: number;
  36434. X: number;
  36435. Y: number;
  36436. Z: number;
  36437. };
  36438. facetDepthSort: boolean;
  36439. facetDepthSortEnabled: boolean;
  36440. depthSortedIndices: IndicesArray;
  36441. depthSortedFacets: {
  36442. ind: number;
  36443. sqDistance: number;
  36444. }[];
  36445. facetDepthSortFunction: (f1: {
  36446. ind: number;
  36447. sqDistance: number;
  36448. }, f2: {
  36449. ind: number;
  36450. sqDistance: number;
  36451. }) => number;
  36452. facetDepthSortFrom: Vector3;
  36453. facetDepthSortOrigin: Vector3;
  36454. invertedMatrix: Matrix;
  36455. }
  36456. /**
  36457. * @hidden
  36458. **/
  36459. class _InternalAbstractMeshDataInfo {
  36460. _hasVertexAlpha: boolean;
  36461. _useVertexColors: boolean;
  36462. _numBoneInfluencers: number;
  36463. _applyFog: boolean;
  36464. _receiveShadows: boolean;
  36465. _facetData: _FacetDataStorage;
  36466. _visibility: number;
  36467. _skeleton: Nullable<Skeleton>;
  36468. _layerMask: number;
  36469. _computeBonesUsingShaders: boolean;
  36470. _isActive: boolean;
  36471. _onlyForInstances: boolean;
  36472. _isActiveIntermediate: boolean;
  36473. _onlyForInstancesIntermediate: boolean;
  36474. _actAsRegularMesh: boolean;
  36475. }
  36476. /**
  36477. * Class used to store all common mesh properties
  36478. */
  36479. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36480. /** No occlusion */
  36481. static OCCLUSION_TYPE_NONE: number;
  36482. /** Occlusion set to optimisitic */
  36483. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36484. /** Occlusion set to strict */
  36485. static OCCLUSION_TYPE_STRICT: number;
  36486. /** Use an accurante occlusion algorithm */
  36487. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36488. /** Use a conservative occlusion algorithm */
  36489. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36490. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36491. * Test order :
  36492. * Is the bounding sphere outside the frustum ?
  36493. * If not, are the bounding box vertices outside the frustum ?
  36494. * It not, then the cullable object is in the frustum.
  36495. */
  36496. static readonly CULLINGSTRATEGY_STANDARD: number;
  36497. /** Culling strategy : Bounding Sphere Only.
  36498. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36499. * It's also less accurate than the standard because some not visible objects can still be selected.
  36500. * Test : is the bounding sphere outside the frustum ?
  36501. * If not, then the cullable object is in the frustum.
  36502. */
  36503. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36504. /** Culling strategy : Optimistic Inclusion.
  36505. * This in an inclusion test first, then the standard exclusion test.
  36506. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36507. * 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.
  36508. * Anyway, it's as accurate as the standard strategy.
  36509. * Test :
  36510. * Is the cullable object bounding sphere center in the frustum ?
  36511. * If not, apply the default culling strategy.
  36512. */
  36513. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36514. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36515. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36516. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36517. * 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.
  36518. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36519. * Test :
  36520. * Is the cullable object bounding sphere center in the frustum ?
  36521. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36522. */
  36523. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36524. /**
  36525. * No billboard
  36526. */
  36527. static get BILLBOARDMODE_NONE(): number;
  36528. /** Billboard on X axis */
  36529. static get BILLBOARDMODE_X(): number;
  36530. /** Billboard on Y axis */
  36531. static get BILLBOARDMODE_Y(): number;
  36532. /** Billboard on Z axis */
  36533. static get BILLBOARDMODE_Z(): number;
  36534. /** Billboard on all axes */
  36535. static get BILLBOARDMODE_ALL(): number;
  36536. /** Billboard on using position instead of orientation */
  36537. static get BILLBOARDMODE_USE_POSITION(): number;
  36538. /** @hidden */
  36539. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36540. /**
  36541. * The culling strategy to use to check whether the mesh must be rendered or not.
  36542. * This value can be changed at any time and will be used on the next render mesh selection.
  36543. * The possible values are :
  36544. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36545. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36546. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36547. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36548. * Please read each static variable documentation to get details about the culling process.
  36549. * */
  36550. cullingStrategy: number;
  36551. /**
  36552. * Gets the number of facets in the mesh
  36553. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36554. */
  36555. get facetNb(): number;
  36556. /**
  36557. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36558. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36559. */
  36560. get partitioningSubdivisions(): number;
  36561. set partitioningSubdivisions(nb: number);
  36562. /**
  36563. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36564. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36565. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36566. */
  36567. get partitioningBBoxRatio(): number;
  36568. set partitioningBBoxRatio(ratio: number);
  36569. /**
  36570. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36571. * Works only for updatable meshes.
  36572. * Doesn't work with multi-materials
  36573. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36574. */
  36575. get mustDepthSortFacets(): boolean;
  36576. set mustDepthSortFacets(sort: boolean);
  36577. /**
  36578. * The location (Vector3) where the facet depth sort must be computed from.
  36579. * By default, the active camera position.
  36580. * Used only when facet depth sort is enabled
  36581. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36582. */
  36583. get facetDepthSortFrom(): Vector3;
  36584. set facetDepthSortFrom(location: Vector3);
  36585. /**
  36586. * gets a boolean indicating if facetData is enabled
  36587. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36588. */
  36589. get isFacetDataEnabled(): boolean;
  36590. /** @hidden */
  36591. _updateNonUniformScalingState(value: boolean): boolean;
  36592. /**
  36593. * An event triggered when this mesh collides with another one
  36594. */
  36595. onCollideObservable: Observable<AbstractMesh>;
  36596. /** Set a function to call when this mesh collides with another one */
  36597. set onCollide(callback: () => void);
  36598. /**
  36599. * An event triggered when the collision's position changes
  36600. */
  36601. onCollisionPositionChangeObservable: Observable<Vector3>;
  36602. /** Set a function to call when the collision's position changes */
  36603. set onCollisionPositionChange(callback: () => void);
  36604. /**
  36605. * An event triggered when material is changed
  36606. */
  36607. onMaterialChangedObservable: Observable<AbstractMesh>;
  36608. /**
  36609. * Gets or sets the orientation for POV movement & rotation
  36610. */
  36611. definedFacingForward: boolean;
  36612. /** @hidden */
  36613. _occlusionQuery: Nullable<WebGLQuery>;
  36614. /** @hidden */
  36615. _renderingGroup: Nullable<RenderingGroup>;
  36616. /**
  36617. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36618. */
  36619. get visibility(): number;
  36620. /**
  36621. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36622. */
  36623. set visibility(value: number);
  36624. /** Gets or sets the alpha index used to sort transparent meshes
  36625. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36626. */
  36627. alphaIndex: number;
  36628. /**
  36629. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36630. */
  36631. isVisible: boolean;
  36632. /**
  36633. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36634. */
  36635. isPickable: boolean;
  36636. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36637. showSubMeshesBoundingBox: boolean;
  36638. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36639. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36640. */
  36641. isBlocker: boolean;
  36642. /**
  36643. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36644. */
  36645. enablePointerMoveEvents: boolean;
  36646. private _renderingGroupId;
  36647. /**
  36648. * Specifies the rendering group id for this mesh (0 by default)
  36649. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36650. */
  36651. get renderingGroupId(): number;
  36652. set renderingGroupId(value: number);
  36653. private _material;
  36654. /** Gets or sets current material */
  36655. get material(): Nullable<Material>;
  36656. set material(value: Nullable<Material>);
  36657. /**
  36658. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36659. * @see https://doc.babylonjs.com/babylon101/shadows
  36660. */
  36661. get receiveShadows(): boolean;
  36662. set receiveShadows(value: boolean);
  36663. /** Defines color to use when rendering outline */
  36664. outlineColor: Color3;
  36665. /** Define width to use when rendering outline */
  36666. outlineWidth: number;
  36667. /** Defines color to use when rendering overlay */
  36668. overlayColor: Color3;
  36669. /** Defines alpha to use when rendering overlay */
  36670. overlayAlpha: number;
  36671. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36672. get hasVertexAlpha(): boolean;
  36673. set hasVertexAlpha(value: boolean);
  36674. /** 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) */
  36675. get useVertexColors(): boolean;
  36676. set useVertexColors(value: boolean);
  36677. /**
  36678. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36679. */
  36680. get computeBonesUsingShaders(): boolean;
  36681. set computeBonesUsingShaders(value: boolean);
  36682. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36683. get numBoneInfluencers(): number;
  36684. set numBoneInfluencers(value: number);
  36685. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36686. get applyFog(): boolean;
  36687. set applyFog(value: boolean);
  36688. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36689. useOctreeForRenderingSelection: boolean;
  36690. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36691. useOctreeForPicking: boolean;
  36692. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36693. useOctreeForCollisions: boolean;
  36694. /**
  36695. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36696. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36697. */
  36698. get layerMask(): number;
  36699. set layerMask(value: number);
  36700. /**
  36701. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36702. */
  36703. alwaysSelectAsActiveMesh: boolean;
  36704. /**
  36705. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36706. */
  36707. doNotSyncBoundingInfo: boolean;
  36708. /**
  36709. * Gets or sets the current action manager
  36710. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36711. */
  36712. actionManager: Nullable<AbstractActionManager>;
  36713. private _meshCollisionData;
  36714. /**
  36715. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36716. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36717. */
  36718. ellipsoid: Vector3;
  36719. /**
  36720. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36721. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36722. */
  36723. ellipsoidOffset: Vector3;
  36724. /**
  36725. * Gets or sets a collision mask used to mask collisions (default is -1).
  36726. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36727. */
  36728. get collisionMask(): number;
  36729. set collisionMask(mask: number);
  36730. /**
  36731. * Gets or sets a collision response flag (default is true).
  36732. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36733. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36734. * to respond to the collision.
  36735. */
  36736. get collisionResponse(): boolean;
  36737. set collisionResponse(response: boolean);
  36738. /**
  36739. * Gets or sets the current collision group mask (-1 by default).
  36740. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36741. */
  36742. get collisionGroup(): number;
  36743. set collisionGroup(mask: number);
  36744. /**
  36745. * Gets or sets current surrounding meshes (null by default).
  36746. *
  36747. * By default collision detection is tested against every mesh in the scene.
  36748. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36749. * meshes will be tested for the collision.
  36750. *
  36751. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36752. */
  36753. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36754. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36755. /**
  36756. * Defines edge width used when edgesRenderer is enabled
  36757. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36758. */
  36759. edgesWidth: number;
  36760. /**
  36761. * Defines edge color used when edgesRenderer is enabled
  36762. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36763. */
  36764. edgesColor: Color4;
  36765. /** @hidden */
  36766. _edgesRenderer: Nullable<IEdgesRenderer>;
  36767. /** @hidden */
  36768. _masterMesh: Nullable<AbstractMesh>;
  36769. /** @hidden */
  36770. _boundingInfo: Nullable<BoundingInfo>;
  36771. /** @hidden */
  36772. _renderId: number;
  36773. /**
  36774. * Gets or sets the list of subMeshes
  36775. * @see https://doc.babylonjs.com/how_to/multi_materials
  36776. */
  36777. subMeshes: SubMesh[];
  36778. /** @hidden */
  36779. _intersectionsInProgress: AbstractMesh[];
  36780. /** @hidden */
  36781. _unIndexed: boolean;
  36782. /** @hidden */
  36783. _lightSources: Light[];
  36784. /** Gets the list of lights affecting that mesh */
  36785. get lightSources(): Light[];
  36786. /** @hidden */
  36787. get _positions(): Nullable<Vector3[]>;
  36788. /** @hidden */
  36789. _waitingData: {
  36790. lods: Nullable<any>;
  36791. actions: Nullable<any>;
  36792. freezeWorldMatrix: Nullable<boolean>;
  36793. };
  36794. /** @hidden */
  36795. _bonesTransformMatrices: Nullable<Float32Array>;
  36796. /** @hidden */
  36797. _transformMatrixTexture: Nullable<RawTexture>;
  36798. /**
  36799. * Gets or sets a skeleton to apply skining transformations
  36800. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36801. */
  36802. set skeleton(value: Nullable<Skeleton>);
  36803. get skeleton(): Nullable<Skeleton>;
  36804. /**
  36805. * An event triggered when the mesh is rebuilt.
  36806. */
  36807. onRebuildObservable: Observable<AbstractMesh>;
  36808. /**
  36809. * Creates a new AbstractMesh
  36810. * @param name defines the name of the mesh
  36811. * @param scene defines the hosting scene
  36812. */
  36813. constructor(name: string, scene?: Nullable<Scene>);
  36814. /**
  36815. * Returns the string "AbstractMesh"
  36816. * @returns "AbstractMesh"
  36817. */
  36818. getClassName(): string;
  36819. /**
  36820. * Gets a string representation of the current mesh
  36821. * @param fullDetails defines a boolean indicating if full details must be included
  36822. * @returns a string representation of the current mesh
  36823. */
  36824. toString(fullDetails?: boolean): string;
  36825. /**
  36826. * @hidden
  36827. */
  36828. protected _getEffectiveParent(): Nullable<Node>;
  36829. /** @hidden */
  36830. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36831. /** @hidden */
  36832. _rebuild(): void;
  36833. /** @hidden */
  36834. _resyncLightSources(): void;
  36835. /** @hidden */
  36836. _resyncLightSource(light: Light): void;
  36837. /** @hidden */
  36838. _unBindEffect(): void;
  36839. /** @hidden */
  36840. _removeLightSource(light: Light, dispose: boolean): void;
  36841. private _markSubMeshesAsDirty;
  36842. /** @hidden */
  36843. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36844. /** @hidden */
  36845. _markSubMeshesAsAttributesDirty(): void;
  36846. /** @hidden */
  36847. _markSubMeshesAsMiscDirty(): void;
  36848. /**
  36849. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36850. */
  36851. get scaling(): Vector3;
  36852. set scaling(newScaling: Vector3);
  36853. /**
  36854. * Returns true if the mesh is blocked. Implemented by child classes
  36855. */
  36856. get isBlocked(): boolean;
  36857. /**
  36858. * Returns the mesh itself by default. Implemented by child classes
  36859. * @param camera defines the camera to use to pick the right LOD level
  36860. * @returns the currentAbstractMesh
  36861. */
  36862. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36863. /**
  36864. * Returns 0 by default. Implemented by child classes
  36865. * @returns an integer
  36866. */
  36867. getTotalVertices(): number;
  36868. /**
  36869. * Returns a positive integer : the total number of indices in this mesh geometry.
  36870. * @returns the numner of indices or zero if the mesh has no geometry.
  36871. */
  36872. getTotalIndices(): number;
  36873. /**
  36874. * Returns null by default. Implemented by child classes
  36875. * @returns null
  36876. */
  36877. getIndices(): Nullable<IndicesArray>;
  36878. /**
  36879. * Returns the array of the requested vertex data kind. Implemented by child classes
  36880. * @param kind defines the vertex data kind to use
  36881. * @returns null
  36882. */
  36883. getVerticesData(kind: string): Nullable<FloatArray>;
  36884. /**
  36885. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36886. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36887. * Note that a new underlying VertexBuffer object is created each call.
  36888. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36889. * @param kind defines vertex data kind:
  36890. * * VertexBuffer.PositionKind
  36891. * * VertexBuffer.UVKind
  36892. * * VertexBuffer.UV2Kind
  36893. * * VertexBuffer.UV3Kind
  36894. * * VertexBuffer.UV4Kind
  36895. * * VertexBuffer.UV5Kind
  36896. * * VertexBuffer.UV6Kind
  36897. * * VertexBuffer.ColorKind
  36898. * * VertexBuffer.MatricesIndicesKind
  36899. * * VertexBuffer.MatricesIndicesExtraKind
  36900. * * VertexBuffer.MatricesWeightsKind
  36901. * * VertexBuffer.MatricesWeightsExtraKind
  36902. * @param data defines the data source
  36903. * @param updatable defines if the data must be flagged as updatable (or static)
  36904. * @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
  36905. * @returns the current mesh
  36906. */
  36907. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36908. /**
  36909. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36910. * If the mesh has no geometry, it is simply returned as it is.
  36911. * @param kind defines vertex data kind:
  36912. * * VertexBuffer.PositionKind
  36913. * * VertexBuffer.UVKind
  36914. * * VertexBuffer.UV2Kind
  36915. * * VertexBuffer.UV3Kind
  36916. * * VertexBuffer.UV4Kind
  36917. * * VertexBuffer.UV5Kind
  36918. * * VertexBuffer.UV6Kind
  36919. * * VertexBuffer.ColorKind
  36920. * * VertexBuffer.MatricesIndicesKind
  36921. * * VertexBuffer.MatricesIndicesExtraKind
  36922. * * VertexBuffer.MatricesWeightsKind
  36923. * * VertexBuffer.MatricesWeightsExtraKind
  36924. * @param data defines the data source
  36925. * @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
  36926. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36927. * @returns the current mesh
  36928. */
  36929. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36930. /**
  36931. * Sets the mesh indices,
  36932. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36933. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36934. * @param totalVertices Defines the total number of vertices
  36935. * @returns the current mesh
  36936. */
  36937. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36938. /**
  36939. * Gets a boolean indicating if specific vertex data is present
  36940. * @param kind defines the vertex data kind to use
  36941. * @returns true is data kind is present
  36942. */
  36943. isVerticesDataPresent(kind: string): boolean;
  36944. /**
  36945. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36946. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36947. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36948. * @returns a BoundingInfo
  36949. */
  36950. getBoundingInfo(): BoundingInfo;
  36951. /**
  36952. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36953. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36954. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36955. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36956. * @returns the current mesh
  36957. */
  36958. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36959. /**
  36960. * Overwrite the current bounding info
  36961. * @param boundingInfo defines the new bounding info
  36962. * @returns the current mesh
  36963. */
  36964. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36965. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36966. get useBones(): boolean;
  36967. /** @hidden */
  36968. _preActivate(): void;
  36969. /** @hidden */
  36970. _preActivateForIntermediateRendering(renderId: number): void;
  36971. /** @hidden */
  36972. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36973. /** @hidden */
  36974. _postActivate(): void;
  36975. /** @hidden */
  36976. _freeze(): void;
  36977. /** @hidden */
  36978. _unFreeze(): void;
  36979. /**
  36980. * Gets the current world matrix
  36981. * @returns a Matrix
  36982. */
  36983. getWorldMatrix(): Matrix;
  36984. /** @hidden */
  36985. _getWorldMatrixDeterminant(): number;
  36986. /**
  36987. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36988. */
  36989. get isAnInstance(): boolean;
  36990. /**
  36991. * Gets a boolean indicating if this mesh has instances
  36992. */
  36993. get hasInstances(): boolean;
  36994. /**
  36995. * Gets a boolean indicating if this mesh has thin instances
  36996. */
  36997. get hasThinInstances(): boolean;
  36998. /**
  36999. * Perform relative position change from the point of view of behind the front of the mesh.
  37000. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37001. * Supports definition of mesh facing forward or backward
  37002. * @param amountRight defines the distance on the right axis
  37003. * @param amountUp defines the distance on the up axis
  37004. * @param amountForward defines the distance on the forward axis
  37005. * @returns the current mesh
  37006. */
  37007. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37008. /**
  37009. * Calculate relative position change from the point of view of behind the front of the mesh.
  37010. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37011. * Supports definition of mesh facing forward or backward
  37012. * @param amountRight defines the distance on the right axis
  37013. * @param amountUp defines the distance on the up axis
  37014. * @param amountForward defines the distance on the forward axis
  37015. * @returns the new displacement vector
  37016. */
  37017. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37018. /**
  37019. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37020. * Supports definition of mesh facing forward or backward
  37021. * @param flipBack defines the flip
  37022. * @param twirlClockwise defines the twirl
  37023. * @param tiltRight defines the tilt
  37024. * @returns the current mesh
  37025. */
  37026. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37027. /**
  37028. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37029. * Supports definition of mesh facing forward or backward.
  37030. * @param flipBack defines the flip
  37031. * @param twirlClockwise defines the twirl
  37032. * @param tiltRight defines the tilt
  37033. * @returns the new rotation vector
  37034. */
  37035. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37036. /**
  37037. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37038. * This means the mesh underlying bounding box and sphere are recomputed.
  37039. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37040. * @returns the current mesh
  37041. */
  37042. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37043. /** @hidden */
  37044. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37045. /** @hidden */
  37046. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37047. /** @hidden */
  37048. _updateBoundingInfo(): AbstractMesh;
  37049. /** @hidden */
  37050. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37051. /** @hidden */
  37052. protected _afterComputeWorldMatrix(): void;
  37053. /** @hidden */
  37054. get _effectiveMesh(): AbstractMesh;
  37055. /**
  37056. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37057. * A mesh is in the frustum if its bounding box intersects the frustum
  37058. * @param frustumPlanes defines the frustum to test
  37059. * @returns true if the mesh is in the frustum planes
  37060. */
  37061. isInFrustum(frustumPlanes: Plane[]): boolean;
  37062. /**
  37063. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37064. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37065. * @param frustumPlanes defines the frustum to test
  37066. * @returns true if the mesh is completely in the frustum planes
  37067. */
  37068. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37069. /**
  37070. * True if the mesh intersects another mesh or a SolidParticle object
  37071. * @param mesh defines a target mesh or SolidParticle to test
  37072. * @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)
  37073. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37074. * @returns true if there is an intersection
  37075. */
  37076. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37077. /**
  37078. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37079. * @param point defines the point to test
  37080. * @returns true if there is an intersection
  37081. */
  37082. intersectsPoint(point: Vector3): boolean;
  37083. /**
  37084. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37085. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37086. */
  37087. get checkCollisions(): boolean;
  37088. set checkCollisions(collisionEnabled: boolean);
  37089. /**
  37090. * Gets Collider object used to compute collisions (not physics)
  37091. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37092. */
  37093. get collider(): Nullable<Collider>;
  37094. /**
  37095. * Move the mesh using collision engine
  37096. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37097. * @param displacement defines the requested displacement vector
  37098. * @returns the current mesh
  37099. */
  37100. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37101. private _onCollisionPositionChange;
  37102. /** @hidden */
  37103. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37104. /** @hidden */
  37105. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37106. /** @hidden */
  37107. _checkCollision(collider: Collider): AbstractMesh;
  37108. /** @hidden */
  37109. _generatePointsArray(): boolean;
  37110. /**
  37111. * Checks if the passed Ray intersects with the mesh
  37112. * @param ray defines the ray to use
  37113. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37114. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37115. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37116. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37117. * @returns the picking info
  37118. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37119. */
  37120. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  37121. /**
  37122. * Clones the current mesh
  37123. * @param name defines the mesh name
  37124. * @param newParent defines the new mesh parent
  37125. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37126. * @returns the new mesh
  37127. */
  37128. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37129. /**
  37130. * Disposes all the submeshes of the current meshnp
  37131. * @returns the current mesh
  37132. */
  37133. releaseSubMeshes(): AbstractMesh;
  37134. /**
  37135. * Releases resources associated with this abstract mesh.
  37136. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37137. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37138. */
  37139. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37140. /**
  37141. * Adds the passed mesh as a child to the current mesh
  37142. * @param mesh defines the child mesh
  37143. * @returns the current mesh
  37144. */
  37145. addChild(mesh: AbstractMesh): AbstractMesh;
  37146. /**
  37147. * Removes the passed mesh from the current mesh children list
  37148. * @param mesh defines the child mesh
  37149. * @returns the current mesh
  37150. */
  37151. removeChild(mesh: AbstractMesh): AbstractMesh;
  37152. /** @hidden */
  37153. private _initFacetData;
  37154. /**
  37155. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37156. * This method can be called within the render loop.
  37157. * 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
  37158. * @returns the current mesh
  37159. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37160. */
  37161. updateFacetData(): AbstractMesh;
  37162. /**
  37163. * Returns the facetLocalNormals array.
  37164. * The normals are expressed in the mesh local spac
  37165. * @returns an array of Vector3
  37166. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37167. */
  37168. getFacetLocalNormals(): Vector3[];
  37169. /**
  37170. * Returns the facetLocalPositions array.
  37171. * The facet positions are expressed in the mesh local space
  37172. * @returns an array of Vector3
  37173. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37174. */
  37175. getFacetLocalPositions(): Vector3[];
  37176. /**
  37177. * Returns the facetLocalPartioning array
  37178. * @returns an array of array of numbers
  37179. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37180. */
  37181. getFacetLocalPartitioning(): number[][];
  37182. /**
  37183. * Returns the i-th facet position in the world system.
  37184. * This method allocates a new Vector3 per call
  37185. * @param i defines the facet index
  37186. * @returns a new Vector3
  37187. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37188. */
  37189. getFacetPosition(i: number): Vector3;
  37190. /**
  37191. * Sets the reference Vector3 with the i-th facet position in the world system
  37192. * @param i defines the facet index
  37193. * @param ref defines the target vector
  37194. * @returns the current mesh
  37195. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37196. */
  37197. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37198. /**
  37199. * Returns the i-th facet normal in the world system.
  37200. * This method allocates a new Vector3 per call
  37201. * @param i defines the facet index
  37202. * @returns a new Vector3
  37203. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37204. */
  37205. getFacetNormal(i: number): Vector3;
  37206. /**
  37207. * Sets the reference Vector3 with the i-th facet normal in the world system
  37208. * @param i defines the facet index
  37209. * @param ref defines the target vector
  37210. * @returns the current mesh
  37211. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37212. */
  37213. getFacetNormalToRef(i: number, ref: Vector3): this;
  37214. /**
  37215. * 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)
  37216. * @param x defines x coordinate
  37217. * @param y defines y coordinate
  37218. * @param z defines z coordinate
  37219. * @returns the array of facet indexes
  37220. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37221. */
  37222. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37223. /**
  37224. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37225. * @param projected sets as the (x,y,z) world projection on the facet
  37226. * @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
  37227. * @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
  37228. * @param x defines x coordinate
  37229. * @param y defines y coordinate
  37230. * @param z defines z coordinate
  37231. * @returns the face index if found (or null instead)
  37232. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37233. */
  37234. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37235. /**
  37236. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37237. * @param projected sets as the (x,y,z) local projection on the facet
  37238. * @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
  37239. * @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
  37240. * @param x defines x coordinate
  37241. * @param y defines y coordinate
  37242. * @param z defines z coordinate
  37243. * @returns the face index if found (or null instead)
  37244. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37245. */
  37246. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37247. /**
  37248. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37249. * @returns the parameters
  37250. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37251. */
  37252. getFacetDataParameters(): any;
  37253. /**
  37254. * Disables the feature FacetData and frees the related memory
  37255. * @returns the current mesh
  37256. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37257. */
  37258. disableFacetData(): AbstractMesh;
  37259. /**
  37260. * Updates the AbstractMesh indices array
  37261. * @param indices defines the data source
  37262. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37263. * @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)
  37264. * @returns the current mesh
  37265. */
  37266. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37267. /**
  37268. * Creates new normals data for the mesh
  37269. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37270. * @returns the current mesh
  37271. */
  37272. createNormals(updatable: boolean): AbstractMesh;
  37273. /**
  37274. * Align the mesh with a normal
  37275. * @param normal defines the normal to use
  37276. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37277. * @returns the current mesh
  37278. */
  37279. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37280. /** @hidden */
  37281. _checkOcclusionQuery(): boolean;
  37282. /**
  37283. * Disables the mesh edge rendering mode
  37284. * @returns the currentAbstractMesh
  37285. */
  37286. disableEdgesRendering(): AbstractMesh;
  37287. /**
  37288. * Enables the edge rendering mode on the mesh.
  37289. * This mode makes the mesh edges visible
  37290. * @param epsilon defines the maximal distance between two angles to detect a face
  37291. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37292. * @returns the currentAbstractMesh
  37293. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37294. */
  37295. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37296. /**
  37297. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37298. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37299. */
  37300. getConnectedParticleSystems(): IParticleSystem[];
  37301. }
  37302. }
  37303. declare module "babylonjs/Actions/actionEvent" {
  37304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37305. import { Nullable } from "babylonjs/types";
  37306. import { Sprite } from "babylonjs/Sprites/sprite";
  37307. import { Scene } from "babylonjs/scene";
  37308. import { Vector2 } from "babylonjs/Maths/math.vector";
  37309. /**
  37310. * Interface used to define ActionEvent
  37311. */
  37312. export interface IActionEvent {
  37313. /** The mesh or sprite that triggered the action */
  37314. source: any;
  37315. /** The X mouse cursor position at the time of the event */
  37316. pointerX: number;
  37317. /** The Y mouse cursor position at the time of the event */
  37318. pointerY: number;
  37319. /** The mesh that is currently pointed at (can be null) */
  37320. meshUnderPointer: Nullable<AbstractMesh>;
  37321. /** the original (browser) event that triggered the ActionEvent */
  37322. sourceEvent?: any;
  37323. /** additional data for the event */
  37324. additionalData?: any;
  37325. }
  37326. /**
  37327. * ActionEvent is the event being sent when an action is triggered.
  37328. */
  37329. export class ActionEvent implements IActionEvent {
  37330. /** The mesh or sprite that triggered the action */
  37331. source: any;
  37332. /** The X mouse cursor position at the time of the event */
  37333. pointerX: number;
  37334. /** The Y mouse cursor position at the time of the event */
  37335. pointerY: number;
  37336. /** The mesh that is currently pointed at (can be null) */
  37337. meshUnderPointer: Nullable<AbstractMesh>;
  37338. /** the original (browser) event that triggered the ActionEvent */
  37339. sourceEvent?: any;
  37340. /** additional data for the event */
  37341. additionalData?: any;
  37342. /**
  37343. * Creates a new ActionEvent
  37344. * @param source The mesh or sprite that triggered the action
  37345. * @param pointerX The X mouse cursor position at the time of the event
  37346. * @param pointerY The Y mouse cursor position at the time of the event
  37347. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37348. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37349. * @param additionalData additional data for the event
  37350. */
  37351. constructor(
  37352. /** The mesh or sprite that triggered the action */
  37353. source: any,
  37354. /** The X mouse cursor position at the time of the event */
  37355. pointerX: number,
  37356. /** The Y mouse cursor position at the time of the event */
  37357. pointerY: number,
  37358. /** The mesh that is currently pointed at (can be null) */
  37359. meshUnderPointer: Nullable<AbstractMesh>,
  37360. /** the original (browser) event that triggered the ActionEvent */
  37361. sourceEvent?: any,
  37362. /** additional data for the event */
  37363. additionalData?: any);
  37364. /**
  37365. * Helper function to auto-create an ActionEvent from a source mesh.
  37366. * @param source The source mesh that triggered the event
  37367. * @param evt The original (browser) event
  37368. * @param additionalData additional data for the event
  37369. * @returns the new ActionEvent
  37370. */
  37371. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37372. /**
  37373. * Helper function to auto-create an ActionEvent from a source sprite
  37374. * @param source The source sprite that triggered the event
  37375. * @param scene Scene associated with the sprite
  37376. * @param evt The original (browser) event
  37377. * @param additionalData additional data for the event
  37378. * @returns the new ActionEvent
  37379. */
  37380. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37381. /**
  37382. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37383. * @param scene the scene where the event occurred
  37384. * @param evt The original (browser) event
  37385. * @returns the new ActionEvent
  37386. */
  37387. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37388. /**
  37389. * Helper function to auto-create an ActionEvent from a primitive
  37390. * @param prim defines the target primitive
  37391. * @param pointerPos defines the pointer position
  37392. * @param evt The original (browser) event
  37393. * @param additionalData additional data for the event
  37394. * @returns the new ActionEvent
  37395. */
  37396. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37397. }
  37398. }
  37399. declare module "babylonjs/Actions/abstractActionManager" {
  37400. import { IDisposable } from "babylonjs/scene";
  37401. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37402. import { IAction } from "babylonjs/Actions/action";
  37403. import { Nullable } from "babylonjs/types";
  37404. /**
  37405. * Abstract class used to decouple action Manager from scene and meshes.
  37406. * Do not instantiate.
  37407. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37408. */
  37409. export abstract class AbstractActionManager implements IDisposable {
  37410. /** Gets the list of active triggers */
  37411. static Triggers: {
  37412. [key: string]: number;
  37413. };
  37414. /** Gets the cursor to use when hovering items */
  37415. hoverCursor: string;
  37416. /** Gets the list of actions */
  37417. actions: IAction[];
  37418. /**
  37419. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37420. */
  37421. isRecursive: boolean;
  37422. /**
  37423. * Releases all associated resources
  37424. */
  37425. abstract dispose(): void;
  37426. /**
  37427. * Does this action manager has pointer triggers
  37428. */
  37429. abstract get hasPointerTriggers(): boolean;
  37430. /**
  37431. * Does this action manager has pick triggers
  37432. */
  37433. abstract get hasPickTriggers(): boolean;
  37434. /**
  37435. * Process a specific trigger
  37436. * @param trigger defines the trigger to process
  37437. * @param evt defines the event details to be processed
  37438. */
  37439. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37440. /**
  37441. * Does this action manager handles actions of any of the given triggers
  37442. * @param triggers defines the triggers to be tested
  37443. * @return a boolean indicating whether one (or more) of the triggers is handled
  37444. */
  37445. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37446. /**
  37447. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37448. * speed.
  37449. * @param triggerA defines the trigger to be tested
  37450. * @param triggerB defines the trigger to be tested
  37451. * @return a boolean indicating whether one (or more) of the triggers is handled
  37452. */
  37453. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37454. /**
  37455. * Does this action manager handles actions of a given trigger
  37456. * @param trigger defines the trigger to be tested
  37457. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37458. * @return whether the trigger is handled
  37459. */
  37460. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37461. /**
  37462. * Serialize this manager to a JSON object
  37463. * @param name defines the property name to store this manager
  37464. * @returns a JSON representation of this manager
  37465. */
  37466. abstract serialize(name: string): any;
  37467. /**
  37468. * Registers an action to this action manager
  37469. * @param action defines the action to be registered
  37470. * @return the action amended (prepared) after registration
  37471. */
  37472. abstract registerAction(action: IAction): Nullable<IAction>;
  37473. /**
  37474. * Unregisters an action to this action manager
  37475. * @param action defines the action to be unregistered
  37476. * @return a boolean indicating whether the action has been unregistered
  37477. */
  37478. abstract unregisterAction(action: IAction): Boolean;
  37479. /**
  37480. * Does exist one action manager with at least one trigger
  37481. **/
  37482. static get HasTriggers(): boolean;
  37483. /**
  37484. * Does exist one action manager with at least one pick trigger
  37485. **/
  37486. static get HasPickTriggers(): boolean;
  37487. /**
  37488. * Does exist one action manager that handles actions of a given trigger
  37489. * @param trigger defines the trigger to be tested
  37490. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37491. **/
  37492. static HasSpecificTrigger(trigger: number): boolean;
  37493. }
  37494. }
  37495. declare module "babylonjs/node" {
  37496. import { Scene } from "babylonjs/scene";
  37497. import { Nullable } from "babylonjs/types";
  37498. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37499. import { Engine } from "babylonjs/Engines/engine";
  37500. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37501. import { Observable } from "babylonjs/Misc/observable";
  37502. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37503. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37504. import { Animatable } from "babylonjs/Animations/animatable";
  37505. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37506. import { Animation } from "babylonjs/Animations/animation";
  37507. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37509. /**
  37510. * Defines how a node can be built from a string name.
  37511. */
  37512. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37513. /**
  37514. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37515. */
  37516. export class Node implements IBehaviorAware<Node> {
  37517. /** @hidden */
  37518. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37519. private static _NodeConstructors;
  37520. /**
  37521. * Add a new node constructor
  37522. * @param type defines the type name of the node to construct
  37523. * @param constructorFunc defines the constructor function
  37524. */
  37525. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37526. /**
  37527. * Returns a node constructor based on type name
  37528. * @param type defines the type name
  37529. * @param name defines the new node name
  37530. * @param scene defines the hosting scene
  37531. * @param options defines optional options to transmit to constructors
  37532. * @returns the new constructor or null
  37533. */
  37534. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37535. /**
  37536. * Gets or sets the name of the node
  37537. */
  37538. name: string;
  37539. /**
  37540. * Gets or sets the id of the node
  37541. */
  37542. id: string;
  37543. /**
  37544. * Gets or sets the unique id of the node
  37545. */
  37546. uniqueId: number;
  37547. /**
  37548. * Gets or sets a string used to store user defined state for the node
  37549. */
  37550. state: string;
  37551. /**
  37552. * Gets or sets an object used to store user defined information for the node
  37553. */
  37554. metadata: any;
  37555. /**
  37556. * For internal use only. Please do not use.
  37557. */
  37558. reservedDataStore: any;
  37559. /**
  37560. * List of inspectable custom properties (used by the Inspector)
  37561. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37562. */
  37563. inspectableCustomProperties: IInspectable[];
  37564. private _doNotSerialize;
  37565. /**
  37566. * Gets or sets a boolean used to define if the node must be serialized
  37567. */
  37568. get doNotSerialize(): boolean;
  37569. set doNotSerialize(value: boolean);
  37570. /** @hidden */
  37571. _isDisposed: boolean;
  37572. /**
  37573. * Gets a list of Animations associated with the node
  37574. */
  37575. animations: import("babylonjs/Animations/animation").Animation[];
  37576. protected _ranges: {
  37577. [name: string]: Nullable<AnimationRange>;
  37578. };
  37579. /**
  37580. * Callback raised when the node is ready to be used
  37581. */
  37582. onReady: Nullable<(node: Node) => void>;
  37583. private _isEnabled;
  37584. private _isParentEnabled;
  37585. private _isReady;
  37586. /** @hidden */
  37587. _currentRenderId: number;
  37588. private _parentUpdateId;
  37589. /** @hidden */
  37590. _childUpdateId: number;
  37591. /** @hidden */
  37592. _waitingParentId: Nullable<string>;
  37593. /** @hidden */
  37594. _scene: Scene;
  37595. /** @hidden */
  37596. _cache: any;
  37597. private _parentNode;
  37598. private _children;
  37599. /** @hidden */
  37600. _worldMatrix: Matrix;
  37601. /** @hidden */
  37602. _worldMatrixDeterminant: number;
  37603. /** @hidden */
  37604. _worldMatrixDeterminantIsDirty: boolean;
  37605. /** @hidden */
  37606. private _sceneRootNodesIndex;
  37607. /**
  37608. * Gets a boolean indicating if the node has been disposed
  37609. * @returns true if the node was disposed
  37610. */
  37611. isDisposed(): boolean;
  37612. /**
  37613. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37614. * @see https://doc.babylonjs.com/how_to/parenting
  37615. */
  37616. set parent(parent: Nullable<Node>);
  37617. get parent(): Nullable<Node>;
  37618. /** @hidden */
  37619. _addToSceneRootNodes(): void;
  37620. /** @hidden */
  37621. _removeFromSceneRootNodes(): void;
  37622. private _animationPropertiesOverride;
  37623. /**
  37624. * Gets or sets the animation properties override
  37625. */
  37626. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37627. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37628. /**
  37629. * Gets a string identifying the name of the class
  37630. * @returns "Node" string
  37631. */
  37632. getClassName(): string;
  37633. /** @hidden */
  37634. readonly _isNode: boolean;
  37635. /**
  37636. * An event triggered when the mesh is disposed
  37637. */
  37638. onDisposeObservable: Observable<Node>;
  37639. private _onDisposeObserver;
  37640. /**
  37641. * Sets a callback that will be raised when the node will be disposed
  37642. */
  37643. set onDispose(callback: () => void);
  37644. /**
  37645. * Creates a new Node
  37646. * @param name the name and id to be given to this node
  37647. * @param scene the scene this node will be added to
  37648. */
  37649. constructor(name: string, scene?: Nullable<Scene>);
  37650. /**
  37651. * Gets the scene of the node
  37652. * @returns a scene
  37653. */
  37654. getScene(): Scene;
  37655. /**
  37656. * Gets the engine of the node
  37657. * @returns a Engine
  37658. */
  37659. getEngine(): Engine;
  37660. private _behaviors;
  37661. /**
  37662. * Attach a behavior to the node
  37663. * @see https://doc.babylonjs.com/features/behaviour
  37664. * @param behavior defines the behavior to attach
  37665. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37666. * @returns the current Node
  37667. */
  37668. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37669. /**
  37670. * Remove an attached behavior
  37671. * @see https://doc.babylonjs.com/features/behaviour
  37672. * @param behavior defines the behavior to attach
  37673. * @returns the current Node
  37674. */
  37675. removeBehavior(behavior: Behavior<Node>): Node;
  37676. /**
  37677. * Gets the list of attached behaviors
  37678. * @see https://doc.babylonjs.com/features/behaviour
  37679. */
  37680. get behaviors(): Behavior<Node>[];
  37681. /**
  37682. * Gets an attached behavior by name
  37683. * @param name defines the name of the behavior to look for
  37684. * @see https://doc.babylonjs.com/features/behaviour
  37685. * @returns null if behavior was not found else the requested behavior
  37686. */
  37687. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37688. /**
  37689. * Returns the latest update of the World matrix
  37690. * @returns a Matrix
  37691. */
  37692. getWorldMatrix(): Matrix;
  37693. /** @hidden */
  37694. _getWorldMatrixDeterminant(): number;
  37695. /**
  37696. * Returns directly the latest state of the mesh World matrix.
  37697. * A Matrix is returned.
  37698. */
  37699. get worldMatrixFromCache(): Matrix;
  37700. /** @hidden */
  37701. _initCache(): void;
  37702. /** @hidden */
  37703. updateCache(force?: boolean): void;
  37704. /** @hidden */
  37705. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37706. /** @hidden */
  37707. _updateCache(ignoreParentClass?: boolean): void;
  37708. /** @hidden */
  37709. _isSynchronized(): boolean;
  37710. /** @hidden */
  37711. _markSyncedWithParent(): void;
  37712. /** @hidden */
  37713. isSynchronizedWithParent(): boolean;
  37714. /** @hidden */
  37715. isSynchronized(): boolean;
  37716. /**
  37717. * Is this node ready to be used/rendered
  37718. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37719. * @return true if the node is ready
  37720. */
  37721. isReady(completeCheck?: boolean): boolean;
  37722. /**
  37723. * Is this node enabled?
  37724. * 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
  37725. * @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
  37726. * @return whether this node (and its parent) is enabled
  37727. */
  37728. isEnabled(checkAncestors?: boolean): boolean;
  37729. /** @hidden */
  37730. protected _syncParentEnabledState(): void;
  37731. /**
  37732. * Set the enabled state of this node
  37733. * @param value defines the new enabled state
  37734. */
  37735. setEnabled(value: boolean): void;
  37736. /**
  37737. * Is this node a descendant of the given node?
  37738. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37739. * @param ancestor defines the parent node to inspect
  37740. * @returns a boolean indicating if this node is a descendant of the given node
  37741. */
  37742. isDescendantOf(ancestor: Node): boolean;
  37743. /** @hidden */
  37744. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37745. /**
  37746. * Will return all nodes that have this node as ascendant
  37747. * @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
  37748. * @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
  37749. * @return all children nodes of all types
  37750. */
  37751. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37752. /**
  37753. * Get all child-meshes of this node
  37754. * @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)
  37755. * @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
  37756. * @returns an array of AbstractMesh
  37757. */
  37758. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37759. /**
  37760. * Get all direct children of this node
  37761. * @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
  37762. * @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)
  37763. * @returns an array of Node
  37764. */
  37765. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37766. /** @hidden */
  37767. _setReady(state: boolean): void;
  37768. /**
  37769. * Get an animation by name
  37770. * @param name defines the name of the animation to look for
  37771. * @returns null if not found else the requested animation
  37772. */
  37773. getAnimationByName(name: string): Nullable<Animation>;
  37774. /**
  37775. * Creates an animation range for this node
  37776. * @param name defines the name of the range
  37777. * @param from defines the starting key
  37778. * @param to defines the end key
  37779. */
  37780. createAnimationRange(name: string, from: number, to: number): void;
  37781. /**
  37782. * Delete a specific animation range
  37783. * @param name defines the name of the range to delete
  37784. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37785. */
  37786. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37787. /**
  37788. * Get an animation range by name
  37789. * @param name defines the name of the animation range to look for
  37790. * @returns null if not found else the requested animation range
  37791. */
  37792. getAnimationRange(name: string): Nullable<AnimationRange>;
  37793. /**
  37794. * Gets the list of all animation ranges defined on this node
  37795. * @returns an array
  37796. */
  37797. getAnimationRanges(): Nullable<AnimationRange>[];
  37798. /**
  37799. * Will start the animation sequence
  37800. * @param name defines the range frames for animation sequence
  37801. * @param loop defines if the animation should loop (false by default)
  37802. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37803. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37804. * @returns the object created for this animation. If range does not exist, it will return null
  37805. */
  37806. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37807. /**
  37808. * Serialize animation ranges into a JSON compatible object
  37809. * @returns serialization object
  37810. */
  37811. serializeAnimationRanges(): any;
  37812. /**
  37813. * Computes the world matrix of the node
  37814. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37815. * @returns the world matrix
  37816. */
  37817. computeWorldMatrix(force?: boolean): Matrix;
  37818. /**
  37819. * Releases resources associated with this node.
  37820. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37821. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37822. */
  37823. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37824. /**
  37825. * Parse animation range data from a serialization object and store them into a given node
  37826. * @param node defines where to store the animation ranges
  37827. * @param parsedNode defines the serialization object to read data from
  37828. * @param scene defines the hosting scene
  37829. */
  37830. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37831. /**
  37832. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37833. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37834. * @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
  37835. * @returns the new bounding vectors
  37836. */
  37837. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37838. min: Vector3;
  37839. max: Vector3;
  37840. };
  37841. }
  37842. }
  37843. declare module "babylonjs/Animations/animation" {
  37844. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37845. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37846. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37847. import { Nullable } from "babylonjs/types";
  37848. import { Scene } from "babylonjs/scene";
  37849. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37850. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37851. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37852. import { Node } from "babylonjs/node";
  37853. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37854. import { Size } from "babylonjs/Maths/math.size";
  37855. import { Animatable } from "babylonjs/Animations/animatable";
  37856. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37857. /**
  37858. * @hidden
  37859. */
  37860. export class _IAnimationState {
  37861. key: number;
  37862. repeatCount: number;
  37863. workValue?: any;
  37864. loopMode?: number;
  37865. offsetValue?: any;
  37866. highLimitValue?: any;
  37867. }
  37868. /**
  37869. * Class used to store any kind of animation
  37870. */
  37871. export class Animation {
  37872. /**Name of the animation */
  37873. name: string;
  37874. /**Property to animate */
  37875. targetProperty: string;
  37876. /**The frames per second of the animation */
  37877. framePerSecond: number;
  37878. /**The data type of the animation */
  37879. dataType: number;
  37880. /**The loop mode of the animation */
  37881. loopMode?: number | undefined;
  37882. /**Specifies if blending should be enabled */
  37883. enableBlending?: boolean | undefined;
  37884. /**
  37885. * Use matrix interpolation instead of using direct key value when animating matrices
  37886. */
  37887. static AllowMatricesInterpolation: boolean;
  37888. /**
  37889. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37890. */
  37891. static AllowMatrixDecomposeForInterpolation: boolean;
  37892. /** Define the Url to load snippets */
  37893. static SnippetUrl: string;
  37894. /** Snippet ID if the animation was created from the snippet server */
  37895. snippetId: string;
  37896. /**
  37897. * Stores the key frames of the animation
  37898. */
  37899. private _keys;
  37900. /**
  37901. * Stores the easing function of the animation
  37902. */
  37903. private _easingFunction;
  37904. /**
  37905. * @hidden Internal use only
  37906. */
  37907. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37908. /**
  37909. * The set of event that will be linked to this animation
  37910. */
  37911. private _events;
  37912. /**
  37913. * Stores an array of target property paths
  37914. */
  37915. targetPropertyPath: string[];
  37916. /**
  37917. * Stores the blending speed of the animation
  37918. */
  37919. blendingSpeed: number;
  37920. /**
  37921. * Stores the animation ranges for the animation
  37922. */
  37923. private _ranges;
  37924. /**
  37925. * @hidden Internal use
  37926. */
  37927. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37928. /**
  37929. * Sets up an animation
  37930. * @param property The property to animate
  37931. * @param animationType The animation type to apply
  37932. * @param framePerSecond The frames per second of the animation
  37933. * @param easingFunction The easing function used in the animation
  37934. * @returns The created animation
  37935. */
  37936. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37937. /**
  37938. * Create and start an animation on a node
  37939. * @param name defines the name of the global animation that will be run on all nodes
  37940. * @param node defines the root node where the animation will take place
  37941. * @param targetProperty defines property to animate
  37942. * @param framePerSecond defines the number of frame per second yo use
  37943. * @param totalFrame defines the number of frames in total
  37944. * @param from defines the initial value
  37945. * @param to defines the final value
  37946. * @param loopMode defines which loop mode you want to use (off by default)
  37947. * @param easingFunction defines the easing function to use (linear by default)
  37948. * @param onAnimationEnd defines the callback to call when animation end
  37949. * @returns the animatable created for this animation
  37950. */
  37951. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37952. /**
  37953. * Create and start an animation on a node and its descendants
  37954. * @param name defines the name of the global animation that will be run on all nodes
  37955. * @param node defines the root node where the animation will take place
  37956. * @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
  37957. * @param targetProperty defines property to animate
  37958. * @param framePerSecond defines the number of frame per second to use
  37959. * @param totalFrame defines the number of frames in total
  37960. * @param from defines the initial value
  37961. * @param to defines the final value
  37962. * @param loopMode defines which loop mode you want to use (off by default)
  37963. * @param easingFunction defines the easing function to use (linear by default)
  37964. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37965. * @returns the list of animatables created for all nodes
  37966. * @example https://www.babylonjs-playground.com/#MH0VLI
  37967. */
  37968. 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[]>;
  37969. /**
  37970. * Creates a new animation, merges it with the existing animations and starts it
  37971. * @param name Name of the animation
  37972. * @param node Node which contains the scene that begins the animations
  37973. * @param targetProperty Specifies which property to animate
  37974. * @param framePerSecond The frames per second of the animation
  37975. * @param totalFrame The total number of frames
  37976. * @param from The frame at the beginning of the animation
  37977. * @param to The frame at the end of the animation
  37978. * @param loopMode Specifies the loop mode of the animation
  37979. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37980. * @param onAnimationEnd Callback to run once the animation is complete
  37981. * @returns Nullable animation
  37982. */
  37983. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37984. /**
  37985. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37986. * @param sourceAnimation defines the Animation containing keyframes to convert
  37987. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37988. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37989. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37990. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37991. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37992. */
  37993. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37994. /**
  37995. * Transition property of an host to the target Value
  37996. * @param property The property to transition
  37997. * @param targetValue The target Value of the property
  37998. * @param host The object where the property to animate belongs
  37999. * @param scene Scene used to run the animation
  38000. * @param frameRate Framerate (in frame/s) to use
  38001. * @param transition The transition type we want to use
  38002. * @param duration The duration of the animation, in milliseconds
  38003. * @param onAnimationEnd Callback trigger at the end of the animation
  38004. * @returns Nullable animation
  38005. */
  38006. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38007. /**
  38008. * Return the array of runtime animations currently using this animation
  38009. */
  38010. get runtimeAnimations(): RuntimeAnimation[];
  38011. /**
  38012. * Specifies if any of the runtime animations are currently running
  38013. */
  38014. get hasRunningRuntimeAnimations(): boolean;
  38015. /**
  38016. * Initializes the animation
  38017. * @param name Name of the animation
  38018. * @param targetProperty Property to animate
  38019. * @param framePerSecond The frames per second of the animation
  38020. * @param dataType The data type of the animation
  38021. * @param loopMode The loop mode of the animation
  38022. * @param enableBlending Specifies if blending should be enabled
  38023. */
  38024. constructor(
  38025. /**Name of the animation */
  38026. name: string,
  38027. /**Property to animate */
  38028. targetProperty: string,
  38029. /**The frames per second of the animation */
  38030. framePerSecond: number,
  38031. /**The data type of the animation */
  38032. dataType: number,
  38033. /**The loop mode of the animation */
  38034. loopMode?: number | undefined,
  38035. /**Specifies if blending should be enabled */
  38036. enableBlending?: boolean | undefined);
  38037. /**
  38038. * Converts the animation to a string
  38039. * @param fullDetails support for multiple levels of logging within scene loading
  38040. * @returns String form of the animation
  38041. */
  38042. toString(fullDetails?: boolean): string;
  38043. /**
  38044. * Add an event to this animation
  38045. * @param event Event to add
  38046. */
  38047. addEvent(event: AnimationEvent): void;
  38048. /**
  38049. * Remove all events found at the given frame
  38050. * @param frame The frame to remove events from
  38051. */
  38052. removeEvents(frame: number): void;
  38053. /**
  38054. * Retrieves all the events from the animation
  38055. * @returns Events from the animation
  38056. */
  38057. getEvents(): AnimationEvent[];
  38058. /**
  38059. * Creates an animation range
  38060. * @param name Name of the animation range
  38061. * @param from Starting frame of the animation range
  38062. * @param to Ending frame of the animation
  38063. */
  38064. createRange(name: string, from: number, to: number): void;
  38065. /**
  38066. * Deletes an animation range by name
  38067. * @param name Name of the animation range to delete
  38068. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38069. */
  38070. deleteRange(name: string, deleteFrames?: boolean): void;
  38071. /**
  38072. * Gets the animation range by name, or null if not defined
  38073. * @param name Name of the animation range
  38074. * @returns Nullable animation range
  38075. */
  38076. getRange(name: string): Nullable<AnimationRange>;
  38077. /**
  38078. * Gets the key frames from the animation
  38079. * @returns The key frames of the animation
  38080. */
  38081. getKeys(): Array<IAnimationKey>;
  38082. /**
  38083. * Gets the highest frame rate of the animation
  38084. * @returns Highest frame rate of the animation
  38085. */
  38086. getHighestFrame(): number;
  38087. /**
  38088. * Gets the easing function of the animation
  38089. * @returns Easing function of the animation
  38090. */
  38091. getEasingFunction(): IEasingFunction;
  38092. /**
  38093. * Sets the easing function of the animation
  38094. * @param easingFunction A custom mathematical formula for animation
  38095. */
  38096. setEasingFunction(easingFunction: EasingFunction): void;
  38097. /**
  38098. * Interpolates a scalar linearly
  38099. * @param startValue Start value of the animation curve
  38100. * @param endValue End value of the animation curve
  38101. * @param gradient Scalar amount to interpolate
  38102. * @returns Interpolated scalar value
  38103. */
  38104. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38105. /**
  38106. * Interpolates a scalar cubically
  38107. * @param startValue Start value of the animation curve
  38108. * @param outTangent End tangent of the animation
  38109. * @param endValue End value of the animation curve
  38110. * @param inTangent Start tangent of the animation curve
  38111. * @param gradient Scalar amount to interpolate
  38112. * @returns Interpolated scalar value
  38113. */
  38114. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38115. /**
  38116. * Interpolates a quaternion using a spherical linear interpolation
  38117. * @param startValue Start value of the animation curve
  38118. * @param endValue End value of the animation curve
  38119. * @param gradient Scalar amount to interpolate
  38120. * @returns Interpolated quaternion value
  38121. */
  38122. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38123. /**
  38124. * Interpolates a quaternion cubically
  38125. * @param startValue Start value of the animation curve
  38126. * @param outTangent End tangent of the animation curve
  38127. * @param endValue End value of the animation curve
  38128. * @param inTangent Start tangent of the animation curve
  38129. * @param gradient Scalar amount to interpolate
  38130. * @returns Interpolated quaternion value
  38131. */
  38132. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38133. /**
  38134. * Interpolates a Vector3 linearl
  38135. * @param startValue Start value of the animation curve
  38136. * @param endValue End value of the animation curve
  38137. * @param gradient Scalar amount to interpolate
  38138. * @returns Interpolated scalar value
  38139. */
  38140. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38141. /**
  38142. * Interpolates a Vector3 cubically
  38143. * @param startValue Start value of the animation curve
  38144. * @param outTangent End tangent of the animation
  38145. * @param endValue End value of the animation curve
  38146. * @param inTangent Start tangent of the animation curve
  38147. * @param gradient Scalar amount to interpolate
  38148. * @returns InterpolatedVector3 value
  38149. */
  38150. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38151. /**
  38152. * Interpolates a Vector2 linearly
  38153. * @param startValue Start value of the animation curve
  38154. * @param endValue End value of the animation curve
  38155. * @param gradient Scalar amount to interpolate
  38156. * @returns Interpolated Vector2 value
  38157. */
  38158. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38159. /**
  38160. * Interpolates a Vector2 cubically
  38161. * @param startValue Start value of the animation curve
  38162. * @param outTangent End tangent of the animation
  38163. * @param endValue End value of the animation curve
  38164. * @param inTangent Start tangent of the animation curve
  38165. * @param gradient Scalar amount to interpolate
  38166. * @returns Interpolated Vector2 value
  38167. */
  38168. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38169. /**
  38170. * Interpolates a size linearly
  38171. * @param startValue Start value of the animation curve
  38172. * @param endValue End value of the animation curve
  38173. * @param gradient Scalar amount to interpolate
  38174. * @returns Interpolated Size value
  38175. */
  38176. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38177. /**
  38178. * Interpolates a Color3 linearly
  38179. * @param startValue Start value of the animation curve
  38180. * @param endValue End value of the animation curve
  38181. * @param gradient Scalar amount to interpolate
  38182. * @returns Interpolated Color3 value
  38183. */
  38184. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38185. /**
  38186. * Interpolates a Color4 linearly
  38187. * @param startValue Start value of the animation curve
  38188. * @param endValue End value of the animation curve
  38189. * @param gradient Scalar amount to interpolate
  38190. * @returns Interpolated Color3 value
  38191. */
  38192. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38193. /**
  38194. * @hidden Internal use only
  38195. */
  38196. _getKeyValue(value: any): any;
  38197. /**
  38198. * @hidden Internal use only
  38199. */
  38200. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38201. /**
  38202. * Defines the function to use to interpolate matrices
  38203. * @param startValue defines the start matrix
  38204. * @param endValue defines the end matrix
  38205. * @param gradient defines the gradient between both matrices
  38206. * @param result defines an optional target matrix where to store the interpolation
  38207. * @returns the interpolated matrix
  38208. */
  38209. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38210. /**
  38211. * Makes a copy of the animation
  38212. * @returns Cloned animation
  38213. */
  38214. clone(): Animation;
  38215. /**
  38216. * Sets the key frames of the animation
  38217. * @param values The animation key frames to set
  38218. */
  38219. setKeys(values: Array<IAnimationKey>): void;
  38220. /**
  38221. * Serializes the animation to an object
  38222. * @returns Serialized object
  38223. */
  38224. serialize(): any;
  38225. /**
  38226. * Float animation type
  38227. */
  38228. static readonly ANIMATIONTYPE_FLOAT: number;
  38229. /**
  38230. * Vector3 animation type
  38231. */
  38232. static readonly ANIMATIONTYPE_VECTOR3: number;
  38233. /**
  38234. * Quaternion animation type
  38235. */
  38236. static readonly ANIMATIONTYPE_QUATERNION: number;
  38237. /**
  38238. * Matrix animation type
  38239. */
  38240. static readonly ANIMATIONTYPE_MATRIX: number;
  38241. /**
  38242. * Color3 animation type
  38243. */
  38244. static readonly ANIMATIONTYPE_COLOR3: number;
  38245. /**
  38246. * Color3 animation type
  38247. */
  38248. static readonly ANIMATIONTYPE_COLOR4: number;
  38249. /**
  38250. * Vector2 animation type
  38251. */
  38252. static readonly ANIMATIONTYPE_VECTOR2: number;
  38253. /**
  38254. * Size animation type
  38255. */
  38256. static readonly ANIMATIONTYPE_SIZE: number;
  38257. /**
  38258. * Relative Loop Mode
  38259. */
  38260. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38261. /**
  38262. * Cycle Loop Mode
  38263. */
  38264. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38265. /**
  38266. * Constant Loop Mode
  38267. */
  38268. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38269. /** @hidden */
  38270. static _UniversalLerp(left: any, right: any, amount: number): any;
  38271. /**
  38272. * Parses an animation object and creates an animation
  38273. * @param parsedAnimation Parsed animation object
  38274. * @returns Animation object
  38275. */
  38276. static Parse(parsedAnimation: any): Animation;
  38277. /**
  38278. * Appends the serialized animations from the source animations
  38279. * @param source Source containing the animations
  38280. * @param destination Target to store the animations
  38281. */
  38282. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38283. /**
  38284. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38285. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38286. * @param url defines the url to load from
  38287. * @returns a promise that will resolve to the new animation or an array of animations
  38288. */
  38289. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38290. /**
  38291. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38292. * @param snippetId defines the snippet to load
  38293. * @returns a promise that will resolve to the new animation or a new array of animations
  38294. */
  38295. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38296. }
  38297. }
  38298. declare module "babylonjs/Animations/animatable.interface" {
  38299. import { Nullable } from "babylonjs/types";
  38300. import { Animation } from "babylonjs/Animations/animation";
  38301. /**
  38302. * Interface containing an array of animations
  38303. */
  38304. export interface IAnimatable {
  38305. /**
  38306. * Array of animations
  38307. */
  38308. animations: Nullable<Array<Animation>>;
  38309. }
  38310. }
  38311. declare module "babylonjs/Misc/decorators" {
  38312. import { Nullable } from "babylonjs/types";
  38313. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38314. import { Scene } from "babylonjs/scene";
  38315. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38316. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38317. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38318. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38319. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38320. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38321. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38322. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38323. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38324. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38325. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38326. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38327. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38328. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38329. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38330. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38331. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38332. /**
  38333. * Decorator used to define property that can be serialized as reference to a camera
  38334. * @param sourceName defines the name of the property to decorate
  38335. */
  38336. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38337. /**
  38338. * Class used to help serialization objects
  38339. */
  38340. export class SerializationHelper {
  38341. /** @hidden */
  38342. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38343. /** @hidden */
  38344. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38345. /** @hidden */
  38346. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38347. /** @hidden */
  38348. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38349. /**
  38350. * Appends the serialized animations from the source animations
  38351. * @param source Source containing the animations
  38352. * @param destination Target to store the animations
  38353. */
  38354. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38355. /**
  38356. * Static function used to serialized a specific entity
  38357. * @param entity defines the entity to serialize
  38358. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38359. * @returns a JSON compatible object representing the serialization of the entity
  38360. */
  38361. static Serialize<T>(entity: T, serializationObject?: any): any;
  38362. /**
  38363. * Creates a new entity from a serialization data object
  38364. * @param creationFunction defines a function used to instanciated the new entity
  38365. * @param source defines the source serialization data
  38366. * @param scene defines the hosting scene
  38367. * @param rootUrl defines the root url for resources
  38368. * @returns a new entity
  38369. */
  38370. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38371. /**
  38372. * Clones an object
  38373. * @param creationFunction defines the function used to instanciate the new object
  38374. * @param source defines the source object
  38375. * @returns the cloned object
  38376. */
  38377. static Clone<T>(creationFunction: () => T, source: T): T;
  38378. /**
  38379. * Instanciates a new object based on a source one (some data will be shared between both object)
  38380. * @param creationFunction defines the function used to instanciate the new object
  38381. * @param source defines the source object
  38382. * @returns the new object
  38383. */
  38384. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38385. }
  38386. }
  38387. declare module "babylonjs/Materials/Textures/baseTexture" {
  38388. import { Observable } from "babylonjs/Misc/observable";
  38389. import { Nullable } from "babylonjs/types";
  38390. import { Scene } from "babylonjs/scene";
  38391. import { Matrix } from "babylonjs/Maths/math.vector";
  38392. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38393. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38394. import { ISize } from "babylonjs/Maths/math.size";
  38395. import "babylonjs/Misc/fileTools";
  38396. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38397. /**
  38398. * Base class of all the textures in babylon.
  38399. * It groups all the common properties the materials, post process, lights... might need
  38400. * in order to make a correct use of the texture.
  38401. */
  38402. export class BaseTexture implements IAnimatable {
  38403. /**
  38404. * Default anisotropic filtering level for the application.
  38405. * It is set to 4 as a good tradeoff between perf and quality.
  38406. */
  38407. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38408. /**
  38409. * Gets or sets the unique id of the texture
  38410. */
  38411. uniqueId: number;
  38412. /**
  38413. * Define the name of the texture.
  38414. */
  38415. name: string;
  38416. /**
  38417. * Gets or sets an object used to store user defined information.
  38418. */
  38419. metadata: any;
  38420. /**
  38421. * For internal use only. Please do not use.
  38422. */
  38423. reservedDataStore: any;
  38424. private _hasAlpha;
  38425. /**
  38426. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38427. */
  38428. set hasAlpha(value: boolean);
  38429. get hasAlpha(): boolean;
  38430. /**
  38431. * Defines if the alpha value should be determined via the rgb values.
  38432. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38433. */
  38434. getAlphaFromRGB: boolean;
  38435. /**
  38436. * Intensity or strength of the texture.
  38437. * It is commonly used by materials to fine tune the intensity of the texture
  38438. */
  38439. level: number;
  38440. /**
  38441. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38442. * This is part of the texture as textures usually maps to one uv set.
  38443. */
  38444. coordinatesIndex: number;
  38445. protected _coordinatesMode: number;
  38446. /**
  38447. * How a texture is mapped.
  38448. *
  38449. * | Value | Type | Description |
  38450. * | ----- | ----------------------------------- | ----------- |
  38451. * | 0 | EXPLICIT_MODE | |
  38452. * | 1 | SPHERICAL_MODE | |
  38453. * | 2 | PLANAR_MODE | |
  38454. * | 3 | CUBIC_MODE | |
  38455. * | 4 | PROJECTION_MODE | |
  38456. * | 5 | SKYBOX_MODE | |
  38457. * | 6 | INVCUBIC_MODE | |
  38458. * | 7 | EQUIRECTANGULAR_MODE | |
  38459. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38460. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38461. */
  38462. set coordinatesMode(value: number);
  38463. get coordinatesMode(): number;
  38464. private _wrapU;
  38465. /**
  38466. * | Value | Type | Description |
  38467. * | ----- | ------------------ | ----------- |
  38468. * | 0 | CLAMP_ADDRESSMODE | |
  38469. * | 1 | WRAP_ADDRESSMODE | |
  38470. * | 2 | MIRROR_ADDRESSMODE | |
  38471. */
  38472. get wrapU(): number;
  38473. set wrapU(value: number);
  38474. private _wrapV;
  38475. /**
  38476. * | Value | Type | Description |
  38477. * | ----- | ------------------ | ----------- |
  38478. * | 0 | CLAMP_ADDRESSMODE | |
  38479. * | 1 | WRAP_ADDRESSMODE | |
  38480. * | 2 | MIRROR_ADDRESSMODE | |
  38481. */
  38482. get wrapV(): number;
  38483. set wrapV(value: number);
  38484. /**
  38485. * | Value | Type | Description |
  38486. * | ----- | ------------------ | ----------- |
  38487. * | 0 | CLAMP_ADDRESSMODE | |
  38488. * | 1 | WRAP_ADDRESSMODE | |
  38489. * | 2 | MIRROR_ADDRESSMODE | |
  38490. */
  38491. wrapR: number;
  38492. /**
  38493. * With compliant hardware and browser (supporting anisotropic filtering)
  38494. * this defines the level of anisotropic filtering in the texture.
  38495. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38496. */
  38497. anisotropicFilteringLevel: number;
  38498. /**
  38499. * Define if the texture is a cube texture or if false a 2d texture.
  38500. */
  38501. get isCube(): boolean;
  38502. set isCube(value: boolean);
  38503. /**
  38504. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38505. */
  38506. get is3D(): boolean;
  38507. set is3D(value: boolean);
  38508. /**
  38509. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38510. */
  38511. get is2DArray(): boolean;
  38512. set is2DArray(value: boolean);
  38513. private _gammaSpace;
  38514. /**
  38515. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38516. * HDR texture are usually stored in linear space.
  38517. * This only impacts the PBR and Background materials
  38518. */
  38519. get gammaSpace(): boolean;
  38520. set gammaSpace(gamma: boolean);
  38521. /**
  38522. * Gets or sets whether or not the texture contains RGBD data.
  38523. */
  38524. get isRGBD(): boolean;
  38525. set isRGBD(value: boolean);
  38526. /**
  38527. * Is Z inverted in the texture (useful in a cube texture).
  38528. */
  38529. invertZ: boolean;
  38530. /**
  38531. * Are mip maps generated for this texture or not.
  38532. */
  38533. get noMipmap(): boolean;
  38534. /**
  38535. * @hidden
  38536. */
  38537. lodLevelInAlpha: boolean;
  38538. /**
  38539. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38540. */
  38541. get lodGenerationOffset(): number;
  38542. set lodGenerationOffset(value: number);
  38543. /**
  38544. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38545. */
  38546. get lodGenerationScale(): number;
  38547. set lodGenerationScale(value: number);
  38548. /**
  38549. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38550. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38551. * average roughness values.
  38552. */
  38553. get linearSpecularLOD(): boolean;
  38554. set linearSpecularLOD(value: boolean);
  38555. /**
  38556. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38557. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38558. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38559. */
  38560. get irradianceTexture(): Nullable<BaseTexture>;
  38561. set irradianceTexture(value: Nullable<BaseTexture>);
  38562. /**
  38563. * Define if the texture is a render target.
  38564. */
  38565. isRenderTarget: boolean;
  38566. /**
  38567. * Define the unique id of the texture in the scene.
  38568. */
  38569. get uid(): string;
  38570. /** @hidden */
  38571. _prefiltered: boolean;
  38572. /**
  38573. * Return a string representation of the texture.
  38574. * @returns the texture as a string
  38575. */
  38576. toString(): string;
  38577. /**
  38578. * Get the class name of the texture.
  38579. * @returns "BaseTexture"
  38580. */
  38581. getClassName(): string;
  38582. /**
  38583. * Define the list of animation attached to the texture.
  38584. */
  38585. animations: import("babylonjs/Animations/animation").Animation[];
  38586. /**
  38587. * An event triggered when the texture is disposed.
  38588. */
  38589. onDisposeObservable: Observable<BaseTexture>;
  38590. private _onDisposeObserver;
  38591. /**
  38592. * Callback triggered when the texture has been disposed.
  38593. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38594. */
  38595. set onDispose(callback: () => void);
  38596. /**
  38597. * Define the current state of the loading sequence when in delayed load mode.
  38598. */
  38599. delayLoadState: number;
  38600. protected _scene: Nullable<Scene>;
  38601. protected _engine: Nullable<ThinEngine>;
  38602. /** @hidden */
  38603. _texture: Nullable<InternalTexture>;
  38604. private _uid;
  38605. /**
  38606. * Define if the texture is preventinga material to render or not.
  38607. * If not and the texture is not ready, the engine will use a default black texture instead.
  38608. */
  38609. get isBlocking(): boolean;
  38610. /**
  38611. * Instantiates a new BaseTexture.
  38612. * Base class of all the textures in babylon.
  38613. * It groups all the common properties the materials, post process, lights... might need
  38614. * in order to make a correct use of the texture.
  38615. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38616. */
  38617. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38618. /**
  38619. * Get the scene the texture belongs to.
  38620. * @returns the scene or null if undefined
  38621. */
  38622. getScene(): Nullable<Scene>;
  38623. /** @hidden */
  38624. protected _getEngine(): Nullable<ThinEngine>;
  38625. /**
  38626. * Checks if the texture has the same transform matrix than another texture
  38627. * @param texture texture to check against
  38628. * @returns true if the transforms are the same, else false
  38629. */
  38630. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  38631. /**
  38632. * Get the texture transform matrix used to offset tile the texture for istance.
  38633. * @returns the transformation matrix
  38634. */
  38635. getTextureMatrix(): Matrix;
  38636. /**
  38637. * Get the texture reflection matrix used to rotate/transform the reflection.
  38638. * @returns the reflection matrix
  38639. */
  38640. getReflectionTextureMatrix(): Matrix;
  38641. /**
  38642. * Get the underlying lower level texture from Babylon.
  38643. * @returns the insternal texture
  38644. */
  38645. getInternalTexture(): Nullable<InternalTexture>;
  38646. /**
  38647. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38648. * @returns true if ready or not blocking
  38649. */
  38650. isReadyOrNotBlocking(): boolean;
  38651. /**
  38652. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38653. * @returns true if fully ready
  38654. */
  38655. isReady(): boolean;
  38656. private _cachedSize;
  38657. /**
  38658. * Get the size of the texture.
  38659. * @returns the texture size.
  38660. */
  38661. getSize(): ISize;
  38662. /**
  38663. * Get the base size of the texture.
  38664. * It can be different from the size if the texture has been resized for POT for instance
  38665. * @returns the base size
  38666. */
  38667. getBaseSize(): ISize;
  38668. /**
  38669. * Update the sampling mode of the texture.
  38670. * Default is Trilinear mode.
  38671. *
  38672. * | Value | Type | Description |
  38673. * | ----- | ------------------ | ----------- |
  38674. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38675. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38676. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38677. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38678. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38679. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38680. * | 7 | NEAREST_LINEAR | |
  38681. * | 8 | NEAREST_NEAREST | |
  38682. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38683. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38684. * | 11 | LINEAR_LINEAR | |
  38685. * | 12 | LINEAR_NEAREST | |
  38686. *
  38687. * > _mag_: magnification filter (close to the viewer)
  38688. * > _min_: minification filter (far from the viewer)
  38689. * > _mip_: filter used between mip map levels
  38690. *@param samplingMode Define the new sampling mode of the texture
  38691. */
  38692. updateSamplingMode(samplingMode: number): void;
  38693. /**
  38694. * Scales the texture if is `canRescale()`
  38695. * @param ratio the resize factor we want to use to rescale
  38696. */
  38697. scale(ratio: number): void;
  38698. /**
  38699. * Get if the texture can rescale.
  38700. */
  38701. get canRescale(): boolean;
  38702. /** @hidden */
  38703. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  38704. /** @hidden */
  38705. _rebuild(): void;
  38706. /**
  38707. * Triggers the load sequence in delayed load mode.
  38708. */
  38709. delayLoad(): void;
  38710. /**
  38711. * Clones the texture.
  38712. * @returns the cloned texture
  38713. */
  38714. clone(): Nullable<BaseTexture>;
  38715. /**
  38716. * Get the texture underlying type (INT, FLOAT...)
  38717. */
  38718. get textureType(): number;
  38719. /**
  38720. * Get the texture underlying format (RGB, RGBA...)
  38721. */
  38722. get textureFormat(): number;
  38723. /**
  38724. * Indicates that textures need to be re-calculated for all materials
  38725. */
  38726. protected _markAllSubMeshesAsTexturesDirty(): void;
  38727. /**
  38728. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  38729. * This will returns an RGBA array buffer containing either in values (0-255) or
  38730. * float values (0-1) depending of the underlying buffer type.
  38731. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  38732. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  38733. * @param buffer defines a user defined buffer to fill with data (can be null)
  38734. * @returns The Array buffer containing the pixels data.
  38735. */
  38736. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  38737. /**
  38738. * Release and destroy the underlying lower level texture aka internalTexture.
  38739. */
  38740. releaseInternalTexture(): void;
  38741. /** @hidden */
  38742. get _lodTextureHigh(): Nullable<BaseTexture>;
  38743. /** @hidden */
  38744. get _lodTextureMid(): Nullable<BaseTexture>;
  38745. /** @hidden */
  38746. get _lodTextureLow(): Nullable<BaseTexture>;
  38747. /**
  38748. * Dispose the texture and release its associated resources.
  38749. */
  38750. dispose(): void;
  38751. /**
  38752. * Serialize the texture into a JSON representation that can be parsed later on.
  38753. * @returns the JSON representation of the texture
  38754. */
  38755. serialize(): any;
  38756. /**
  38757. * Helper function to be called back once a list of texture contains only ready textures.
  38758. * @param textures Define the list of textures to wait for
  38759. * @param callback Define the callback triggered once the entire list will be ready
  38760. */
  38761. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  38762. private static _isScene;
  38763. }
  38764. }
  38765. declare module "babylonjs/Materials/effect" {
  38766. import { Observable } from "babylonjs/Misc/observable";
  38767. import { Nullable } from "babylonjs/types";
  38768. import { IDisposable } from "babylonjs/scene";
  38769. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38770. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38771. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  38772. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38773. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  38774. import { Engine } from "babylonjs/Engines/engine";
  38775. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38778. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38779. /**
  38780. * Options to be used when creating an effect.
  38781. */
  38782. export interface IEffectCreationOptions {
  38783. /**
  38784. * Atrributes that will be used in the shader.
  38785. */
  38786. attributes: string[];
  38787. /**
  38788. * Uniform varible names that will be set in the shader.
  38789. */
  38790. uniformsNames: string[];
  38791. /**
  38792. * Uniform buffer variable names that will be set in the shader.
  38793. */
  38794. uniformBuffersNames: string[];
  38795. /**
  38796. * Sampler texture variable names that will be set in the shader.
  38797. */
  38798. samplers: string[];
  38799. /**
  38800. * Define statements that will be set in the shader.
  38801. */
  38802. defines: any;
  38803. /**
  38804. * Possible fallbacks for this effect to improve performance when needed.
  38805. */
  38806. fallbacks: Nullable<IEffectFallbacks>;
  38807. /**
  38808. * Callback that will be called when the shader is compiled.
  38809. */
  38810. onCompiled: Nullable<(effect: Effect) => void>;
  38811. /**
  38812. * Callback that will be called if an error occurs during shader compilation.
  38813. */
  38814. onError: Nullable<(effect: Effect, errors: string) => void>;
  38815. /**
  38816. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38817. */
  38818. indexParameters?: any;
  38819. /**
  38820. * Max number of lights that can be used in the shader.
  38821. */
  38822. maxSimultaneousLights?: number;
  38823. /**
  38824. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38825. */
  38826. transformFeedbackVaryings?: Nullable<string[]>;
  38827. /**
  38828. * 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
  38829. */
  38830. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38831. /**
  38832. * Is this effect rendering to several color attachments ?
  38833. */
  38834. multiTarget?: boolean;
  38835. }
  38836. /**
  38837. * Effect containing vertex and fragment shader that can be executed on an object.
  38838. */
  38839. export class Effect implements IDisposable {
  38840. /**
  38841. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38842. */
  38843. static ShadersRepository: string;
  38844. /**
  38845. * Enable logging of the shader code when a compilation error occurs
  38846. */
  38847. static LogShaderCodeOnCompilationError: boolean;
  38848. /**
  38849. * Name of the effect.
  38850. */
  38851. name: any;
  38852. /**
  38853. * String container all the define statements that should be set on the shader.
  38854. */
  38855. defines: string;
  38856. /**
  38857. * Callback that will be called when the shader is compiled.
  38858. */
  38859. onCompiled: Nullable<(effect: Effect) => void>;
  38860. /**
  38861. * Callback that will be called if an error occurs during shader compilation.
  38862. */
  38863. onError: Nullable<(effect: Effect, errors: string) => void>;
  38864. /**
  38865. * Callback that will be called when effect is bound.
  38866. */
  38867. onBind: Nullable<(effect: Effect) => void>;
  38868. /**
  38869. * Unique ID of the effect.
  38870. */
  38871. uniqueId: number;
  38872. /**
  38873. * Observable that will be called when the shader is compiled.
  38874. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38875. */
  38876. onCompileObservable: Observable<Effect>;
  38877. /**
  38878. * Observable that will be called if an error occurs during shader compilation.
  38879. */
  38880. onErrorObservable: Observable<Effect>;
  38881. /** @hidden */
  38882. _onBindObservable: Nullable<Observable<Effect>>;
  38883. /**
  38884. * @hidden
  38885. * Specifies if the effect was previously ready
  38886. */
  38887. _wasPreviouslyReady: boolean;
  38888. /**
  38889. * Observable that will be called when effect is bound.
  38890. */
  38891. get onBindObservable(): Observable<Effect>;
  38892. /** @hidden */
  38893. _bonesComputationForcedToCPU: boolean;
  38894. /** @hidden */
  38895. _multiTarget: boolean;
  38896. private static _uniqueIdSeed;
  38897. private _engine;
  38898. private _uniformBuffersNames;
  38899. private _uniformBuffersNamesList;
  38900. private _uniformsNames;
  38901. private _samplerList;
  38902. private _samplers;
  38903. private _isReady;
  38904. private _compilationError;
  38905. private _allFallbacksProcessed;
  38906. private _attributesNames;
  38907. private _attributes;
  38908. private _attributeLocationByName;
  38909. private _uniforms;
  38910. /**
  38911. * Key for the effect.
  38912. * @hidden
  38913. */
  38914. _key: string;
  38915. private _indexParameters;
  38916. private _fallbacks;
  38917. private _vertexSourceCode;
  38918. private _fragmentSourceCode;
  38919. private _vertexSourceCodeOverride;
  38920. private _fragmentSourceCodeOverride;
  38921. private _transformFeedbackVaryings;
  38922. /**
  38923. * Compiled shader to webGL program.
  38924. * @hidden
  38925. */
  38926. _pipelineContext: Nullable<IPipelineContext>;
  38927. private _valueCache;
  38928. private static _baseCache;
  38929. /**
  38930. * Instantiates an effect.
  38931. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38932. * @param baseName Name of the effect.
  38933. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38934. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38935. * @param samplers List of sampler variables that will be passed to the shader.
  38936. * @param engine Engine to be used to render the effect
  38937. * @param defines Define statements to be added to the shader.
  38938. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38939. * @param onCompiled Callback that will be called when the shader is compiled.
  38940. * @param onError Callback that will be called if an error occurs during shader compilation.
  38941. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38942. */
  38943. 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);
  38944. private _useFinalCode;
  38945. /**
  38946. * Unique key for this effect
  38947. */
  38948. get key(): string;
  38949. /**
  38950. * If the effect has been compiled and prepared.
  38951. * @returns if the effect is compiled and prepared.
  38952. */
  38953. isReady(): boolean;
  38954. private _isReadyInternal;
  38955. /**
  38956. * The engine the effect was initialized with.
  38957. * @returns the engine.
  38958. */
  38959. getEngine(): Engine;
  38960. /**
  38961. * The pipeline context for this effect
  38962. * @returns the associated pipeline context
  38963. */
  38964. getPipelineContext(): Nullable<IPipelineContext>;
  38965. /**
  38966. * The set of names of attribute variables for the shader.
  38967. * @returns An array of attribute names.
  38968. */
  38969. getAttributesNames(): string[];
  38970. /**
  38971. * Returns the attribute at the given index.
  38972. * @param index The index of the attribute.
  38973. * @returns The location of the attribute.
  38974. */
  38975. getAttributeLocation(index: number): number;
  38976. /**
  38977. * Returns the attribute based on the name of the variable.
  38978. * @param name of the attribute to look up.
  38979. * @returns the attribute location.
  38980. */
  38981. getAttributeLocationByName(name: string): number;
  38982. /**
  38983. * The number of attributes.
  38984. * @returns the numnber of attributes.
  38985. */
  38986. getAttributesCount(): number;
  38987. /**
  38988. * Gets the index of a uniform variable.
  38989. * @param uniformName of the uniform to look up.
  38990. * @returns the index.
  38991. */
  38992. getUniformIndex(uniformName: string): number;
  38993. /**
  38994. * Returns the attribute based on the name of the variable.
  38995. * @param uniformName of the uniform to look up.
  38996. * @returns the location of the uniform.
  38997. */
  38998. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38999. /**
  39000. * Returns an array of sampler variable names
  39001. * @returns The array of sampler variable names.
  39002. */
  39003. getSamplers(): string[];
  39004. /**
  39005. * Returns an array of uniform variable names
  39006. * @returns The array of uniform variable names.
  39007. */
  39008. getUniformNames(): string[];
  39009. /**
  39010. * Returns an array of uniform buffer variable names
  39011. * @returns The array of uniform buffer variable names.
  39012. */
  39013. getUniformBuffersNames(): string[];
  39014. /**
  39015. * Returns the index parameters used to create the effect
  39016. * @returns The index parameters object
  39017. */
  39018. getIndexParameters(): any;
  39019. /**
  39020. * The error from the last compilation.
  39021. * @returns the error string.
  39022. */
  39023. getCompilationError(): string;
  39024. /**
  39025. * Gets a boolean indicating that all fallbacks were used during compilation
  39026. * @returns true if all fallbacks were used
  39027. */
  39028. allFallbacksProcessed(): boolean;
  39029. /**
  39030. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39031. * @param func The callback to be used.
  39032. */
  39033. executeWhenCompiled(func: (effect: Effect) => void): void;
  39034. private _checkIsReady;
  39035. private _loadShader;
  39036. /**
  39037. * Gets the vertex shader source code of this effect
  39038. */
  39039. get vertexSourceCode(): string;
  39040. /**
  39041. * Gets the fragment shader source code of this effect
  39042. */
  39043. get fragmentSourceCode(): string;
  39044. /**
  39045. * Recompiles the webGL program
  39046. * @param vertexSourceCode The source code for the vertex shader.
  39047. * @param fragmentSourceCode The source code for the fragment shader.
  39048. * @param onCompiled Callback called when completed.
  39049. * @param onError Callback called on error.
  39050. * @hidden
  39051. */
  39052. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39053. /**
  39054. * Prepares the effect
  39055. * @hidden
  39056. */
  39057. _prepareEffect(): void;
  39058. private _getShaderCodeAndErrorLine;
  39059. private _processCompilationErrors;
  39060. /**
  39061. * Checks if the effect is supported. (Must be called after compilation)
  39062. */
  39063. get isSupported(): boolean;
  39064. /**
  39065. * Binds a texture to the engine to be used as output of the shader.
  39066. * @param channel Name of the output variable.
  39067. * @param texture Texture to bind.
  39068. * @hidden
  39069. */
  39070. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39071. /**
  39072. * Sets a texture on the engine to be used in the shader.
  39073. * @param channel Name of the sampler variable.
  39074. * @param texture Texture to set.
  39075. */
  39076. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39077. /**
  39078. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39079. * @param channel Name of the sampler variable.
  39080. * @param texture Texture to set.
  39081. */
  39082. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39083. /**
  39084. * Sets an array of textures on the engine to be used in the shader.
  39085. * @param channel Name of the variable.
  39086. * @param textures Textures to set.
  39087. */
  39088. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39089. /**
  39090. * 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)
  39091. * @param channel Name of the sampler variable.
  39092. * @param postProcess Post process to get the input texture from.
  39093. */
  39094. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39095. /**
  39096. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39097. * 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)
  39098. * @param channel Name of the sampler variable.
  39099. * @param postProcess Post process to get the output texture from.
  39100. */
  39101. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39102. /** @hidden */
  39103. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39104. /** @hidden */
  39105. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39106. /** @hidden */
  39107. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39108. /** @hidden */
  39109. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39110. /**
  39111. * Binds a buffer to a uniform.
  39112. * @param buffer Buffer to bind.
  39113. * @param name Name of the uniform variable to bind to.
  39114. */
  39115. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39116. /**
  39117. * Binds block to a uniform.
  39118. * @param blockName Name of the block to bind.
  39119. * @param index Index to bind.
  39120. */
  39121. bindUniformBlock(blockName: string, index: number): void;
  39122. /**
  39123. * Sets an interger value on a uniform variable.
  39124. * @param uniformName Name of the variable.
  39125. * @param value Value to be set.
  39126. * @returns this effect.
  39127. */
  39128. setInt(uniformName: string, value: number): Effect;
  39129. /**
  39130. * Sets an int array on a uniform variable.
  39131. * @param uniformName Name of the variable.
  39132. * @param array array to be set.
  39133. * @returns this effect.
  39134. */
  39135. setIntArray(uniformName: string, array: Int32Array): Effect;
  39136. /**
  39137. * 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)
  39138. * @param uniformName Name of the variable.
  39139. * @param array array to be set.
  39140. * @returns this effect.
  39141. */
  39142. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39143. /**
  39144. * 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)
  39145. * @param uniformName Name of the variable.
  39146. * @param array array to be set.
  39147. * @returns this effect.
  39148. */
  39149. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39150. /**
  39151. * 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)
  39152. * @param uniformName Name of the variable.
  39153. * @param array array to be set.
  39154. * @returns this effect.
  39155. */
  39156. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39157. /**
  39158. * Sets an float array on a uniform variable.
  39159. * @param uniformName Name of the variable.
  39160. * @param array array to be set.
  39161. * @returns this effect.
  39162. */
  39163. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39164. /**
  39165. * 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)
  39166. * @param uniformName Name of the variable.
  39167. * @param array array to be set.
  39168. * @returns this effect.
  39169. */
  39170. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39171. /**
  39172. * 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)
  39173. * @param uniformName Name of the variable.
  39174. * @param array array to be set.
  39175. * @returns this effect.
  39176. */
  39177. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39178. /**
  39179. * 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)
  39180. * @param uniformName Name of the variable.
  39181. * @param array array to be set.
  39182. * @returns this effect.
  39183. */
  39184. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39185. /**
  39186. * Sets an array on a uniform variable.
  39187. * @param uniformName Name of the variable.
  39188. * @param array array to be set.
  39189. * @returns this effect.
  39190. */
  39191. setArray(uniformName: string, array: number[]): Effect;
  39192. /**
  39193. * 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)
  39194. * @param uniformName Name of the variable.
  39195. * @param array array to be set.
  39196. * @returns this effect.
  39197. */
  39198. setArray2(uniformName: string, array: number[]): Effect;
  39199. /**
  39200. * 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)
  39201. * @param uniformName Name of the variable.
  39202. * @param array array to be set.
  39203. * @returns this effect.
  39204. */
  39205. setArray3(uniformName: string, array: number[]): Effect;
  39206. /**
  39207. * 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)
  39208. * @param uniformName Name of the variable.
  39209. * @param array array to be set.
  39210. * @returns this effect.
  39211. */
  39212. setArray4(uniformName: string, array: number[]): Effect;
  39213. /**
  39214. * Sets matrices on a uniform variable.
  39215. * @param uniformName Name of the variable.
  39216. * @param matrices matrices to be set.
  39217. * @returns this effect.
  39218. */
  39219. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39220. /**
  39221. * Sets matrix on a uniform variable.
  39222. * @param uniformName Name of the variable.
  39223. * @param matrix matrix to be set.
  39224. * @returns this effect.
  39225. */
  39226. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39227. /**
  39228. * 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)
  39229. * @param uniformName Name of the variable.
  39230. * @param matrix matrix to be set.
  39231. * @returns this effect.
  39232. */
  39233. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39234. /**
  39235. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39236. * @param uniformName Name of the variable.
  39237. * @param matrix matrix to be set.
  39238. * @returns this effect.
  39239. */
  39240. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39241. /**
  39242. * Sets a float on a uniform variable.
  39243. * @param uniformName Name of the variable.
  39244. * @param value value to be set.
  39245. * @returns this effect.
  39246. */
  39247. setFloat(uniformName: string, value: number): Effect;
  39248. /**
  39249. * Sets a boolean on a uniform variable.
  39250. * @param uniformName Name of the variable.
  39251. * @param bool value to be set.
  39252. * @returns this effect.
  39253. */
  39254. setBool(uniformName: string, bool: boolean): Effect;
  39255. /**
  39256. * Sets a Vector2 on a uniform variable.
  39257. * @param uniformName Name of the variable.
  39258. * @param vector2 vector2 to be set.
  39259. * @returns this effect.
  39260. */
  39261. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39262. /**
  39263. * Sets a float2 on a uniform variable.
  39264. * @param uniformName Name of the variable.
  39265. * @param x First float in float2.
  39266. * @param y Second float in float2.
  39267. * @returns this effect.
  39268. */
  39269. setFloat2(uniformName: string, x: number, y: number): Effect;
  39270. /**
  39271. * Sets a Vector3 on a uniform variable.
  39272. * @param uniformName Name of the variable.
  39273. * @param vector3 Value to be set.
  39274. * @returns this effect.
  39275. */
  39276. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39277. /**
  39278. * Sets a float3 on a uniform variable.
  39279. * @param uniformName Name of the variable.
  39280. * @param x First float in float3.
  39281. * @param y Second float in float3.
  39282. * @param z Third float in float3.
  39283. * @returns this effect.
  39284. */
  39285. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39286. /**
  39287. * Sets a Vector4 on a uniform variable.
  39288. * @param uniformName Name of the variable.
  39289. * @param vector4 Value to be set.
  39290. * @returns this effect.
  39291. */
  39292. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39293. /**
  39294. * Sets a float4 on a uniform variable.
  39295. * @param uniformName Name of the variable.
  39296. * @param x First float in float4.
  39297. * @param y Second float in float4.
  39298. * @param z Third float in float4.
  39299. * @param w Fourth float in float4.
  39300. * @returns this effect.
  39301. */
  39302. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39303. /**
  39304. * Sets a Color3 on a uniform variable.
  39305. * @param uniformName Name of the variable.
  39306. * @param color3 Value to be set.
  39307. * @returns this effect.
  39308. */
  39309. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39310. /**
  39311. * Sets a Color4 on a uniform variable.
  39312. * @param uniformName Name of the variable.
  39313. * @param color3 Value to be set.
  39314. * @param alpha Alpha value to be set.
  39315. * @returns this effect.
  39316. */
  39317. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39318. /**
  39319. * Sets a Color4 on a uniform variable
  39320. * @param uniformName defines the name of the variable
  39321. * @param color4 defines the value to be set
  39322. * @returns this effect.
  39323. */
  39324. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39325. /** Release all associated resources */
  39326. dispose(): void;
  39327. /**
  39328. * This function will add a new shader to the shader store
  39329. * @param name the name of the shader
  39330. * @param pixelShader optional pixel shader content
  39331. * @param vertexShader optional vertex shader content
  39332. */
  39333. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39334. /**
  39335. * Store of each shader (The can be looked up using effect.key)
  39336. */
  39337. static ShadersStore: {
  39338. [key: string]: string;
  39339. };
  39340. /**
  39341. * Store of each included file for a shader (The can be looked up using effect.key)
  39342. */
  39343. static IncludesShadersStore: {
  39344. [key: string]: string;
  39345. };
  39346. /**
  39347. * Resets the cache of effects.
  39348. */
  39349. static ResetCache(): void;
  39350. }
  39351. }
  39352. declare module "babylonjs/Engines/engineCapabilities" {
  39353. /**
  39354. * Interface used to describe the capabilities of the engine relatively to the current browser
  39355. */
  39356. export interface EngineCapabilities {
  39357. /** Maximum textures units per fragment shader */
  39358. maxTexturesImageUnits: number;
  39359. /** Maximum texture units per vertex shader */
  39360. maxVertexTextureImageUnits: number;
  39361. /** Maximum textures units in the entire pipeline */
  39362. maxCombinedTexturesImageUnits: number;
  39363. /** Maximum texture size */
  39364. maxTextureSize: number;
  39365. /** Maximum texture samples */
  39366. maxSamples?: number;
  39367. /** Maximum cube texture size */
  39368. maxCubemapTextureSize: number;
  39369. /** Maximum render texture size */
  39370. maxRenderTextureSize: number;
  39371. /** Maximum number of vertex attributes */
  39372. maxVertexAttribs: number;
  39373. /** Maximum number of varyings */
  39374. maxVaryingVectors: number;
  39375. /** Maximum number of uniforms per vertex shader */
  39376. maxVertexUniformVectors: number;
  39377. /** Maximum number of uniforms per fragment shader */
  39378. maxFragmentUniformVectors: number;
  39379. /** Defines if standard derivates (dx/dy) are supported */
  39380. standardDerivatives: boolean;
  39381. /** Defines if s3tc texture compression is supported */
  39382. s3tc?: WEBGL_compressed_texture_s3tc;
  39383. /** Defines if pvrtc texture compression is supported */
  39384. pvrtc: any;
  39385. /** Defines if etc1 texture compression is supported */
  39386. etc1: any;
  39387. /** Defines if etc2 texture compression is supported */
  39388. etc2: any;
  39389. /** Defines if astc texture compression is supported */
  39390. astc: any;
  39391. /** Defines if bptc texture compression is supported */
  39392. bptc: any;
  39393. /** Defines if float textures are supported */
  39394. textureFloat: boolean;
  39395. /** Defines if vertex array objects are supported */
  39396. vertexArrayObject: boolean;
  39397. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39398. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39399. /** Gets the maximum level of anisotropy supported */
  39400. maxAnisotropy: number;
  39401. /** Defines if instancing is supported */
  39402. instancedArrays: boolean;
  39403. /** Defines if 32 bits indices are supported */
  39404. uintIndices: boolean;
  39405. /** Defines if high precision shaders are supported */
  39406. highPrecisionShaderSupported: boolean;
  39407. /** Defines if depth reading in the fragment shader is supported */
  39408. fragmentDepthSupported: boolean;
  39409. /** Defines if float texture linear filtering is supported*/
  39410. textureFloatLinearFiltering: boolean;
  39411. /** Defines if rendering to float textures is supported */
  39412. textureFloatRender: boolean;
  39413. /** Defines if half float textures are supported*/
  39414. textureHalfFloat: boolean;
  39415. /** Defines if half float texture linear filtering is supported*/
  39416. textureHalfFloatLinearFiltering: boolean;
  39417. /** Defines if rendering to half float textures is supported */
  39418. textureHalfFloatRender: boolean;
  39419. /** Defines if textureLOD shader command is supported */
  39420. textureLOD: boolean;
  39421. /** Defines if draw buffers extension is supported */
  39422. drawBuffersExtension: boolean;
  39423. /** Defines if depth textures are supported */
  39424. depthTextureExtension: boolean;
  39425. /** Defines if float color buffer are supported */
  39426. colorBufferFloat: boolean;
  39427. /** Gets disjoint timer query extension (null if not supported) */
  39428. timerQuery?: EXT_disjoint_timer_query;
  39429. /** Defines if timestamp can be used with timer query */
  39430. canUseTimestampForTimerQuery: boolean;
  39431. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39432. multiview?: any;
  39433. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39434. oculusMultiview?: any;
  39435. /** Function used to let the system compiles shaders in background */
  39436. parallelShaderCompile?: {
  39437. COMPLETION_STATUS_KHR: number;
  39438. };
  39439. /** Max number of texture samples for MSAA */
  39440. maxMSAASamples: number;
  39441. /** Defines if the blend min max extension is supported */
  39442. blendMinMax: boolean;
  39443. }
  39444. }
  39445. declare module "babylonjs/States/depthCullingState" {
  39446. import { Nullable } from "babylonjs/types";
  39447. /**
  39448. * @hidden
  39449. **/
  39450. export class DepthCullingState {
  39451. private _isDepthTestDirty;
  39452. private _isDepthMaskDirty;
  39453. private _isDepthFuncDirty;
  39454. private _isCullFaceDirty;
  39455. private _isCullDirty;
  39456. private _isZOffsetDirty;
  39457. private _isFrontFaceDirty;
  39458. private _depthTest;
  39459. private _depthMask;
  39460. private _depthFunc;
  39461. private _cull;
  39462. private _cullFace;
  39463. private _zOffset;
  39464. private _frontFace;
  39465. /**
  39466. * Initializes the state.
  39467. */
  39468. constructor();
  39469. get isDirty(): boolean;
  39470. get zOffset(): number;
  39471. set zOffset(value: number);
  39472. get cullFace(): Nullable<number>;
  39473. set cullFace(value: Nullable<number>);
  39474. get cull(): Nullable<boolean>;
  39475. set cull(value: Nullable<boolean>);
  39476. get depthFunc(): Nullable<number>;
  39477. set depthFunc(value: Nullable<number>);
  39478. get depthMask(): boolean;
  39479. set depthMask(value: boolean);
  39480. get depthTest(): boolean;
  39481. set depthTest(value: boolean);
  39482. get frontFace(): Nullable<number>;
  39483. set frontFace(value: Nullable<number>);
  39484. reset(): void;
  39485. apply(gl: WebGLRenderingContext): void;
  39486. }
  39487. }
  39488. declare module "babylonjs/States/stencilState" {
  39489. /**
  39490. * @hidden
  39491. **/
  39492. export class StencilState {
  39493. /** 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 */
  39494. static readonly ALWAYS: number;
  39495. /** Passed to stencilOperation to specify that stencil value must be kept */
  39496. static readonly KEEP: number;
  39497. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39498. static readonly REPLACE: number;
  39499. private _isStencilTestDirty;
  39500. private _isStencilMaskDirty;
  39501. private _isStencilFuncDirty;
  39502. private _isStencilOpDirty;
  39503. private _stencilTest;
  39504. private _stencilMask;
  39505. private _stencilFunc;
  39506. private _stencilFuncRef;
  39507. private _stencilFuncMask;
  39508. private _stencilOpStencilFail;
  39509. private _stencilOpDepthFail;
  39510. private _stencilOpStencilDepthPass;
  39511. get isDirty(): boolean;
  39512. get stencilFunc(): number;
  39513. set stencilFunc(value: number);
  39514. get stencilFuncRef(): number;
  39515. set stencilFuncRef(value: number);
  39516. get stencilFuncMask(): number;
  39517. set stencilFuncMask(value: number);
  39518. get stencilOpStencilFail(): number;
  39519. set stencilOpStencilFail(value: number);
  39520. get stencilOpDepthFail(): number;
  39521. set stencilOpDepthFail(value: number);
  39522. get stencilOpStencilDepthPass(): number;
  39523. set stencilOpStencilDepthPass(value: number);
  39524. get stencilMask(): number;
  39525. set stencilMask(value: number);
  39526. get stencilTest(): boolean;
  39527. set stencilTest(value: boolean);
  39528. constructor();
  39529. reset(): void;
  39530. apply(gl: WebGLRenderingContext): void;
  39531. }
  39532. }
  39533. declare module "babylonjs/States/alphaCullingState" {
  39534. /**
  39535. * @hidden
  39536. **/
  39537. export class AlphaState {
  39538. private _isAlphaBlendDirty;
  39539. private _isBlendFunctionParametersDirty;
  39540. private _isBlendEquationParametersDirty;
  39541. private _isBlendConstantsDirty;
  39542. private _alphaBlend;
  39543. private _blendFunctionParameters;
  39544. private _blendEquationParameters;
  39545. private _blendConstants;
  39546. /**
  39547. * Initializes the state.
  39548. */
  39549. constructor();
  39550. get isDirty(): boolean;
  39551. get alphaBlend(): boolean;
  39552. set alphaBlend(value: boolean);
  39553. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39554. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39555. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39556. reset(): void;
  39557. apply(gl: WebGLRenderingContext): void;
  39558. }
  39559. }
  39560. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39561. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39562. /** @hidden */
  39563. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39564. attributeProcessor(attribute: string): string;
  39565. varyingProcessor(varying: string, isFragment: boolean): string;
  39566. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39567. }
  39568. }
  39569. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39570. /**
  39571. * Interface for attribute information associated with buffer instanciation
  39572. */
  39573. export interface InstancingAttributeInfo {
  39574. /**
  39575. * Name of the GLSL attribute
  39576. * if attribute index is not specified, this is used to retrieve the index from the effect
  39577. */
  39578. attributeName: string;
  39579. /**
  39580. * Index/offset of the attribute in the vertex shader
  39581. * if not specified, this will be computes from the name.
  39582. */
  39583. index?: number;
  39584. /**
  39585. * size of the attribute, 1, 2, 3 or 4
  39586. */
  39587. attributeSize: number;
  39588. /**
  39589. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39590. */
  39591. offset: number;
  39592. /**
  39593. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39594. * default to 1
  39595. */
  39596. divisor?: number;
  39597. /**
  39598. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39599. * default is FLOAT
  39600. */
  39601. attributeType?: number;
  39602. /**
  39603. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39604. */
  39605. normalized?: boolean;
  39606. }
  39607. }
  39608. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39609. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39610. import { Nullable } from "babylonjs/types";
  39611. module "babylonjs/Engines/thinEngine" {
  39612. interface ThinEngine {
  39613. /**
  39614. * Update a video texture
  39615. * @param texture defines the texture to update
  39616. * @param video defines the video element to use
  39617. * @param invertY defines if data must be stored with Y axis inverted
  39618. */
  39619. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39620. }
  39621. }
  39622. }
  39623. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39624. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39625. import { Nullable } from "babylonjs/types";
  39626. module "babylonjs/Engines/thinEngine" {
  39627. interface ThinEngine {
  39628. /**
  39629. * Creates a dynamic texture
  39630. * @param width defines the width of the texture
  39631. * @param height defines the height of the texture
  39632. * @param generateMipMaps defines if the engine should generate the mip levels
  39633. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39634. * @returns the dynamic texture inside an InternalTexture
  39635. */
  39636. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39637. /**
  39638. * Update the content of a dynamic texture
  39639. * @param texture defines the texture to update
  39640. * @param canvas defines the canvas containing the source
  39641. * @param invertY defines if data must be stored with Y axis inverted
  39642. * @param premulAlpha defines if alpha is stored as premultiplied
  39643. * @param format defines the format of the data
  39644. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39645. */
  39646. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39647. }
  39648. }
  39649. }
  39650. declare module "babylonjs/Materials/Textures/videoTexture" {
  39651. import { Observable } from "babylonjs/Misc/observable";
  39652. import { Nullable } from "babylonjs/types";
  39653. import { Scene } from "babylonjs/scene";
  39654. import { Texture } from "babylonjs/Materials/Textures/texture";
  39655. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39656. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39657. /**
  39658. * Settings for finer control over video usage
  39659. */
  39660. export interface VideoTextureSettings {
  39661. /**
  39662. * Applies `autoplay` to video, if specified
  39663. */
  39664. autoPlay?: boolean;
  39665. /**
  39666. * Applies `muted` to video, if specified
  39667. */
  39668. muted?: boolean;
  39669. /**
  39670. * Applies `loop` to video, if specified
  39671. */
  39672. loop?: boolean;
  39673. /**
  39674. * Automatically updates internal texture from video at every frame in the render loop
  39675. */
  39676. autoUpdateTexture: boolean;
  39677. /**
  39678. * Image src displayed during the video loading or until the user interacts with the video.
  39679. */
  39680. poster?: string;
  39681. }
  39682. /**
  39683. * If you want to display a video in your scene, this is the special texture for that.
  39684. * This special texture works similar to other textures, with the exception of a few parameters.
  39685. * @see https://doc.babylonjs.com/how_to/video_texture
  39686. */
  39687. export class VideoTexture extends Texture {
  39688. /**
  39689. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39690. */
  39691. readonly autoUpdateTexture: boolean;
  39692. /**
  39693. * The video instance used by the texture internally
  39694. */
  39695. readonly video: HTMLVideoElement;
  39696. private _onUserActionRequestedObservable;
  39697. /**
  39698. * Event triggerd when a dom action is required by the user to play the video.
  39699. * This happens due to recent changes in browser policies preventing video to auto start.
  39700. */
  39701. get onUserActionRequestedObservable(): Observable<Texture>;
  39702. private _generateMipMaps;
  39703. private _stillImageCaptured;
  39704. private _displayingPosterTexture;
  39705. private _settings;
  39706. private _createInternalTextureOnEvent;
  39707. private _frameId;
  39708. private _currentSrc;
  39709. /**
  39710. * Creates a video texture.
  39711. * If you want to display a video in your scene, this is the special texture for that.
  39712. * This special texture works similar to other textures, with the exception of a few parameters.
  39713. * @see https://doc.babylonjs.com/how_to/video_texture
  39714. * @param name optional name, will detect from video source, if not defined
  39715. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39716. * @param scene is obviously the current scene.
  39717. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39718. * @param invertY is false by default but can be used to invert video on Y axis
  39719. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39720. * @param settings allows finer control over video usage
  39721. */
  39722. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39723. private _getName;
  39724. private _getVideo;
  39725. private _createInternalTexture;
  39726. private reset;
  39727. /**
  39728. * @hidden Internal method to initiate `update`.
  39729. */
  39730. _rebuild(): void;
  39731. /**
  39732. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39733. */
  39734. update(): void;
  39735. /**
  39736. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39737. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39738. */
  39739. updateTexture(isVisible: boolean): void;
  39740. protected _updateInternalTexture: () => void;
  39741. /**
  39742. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39743. * @param url New url.
  39744. */
  39745. updateURL(url: string): void;
  39746. /**
  39747. * Clones the texture.
  39748. * @returns the cloned texture
  39749. */
  39750. clone(): VideoTexture;
  39751. /**
  39752. * Dispose the texture and release its associated resources.
  39753. */
  39754. dispose(): void;
  39755. /**
  39756. * Creates a video texture straight from a stream.
  39757. * @param scene Define the scene the texture should be created in
  39758. * @param stream Define the stream the texture should be created from
  39759. * @returns The created video texture as a promise
  39760. */
  39761. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39762. /**
  39763. * Creates a video texture straight from your WebCam video feed.
  39764. * @param scene Define the scene the texture should be created in
  39765. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39766. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39767. * @returns The created video texture as a promise
  39768. */
  39769. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39770. minWidth: number;
  39771. maxWidth: number;
  39772. minHeight: number;
  39773. maxHeight: number;
  39774. deviceId: string;
  39775. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39776. /**
  39777. * Creates a video texture straight from your WebCam video feed.
  39778. * @param scene Define the scene the texture should be created in
  39779. * @param onReady Define a callback to triggered once the texture will be ready
  39780. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39781. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39782. */
  39783. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39784. minWidth: number;
  39785. maxWidth: number;
  39786. minHeight: number;
  39787. maxHeight: number;
  39788. deviceId: string;
  39789. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39790. }
  39791. }
  39792. declare module "babylonjs/Engines/thinEngine" {
  39793. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  39794. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  39795. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39796. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39797. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  39798. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  39799. import { Observable } from "babylonjs/Misc/observable";
  39800. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  39801. import { StencilState } from "babylonjs/States/stencilState";
  39802. import { AlphaState } from "babylonjs/States/alphaCullingState";
  39803. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39804. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  39805. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39806. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39807. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39808. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  39809. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  39810. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  39811. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39812. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39813. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39814. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  39815. import { WebRequest } from "babylonjs/Misc/webRequest";
  39816. import { LoadFileError } from "babylonjs/Misc/fileTools";
  39817. /**
  39818. * Defines the interface used by objects working like Scene
  39819. * @hidden
  39820. */
  39821. export interface ISceneLike {
  39822. _addPendingData(data: any): void;
  39823. _removePendingData(data: any): void;
  39824. offlineProvider: IOfflineProvider;
  39825. }
  39826. /**
  39827. * Information about the current host
  39828. */
  39829. export interface HostInformation {
  39830. /**
  39831. * Defines if the current host is a mobile
  39832. */
  39833. isMobile: boolean;
  39834. }
  39835. /** Interface defining initialization parameters for Engine class */
  39836. export interface EngineOptions extends WebGLContextAttributes {
  39837. /**
  39838. * Defines if the engine should no exceed a specified device ratio
  39839. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39840. */
  39841. limitDeviceRatio?: number;
  39842. /**
  39843. * Defines if webvr should be enabled automatically
  39844. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39845. */
  39846. autoEnableWebVR?: boolean;
  39847. /**
  39848. * Defines if webgl2 should be turned off even if supported
  39849. * @see https://doc.babylonjs.com/features/webgl2
  39850. */
  39851. disableWebGL2Support?: boolean;
  39852. /**
  39853. * Defines if webaudio should be initialized as well
  39854. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39855. */
  39856. audioEngine?: boolean;
  39857. /**
  39858. * Defines if animations should run using a deterministic lock step
  39859. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39860. */
  39861. deterministicLockstep?: boolean;
  39862. /** Defines the maximum steps to use with deterministic lock step mode */
  39863. lockstepMaxSteps?: number;
  39864. /** Defines the seconds between each deterministic lock step */
  39865. timeStep?: number;
  39866. /**
  39867. * Defines that engine should ignore context lost events
  39868. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39869. */
  39870. doNotHandleContextLost?: boolean;
  39871. /**
  39872. * Defines that engine should ignore modifying touch action attribute and style
  39873. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39874. */
  39875. doNotHandleTouchAction?: boolean;
  39876. /**
  39877. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39878. */
  39879. useHighPrecisionFloats?: boolean;
  39880. /**
  39881. * Make the canvas XR Compatible for XR sessions
  39882. */
  39883. xrCompatible?: boolean;
  39884. /**
  39885. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39886. */
  39887. useHighPrecisionMatrix?: boolean;
  39888. /**
  39889. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39890. */
  39891. failIfMajorPerformanceCaveat?: boolean;
  39892. }
  39893. /**
  39894. * The base engine class (root of all engines)
  39895. */
  39896. export class ThinEngine {
  39897. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39898. static ExceptionList: ({
  39899. key: string;
  39900. capture: string;
  39901. captureConstraint: number;
  39902. targets: string[];
  39903. } | {
  39904. key: string;
  39905. capture: null;
  39906. captureConstraint: null;
  39907. targets: string[];
  39908. })[];
  39909. /** @hidden */
  39910. static _TextureLoaders: IInternalTextureLoader[];
  39911. /**
  39912. * Returns the current npm package of the sdk
  39913. */
  39914. static get NpmPackage(): string;
  39915. /**
  39916. * Returns the current version of the framework
  39917. */
  39918. static get Version(): string;
  39919. /**
  39920. * Returns a string describing the current engine
  39921. */
  39922. get description(): string;
  39923. /**
  39924. * Gets or sets the epsilon value used by collision engine
  39925. */
  39926. static CollisionsEpsilon: number;
  39927. /**
  39928. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39929. */
  39930. static get ShadersRepository(): string;
  39931. static set ShadersRepository(value: string);
  39932. /** @hidden */
  39933. _shaderProcessor: IShaderProcessor;
  39934. /**
  39935. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39936. */
  39937. forcePOTTextures: boolean;
  39938. /**
  39939. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39940. */
  39941. isFullscreen: boolean;
  39942. /**
  39943. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39944. */
  39945. cullBackFaces: boolean;
  39946. /**
  39947. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39948. */
  39949. renderEvenInBackground: boolean;
  39950. /**
  39951. * Gets or sets a boolean indicating that cache can be kept between frames
  39952. */
  39953. preventCacheWipeBetweenFrames: boolean;
  39954. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39955. validateShaderPrograms: boolean;
  39956. /**
  39957. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39958. * This can provide greater z depth for distant objects.
  39959. */
  39960. useReverseDepthBuffer: boolean;
  39961. /**
  39962. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39963. */
  39964. disableUniformBuffers: boolean;
  39965. /** @hidden */
  39966. _uniformBuffers: UniformBuffer[];
  39967. /**
  39968. * Gets a boolean indicating that the engine supports uniform buffers
  39969. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39970. */
  39971. get supportsUniformBuffers(): boolean;
  39972. /** @hidden */
  39973. _gl: WebGLRenderingContext;
  39974. /** @hidden */
  39975. _webGLVersion: number;
  39976. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39977. protected _windowIsBackground: boolean;
  39978. protected _creationOptions: EngineOptions;
  39979. protected _highPrecisionShadersAllowed: boolean;
  39980. /** @hidden */
  39981. get _shouldUseHighPrecisionShader(): boolean;
  39982. /**
  39983. * Gets a boolean indicating that only power of 2 textures are supported
  39984. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39985. */
  39986. get needPOTTextures(): boolean;
  39987. /** @hidden */
  39988. _badOS: boolean;
  39989. /** @hidden */
  39990. _badDesktopOS: boolean;
  39991. private _hardwareScalingLevel;
  39992. /** @hidden */
  39993. _caps: EngineCapabilities;
  39994. private _isStencilEnable;
  39995. private _glVersion;
  39996. private _glRenderer;
  39997. private _glVendor;
  39998. /** @hidden */
  39999. _videoTextureSupported: boolean;
  40000. protected _renderingQueueLaunched: boolean;
  40001. protected _activeRenderLoops: (() => void)[];
  40002. /**
  40003. * Observable signaled when a context lost event is raised
  40004. */
  40005. onContextLostObservable: Observable<ThinEngine>;
  40006. /**
  40007. * Observable signaled when a context restored event is raised
  40008. */
  40009. onContextRestoredObservable: Observable<ThinEngine>;
  40010. private _onContextLost;
  40011. private _onContextRestored;
  40012. protected _contextWasLost: boolean;
  40013. /** @hidden */
  40014. _doNotHandleContextLost: boolean;
  40015. /**
  40016. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40017. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40018. */
  40019. get doNotHandleContextLost(): boolean;
  40020. set doNotHandleContextLost(value: boolean);
  40021. /**
  40022. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40023. */
  40024. disableVertexArrayObjects: boolean;
  40025. /** @hidden */
  40026. protected _colorWrite: boolean;
  40027. /** @hidden */
  40028. protected _colorWriteChanged: boolean;
  40029. /** @hidden */
  40030. protected _depthCullingState: DepthCullingState;
  40031. /** @hidden */
  40032. protected _stencilState: StencilState;
  40033. /** @hidden */
  40034. _alphaState: AlphaState;
  40035. /** @hidden */
  40036. _alphaMode: number;
  40037. /** @hidden */
  40038. _alphaEquation: number;
  40039. /** @hidden */
  40040. _internalTexturesCache: InternalTexture[];
  40041. /** @hidden */
  40042. protected _activeChannel: number;
  40043. private _currentTextureChannel;
  40044. /** @hidden */
  40045. protected _boundTexturesCache: {
  40046. [key: string]: Nullable<InternalTexture>;
  40047. };
  40048. /** @hidden */
  40049. protected _currentEffect: Nullable<Effect>;
  40050. /** @hidden */
  40051. protected _currentProgram: Nullable<WebGLProgram>;
  40052. private _compiledEffects;
  40053. private _vertexAttribArraysEnabled;
  40054. /** @hidden */
  40055. protected _cachedViewport: Nullable<IViewportLike>;
  40056. private _cachedVertexArrayObject;
  40057. /** @hidden */
  40058. protected _cachedVertexBuffers: any;
  40059. /** @hidden */
  40060. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40061. /** @hidden */
  40062. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40063. /** @hidden */
  40064. _currentRenderTarget: Nullable<InternalTexture>;
  40065. private _uintIndicesCurrentlySet;
  40066. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40067. /** @hidden */
  40068. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40069. /** @hidden */
  40070. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40071. private _currentBufferPointers;
  40072. private _currentInstanceLocations;
  40073. private _currentInstanceBuffers;
  40074. private _textureUnits;
  40075. /** @hidden */
  40076. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40077. /** @hidden */
  40078. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40079. /** @hidden */
  40080. _boundRenderFunction: any;
  40081. private _vaoRecordInProgress;
  40082. private _mustWipeVertexAttributes;
  40083. private _emptyTexture;
  40084. private _emptyCubeTexture;
  40085. private _emptyTexture3D;
  40086. private _emptyTexture2DArray;
  40087. /** @hidden */
  40088. _frameHandler: number;
  40089. private _nextFreeTextureSlots;
  40090. private _maxSimultaneousTextures;
  40091. private _activeRequests;
  40092. /** @hidden */
  40093. _transformTextureUrl: Nullable<(url: string) => string>;
  40094. /**
  40095. * Gets information about the current host
  40096. */
  40097. hostInformation: HostInformation;
  40098. protected get _supportsHardwareTextureRescaling(): boolean;
  40099. private _framebufferDimensionsObject;
  40100. /**
  40101. * sets the object from which width and height will be taken from when getting render width and height
  40102. * Will fallback to the gl object
  40103. * @param dimensions the framebuffer width and height that will be used.
  40104. */
  40105. set framebufferDimensionsObject(dimensions: Nullable<{
  40106. framebufferWidth: number;
  40107. framebufferHeight: number;
  40108. }>);
  40109. /**
  40110. * Gets the current viewport
  40111. */
  40112. get currentViewport(): Nullable<IViewportLike>;
  40113. /**
  40114. * Gets the default empty texture
  40115. */
  40116. get emptyTexture(): InternalTexture;
  40117. /**
  40118. * Gets the default empty 3D texture
  40119. */
  40120. get emptyTexture3D(): InternalTexture;
  40121. /**
  40122. * Gets the default empty 2D array texture
  40123. */
  40124. get emptyTexture2DArray(): InternalTexture;
  40125. /**
  40126. * Gets the default empty cube texture
  40127. */
  40128. get emptyCubeTexture(): InternalTexture;
  40129. /**
  40130. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40131. */
  40132. readonly premultipliedAlpha: boolean;
  40133. /**
  40134. * Observable event triggered before each texture is initialized
  40135. */
  40136. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40137. /**
  40138. * Creates a new engine
  40139. * @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
  40140. * @param antialias defines enable antialiasing (default: false)
  40141. * @param options defines further options to be sent to the getContext() function
  40142. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40143. */
  40144. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40145. private _rebuildInternalTextures;
  40146. private _rebuildEffects;
  40147. /**
  40148. * Gets a boolean indicating if all created effects are ready
  40149. * @returns true if all effects are ready
  40150. */
  40151. areAllEffectsReady(): boolean;
  40152. protected _rebuildBuffers(): void;
  40153. protected _initGLContext(): void;
  40154. /**
  40155. * Gets version of the current webGL context
  40156. */
  40157. get webGLVersion(): number;
  40158. /**
  40159. * Gets a string identifying the name of the class
  40160. * @returns "Engine" string
  40161. */
  40162. getClassName(): string;
  40163. /**
  40164. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40165. */
  40166. get isStencilEnable(): boolean;
  40167. /** @hidden */
  40168. _prepareWorkingCanvas(): void;
  40169. /**
  40170. * Reset the texture cache to empty state
  40171. */
  40172. resetTextureCache(): void;
  40173. /**
  40174. * Gets an object containing information about the current webGL context
  40175. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40176. */
  40177. getGlInfo(): {
  40178. vendor: string;
  40179. renderer: string;
  40180. version: string;
  40181. };
  40182. /**
  40183. * Defines the hardware scaling level.
  40184. * By default the hardware scaling level is computed from the window device ratio.
  40185. * 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.
  40186. * @param level defines the level to use
  40187. */
  40188. setHardwareScalingLevel(level: number): void;
  40189. /**
  40190. * Gets the current hardware scaling level.
  40191. * By default the hardware scaling level is computed from the window device ratio.
  40192. * 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.
  40193. * @returns a number indicating the current hardware scaling level
  40194. */
  40195. getHardwareScalingLevel(): number;
  40196. /**
  40197. * Gets the list of loaded textures
  40198. * @returns an array containing all loaded textures
  40199. */
  40200. getLoadedTexturesCache(): InternalTexture[];
  40201. /**
  40202. * Gets the object containing all engine capabilities
  40203. * @returns the EngineCapabilities object
  40204. */
  40205. getCaps(): EngineCapabilities;
  40206. /**
  40207. * stop executing a render loop function and remove it from the execution array
  40208. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40209. */
  40210. stopRenderLoop(renderFunction?: () => void): void;
  40211. /** @hidden */
  40212. _renderLoop(): void;
  40213. /**
  40214. * Gets the HTML canvas attached with the current webGL context
  40215. * @returns a HTML canvas
  40216. */
  40217. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40218. /**
  40219. * Gets host window
  40220. * @returns the host window object
  40221. */
  40222. getHostWindow(): Nullable<Window>;
  40223. /**
  40224. * Gets the current render width
  40225. * @param useScreen defines if screen size must be used (or the current render target if any)
  40226. * @returns a number defining the current render width
  40227. */
  40228. getRenderWidth(useScreen?: boolean): number;
  40229. /**
  40230. * Gets the current render height
  40231. * @param useScreen defines if screen size must be used (or the current render target if any)
  40232. * @returns a number defining the current render height
  40233. */
  40234. getRenderHeight(useScreen?: boolean): number;
  40235. /**
  40236. * Can be used to override the current requestAnimationFrame requester.
  40237. * @hidden
  40238. */
  40239. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40240. /**
  40241. * Register and execute a render loop. The engine can have more than one render function
  40242. * @param renderFunction defines the function to continuously execute
  40243. */
  40244. runRenderLoop(renderFunction: () => void): void;
  40245. /**
  40246. * Clear the current render buffer or the current render target (if any is set up)
  40247. * @param color defines the color to use
  40248. * @param backBuffer defines if the back buffer must be cleared
  40249. * @param depth defines if the depth buffer must be cleared
  40250. * @param stencil defines if the stencil buffer must be cleared
  40251. */
  40252. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40253. private _viewportCached;
  40254. /** @hidden */
  40255. _viewport(x: number, y: number, width: number, height: number): void;
  40256. /**
  40257. * Set the WebGL's viewport
  40258. * @param viewport defines the viewport element to be used
  40259. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40260. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40261. */
  40262. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40263. /**
  40264. * Begin a new frame
  40265. */
  40266. beginFrame(): void;
  40267. /**
  40268. * Enf the current frame
  40269. */
  40270. endFrame(): void;
  40271. /**
  40272. * Resize the view according to the canvas' size
  40273. */
  40274. resize(): void;
  40275. /**
  40276. * Force a specific size of the canvas
  40277. * @param width defines the new canvas' width
  40278. * @param height defines the new canvas' height
  40279. * @returns true if the size was changed
  40280. */
  40281. setSize(width: number, height: number): boolean;
  40282. /**
  40283. * Binds the frame buffer to the specified texture.
  40284. * @param texture The texture to render to or null for the default canvas
  40285. * @param faceIndex The face of the texture to render to in case of cube texture
  40286. * @param requiredWidth The width of the target to render to
  40287. * @param requiredHeight The height of the target to render to
  40288. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40289. * @param lodLevel defines the lod level to bind to the frame buffer
  40290. * @param layer defines the 2d array index to bind to frame buffer to
  40291. */
  40292. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40293. /** @hidden */
  40294. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40295. /**
  40296. * Unbind the current render target texture from the webGL context
  40297. * @param texture defines the render target texture to unbind
  40298. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40299. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40300. */
  40301. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40302. /**
  40303. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40304. */
  40305. flushFramebuffer(): void;
  40306. /**
  40307. * Unbind the current render target and bind the default framebuffer
  40308. */
  40309. restoreDefaultFramebuffer(): void;
  40310. /** @hidden */
  40311. protected _resetVertexBufferBinding(): void;
  40312. /**
  40313. * Creates a vertex buffer
  40314. * @param data the data for the vertex buffer
  40315. * @returns the new WebGL static buffer
  40316. */
  40317. createVertexBuffer(data: DataArray): DataBuffer;
  40318. private _createVertexBuffer;
  40319. /**
  40320. * Creates a dynamic vertex buffer
  40321. * @param data the data for the dynamic vertex buffer
  40322. * @returns the new WebGL dynamic buffer
  40323. */
  40324. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40325. protected _resetIndexBufferBinding(): void;
  40326. /**
  40327. * Creates a new index buffer
  40328. * @param indices defines the content of the index buffer
  40329. * @param updatable defines if the index buffer must be updatable
  40330. * @returns a new webGL buffer
  40331. */
  40332. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40333. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40334. /**
  40335. * Bind a webGL buffer to the webGL context
  40336. * @param buffer defines the buffer to bind
  40337. */
  40338. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40339. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40340. private bindBuffer;
  40341. /**
  40342. * update the bound buffer with the given data
  40343. * @param data defines the data to update
  40344. */
  40345. updateArrayBuffer(data: Float32Array): void;
  40346. private _vertexAttribPointer;
  40347. /** @hidden */
  40348. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40349. private _bindVertexBuffersAttributes;
  40350. /**
  40351. * Records a vertex array object
  40352. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40353. * @param vertexBuffers defines the list of vertex buffers to store
  40354. * @param indexBuffer defines the index buffer to store
  40355. * @param effect defines the effect to store
  40356. * @returns the new vertex array object
  40357. */
  40358. recordVertexArrayObject(vertexBuffers: {
  40359. [key: string]: VertexBuffer;
  40360. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40361. /**
  40362. * Bind a specific vertex array object
  40363. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40364. * @param vertexArrayObject defines the vertex array object to bind
  40365. * @param indexBuffer defines the index buffer to bind
  40366. */
  40367. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40368. /**
  40369. * Bind webGl buffers directly to the webGL context
  40370. * @param vertexBuffer defines the vertex buffer to bind
  40371. * @param indexBuffer defines the index buffer to bind
  40372. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40373. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40374. * @param effect defines the effect associated with the vertex buffer
  40375. */
  40376. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40377. private _unbindVertexArrayObject;
  40378. /**
  40379. * Bind a list of vertex buffers to the webGL context
  40380. * @param vertexBuffers defines the list of vertex buffers to bind
  40381. * @param indexBuffer defines the index buffer to bind
  40382. * @param effect defines the effect associated with the vertex buffers
  40383. */
  40384. bindBuffers(vertexBuffers: {
  40385. [key: string]: Nullable<VertexBuffer>;
  40386. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40387. /**
  40388. * Unbind all instance attributes
  40389. */
  40390. unbindInstanceAttributes(): void;
  40391. /**
  40392. * Release and free the memory of a vertex array object
  40393. * @param vao defines the vertex array object to delete
  40394. */
  40395. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40396. /** @hidden */
  40397. _releaseBuffer(buffer: DataBuffer): boolean;
  40398. protected _deleteBuffer(buffer: DataBuffer): void;
  40399. /**
  40400. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40401. * @param instancesBuffer defines the webGL buffer to update and bind
  40402. * @param data defines the data to store in the buffer
  40403. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40404. */
  40405. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40406. /**
  40407. * Bind the content of a webGL buffer used with instantiation
  40408. * @param instancesBuffer defines the webGL buffer to bind
  40409. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40410. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40411. */
  40412. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40413. /**
  40414. * Disable the instance attribute corresponding to the name in parameter
  40415. * @param name defines the name of the attribute to disable
  40416. */
  40417. disableInstanceAttributeByName(name: string): void;
  40418. /**
  40419. * Disable the instance attribute corresponding to the location in parameter
  40420. * @param attributeLocation defines the attribute location of the attribute to disable
  40421. */
  40422. disableInstanceAttribute(attributeLocation: number): void;
  40423. /**
  40424. * Disable the attribute corresponding to the location in parameter
  40425. * @param attributeLocation defines the attribute location of the attribute to disable
  40426. */
  40427. disableAttributeByIndex(attributeLocation: number): void;
  40428. /**
  40429. * Send a draw order
  40430. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40431. * @param indexStart defines the starting index
  40432. * @param indexCount defines the number of index to draw
  40433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40434. */
  40435. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40436. /**
  40437. * Draw a list of points
  40438. * @param verticesStart defines the index of first vertex to draw
  40439. * @param verticesCount defines the count of vertices to draw
  40440. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40441. */
  40442. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40443. /**
  40444. * Draw a list of unindexed primitives
  40445. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40446. * @param verticesStart defines the index of first vertex to draw
  40447. * @param verticesCount defines the count of vertices to draw
  40448. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40449. */
  40450. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40451. /**
  40452. * Draw a list of indexed primitives
  40453. * @param fillMode defines the primitive to use
  40454. * @param indexStart defines the starting index
  40455. * @param indexCount defines the number of index to draw
  40456. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40457. */
  40458. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40459. /**
  40460. * Draw a list of unindexed primitives
  40461. * @param fillMode defines the primitive to use
  40462. * @param verticesStart defines the index of first vertex to draw
  40463. * @param verticesCount defines the count of vertices to draw
  40464. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40465. */
  40466. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40467. private _drawMode;
  40468. /** @hidden */
  40469. protected _reportDrawCall(): void;
  40470. /** @hidden */
  40471. _releaseEffect(effect: Effect): void;
  40472. /** @hidden */
  40473. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40474. /**
  40475. * Create a new effect (used to store vertex/fragment shaders)
  40476. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40477. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40478. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40479. * @param samplers defines an array of string used to represent textures
  40480. * @param defines defines the string containing the defines to use to compile the shaders
  40481. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40482. * @param onCompiled defines a function to call when the effect creation is successful
  40483. * @param onError defines a function to call when the effect creation has failed
  40484. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40485. * @returns the new Effect
  40486. */
  40487. 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;
  40488. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40489. private _compileShader;
  40490. private _compileRawShader;
  40491. /** @hidden */
  40492. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40493. /**
  40494. * Directly creates a webGL program
  40495. * @param pipelineContext defines the pipeline context to attach to
  40496. * @param vertexCode defines the vertex shader code to use
  40497. * @param fragmentCode defines the fragment shader code to use
  40498. * @param context defines the webGL context to use (if not set, the current one will be used)
  40499. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40500. * @returns the new webGL program
  40501. */
  40502. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40503. /**
  40504. * Creates a webGL program
  40505. * @param pipelineContext defines the pipeline context to attach to
  40506. * @param vertexCode defines the vertex shader code to use
  40507. * @param fragmentCode defines the fragment shader code to use
  40508. * @param defines defines the string containing the defines to use to compile the shaders
  40509. * @param context defines the webGL context to use (if not set, the current one will be used)
  40510. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40511. * @returns the new webGL program
  40512. */
  40513. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40514. /**
  40515. * Creates a new pipeline context
  40516. * @returns the new pipeline
  40517. */
  40518. createPipelineContext(): IPipelineContext;
  40519. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40520. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40521. /** @hidden */
  40522. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40523. /** @hidden */
  40524. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40525. /** @hidden */
  40526. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40527. /**
  40528. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40529. * @param pipelineContext defines the pipeline context to use
  40530. * @param uniformsNames defines the list of uniform names
  40531. * @returns an array of webGL uniform locations
  40532. */
  40533. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40534. /**
  40535. * Gets the lsit of active attributes for a given webGL program
  40536. * @param pipelineContext defines the pipeline context to use
  40537. * @param attributesNames defines the list of attribute names to get
  40538. * @returns an array of indices indicating the offset of each attribute
  40539. */
  40540. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40541. /**
  40542. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40543. * @param effect defines the effect to activate
  40544. */
  40545. enableEffect(effect: Nullable<Effect>): void;
  40546. /**
  40547. * Set the value of an uniform to a number (int)
  40548. * @param uniform defines the webGL uniform location where to store the value
  40549. * @param value defines the int number to store
  40550. * @returns true if the value was set
  40551. */
  40552. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40553. /**
  40554. * Set the value of an uniform to an array of int32
  40555. * @param uniform defines the webGL uniform location where to store the value
  40556. * @param array defines the array of int32 to store
  40557. * @returns true if the value was set
  40558. */
  40559. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40560. /**
  40561. * Set the value of an uniform to an array of int32 (stored as vec2)
  40562. * @param uniform defines the webGL uniform location where to store the value
  40563. * @param array defines the array of int32 to store
  40564. * @returns true if the value was set
  40565. */
  40566. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40567. /**
  40568. * Set the value of an uniform to an array of int32 (stored as vec3)
  40569. * @param uniform defines the webGL uniform location where to store the value
  40570. * @param array defines the array of int32 to store
  40571. * @returns true if the value was set
  40572. */
  40573. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40574. /**
  40575. * Set the value of an uniform to an array of int32 (stored as vec4)
  40576. * @param uniform defines the webGL uniform location where to store the value
  40577. * @param array defines the array of int32 to store
  40578. * @returns true if the value was set
  40579. */
  40580. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40581. /**
  40582. * Set the value of an uniform to an array of number
  40583. * @param uniform defines the webGL uniform location where to store the value
  40584. * @param array defines the array of number to store
  40585. * @returns true if the value was set
  40586. */
  40587. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40588. /**
  40589. * Set the value of an uniform to an array of number (stored as vec2)
  40590. * @param uniform defines the webGL uniform location where to store the value
  40591. * @param array defines the array of number to store
  40592. * @returns true if the value was set
  40593. */
  40594. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40595. /**
  40596. * Set the value of an uniform to an array of number (stored as vec3)
  40597. * @param uniform defines the webGL uniform location where to store the value
  40598. * @param array defines the array of number to store
  40599. * @returns true if the value was set
  40600. */
  40601. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40602. /**
  40603. * Set the value of an uniform to an array of number (stored as vec4)
  40604. * @param uniform defines the webGL uniform location where to store the value
  40605. * @param array defines the array of number to store
  40606. * @returns true if the value was set
  40607. */
  40608. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40609. /**
  40610. * Set the value of an uniform to an array of float32 (stored as matrices)
  40611. * @param uniform defines the webGL uniform location where to store the value
  40612. * @param matrices defines the array of float32 to store
  40613. * @returns true if the value was set
  40614. */
  40615. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40616. /**
  40617. * Set the value of an uniform to a matrix (3x3)
  40618. * @param uniform defines the webGL uniform location where to store the value
  40619. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40620. * @returns true if the value was set
  40621. */
  40622. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40623. /**
  40624. * Set the value of an uniform to a matrix (2x2)
  40625. * @param uniform defines the webGL uniform location where to store the value
  40626. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40627. * @returns true if the value was set
  40628. */
  40629. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40630. /**
  40631. * Set the value of an uniform to a number (float)
  40632. * @param uniform defines the webGL uniform location where to store the value
  40633. * @param value defines the float number to store
  40634. * @returns true if the value was transfered
  40635. */
  40636. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40637. /**
  40638. * Set the value of an uniform to a vec2
  40639. * @param uniform defines the webGL uniform location where to store the value
  40640. * @param x defines the 1st component of the value
  40641. * @param y defines the 2nd component of the value
  40642. * @returns true if the value was set
  40643. */
  40644. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40645. /**
  40646. * Set the value of an uniform to a vec3
  40647. * @param uniform defines the webGL uniform location where to store the value
  40648. * @param x defines the 1st component of the value
  40649. * @param y defines the 2nd component of the value
  40650. * @param z defines the 3rd component of the value
  40651. * @returns true if the value was set
  40652. */
  40653. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40654. /**
  40655. * Set the value of an uniform to a vec4
  40656. * @param uniform defines the webGL uniform location where to store the value
  40657. * @param x defines the 1st component of the value
  40658. * @param y defines the 2nd component of the value
  40659. * @param z defines the 3rd component of the value
  40660. * @param w defines the 4th component of the value
  40661. * @returns true if the value was set
  40662. */
  40663. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40664. /**
  40665. * Apply all cached states (depth, culling, stencil and alpha)
  40666. */
  40667. applyStates(): void;
  40668. /**
  40669. * Enable or disable color writing
  40670. * @param enable defines the state to set
  40671. */
  40672. setColorWrite(enable: boolean): void;
  40673. /**
  40674. * Gets a boolean indicating if color writing is enabled
  40675. * @returns the current color writing state
  40676. */
  40677. getColorWrite(): boolean;
  40678. /**
  40679. * Gets the depth culling state manager
  40680. */
  40681. get depthCullingState(): DepthCullingState;
  40682. /**
  40683. * Gets the alpha state manager
  40684. */
  40685. get alphaState(): AlphaState;
  40686. /**
  40687. * Gets the stencil state manager
  40688. */
  40689. get stencilState(): StencilState;
  40690. /**
  40691. * Clears the list of texture accessible through engine.
  40692. * This can help preventing texture load conflict due to name collision.
  40693. */
  40694. clearInternalTexturesCache(): void;
  40695. /**
  40696. * Force the entire cache to be cleared
  40697. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40698. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40699. */
  40700. wipeCaches(bruteForce?: boolean): void;
  40701. /** @hidden */
  40702. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40703. min: number;
  40704. mag: number;
  40705. };
  40706. /** @hidden */
  40707. _createTexture(): WebGLTexture;
  40708. /**
  40709. * Usually called from Texture.ts.
  40710. * Passed information to create a WebGLTexture
  40711. * @param url defines a value which contains one of the following:
  40712. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40713. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40714. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40715. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40716. * @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)
  40717. * @param scene needed for loading to the correct scene
  40718. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40719. * @param onLoad optional callback to be called upon successful completion
  40720. * @param onError optional callback to be called upon failure
  40721. * @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
  40722. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40723. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40724. * @param forcedExtension defines the extension to use to pick the right loader
  40725. * @param mimeType defines an optional mime type
  40726. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40727. */
  40728. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  40729. /**
  40730. * Loads an image as an HTMLImageElement.
  40731. * @param input url string, ArrayBuffer, or Blob to load
  40732. * @param onLoad callback called when the image successfully loads
  40733. * @param onError callback called when the image fails to load
  40734. * @param offlineProvider offline provider for caching
  40735. * @param mimeType optional mime type
  40736. * @returns the HTMLImageElement of the loaded image
  40737. * @hidden
  40738. */
  40739. 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>;
  40740. /**
  40741. * @hidden
  40742. */
  40743. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40744. private _unpackFlipYCached;
  40745. /**
  40746. * In case you are sharing the context with other applications, it might
  40747. * be interested to not cache the unpack flip y state to ensure a consistent
  40748. * value would be set.
  40749. */
  40750. enableUnpackFlipYCached: boolean;
  40751. /** @hidden */
  40752. _unpackFlipY(value: boolean): void;
  40753. /** @hidden */
  40754. _getUnpackAlignement(): number;
  40755. private _getTextureTarget;
  40756. /**
  40757. * Update the sampling mode of a given texture
  40758. * @param samplingMode defines the required sampling mode
  40759. * @param texture defines the texture to update
  40760. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40761. */
  40762. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40763. /**
  40764. * Update the sampling mode of a given texture
  40765. * @param texture defines the texture to update
  40766. * @param wrapU defines the texture wrap mode of the u coordinates
  40767. * @param wrapV defines the texture wrap mode of the v coordinates
  40768. * @param wrapR defines the texture wrap mode of the r coordinates
  40769. */
  40770. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40771. /** @hidden */
  40772. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40773. width: number;
  40774. height: number;
  40775. layers?: number;
  40776. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  40777. /** @hidden */
  40778. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40779. /** @hidden */
  40780. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40781. /**
  40782. * Update a portion of an internal texture
  40783. * @param texture defines the texture to update
  40784. * @param imageData defines the data to store into the texture
  40785. * @param xOffset defines the x coordinates of the update rectangle
  40786. * @param yOffset defines the y coordinates of the update rectangle
  40787. * @param width defines the width of the update rectangle
  40788. * @param height defines the height of the update rectangle
  40789. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40790. * @param lod defines the lod level to update (0 by default)
  40791. */
  40792. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40793. /** @hidden */
  40794. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40795. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40796. private _prepareWebGLTexture;
  40797. /** @hidden */
  40798. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40799. private _getDepthStencilBuffer;
  40800. /** @hidden */
  40801. _releaseFramebufferObjects(texture: InternalTexture): void;
  40802. /** @hidden */
  40803. _releaseTexture(texture: InternalTexture): void;
  40804. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40805. protected _setProgram(program: WebGLProgram): void;
  40806. protected _boundUniforms: {
  40807. [key: number]: WebGLUniformLocation;
  40808. };
  40809. /**
  40810. * Binds an effect to the webGL context
  40811. * @param effect defines the effect to bind
  40812. */
  40813. bindSamplers(effect: Effect): void;
  40814. private _activateCurrentTexture;
  40815. /** @hidden */
  40816. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40817. /** @hidden */
  40818. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  40819. /**
  40820. * Unbind all textures from the webGL context
  40821. */
  40822. unbindAllTextures(): void;
  40823. /**
  40824. * Sets a texture to the according uniform.
  40825. * @param channel The texture channel
  40826. * @param uniform The uniform to set
  40827. * @param texture The texture to apply
  40828. */
  40829. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  40830. private _bindSamplerUniformToChannel;
  40831. private _getTextureWrapMode;
  40832. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40833. /**
  40834. * Sets an array of texture to the webGL context
  40835. * @param channel defines the channel where the texture array must be set
  40836. * @param uniform defines the associated uniform location
  40837. * @param textures defines the array of textures to bind
  40838. */
  40839. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  40840. /** @hidden */
  40841. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40842. private _setTextureParameterFloat;
  40843. private _setTextureParameterInteger;
  40844. /**
  40845. * Unbind all vertex attributes from the webGL context
  40846. */
  40847. unbindAllAttributes(): void;
  40848. /**
  40849. * 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
  40850. */
  40851. releaseEffects(): void;
  40852. /**
  40853. * Dispose and release all associated resources
  40854. */
  40855. dispose(): void;
  40856. /**
  40857. * Attach a new callback raised when context lost event is fired
  40858. * @param callback defines the callback to call
  40859. */
  40860. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40861. /**
  40862. * Attach a new callback raised when context restored event is fired
  40863. * @param callback defines the callback to call
  40864. */
  40865. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40866. /**
  40867. * Get the current error code of the webGL context
  40868. * @returns the error code
  40869. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40870. */
  40871. getError(): number;
  40872. private _canRenderToFloatFramebuffer;
  40873. private _canRenderToHalfFloatFramebuffer;
  40874. private _canRenderToFramebuffer;
  40875. /** @hidden */
  40876. _getWebGLTextureType(type: number): number;
  40877. /** @hidden */
  40878. _getInternalFormat(format: number): number;
  40879. /** @hidden */
  40880. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40881. /** @hidden */
  40882. _getRGBAMultiSampleBufferFormat(type: number): number;
  40883. /** @hidden */
  40884. _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;
  40885. /**
  40886. * Loads a file from a url
  40887. * @param url url to load
  40888. * @param onSuccess callback called when the file successfully loads
  40889. * @param onProgress callback called while file is loading (if the server supports this mode)
  40890. * @param offlineProvider defines the offline provider for caching
  40891. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40892. * @param onError callback called when the file fails to load
  40893. * @returns a file request object
  40894. * @hidden
  40895. */
  40896. 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;
  40897. /**
  40898. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40899. * @param x defines the x coordinate of the rectangle where pixels must be read
  40900. * @param y defines the y coordinate of the rectangle where pixels must be read
  40901. * @param width defines the width of the rectangle where pixels must be read
  40902. * @param height defines the height of the rectangle where pixels must be read
  40903. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40904. * @returns a Uint8Array containing RGBA colors
  40905. */
  40906. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40907. private static _IsSupported;
  40908. private static _HasMajorPerformanceCaveat;
  40909. /**
  40910. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40911. */
  40912. static get IsSupported(): boolean;
  40913. /**
  40914. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40915. * @returns true if the engine can be created
  40916. * @ignorenaming
  40917. */
  40918. static isSupported(): boolean;
  40919. /**
  40920. * 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)
  40921. */
  40922. static get HasMajorPerformanceCaveat(): boolean;
  40923. /**
  40924. * Find the next highest power of two.
  40925. * @param x Number to start search from.
  40926. * @return Next highest power of two.
  40927. */
  40928. static CeilingPOT(x: number): number;
  40929. /**
  40930. * Find the next lowest power of two.
  40931. * @param x Number to start search from.
  40932. * @return Next lowest power of two.
  40933. */
  40934. static FloorPOT(x: number): number;
  40935. /**
  40936. * Find the nearest power of two.
  40937. * @param x Number to start search from.
  40938. * @return Next nearest power of two.
  40939. */
  40940. static NearestPOT(x: number): number;
  40941. /**
  40942. * Get the closest exponent of two
  40943. * @param value defines the value to approximate
  40944. * @param max defines the maximum value to return
  40945. * @param mode defines how to define the closest value
  40946. * @returns closest exponent of two of the given value
  40947. */
  40948. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40949. /**
  40950. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40951. * @param func - the function to be called
  40952. * @param requester - the object that will request the next frame. Falls back to window.
  40953. * @returns frame number
  40954. */
  40955. static QueueNewFrame(func: () => void, requester?: any): number;
  40956. /**
  40957. * Gets host document
  40958. * @returns the host document object
  40959. */
  40960. getHostDocument(): Nullable<Document>;
  40961. }
  40962. }
  40963. declare module "babylonjs/Materials/Textures/internalTexture" {
  40964. import { Observable } from "babylonjs/Misc/observable";
  40965. import { Nullable, int } from "babylonjs/types";
  40966. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40968. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  40969. /**
  40970. * Defines the source of the internal texture
  40971. */
  40972. export enum InternalTextureSource {
  40973. /**
  40974. * The source of the texture data is unknown
  40975. */
  40976. Unknown = 0,
  40977. /**
  40978. * Texture data comes from an URL
  40979. */
  40980. Url = 1,
  40981. /**
  40982. * Texture data is only used for temporary storage
  40983. */
  40984. Temp = 2,
  40985. /**
  40986. * Texture data comes from raw data (ArrayBuffer)
  40987. */
  40988. Raw = 3,
  40989. /**
  40990. * Texture content is dynamic (video or dynamic texture)
  40991. */
  40992. Dynamic = 4,
  40993. /**
  40994. * Texture content is generated by rendering to it
  40995. */
  40996. RenderTarget = 5,
  40997. /**
  40998. * Texture content is part of a multi render target process
  40999. */
  41000. MultiRenderTarget = 6,
  41001. /**
  41002. * Texture data comes from a cube data file
  41003. */
  41004. Cube = 7,
  41005. /**
  41006. * Texture data comes from a raw cube data
  41007. */
  41008. CubeRaw = 8,
  41009. /**
  41010. * Texture data come from a prefiltered cube data file
  41011. */
  41012. CubePrefiltered = 9,
  41013. /**
  41014. * Texture content is raw 3D data
  41015. */
  41016. Raw3D = 10,
  41017. /**
  41018. * Texture content is raw 2D array data
  41019. */
  41020. Raw2DArray = 11,
  41021. /**
  41022. * Texture content is a depth texture
  41023. */
  41024. Depth = 12,
  41025. /**
  41026. * Texture data comes from a raw cube data encoded with RGBD
  41027. */
  41028. CubeRawRGBD = 13
  41029. }
  41030. /**
  41031. * Class used to store data associated with WebGL texture data for the engine
  41032. * This class should not be used directly
  41033. */
  41034. export class InternalTexture {
  41035. /** @hidden */
  41036. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41037. /**
  41038. * Defines if the texture is ready
  41039. */
  41040. isReady: boolean;
  41041. /**
  41042. * Defines if the texture is a cube texture
  41043. */
  41044. isCube: boolean;
  41045. /**
  41046. * Defines if the texture contains 3D data
  41047. */
  41048. is3D: boolean;
  41049. /**
  41050. * Defines if the texture contains 2D array data
  41051. */
  41052. is2DArray: boolean;
  41053. /**
  41054. * Defines if the texture contains multiview data
  41055. */
  41056. isMultiview: boolean;
  41057. /**
  41058. * Gets the URL used to load this texture
  41059. */
  41060. url: string;
  41061. /**
  41062. * Gets the sampling mode of the texture
  41063. */
  41064. samplingMode: number;
  41065. /**
  41066. * Gets a boolean indicating if the texture needs mipmaps generation
  41067. */
  41068. generateMipMaps: boolean;
  41069. /**
  41070. * Gets the number of samples used by the texture (WebGL2+ only)
  41071. */
  41072. samples: number;
  41073. /**
  41074. * Gets the type of the texture (int, float...)
  41075. */
  41076. type: number;
  41077. /**
  41078. * Gets the format of the texture (RGB, RGBA...)
  41079. */
  41080. format: number;
  41081. /**
  41082. * Observable called when the texture is loaded
  41083. */
  41084. onLoadedObservable: Observable<InternalTexture>;
  41085. /**
  41086. * Gets the width of the texture
  41087. */
  41088. width: number;
  41089. /**
  41090. * Gets the height of the texture
  41091. */
  41092. height: number;
  41093. /**
  41094. * Gets the depth of the texture
  41095. */
  41096. depth: number;
  41097. /**
  41098. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41099. */
  41100. baseWidth: number;
  41101. /**
  41102. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41103. */
  41104. baseHeight: number;
  41105. /**
  41106. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41107. */
  41108. baseDepth: number;
  41109. /**
  41110. * Gets a boolean indicating if the texture is inverted on Y axis
  41111. */
  41112. invertY: boolean;
  41113. /** @hidden */
  41114. _invertVScale: boolean;
  41115. /** @hidden */
  41116. _associatedChannel: number;
  41117. /** @hidden */
  41118. _source: InternalTextureSource;
  41119. /** @hidden */
  41120. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41121. /** @hidden */
  41122. _bufferView: Nullable<ArrayBufferView>;
  41123. /** @hidden */
  41124. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41125. /** @hidden */
  41126. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41127. /** @hidden */
  41128. _size: number;
  41129. /** @hidden */
  41130. _extension: string;
  41131. /** @hidden */
  41132. _files: Nullable<string[]>;
  41133. /** @hidden */
  41134. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41135. /** @hidden */
  41136. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41137. /** @hidden */
  41138. _framebuffer: Nullable<WebGLFramebuffer>;
  41139. /** @hidden */
  41140. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41141. /** @hidden */
  41142. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41143. /** @hidden */
  41144. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41145. /** @hidden */
  41146. _attachments: Nullable<number[]>;
  41147. /** @hidden */
  41148. _textureArray: Nullable<InternalTexture[]>;
  41149. /** @hidden */
  41150. _cachedCoordinatesMode: Nullable<number>;
  41151. /** @hidden */
  41152. _cachedWrapU: Nullable<number>;
  41153. /** @hidden */
  41154. _cachedWrapV: Nullable<number>;
  41155. /** @hidden */
  41156. _cachedWrapR: Nullable<number>;
  41157. /** @hidden */
  41158. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41159. /** @hidden */
  41160. _isDisabled: boolean;
  41161. /** @hidden */
  41162. _compression: Nullable<string>;
  41163. /** @hidden */
  41164. _generateStencilBuffer: boolean;
  41165. /** @hidden */
  41166. _generateDepthBuffer: boolean;
  41167. /** @hidden */
  41168. _comparisonFunction: number;
  41169. /** @hidden */
  41170. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41171. /** @hidden */
  41172. _lodGenerationScale: number;
  41173. /** @hidden */
  41174. _lodGenerationOffset: number;
  41175. /** @hidden */
  41176. _depthStencilTexture: Nullable<InternalTexture>;
  41177. /** @hidden */
  41178. _colorTextureArray: Nullable<WebGLTexture>;
  41179. /** @hidden */
  41180. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41181. /** @hidden */
  41182. _lodTextureHigh: Nullable<BaseTexture>;
  41183. /** @hidden */
  41184. _lodTextureMid: Nullable<BaseTexture>;
  41185. /** @hidden */
  41186. _lodTextureLow: Nullable<BaseTexture>;
  41187. /** @hidden */
  41188. _isRGBD: boolean;
  41189. /** @hidden */
  41190. _linearSpecularLOD: boolean;
  41191. /** @hidden */
  41192. _irradianceTexture: Nullable<BaseTexture>;
  41193. /** @hidden */
  41194. _webGLTexture: Nullable<WebGLTexture>;
  41195. /** @hidden */
  41196. _references: number;
  41197. /** @hidden */
  41198. _gammaSpace: Nullable<boolean>;
  41199. private _engine;
  41200. /**
  41201. * Gets the Engine the texture belongs to.
  41202. * @returns The babylon engine
  41203. */
  41204. getEngine(): ThinEngine;
  41205. /**
  41206. * Gets the data source type of the texture
  41207. */
  41208. get source(): InternalTextureSource;
  41209. /**
  41210. * Creates a new InternalTexture
  41211. * @param engine defines the engine to use
  41212. * @param source defines the type of data that will be used
  41213. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41214. */
  41215. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41216. /**
  41217. * Increments the number of references (ie. the number of Texture that point to it)
  41218. */
  41219. incrementReferences(): void;
  41220. /**
  41221. * Change the size of the texture (not the size of the content)
  41222. * @param width defines the new width
  41223. * @param height defines the new height
  41224. * @param depth defines the new depth (1 by default)
  41225. */
  41226. updateSize(width: int, height: int, depth?: int): void;
  41227. /** @hidden */
  41228. _rebuild(): void;
  41229. /** @hidden */
  41230. _swapAndDie(target: InternalTexture): void;
  41231. /**
  41232. * Dispose the current allocated resources
  41233. */
  41234. dispose(): void;
  41235. }
  41236. }
  41237. declare module "babylonjs/Audio/analyser" {
  41238. import { Scene } from "babylonjs/scene";
  41239. /**
  41240. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41241. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41242. */
  41243. export class Analyser {
  41244. /**
  41245. * Gets or sets the smoothing
  41246. * @ignorenaming
  41247. */
  41248. SMOOTHING: number;
  41249. /**
  41250. * Gets or sets the FFT table size
  41251. * @ignorenaming
  41252. */
  41253. FFT_SIZE: number;
  41254. /**
  41255. * Gets or sets the bar graph amplitude
  41256. * @ignorenaming
  41257. */
  41258. BARGRAPHAMPLITUDE: number;
  41259. /**
  41260. * Gets or sets the position of the debug canvas
  41261. * @ignorenaming
  41262. */
  41263. DEBUGCANVASPOS: {
  41264. x: number;
  41265. y: number;
  41266. };
  41267. /**
  41268. * Gets or sets the debug canvas size
  41269. * @ignorenaming
  41270. */
  41271. DEBUGCANVASSIZE: {
  41272. width: number;
  41273. height: number;
  41274. };
  41275. private _byteFreqs;
  41276. private _byteTime;
  41277. private _floatFreqs;
  41278. private _webAudioAnalyser;
  41279. private _debugCanvas;
  41280. private _debugCanvasContext;
  41281. private _scene;
  41282. private _registerFunc;
  41283. private _audioEngine;
  41284. /**
  41285. * Creates a new analyser
  41286. * @param scene defines hosting scene
  41287. */
  41288. constructor(scene: Scene);
  41289. /**
  41290. * Get the number of data values you will have to play with for the visualization
  41291. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41292. * @returns a number
  41293. */
  41294. getFrequencyBinCount(): number;
  41295. /**
  41296. * Gets the current frequency data as a byte array
  41297. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41298. * @returns a Uint8Array
  41299. */
  41300. getByteFrequencyData(): Uint8Array;
  41301. /**
  41302. * Gets the current waveform as a byte array
  41303. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41304. * @returns a Uint8Array
  41305. */
  41306. getByteTimeDomainData(): Uint8Array;
  41307. /**
  41308. * Gets the current frequency data as a float array
  41309. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41310. * @returns a Float32Array
  41311. */
  41312. getFloatFrequencyData(): Float32Array;
  41313. /**
  41314. * Renders the debug canvas
  41315. */
  41316. drawDebugCanvas(): void;
  41317. /**
  41318. * Stops rendering the debug canvas and removes it
  41319. */
  41320. stopDebugCanvas(): void;
  41321. /**
  41322. * Connects two audio nodes
  41323. * @param inputAudioNode defines first node to connect
  41324. * @param outputAudioNode defines second node to connect
  41325. */
  41326. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41327. /**
  41328. * Releases all associated resources
  41329. */
  41330. dispose(): void;
  41331. }
  41332. }
  41333. declare module "babylonjs/Audio/audioEngine" {
  41334. import { IDisposable } from "babylonjs/scene";
  41335. import { Analyser } from "babylonjs/Audio/analyser";
  41336. import { Nullable } from "babylonjs/types";
  41337. import { Observable } from "babylonjs/Misc/observable";
  41338. /**
  41339. * This represents an audio engine and it is responsible
  41340. * to play, synchronize and analyse sounds throughout the application.
  41341. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41342. */
  41343. export interface IAudioEngine extends IDisposable {
  41344. /**
  41345. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41346. */
  41347. readonly canUseWebAudio: boolean;
  41348. /**
  41349. * Gets the current AudioContext if available.
  41350. */
  41351. readonly audioContext: Nullable<AudioContext>;
  41352. /**
  41353. * The master gain node defines the global audio volume of your audio engine.
  41354. */
  41355. readonly masterGain: GainNode;
  41356. /**
  41357. * Gets whether or not mp3 are supported by your browser.
  41358. */
  41359. readonly isMP3supported: boolean;
  41360. /**
  41361. * Gets whether or not ogg are supported by your browser.
  41362. */
  41363. readonly isOGGsupported: boolean;
  41364. /**
  41365. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41366. * @ignoreNaming
  41367. */
  41368. WarnedWebAudioUnsupported: boolean;
  41369. /**
  41370. * Defines if the audio engine relies on a custom unlocked button.
  41371. * In this case, the embedded button will not be displayed.
  41372. */
  41373. useCustomUnlockedButton: boolean;
  41374. /**
  41375. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41376. */
  41377. readonly unlocked: boolean;
  41378. /**
  41379. * Event raised when audio has been unlocked on the browser.
  41380. */
  41381. onAudioUnlockedObservable: Observable<AudioEngine>;
  41382. /**
  41383. * Event raised when audio has been locked on the browser.
  41384. */
  41385. onAudioLockedObservable: Observable<AudioEngine>;
  41386. /**
  41387. * Flags the audio engine in Locked state.
  41388. * This happens due to new browser policies preventing audio to autoplay.
  41389. */
  41390. lock(): void;
  41391. /**
  41392. * Unlocks the audio engine once a user action has been done on the dom.
  41393. * This is helpful to resume play once browser policies have been satisfied.
  41394. */
  41395. unlock(): void;
  41396. /**
  41397. * Gets the global volume sets on the master gain.
  41398. * @returns the global volume if set or -1 otherwise
  41399. */
  41400. getGlobalVolume(): number;
  41401. /**
  41402. * Sets the global volume of your experience (sets on the master gain).
  41403. * @param newVolume Defines the new global volume of the application
  41404. */
  41405. setGlobalVolume(newVolume: number): void;
  41406. /**
  41407. * Connect the audio engine to an audio analyser allowing some amazing
  41408. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41409. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41410. * @param analyser The analyser to connect to the engine
  41411. */
  41412. connectToAnalyser(analyser: Analyser): void;
  41413. }
  41414. /**
  41415. * This represents the default audio engine used in babylon.
  41416. * It is responsible to play, synchronize and analyse sounds throughout the application.
  41417. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41418. */
  41419. export class AudioEngine implements IAudioEngine {
  41420. private _audioContext;
  41421. private _audioContextInitialized;
  41422. private _muteButton;
  41423. private _hostElement;
  41424. /**
  41425. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41426. */
  41427. canUseWebAudio: boolean;
  41428. /**
  41429. * The master gain node defines the global audio volume of your audio engine.
  41430. */
  41431. masterGain: GainNode;
  41432. /**
  41433. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41434. * @ignoreNaming
  41435. */
  41436. WarnedWebAudioUnsupported: boolean;
  41437. /**
  41438. * Gets whether or not mp3 are supported by your browser.
  41439. */
  41440. isMP3supported: boolean;
  41441. /**
  41442. * Gets whether or not ogg are supported by your browser.
  41443. */
  41444. isOGGsupported: boolean;
  41445. /**
  41446. * Gets whether audio has been unlocked on the device.
  41447. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  41448. * a user interaction has happened.
  41449. */
  41450. unlocked: boolean;
  41451. /**
  41452. * Defines if the audio engine relies on a custom unlocked button.
  41453. * In this case, the embedded button will not be displayed.
  41454. */
  41455. useCustomUnlockedButton: boolean;
  41456. /**
  41457. * Event raised when audio has been unlocked on the browser.
  41458. */
  41459. onAudioUnlockedObservable: Observable<AudioEngine>;
  41460. /**
  41461. * Event raised when audio has been locked on the browser.
  41462. */
  41463. onAudioLockedObservable: Observable<AudioEngine>;
  41464. /**
  41465. * Gets the current AudioContext if available.
  41466. */
  41467. get audioContext(): Nullable<AudioContext>;
  41468. private _connectedAnalyser;
  41469. /**
  41470. * Instantiates a new audio engine.
  41471. *
  41472. * There should be only one per page as some browsers restrict the number
  41473. * of audio contexts you can create.
  41474. * @param hostElement defines the host element where to display the mute icon if necessary
  41475. */
  41476. constructor(hostElement?: Nullable<HTMLElement>);
  41477. /**
  41478. * Flags the audio engine in Locked state.
  41479. * This happens due to new browser policies preventing audio to autoplay.
  41480. */
  41481. lock(): void;
  41482. /**
  41483. * Unlocks the audio engine once a user action has been done on the dom.
  41484. * This is helpful to resume play once browser policies have been satisfied.
  41485. */
  41486. unlock(): void;
  41487. private _resumeAudioContext;
  41488. private _initializeAudioContext;
  41489. private _tryToRun;
  41490. private _triggerRunningState;
  41491. private _triggerSuspendedState;
  41492. private _displayMuteButton;
  41493. private _moveButtonToTopLeft;
  41494. private _onResize;
  41495. private _hideMuteButton;
  41496. /**
  41497. * Destroy and release the resources associated with the audio ccontext.
  41498. */
  41499. dispose(): void;
  41500. /**
  41501. * Gets the global volume sets on the master gain.
  41502. * @returns the global volume if set or -1 otherwise
  41503. */
  41504. getGlobalVolume(): number;
  41505. /**
  41506. * Sets the global volume of your experience (sets on the master gain).
  41507. * @param newVolume Defines the new global volume of the application
  41508. */
  41509. setGlobalVolume(newVolume: number): void;
  41510. /**
  41511. * Connect the audio engine to an audio analyser allowing some amazing
  41512. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41513. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41514. * @param analyser The analyser to connect to the engine
  41515. */
  41516. connectToAnalyser(analyser: Analyser): void;
  41517. }
  41518. }
  41519. declare module "babylonjs/Loading/loadingScreen" {
  41520. /**
  41521. * Interface used to present a loading screen while loading a scene
  41522. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41523. */
  41524. export interface ILoadingScreen {
  41525. /**
  41526. * Function called to display the loading screen
  41527. */
  41528. displayLoadingUI: () => void;
  41529. /**
  41530. * Function called to hide the loading screen
  41531. */
  41532. hideLoadingUI: () => void;
  41533. /**
  41534. * Gets or sets the color to use for the background
  41535. */
  41536. loadingUIBackgroundColor: string;
  41537. /**
  41538. * Gets or sets the text to display while loading
  41539. */
  41540. loadingUIText: string;
  41541. }
  41542. /**
  41543. * Class used for the default loading screen
  41544. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41545. */
  41546. export class DefaultLoadingScreen implements ILoadingScreen {
  41547. private _renderingCanvas;
  41548. private _loadingText;
  41549. private _loadingDivBackgroundColor;
  41550. private _loadingDiv;
  41551. private _loadingTextDiv;
  41552. /** Gets or sets the logo url to use for the default loading screen */
  41553. static DefaultLogoUrl: string;
  41554. /** Gets or sets the spinner url to use for the default loading screen */
  41555. static DefaultSpinnerUrl: string;
  41556. /**
  41557. * Creates a new default loading screen
  41558. * @param _renderingCanvas defines the canvas used to render the scene
  41559. * @param _loadingText defines the default text to display
  41560. * @param _loadingDivBackgroundColor defines the default background color
  41561. */
  41562. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41563. /**
  41564. * Function called to display the loading screen
  41565. */
  41566. displayLoadingUI(): void;
  41567. /**
  41568. * Function called to hide the loading screen
  41569. */
  41570. hideLoadingUI(): void;
  41571. /**
  41572. * Gets or sets the text to display while loading
  41573. */
  41574. set loadingUIText(text: string);
  41575. get loadingUIText(): string;
  41576. /**
  41577. * Gets or sets the color to use for the background
  41578. */
  41579. get loadingUIBackgroundColor(): string;
  41580. set loadingUIBackgroundColor(color: string);
  41581. private _resizeLoadingUI;
  41582. }
  41583. }
  41584. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41585. /**
  41586. * Interface for any object that can request an animation frame
  41587. */
  41588. export interface ICustomAnimationFrameRequester {
  41589. /**
  41590. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41591. */
  41592. renderFunction?: Function;
  41593. /**
  41594. * Called to request the next frame to render to
  41595. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41596. */
  41597. requestAnimationFrame: Function;
  41598. /**
  41599. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41600. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41601. */
  41602. requestID?: number;
  41603. }
  41604. }
  41605. declare module "babylonjs/Misc/performanceMonitor" {
  41606. /**
  41607. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41608. */
  41609. export class PerformanceMonitor {
  41610. private _enabled;
  41611. private _rollingFrameTime;
  41612. private _lastFrameTimeMs;
  41613. /**
  41614. * constructor
  41615. * @param frameSampleSize The number of samples required to saturate the sliding window
  41616. */
  41617. constructor(frameSampleSize?: number);
  41618. /**
  41619. * Samples current frame
  41620. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41621. */
  41622. sampleFrame(timeMs?: number): void;
  41623. /**
  41624. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41625. */
  41626. get averageFrameTime(): number;
  41627. /**
  41628. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41629. */
  41630. get averageFrameTimeVariance(): number;
  41631. /**
  41632. * Returns the frame time of the most recent frame
  41633. */
  41634. get instantaneousFrameTime(): number;
  41635. /**
  41636. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41637. */
  41638. get averageFPS(): number;
  41639. /**
  41640. * Returns the average framerate in frames per second using the most recent frame time
  41641. */
  41642. get instantaneousFPS(): number;
  41643. /**
  41644. * Returns true if enough samples have been taken to completely fill the sliding window
  41645. */
  41646. get isSaturated(): boolean;
  41647. /**
  41648. * Enables contributions to the sliding window sample set
  41649. */
  41650. enable(): void;
  41651. /**
  41652. * Disables contributions to the sliding window sample set
  41653. * Samples will not be interpolated over the disabled period
  41654. */
  41655. disable(): void;
  41656. /**
  41657. * Returns true if sampling is enabled
  41658. */
  41659. get isEnabled(): boolean;
  41660. /**
  41661. * Resets performance monitor
  41662. */
  41663. reset(): void;
  41664. }
  41665. /**
  41666. * RollingAverage
  41667. *
  41668. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41669. */
  41670. export class RollingAverage {
  41671. /**
  41672. * Current average
  41673. */
  41674. average: number;
  41675. /**
  41676. * Current variance
  41677. */
  41678. variance: number;
  41679. protected _samples: Array<number>;
  41680. protected _sampleCount: number;
  41681. protected _pos: number;
  41682. protected _m2: number;
  41683. /**
  41684. * constructor
  41685. * @param length The number of samples required to saturate the sliding window
  41686. */
  41687. constructor(length: number);
  41688. /**
  41689. * Adds a sample to the sample set
  41690. * @param v The sample value
  41691. */
  41692. add(v: number): void;
  41693. /**
  41694. * Returns previously added values or null if outside of history or outside the sliding window domain
  41695. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41696. * @return Value previously recorded with add() or null if outside of range
  41697. */
  41698. history(i: number): number;
  41699. /**
  41700. * Returns true if enough samples have been taken to completely fill the sliding window
  41701. * @return true if sample-set saturated
  41702. */
  41703. isSaturated(): boolean;
  41704. /**
  41705. * Resets the rolling average (equivalent to 0 samples taken so far)
  41706. */
  41707. reset(): void;
  41708. /**
  41709. * Wraps a value around the sample range boundaries
  41710. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41711. * @return Wrapped position in sample range
  41712. */
  41713. protected _wrapPosition(i: number): number;
  41714. }
  41715. }
  41716. declare module "babylonjs/Misc/perfCounter" {
  41717. /**
  41718. * This class is used to track a performance counter which is number based.
  41719. * The user has access to many properties which give statistics of different nature.
  41720. *
  41721. * The implementer can track two kinds of Performance Counter: time and count.
  41722. * 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.
  41723. * 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.
  41724. */
  41725. export class PerfCounter {
  41726. /**
  41727. * Gets or sets a global boolean to turn on and off all the counters
  41728. */
  41729. static Enabled: boolean;
  41730. /**
  41731. * Returns the smallest value ever
  41732. */
  41733. get min(): number;
  41734. /**
  41735. * Returns the biggest value ever
  41736. */
  41737. get max(): number;
  41738. /**
  41739. * Returns the average value since the performance counter is running
  41740. */
  41741. get average(): number;
  41742. /**
  41743. * Returns the average value of the last second the counter was monitored
  41744. */
  41745. get lastSecAverage(): number;
  41746. /**
  41747. * Returns the current value
  41748. */
  41749. get current(): number;
  41750. /**
  41751. * Gets the accumulated total
  41752. */
  41753. get total(): number;
  41754. /**
  41755. * Gets the total value count
  41756. */
  41757. get count(): number;
  41758. /**
  41759. * Creates a new counter
  41760. */
  41761. constructor();
  41762. /**
  41763. * Call this method to start monitoring a new frame.
  41764. * 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.
  41765. */
  41766. fetchNewFrame(): void;
  41767. /**
  41768. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41769. * @param newCount the count value to add to the monitored count
  41770. * @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.
  41771. */
  41772. addCount(newCount: number, fetchResult: boolean): void;
  41773. /**
  41774. * Start monitoring this performance counter
  41775. */
  41776. beginMonitoring(): void;
  41777. /**
  41778. * Compute the time lapsed since the previous beginMonitoring() call.
  41779. * @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
  41780. */
  41781. endMonitoring(newFrame?: boolean): void;
  41782. private _fetchResult;
  41783. private _startMonitoringTime;
  41784. private _min;
  41785. private _max;
  41786. private _average;
  41787. private _current;
  41788. private _totalValueCount;
  41789. private _totalAccumulated;
  41790. private _lastSecAverage;
  41791. private _lastSecAccumulated;
  41792. private _lastSecTime;
  41793. private _lastSecValueCount;
  41794. }
  41795. }
  41796. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  41797. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41798. import { Nullable } from "babylonjs/types";
  41799. module "babylonjs/Engines/thinEngine" {
  41800. interface ThinEngine {
  41801. /** @hidden */
  41802. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  41803. }
  41804. }
  41805. }
  41806. declare module "babylonjs/Engines/engine" {
  41807. import { Observable } from "babylonjs/Misc/observable";
  41808. import { Nullable } from "babylonjs/types";
  41809. import { Scene } from "babylonjs/scene";
  41810. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41811. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  41812. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41813. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  41814. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41815. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41816. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  41817. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  41818. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41819. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41820. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  41821. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41822. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  41823. import "babylonjs/Engines/Extensions/engine.alpha";
  41824. import "babylonjs/Engines/Extensions/engine.readTexture";
  41825. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  41826. import { Material } from "babylonjs/Materials/material";
  41827. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41828. /**
  41829. * Defines the interface used by display changed events
  41830. */
  41831. export interface IDisplayChangedEventArgs {
  41832. /** Gets the vrDisplay object (if any) */
  41833. vrDisplay: Nullable<any>;
  41834. /** Gets a boolean indicating if webVR is supported */
  41835. vrSupported: boolean;
  41836. }
  41837. /**
  41838. * Defines the interface used by objects containing a viewport (like a camera)
  41839. */
  41840. interface IViewportOwnerLike {
  41841. /**
  41842. * Gets or sets the viewport
  41843. */
  41844. viewport: IViewportLike;
  41845. }
  41846. /**
  41847. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41848. */
  41849. export class Engine extends ThinEngine {
  41850. /** Defines that alpha blending is disabled */
  41851. static readonly ALPHA_DISABLE: number;
  41852. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41853. static readonly ALPHA_ADD: number;
  41854. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41855. static readonly ALPHA_COMBINE: number;
  41856. /** Defines that alpha blending to DEST - SRC * DEST */
  41857. static readonly ALPHA_SUBTRACT: number;
  41858. /** Defines that alpha blending to SRC * DEST */
  41859. static readonly ALPHA_MULTIPLY: number;
  41860. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41861. static readonly ALPHA_MAXIMIZED: number;
  41862. /** Defines that alpha blending to SRC + DEST */
  41863. static readonly ALPHA_ONEONE: number;
  41864. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41865. static readonly ALPHA_PREMULTIPLIED: number;
  41866. /**
  41867. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41868. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41869. */
  41870. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41871. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41872. static readonly ALPHA_INTERPOLATE: number;
  41873. /**
  41874. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41875. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41876. */
  41877. static readonly ALPHA_SCREENMODE: number;
  41878. /** Defines that the ressource is not delayed*/
  41879. static readonly DELAYLOADSTATE_NONE: number;
  41880. /** Defines that the ressource was successfully delay loaded */
  41881. static readonly DELAYLOADSTATE_LOADED: number;
  41882. /** Defines that the ressource is currently delay loading */
  41883. static readonly DELAYLOADSTATE_LOADING: number;
  41884. /** Defines that the ressource is delayed and has not started loading */
  41885. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41886. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41887. static readonly NEVER: number;
  41888. /** 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 */
  41889. static readonly ALWAYS: number;
  41890. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41891. static readonly LESS: number;
  41892. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41893. static readonly EQUAL: number;
  41894. /** 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 */
  41895. static readonly LEQUAL: number;
  41896. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41897. static readonly GREATER: number;
  41898. /** 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 */
  41899. static readonly GEQUAL: number;
  41900. /** 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 */
  41901. static readonly NOTEQUAL: number;
  41902. /** Passed to stencilOperation to specify that stencil value must be kept */
  41903. static readonly KEEP: number;
  41904. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41905. static readonly REPLACE: number;
  41906. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41907. static readonly INCR: number;
  41908. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41909. static readonly DECR: number;
  41910. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41911. static readonly INVERT: number;
  41912. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41913. static readonly INCR_WRAP: number;
  41914. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41915. static readonly DECR_WRAP: number;
  41916. /** Texture is not repeating outside of 0..1 UVs */
  41917. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41918. /** Texture is repeating outside of 0..1 UVs */
  41919. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41920. /** Texture is repeating and mirrored */
  41921. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41922. /** ALPHA */
  41923. static readonly TEXTUREFORMAT_ALPHA: number;
  41924. /** LUMINANCE */
  41925. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41926. /** LUMINANCE_ALPHA */
  41927. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41928. /** RGB */
  41929. static readonly TEXTUREFORMAT_RGB: number;
  41930. /** RGBA */
  41931. static readonly TEXTUREFORMAT_RGBA: number;
  41932. /** RED */
  41933. static readonly TEXTUREFORMAT_RED: number;
  41934. /** RED (2nd reference) */
  41935. static readonly TEXTUREFORMAT_R: number;
  41936. /** RG */
  41937. static readonly TEXTUREFORMAT_RG: number;
  41938. /** RED_INTEGER */
  41939. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41940. /** RED_INTEGER (2nd reference) */
  41941. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41942. /** RG_INTEGER */
  41943. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41944. /** RGB_INTEGER */
  41945. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41946. /** RGBA_INTEGER */
  41947. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41948. /** UNSIGNED_BYTE */
  41949. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41950. /** UNSIGNED_BYTE (2nd reference) */
  41951. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41952. /** FLOAT */
  41953. static readonly TEXTURETYPE_FLOAT: number;
  41954. /** HALF_FLOAT */
  41955. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41956. /** BYTE */
  41957. static readonly TEXTURETYPE_BYTE: number;
  41958. /** SHORT */
  41959. static readonly TEXTURETYPE_SHORT: number;
  41960. /** UNSIGNED_SHORT */
  41961. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41962. /** INT */
  41963. static readonly TEXTURETYPE_INT: number;
  41964. /** UNSIGNED_INT */
  41965. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41966. /** UNSIGNED_SHORT_4_4_4_4 */
  41967. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41968. /** UNSIGNED_SHORT_5_5_5_1 */
  41969. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41970. /** UNSIGNED_SHORT_5_6_5 */
  41971. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41972. /** UNSIGNED_INT_2_10_10_10_REV */
  41973. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41974. /** UNSIGNED_INT_24_8 */
  41975. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41976. /** UNSIGNED_INT_10F_11F_11F_REV */
  41977. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41978. /** UNSIGNED_INT_5_9_9_9_REV */
  41979. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41980. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41981. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41982. /** nearest is mag = nearest and min = nearest and mip = linear */
  41983. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41984. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41985. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41986. /** Trilinear is mag = linear and min = linear and mip = linear */
  41987. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41988. /** nearest is mag = nearest and min = nearest and mip = linear */
  41989. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41990. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41991. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41992. /** Trilinear is mag = linear and min = linear and mip = linear */
  41993. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41994. /** mag = nearest and min = nearest and mip = nearest */
  41995. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41996. /** mag = nearest and min = linear and mip = nearest */
  41997. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41998. /** mag = nearest and min = linear and mip = linear */
  41999. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42000. /** mag = nearest and min = linear and mip = none */
  42001. static readonly TEXTURE_NEAREST_LINEAR: number;
  42002. /** mag = nearest and min = nearest and mip = none */
  42003. static readonly TEXTURE_NEAREST_NEAREST: number;
  42004. /** mag = linear and min = nearest and mip = nearest */
  42005. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42006. /** mag = linear and min = nearest and mip = linear */
  42007. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42008. /** mag = linear and min = linear and mip = none */
  42009. static readonly TEXTURE_LINEAR_LINEAR: number;
  42010. /** mag = linear and min = nearest and mip = none */
  42011. static readonly TEXTURE_LINEAR_NEAREST: number;
  42012. /** Explicit coordinates mode */
  42013. static readonly TEXTURE_EXPLICIT_MODE: number;
  42014. /** Spherical coordinates mode */
  42015. static readonly TEXTURE_SPHERICAL_MODE: number;
  42016. /** Planar coordinates mode */
  42017. static readonly TEXTURE_PLANAR_MODE: number;
  42018. /** Cubic coordinates mode */
  42019. static readonly TEXTURE_CUBIC_MODE: number;
  42020. /** Projection coordinates mode */
  42021. static readonly TEXTURE_PROJECTION_MODE: number;
  42022. /** Skybox coordinates mode */
  42023. static readonly TEXTURE_SKYBOX_MODE: number;
  42024. /** Inverse Cubic coordinates mode */
  42025. static readonly TEXTURE_INVCUBIC_MODE: number;
  42026. /** Equirectangular coordinates mode */
  42027. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42028. /** Equirectangular Fixed coordinates mode */
  42029. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42030. /** Equirectangular Fixed Mirrored coordinates mode */
  42031. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42032. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42033. static readonly SCALEMODE_FLOOR: number;
  42034. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42035. static readonly SCALEMODE_NEAREST: number;
  42036. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42037. static readonly SCALEMODE_CEILING: number;
  42038. /**
  42039. * Returns the current npm package of the sdk
  42040. */
  42041. static get NpmPackage(): string;
  42042. /**
  42043. * Returns the current version of the framework
  42044. */
  42045. static get Version(): string;
  42046. /** Gets the list of created engines */
  42047. static get Instances(): Engine[];
  42048. /**
  42049. * Gets the latest created engine
  42050. */
  42051. static get LastCreatedEngine(): Nullable<Engine>;
  42052. /**
  42053. * Gets the latest created scene
  42054. */
  42055. static get LastCreatedScene(): Nullable<Scene>;
  42056. /**
  42057. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42058. * @param flag defines which part of the materials must be marked as dirty
  42059. * @param predicate defines a predicate used to filter which materials should be affected
  42060. */
  42061. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42062. /**
  42063. * Method called to create the default loading screen.
  42064. * This can be overriden in your own app.
  42065. * @param canvas The rendering canvas element
  42066. * @returns The loading screen
  42067. */
  42068. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42069. /**
  42070. * Method called to create the default rescale post process on each engine.
  42071. */
  42072. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42073. /**
  42074. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42075. **/
  42076. enableOfflineSupport: boolean;
  42077. /**
  42078. * 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)
  42079. **/
  42080. disableManifestCheck: boolean;
  42081. /**
  42082. * Gets the list of created scenes
  42083. */
  42084. scenes: Scene[];
  42085. /**
  42086. * Event raised when a new scene is created
  42087. */
  42088. onNewSceneAddedObservable: Observable<Scene>;
  42089. /**
  42090. * Gets the list of created postprocesses
  42091. */
  42092. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42093. /**
  42094. * Gets a boolean indicating if the pointer is currently locked
  42095. */
  42096. isPointerLock: boolean;
  42097. /**
  42098. * Observable event triggered each time the rendering canvas is resized
  42099. */
  42100. onResizeObservable: Observable<Engine>;
  42101. /**
  42102. * Observable event triggered each time the canvas loses focus
  42103. */
  42104. onCanvasBlurObservable: Observable<Engine>;
  42105. /**
  42106. * Observable event triggered each time the canvas gains focus
  42107. */
  42108. onCanvasFocusObservable: Observable<Engine>;
  42109. /**
  42110. * Observable event triggered each time the canvas receives pointerout event
  42111. */
  42112. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42113. /**
  42114. * Observable raised when the engine begins a new frame
  42115. */
  42116. onBeginFrameObservable: Observable<Engine>;
  42117. /**
  42118. * If set, will be used to request the next animation frame for the render loop
  42119. */
  42120. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42121. /**
  42122. * Observable raised when the engine ends the current frame
  42123. */
  42124. onEndFrameObservable: Observable<Engine>;
  42125. /**
  42126. * Observable raised when the engine is about to compile a shader
  42127. */
  42128. onBeforeShaderCompilationObservable: Observable<Engine>;
  42129. /**
  42130. * Observable raised when the engine has jsut compiled a shader
  42131. */
  42132. onAfterShaderCompilationObservable: Observable<Engine>;
  42133. /**
  42134. * Gets the audio engine
  42135. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42136. * @ignorenaming
  42137. */
  42138. static audioEngine: IAudioEngine;
  42139. /**
  42140. * Default AudioEngine factory responsible of creating the Audio Engine.
  42141. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42142. */
  42143. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42144. /**
  42145. * Default offline support factory responsible of creating a tool used to store data locally.
  42146. * By default, this will create a Database object if the workload has been embedded.
  42147. */
  42148. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42149. private _loadingScreen;
  42150. private _pointerLockRequested;
  42151. private _rescalePostProcess;
  42152. private _deterministicLockstep;
  42153. private _lockstepMaxSteps;
  42154. private _timeStep;
  42155. protected get _supportsHardwareTextureRescaling(): boolean;
  42156. private _fps;
  42157. private _deltaTime;
  42158. /** @hidden */
  42159. _drawCalls: PerfCounter;
  42160. /** 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 */
  42161. canvasTabIndex: number;
  42162. /**
  42163. * Turn this value on if you want to pause FPS computation when in background
  42164. */
  42165. disablePerformanceMonitorInBackground: boolean;
  42166. private _performanceMonitor;
  42167. /**
  42168. * Gets the performance monitor attached to this engine
  42169. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42170. */
  42171. get performanceMonitor(): PerformanceMonitor;
  42172. private _onFocus;
  42173. private _onBlur;
  42174. private _onCanvasPointerOut;
  42175. private _onCanvasBlur;
  42176. private _onCanvasFocus;
  42177. private _onFullscreenChange;
  42178. private _onPointerLockChange;
  42179. /**
  42180. * Gets the HTML element used to attach event listeners
  42181. * @returns a HTML element
  42182. */
  42183. getInputElement(): Nullable<HTMLElement>;
  42184. /**
  42185. * Creates a new engine
  42186. * @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
  42187. * @param antialias defines enable antialiasing (default: false)
  42188. * @param options defines further options to be sent to the getContext() function
  42189. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42190. */
  42191. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42192. /**
  42193. * Gets current aspect ratio
  42194. * @param viewportOwner defines the camera to use to get the aspect ratio
  42195. * @param useScreen defines if screen size must be used (or the current render target if any)
  42196. * @returns a number defining the aspect ratio
  42197. */
  42198. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42199. /**
  42200. * Gets current screen aspect ratio
  42201. * @returns a number defining the aspect ratio
  42202. */
  42203. getScreenAspectRatio(): number;
  42204. /**
  42205. * Gets the client rect of the HTML canvas attached with the current webGL context
  42206. * @returns a client rectanglee
  42207. */
  42208. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42209. /**
  42210. * Gets the client rect of the HTML element used for events
  42211. * @returns a client rectanglee
  42212. */
  42213. getInputElementClientRect(): Nullable<ClientRect>;
  42214. /**
  42215. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42216. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42217. * @returns true if engine is in deterministic lock step mode
  42218. */
  42219. isDeterministicLockStep(): boolean;
  42220. /**
  42221. * Gets the max steps when engine is running in deterministic lock step
  42222. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42223. * @returns the max steps
  42224. */
  42225. getLockstepMaxSteps(): number;
  42226. /**
  42227. * Returns the time in ms between steps when using deterministic lock step.
  42228. * @returns time step in (ms)
  42229. */
  42230. getTimeStep(): number;
  42231. /**
  42232. * Force the mipmap generation for the given render target texture
  42233. * @param texture defines the render target texture to use
  42234. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42235. */
  42236. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42237. /** States */
  42238. /**
  42239. * Set various states to the webGL context
  42240. * @param culling defines backface culling state
  42241. * @param zOffset defines the value to apply to zOffset (0 by default)
  42242. * @param force defines if states must be applied even if cache is up to date
  42243. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42244. */
  42245. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42246. /**
  42247. * Set the z offset to apply to current rendering
  42248. * @param value defines the offset to apply
  42249. */
  42250. setZOffset(value: number): void;
  42251. /**
  42252. * Gets the current value of the zOffset
  42253. * @returns the current zOffset state
  42254. */
  42255. getZOffset(): number;
  42256. /**
  42257. * Enable or disable depth buffering
  42258. * @param enable defines the state to set
  42259. */
  42260. setDepthBuffer(enable: boolean): void;
  42261. /**
  42262. * Gets a boolean indicating if depth writing is enabled
  42263. * @returns the current depth writing state
  42264. */
  42265. getDepthWrite(): boolean;
  42266. /**
  42267. * Enable or disable depth writing
  42268. * @param enable defines the state to set
  42269. */
  42270. setDepthWrite(enable: boolean): void;
  42271. /**
  42272. * Gets a boolean indicating if stencil buffer is enabled
  42273. * @returns the current stencil buffer state
  42274. */
  42275. getStencilBuffer(): boolean;
  42276. /**
  42277. * Enable or disable the stencil buffer
  42278. * @param enable defines if the stencil buffer must be enabled or disabled
  42279. */
  42280. setStencilBuffer(enable: boolean): void;
  42281. /**
  42282. * Gets the current stencil mask
  42283. * @returns a number defining the new stencil mask to use
  42284. */
  42285. getStencilMask(): number;
  42286. /**
  42287. * Sets the current stencil mask
  42288. * @param mask defines the new stencil mask to use
  42289. */
  42290. setStencilMask(mask: number): void;
  42291. /**
  42292. * Gets the current stencil function
  42293. * @returns a number defining the stencil function to use
  42294. */
  42295. getStencilFunction(): number;
  42296. /**
  42297. * Gets the current stencil reference value
  42298. * @returns a number defining the stencil reference value to use
  42299. */
  42300. getStencilFunctionReference(): number;
  42301. /**
  42302. * Gets the current stencil mask
  42303. * @returns a number defining the stencil mask to use
  42304. */
  42305. getStencilFunctionMask(): number;
  42306. /**
  42307. * Sets the current stencil function
  42308. * @param stencilFunc defines the new stencil function to use
  42309. */
  42310. setStencilFunction(stencilFunc: number): void;
  42311. /**
  42312. * Sets the current stencil reference
  42313. * @param reference defines the new stencil reference to use
  42314. */
  42315. setStencilFunctionReference(reference: number): void;
  42316. /**
  42317. * Sets the current stencil mask
  42318. * @param mask defines the new stencil mask to use
  42319. */
  42320. setStencilFunctionMask(mask: number): void;
  42321. /**
  42322. * Gets the current stencil operation when stencil fails
  42323. * @returns a number defining stencil operation to use when stencil fails
  42324. */
  42325. getStencilOperationFail(): number;
  42326. /**
  42327. * Gets the current stencil operation when depth fails
  42328. * @returns a number defining stencil operation to use when depth fails
  42329. */
  42330. getStencilOperationDepthFail(): number;
  42331. /**
  42332. * Gets the current stencil operation when stencil passes
  42333. * @returns a number defining stencil operation to use when stencil passes
  42334. */
  42335. getStencilOperationPass(): number;
  42336. /**
  42337. * Sets the stencil operation to use when stencil fails
  42338. * @param operation defines the stencil operation to use when stencil fails
  42339. */
  42340. setStencilOperationFail(operation: number): void;
  42341. /**
  42342. * Sets the stencil operation to use when depth fails
  42343. * @param operation defines the stencil operation to use when depth fails
  42344. */
  42345. setStencilOperationDepthFail(operation: number): void;
  42346. /**
  42347. * Sets the stencil operation to use when stencil passes
  42348. * @param operation defines the stencil operation to use when stencil passes
  42349. */
  42350. setStencilOperationPass(operation: number): void;
  42351. /**
  42352. * Sets a boolean indicating if the dithering state is enabled or disabled
  42353. * @param value defines the dithering state
  42354. */
  42355. setDitheringState(value: boolean): void;
  42356. /**
  42357. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42358. * @param value defines the rasterizer state
  42359. */
  42360. setRasterizerState(value: boolean): void;
  42361. /**
  42362. * Gets the current depth function
  42363. * @returns a number defining the depth function
  42364. */
  42365. getDepthFunction(): Nullable<number>;
  42366. /**
  42367. * Sets the current depth function
  42368. * @param depthFunc defines the function to use
  42369. */
  42370. setDepthFunction(depthFunc: number): void;
  42371. /**
  42372. * Sets the current depth function to GREATER
  42373. */
  42374. setDepthFunctionToGreater(): void;
  42375. /**
  42376. * Sets the current depth function to GEQUAL
  42377. */
  42378. setDepthFunctionToGreaterOrEqual(): void;
  42379. /**
  42380. * Sets the current depth function to LESS
  42381. */
  42382. setDepthFunctionToLess(): void;
  42383. /**
  42384. * Sets the current depth function to LEQUAL
  42385. */
  42386. setDepthFunctionToLessOrEqual(): void;
  42387. private _cachedStencilBuffer;
  42388. private _cachedStencilFunction;
  42389. private _cachedStencilMask;
  42390. private _cachedStencilOperationPass;
  42391. private _cachedStencilOperationFail;
  42392. private _cachedStencilOperationDepthFail;
  42393. private _cachedStencilReference;
  42394. /**
  42395. * Caches the the state of the stencil buffer
  42396. */
  42397. cacheStencilState(): void;
  42398. /**
  42399. * Restores the state of the stencil buffer
  42400. */
  42401. restoreStencilState(): void;
  42402. /**
  42403. * Directly set the WebGL Viewport
  42404. * @param x defines the x coordinate of the viewport (in screen space)
  42405. * @param y defines the y coordinate of the viewport (in screen space)
  42406. * @param width defines the width of the viewport (in screen space)
  42407. * @param height defines the height of the viewport (in screen space)
  42408. * @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
  42409. */
  42410. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42411. /**
  42412. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42413. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42414. * @param y defines the y-coordinate of the corner of the clear rectangle
  42415. * @param width defines the width of the clear rectangle
  42416. * @param height defines the height of the clear rectangle
  42417. * @param clearColor defines the clear color
  42418. */
  42419. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42420. /**
  42421. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42422. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42423. * @param y defines the y-coordinate of the corner of the clear rectangle
  42424. * @param width defines the width of the clear rectangle
  42425. * @param height defines the height of the clear rectangle
  42426. */
  42427. enableScissor(x: number, y: number, width: number, height: number): void;
  42428. /**
  42429. * Disable previously set scissor test rectangle
  42430. */
  42431. disableScissor(): void;
  42432. protected _reportDrawCall(): void;
  42433. /**
  42434. * Initializes a webVR display and starts listening to display change events
  42435. * The onVRDisplayChangedObservable will be notified upon these changes
  42436. * @returns The onVRDisplayChangedObservable
  42437. */
  42438. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42439. /** @hidden */
  42440. _prepareVRComponent(): void;
  42441. /** @hidden */
  42442. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42443. /** @hidden */
  42444. _submitVRFrame(): void;
  42445. /**
  42446. * Call this function to leave webVR mode
  42447. * Will do nothing if webVR is not supported or if there is no webVR device
  42448. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42449. */
  42450. disableVR(): void;
  42451. /**
  42452. * Gets a boolean indicating that the system is in VR mode and is presenting
  42453. * @returns true if VR mode is engaged
  42454. */
  42455. isVRPresenting(): boolean;
  42456. /** @hidden */
  42457. _requestVRFrame(): void;
  42458. /** @hidden */
  42459. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42460. /**
  42461. * Gets the source code of the vertex shader associated with a specific webGL program
  42462. * @param program defines the program to use
  42463. * @returns a string containing the source code of the vertex shader associated with the program
  42464. */
  42465. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42466. /**
  42467. * Gets the source code of the fragment shader associated with a specific webGL program
  42468. * @param program defines the program to use
  42469. * @returns a string containing the source code of the fragment shader associated with the program
  42470. */
  42471. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42472. /**
  42473. * Sets a depth stencil texture from a render target to the according uniform.
  42474. * @param channel The texture channel
  42475. * @param uniform The uniform to set
  42476. * @param texture The render target texture containing the depth stencil texture to apply
  42477. */
  42478. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42479. /**
  42480. * Sets a texture to the webGL context from a postprocess
  42481. * @param channel defines the channel to use
  42482. * @param postProcess defines the source postprocess
  42483. */
  42484. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42485. /**
  42486. * Binds the output of the passed in post process to the texture channel specified
  42487. * @param channel The channel the texture should be bound to
  42488. * @param postProcess The post process which's output should be bound
  42489. */
  42490. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42491. protected _rebuildBuffers(): void;
  42492. /** @hidden */
  42493. _renderFrame(): void;
  42494. _renderLoop(): void;
  42495. /** @hidden */
  42496. _renderViews(): boolean;
  42497. /**
  42498. * Toggle full screen mode
  42499. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42500. */
  42501. switchFullscreen(requestPointerLock: boolean): void;
  42502. /**
  42503. * Enters full screen mode
  42504. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42505. */
  42506. enterFullscreen(requestPointerLock: boolean): void;
  42507. /**
  42508. * Exits full screen mode
  42509. */
  42510. exitFullscreen(): void;
  42511. /**
  42512. * Enters Pointerlock mode
  42513. */
  42514. enterPointerlock(): void;
  42515. /**
  42516. * Exits Pointerlock mode
  42517. */
  42518. exitPointerlock(): void;
  42519. /**
  42520. * Begin a new frame
  42521. */
  42522. beginFrame(): void;
  42523. /**
  42524. * Enf the current frame
  42525. */
  42526. endFrame(): void;
  42527. resize(): void;
  42528. /**
  42529. * Force a specific size of the canvas
  42530. * @param width defines the new canvas' width
  42531. * @param height defines the new canvas' height
  42532. * @returns true if the size was changed
  42533. */
  42534. setSize(width: number, height: number): boolean;
  42535. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42536. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42537. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42538. _releaseTexture(texture: InternalTexture): void;
  42539. /**
  42540. * @hidden
  42541. * Rescales a texture
  42542. * @param source input texutre
  42543. * @param destination destination texture
  42544. * @param scene scene to use to render the resize
  42545. * @param internalFormat format to use when resizing
  42546. * @param onComplete callback to be called when resize has completed
  42547. */
  42548. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42549. /**
  42550. * Gets the current framerate
  42551. * @returns a number representing the framerate
  42552. */
  42553. getFps(): number;
  42554. /**
  42555. * Gets the time spent between current and previous frame
  42556. * @returns a number representing the delta time in ms
  42557. */
  42558. getDeltaTime(): number;
  42559. private _measureFps;
  42560. /** @hidden */
  42561. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42562. /**
  42563. * Updates the sample count of a render target texture
  42564. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42565. * @param texture defines the texture to update
  42566. * @param samples defines the sample count to set
  42567. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42568. */
  42569. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42570. /**
  42571. * Updates a depth texture Comparison Mode and Function.
  42572. * If the comparison Function is equal to 0, the mode will be set to none.
  42573. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42574. * @param texture The texture to set the comparison function for
  42575. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42576. */
  42577. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42578. /**
  42579. * Creates a webGL buffer to use with instanciation
  42580. * @param capacity defines the size of the buffer
  42581. * @returns the webGL buffer
  42582. */
  42583. createInstancesBuffer(capacity: number): DataBuffer;
  42584. /**
  42585. * Delete a webGL buffer used with instanciation
  42586. * @param buffer defines the webGL buffer to delete
  42587. */
  42588. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42589. private _clientWaitAsync;
  42590. /** @hidden */
  42591. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42592. dispose(): void;
  42593. private _disableTouchAction;
  42594. /**
  42595. * Display the loading screen
  42596. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42597. */
  42598. displayLoadingUI(): void;
  42599. /**
  42600. * Hide the loading screen
  42601. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42602. */
  42603. hideLoadingUI(): void;
  42604. /**
  42605. * Gets the current loading screen object
  42606. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42607. */
  42608. get loadingScreen(): ILoadingScreen;
  42609. /**
  42610. * Sets the current loading screen object
  42611. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42612. */
  42613. set loadingScreen(loadingScreen: ILoadingScreen);
  42614. /**
  42615. * Sets the current loading screen text
  42616. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42617. */
  42618. set loadingUIText(text: string);
  42619. /**
  42620. * Sets the current loading screen background color
  42621. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42622. */
  42623. set loadingUIBackgroundColor(color: string);
  42624. /** Pointerlock and fullscreen */
  42625. /**
  42626. * Ask the browser to promote the current element to pointerlock mode
  42627. * @param element defines the DOM element to promote
  42628. */
  42629. static _RequestPointerlock(element: HTMLElement): void;
  42630. /**
  42631. * Asks the browser to exit pointerlock mode
  42632. */
  42633. static _ExitPointerlock(): void;
  42634. /**
  42635. * Ask the browser to promote the current element to fullscreen rendering mode
  42636. * @param element defines the DOM element to promote
  42637. */
  42638. static _RequestFullscreen(element: HTMLElement): void;
  42639. /**
  42640. * Asks the browser to exit fullscreen mode
  42641. */
  42642. static _ExitFullscreen(): void;
  42643. }
  42644. }
  42645. declare module "babylonjs/Engines/engineStore" {
  42646. import { Nullable } from "babylonjs/types";
  42647. import { Engine } from "babylonjs/Engines/engine";
  42648. import { Scene } from "babylonjs/scene";
  42649. /**
  42650. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42651. * during the life time of the application.
  42652. */
  42653. export class EngineStore {
  42654. /** Gets the list of created engines */
  42655. static Instances: import("babylonjs/Engines/engine").Engine[];
  42656. /** @hidden */
  42657. static _LastCreatedScene: Nullable<Scene>;
  42658. /**
  42659. * Gets the latest created engine
  42660. */
  42661. static get LastCreatedEngine(): Nullable<Engine>;
  42662. /**
  42663. * Gets the latest created scene
  42664. */
  42665. static get LastCreatedScene(): Nullable<Scene>;
  42666. /**
  42667. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42668. * @ignorenaming
  42669. */
  42670. static UseFallbackTexture: boolean;
  42671. /**
  42672. * Texture content used if a texture cannot loaded
  42673. * @ignorenaming
  42674. */
  42675. static FallbackTexture: string;
  42676. }
  42677. }
  42678. declare module "babylonjs/Misc/promise" {
  42679. /**
  42680. * Helper class that provides a small promise polyfill
  42681. */
  42682. export class PromisePolyfill {
  42683. /**
  42684. * Static function used to check if the polyfill is required
  42685. * If this is the case then the function will inject the polyfill to window.Promise
  42686. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42687. */
  42688. static Apply(force?: boolean): void;
  42689. }
  42690. }
  42691. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  42692. /**
  42693. * Interface for screenshot methods with describe argument called `size` as object with options
  42694. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42695. */
  42696. export interface IScreenshotSize {
  42697. /**
  42698. * number in pixels for canvas height
  42699. */
  42700. height?: number;
  42701. /**
  42702. * multiplier allowing render at a higher or lower resolution
  42703. * If value is defined then height and width will be ignored and taken from camera
  42704. */
  42705. precision?: number;
  42706. /**
  42707. * number in pixels for canvas width
  42708. */
  42709. width?: number;
  42710. }
  42711. }
  42712. declare module "babylonjs/Misc/tools" {
  42713. import { Nullable, float } from "babylonjs/types";
  42714. import { DomManagement } from "babylonjs/Misc/domManagement";
  42715. import { WebRequest } from "babylonjs/Misc/webRequest";
  42716. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  42717. import { ReadFileError } from "babylonjs/Misc/fileTools";
  42718. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42719. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  42720. import { Camera } from "babylonjs/Cameras/camera";
  42721. import { Engine } from "babylonjs/Engines/engine";
  42722. interface IColor4Like {
  42723. r: float;
  42724. g: float;
  42725. b: float;
  42726. a: float;
  42727. }
  42728. /**
  42729. * Class containing a set of static utilities functions
  42730. */
  42731. export class Tools {
  42732. /**
  42733. * Gets or sets the base URL to use to load assets
  42734. */
  42735. static get BaseUrl(): string;
  42736. static set BaseUrl(value: string);
  42737. /**
  42738. * Enable/Disable Custom HTTP Request Headers globally.
  42739. * default = false
  42740. * @see CustomRequestHeaders
  42741. */
  42742. static UseCustomRequestHeaders: boolean;
  42743. /**
  42744. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42745. * i.e. when loading files, where the server/service expects an Authorization header
  42746. */
  42747. static CustomRequestHeaders: {
  42748. [key: string]: string;
  42749. };
  42750. /**
  42751. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42752. */
  42753. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42754. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42755. /**
  42756. * Default behaviour for cors in the application.
  42757. * It can be a string if the expected behavior is identical in the entire app.
  42758. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42759. */
  42760. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42761. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42762. /**
  42763. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42764. * @ignorenaming
  42765. */
  42766. static get UseFallbackTexture(): boolean;
  42767. static set UseFallbackTexture(value: boolean);
  42768. /**
  42769. * Use this object to register external classes like custom textures or material
  42770. * to allow the laoders to instantiate them
  42771. */
  42772. static get RegisteredExternalClasses(): {
  42773. [key: string]: Object;
  42774. };
  42775. static set RegisteredExternalClasses(classes: {
  42776. [key: string]: Object;
  42777. });
  42778. /**
  42779. * Texture content used if a texture cannot loaded
  42780. * @ignorenaming
  42781. */
  42782. static get fallbackTexture(): string;
  42783. static set fallbackTexture(value: string);
  42784. /**
  42785. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42786. * @param u defines the coordinate on X axis
  42787. * @param v defines the coordinate on Y axis
  42788. * @param width defines the width of the source data
  42789. * @param height defines the height of the source data
  42790. * @param pixels defines the source byte array
  42791. * @param color defines the output color
  42792. */
  42793. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42794. /**
  42795. * Interpolates between a and b via alpha
  42796. * @param a The lower value (returned when alpha = 0)
  42797. * @param b The upper value (returned when alpha = 1)
  42798. * @param alpha The interpolation-factor
  42799. * @return The mixed value
  42800. */
  42801. static Mix(a: number, b: number, alpha: number): number;
  42802. /**
  42803. * Tries to instantiate a new object from a given class name
  42804. * @param className defines the class name to instantiate
  42805. * @returns the new object or null if the system was not able to do the instantiation
  42806. */
  42807. static Instantiate(className: string): any;
  42808. /**
  42809. * Provides a slice function that will work even on IE
  42810. * @param data defines the array to slice
  42811. * @param start defines the start of the data (optional)
  42812. * @param end defines the end of the data (optional)
  42813. * @returns the new sliced array
  42814. */
  42815. static Slice<T>(data: T, start?: number, end?: number): T;
  42816. /**
  42817. * Polyfill for setImmediate
  42818. * @param action defines the action to execute after the current execution block
  42819. */
  42820. static SetImmediate(action: () => void): void;
  42821. /**
  42822. * Function indicating if a number is an exponent of 2
  42823. * @param value defines the value to test
  42824. * @returns true if the value is an exponent of 2
  42825. */
  42826. static IsExponentOfTwo(value: number): boolean;
  42827. private static _tmpFloatArray;
  42828. /**
  42829. * Returns the nearest 32-bit single precision float representation of a Number
  42830. * @param value A Number. If the parameter is of a different type, it will get converted
  42831. * to a number or to NaN if it cannot be converted
  42832. * @returns number
  42833. */
  42834. static FloatRound(value: number): number;
  42835. /**
  42836. * Extracts the filename from a path
  42837. * @param path defines the path to use
  42838. * @returns the filename
  42839. */
  42840. static GetFilename(path: string): string;
  42841. /**
  42842. * Extracts the "folder" part of a path (everything before the filename).
  42843. * @param uri The URI to extract the info from
  42844. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42845. * @returns The "folder" part of the path
  42846. */
  42847. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42848. /**
  42849. * Extracts text content from a DOM element hierarchy
  42850. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42851. */
  42852. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42853. /**
  42854. * Convert an angle in radians to degrees
  42855. * @param angle defines the angle to convert
  42856. * @returns the angle in degrees
  42857. */
  42858. static ToDegrees(angle: number): number;
  42859. /**
  42860. * Convert an angle in degrees to radians
  42861. * @param angle defines the angle to convert
  42862. * @returns the angle in radians
  42863. */
  42864. static ToRadians(angle: number): number;
  42865. /**
  42866. * Returns an array if obj is not an array
  42867. * @param obj defines the object to evaluate as an array
  42868. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42869. * @returns either obj directly if obj is an array or a new array containing obj
  42870. */
  42871. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42872. /**
  42873. * Gets the pointer prefix to use
  42874. * @param engine defines the engine we are finding the prefix for
  42875. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42876. */
  42877. static GetPointerPrefix(engine: Engine): string;
  42878. /**
  42879. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42880. * @param url define the url we are trying
  42881. * @param element define the dom element where to configure the cors policy
  42882. */
  42883. static SetCorsBehavior(url: string | string[], element: {
  42884. crossOrigin: string | null;
  42885. }): void;
  42886. /**
  42887. * Removes unwanted characters from an url
  42888. * @param url defines the url to clean
  42889. * @returns the cleaned url
  42890. */
  42891. static CleanUrl(url: string): string;
  42892. /**
  42893. * Gets or sets a function used to pre-process url before using them to load assets
  42894. */
  42895. static get PreprocessUrl(): (url: string) => string;
  42896. static set PreprocessUrl(processor: (url: string) => string);
  42897. /**
  42898. * Loads an image as an HTMLImageElement.
  42899. * @param input url string, ArrayBuffer, or Blob to load
  42900. * @param onLoad callback called when the image successfully loads
  42901. * @param onError callback called when the image fails to load
  42902. * @param offlineProvider offline provider for caching
  42903. * @param mimeType optional mime type
  42904. * @returns the HTMLImageElement of the loaded image
  42905. */
  42906. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42907. /**
  42908. * Loads a file from a url
  42909. * @param url url string, ArrayBuffer, or Blob to load
  42910. * @param onSuccess callback called when the file successfully loads
  42911. * @param onProgress callback called while file is loading (if the server supports this mode)
  42912. * @param offlineProvider defines the offline provider for caching
  42913. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42914. * @param onError callback called when the file fails to load
  42915. * @returns a file request object
  42916. */
  42917. 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;
  42918. /**
  42919. * Loads a file from a url
  42920. * @param url the file url to load
  42921. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42922. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42923. */
  42924. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42925. /**
  42926. * Load a script (identified by an url). When the url returns, the
  42927. * content of this file is added into a new script element, attached to the DOM (body element)
  42928. * @param scriptUrl defines the url of the script to laod
  42929. * @param onSuccess defines the callback called when the script is loaded
  42930. * @param onError defines the callback to call if an error occurs
  42931. * @param scriptId defines the id of the script element
  42932. */
  42933. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42934. /**
  42935. * Load an asynchronous script (identified by an url). When the url returns, the
  42936. * content of this file is added into a new script element, attached to the DOM (body element)
  42937. * @param scriptUrl defines the url of the script to laod
  42938. * @param scriptId defines the id of the script element
  42939. * @returns a promise request object
  42940. */
  42941. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42942. /**
  42943. * Loads a file from a blob
  42944. * @param fileToLoad defines the blob to use
  42945. * @param callback defines the callback to call when data is loaded
  42946. * @param progressCallback defines the callback to call during loading process
  42947. * @returns a file request object
  42948. */
  42949. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42950. /**
  42951. * Reads a file from a File object
  42952. * @param file defines the file to load
  42953. * @param onSuccess defines the callback to call when data is loaded
  42954. * @param onProgress defines the callback to call during loading process
  42955. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42956. * @param onError defines the callback to call when an error occurs
  42957. * @returns a file request object
  42958. */
  42959. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42960. /**
  42961. * Creates a data url from a given string content
  42962. * @param content defines the content to convert
  42963. * @returns the new data url link
  42964. */
  42965. static FileAsURL(content: string): string;
  42966. /**
  42967. * Format the given number to a specific decimal format
  42968. * @param value defines the number to format
  42969. * @param decimals defines the number of decimals to use
  42970. * @returns the formatted string
  42971. */
  42972. static Format(value: number, decimals?: number): string;
  42973. /**
  42974. * Tries to copy an object by duplicating every property
  42975. * @param source defines the source object
  42976. * @param destination defines the target object
  42977. * @param doNotCopyList defines a list of properties to avoid
  42978. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42979. */
  42980. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42981. /**
  42982. * Gets a boolean indicating if the given object has no own property
  42983. * @param obj defines the object to test
  42984. * @returns true if object has no own property
  42985. */
  42986. static IsEmpty(obj: any): boolean;
  42987. /**
  42988. * Function used to register events at window level
  42989. * @param windowElement defines the Window object to use
  42990. * @param events defines the events to register
  42991. */
  42992. static RegisterTopRootEvents(windowElement: Window, events: {
  42993. name: string;
  42994. handler: Nullable<(e: FocusEvent) => any>;
  42995. }[]): void;
  42996. /**
  42997. * Function used to unregister events from window level
  42998. * @param windowElement defines the Window object to use
  42999. * @param events defines the events to unregister
  43000. */
  43001. static UnregisterTopRootEvents(windowElement: Window, events: {
  43002. name: string;
  43003. handler: Nullable<(e: FocusEvent) => any>;
  43004. }[]): void;
  43005. /**
  43006. * @ignore
  43007. */
  43008. static _ScreenshotCanvas: HTMLCanvasElement;
  43009. /**
  43010. * Dumps the current bound framebuffer
  43011. * @param width defines the rendering width
  43012. * @param height defines the rendering height
  43013. * @param engine defines the hosting engine
  43014. * @param successCallback defines the callback triggered once the data are available
  43015. * @param mimeType defines the mime type of the result
  43016. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43017. */
  43018. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43019. /**
  43020. * Converts the canvas data to blob.
  43021. * This acts as a polyfill for browsers not supporting the to blob function.
  43022. * @param canvas Defines the canvas to extract the data from
  43023. * @param successCallback Defines the callback triggered once the data are available
  43024. * @param mimeType Defines the mime type of the result
  43025. */
  43026. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43027. /**
  43028. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43029. * @param successCallback defines the callback triggered once the data are available
  43030. * @param mimeType defines the mime type of the result
  43031. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43032. */
  43033. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43034. /**
  43035. * Downloads a blob in the browser
  43036. * @param blob defines the blob to download
  43037. * @param fileName defines the name of the downloaded file
  43038. */
  43039. static Download(blob: Blob, fileName: string): void;
  43040. /**
  43041. * Captures a screenshot of the current rendering
  43042. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43043. * @param engine defines the rendering engine
  43044. * @param camera defines the source camera
  43045. * @param size This parameter can be set to a single number or to an object with the
  43046. * following (optional) properties: precision, width, height. If a single number is passed,
  43047. * it will be used for both width and height. If an object is passed, the screenshot size
  43048. * will be derived from the parameters. The precision property is a multiplier allowing
  43049. * rendering at a higher or lower resolution
  43050. * @param successCallback defines the callback receives a single parameter which contains the
  43051. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43052. * src parameter of an <img> to display it
  43053. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43054. * Check your browser for supported MIME types
  43055. */
  43056. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43057. /**
  43058. * Captures a screenshot of the current rendering
  43059. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43060. * @param engine defines the rendering engine
  43061. * @param camera defines the source camera
  43062. * @param size This parameter can be set to a single number or to an object with the
  43063. * following (optional) properties: precision, width, height. If a single number is passed,
  43064. * it will be used for both width and height. If an object is passed, the screenshot size
  43065. * will be derived from the parameters. The precision property is a multiplier allowing
  43066. * rendering at a higher or lower resolution
  43067. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43068. * Check your browser for supported MIME types
  43069. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43070. * to the src parameter of an <img> to display it
  43071. */
  43072. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43073. /**
  43074. * Generates an image screenshot from the specified camera.
  43075. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43076. * @param engine The engine to use for rendering
  43077. * @param camera The camera to use for rendering
  43078. * @param size This parameter can be set to a single number or to an object with the
  43079. * following (optional) properties: precision, width, height. If a single number is passed,
  43080. * it will be used for both width and height. If an object is passed, the screenshot size
  43081. * will be derived from the parameters. The precision property is a multiplier allowing
  43082. * rendering at a higher or lower resolution
  43083. * @param successCallback The callback receives a single parameter which contains the
  43084. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43085. * src parameter of an <img> to display it
  43086. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43087. * Check your browser for supported MIME types
  43088. * @param samples Texture samples (default: 1)
  43089. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43090. * @param fileName A name for for the downloaded file.
  43091. */
  43092. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43093. /**
  43094. * Generates an image screenshot from the specified camera.
  43095. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43096. * @param engine The engine to use for rendering
  43097. * @param camera The camera to use for rendering
  43098. * @param size This parameter can be set to a single number or to an object with the
  43099. * following (optional) properties: precision, width, height. If a single number is passed,
  43100. * it will be used for both width and height. If an object is passed, the screenshot size
  43101. * will be derived from the parameters. The precision property is a multiplier allowing
  43102. * rendering at a higher or lower resolution
  43103. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43104. * Check your browser for supported MIME types
  43105. * @param samples Texture samples (default: 1)
  43106. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43107. * @param fileName A name for for the downloaded file.
  43108. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43109. * to the src parameter of an <img> to display it
  43110. */
  43111. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43112. /**
  43113. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43114. * Be aware Math.random() could cause collisions, but:
  43115. * "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"
  43116. * @returns a pseudo random id
  43117. */
  43118. static RandomId(): string;
  43119. /**
  43120. * Test if the given uri is a base64 string
  43121. * @param uri The uri to test
  43122. * @return True if the uri is a base64 string or false otherwise
  43123. */
  43124. static IsBase64(uri: string): boolean;
  43125. /**
  43126. * Decode the given base64 uri.
  43127. * @param uri The uri to decode
  43128. * @return The decoded base64 data.
  43129. */
  43130. static DecodeBase64(uri: string): ArrayBuffer;
  43131. /**
  43132. * Gets the absolute url.
  43133. * @param url the input url
  43134. * @return the absolute url
  43135. */
  43136. static GetAbsoluteUrl(url: string): string;
  43137. /**
  43138. * No log
  43139. */
  43140. static readonly NoneLogLevel: number;
  43141. /**
  43142. * Only message logs
  43143. */
  43144. static readonly MessageLogLevel: number;
  43145. /**
  43146. * Only warning logs
  43147. */
  43148. static readonly WarningLogLevel: number;
  43149. /**
  43150. * Only error logs
  43151. */
  43152. static readonly ErrorLogLevel: number;
  43153. /**
  43154. * All logs
  43155. */
  43156. static readonly AllLogLevel: number;
  43157. /**
  43158. * Gets a value indicating the number of loading errors
  43159. * @ignorenaming
  43160. */
  43161. static get errorsCount(): number;
  43162. /**
  43163. * Callback called when a new log is added
  43164. */
  43165. static OnNewCacheEntry: (entry: string) => void;
  43166. /**
  43167. * Log a message to the console
  43168. * @param message defines the message to log
  43169. */
  43170. static Log(message: string): void;
  43171. /**
  43172. * Write a warning message to the console
  43173. * @param message defines the message to log
  43174. */
  43175. static Warn(message: string): void;
  43176. /**
  43177. * Write an error message to the console
  43178. * @param message defines the message to log
  43179. */
  43180. static Error(message: string): void;
  43181. /**
  43182. * Gets current log cache (list of logs)
  43183. */
  43184. static get LogCache(): string;
  43185. /**
  43186. * Clears the log cache
  43187. */
  43188. static ClearLogCache(): void;
  43189. /**
  43190. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43191. */
  43192. static set LogLevels(level: number);
  43193. /**
  43194. * Checks if the window object exists
  43195. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43196. */
  43197. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43198. /**
  43199. * No performance log
  43200. */
  43201. static readonly PerformanceNoneLogLevel: number;
  43202. /**
  43203. * Use user marks to log performance
  43204. */
  43205. static readonly PerformanceUserMarkLogLevel: number;
  43206. /**
  43207. * Log performance to the console
  43208. */
  43209. static readonly PerformanceConsoleLogLevel: number;
  43210. private static _performance;
  43211. /**
  43212. * Sets the current performance log level
  43213. */
  43214. static set PerformanceLogLevel(level: number);
  43215. private static _StartPerformanceCounterDisabled;
  43216. private static _EndPerformanceCounterDisabled;
  43217. private static _StartUserMark;
  43218. private static _EndUserMark;
  43219. private static _StartPerformanceConsole;
  43220. private static _EndPerformanceConsole;
  43221. /**
  43222. * Starts a performance counter
  43223. */
  43224. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43225. /**
  43226. * Ends a specific performance coutner
  43227. */
  43228. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43229. /**
  43230. * Gets either window.performance.now() if supported or Date.now() else
  43231. */
  43232. static get Now(): number;
  43233. /**
  43234. * This method will return the name of the class used to create the instance of the given object.
  43235. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43236. * @param object the object to get the class name from
  43237. * @param isType defines if the object is actually a type
  43238. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43239. */
  43240. static GetClassName(object: any, isType?: boolean): string;
  43241. /**
  43242. * Gets the first element of an array satisfying a given predicate
  43243. * @param array defines the array to browse
  43244. * @param predicate defines the predicate to use
  43245. * @returns null if not found or the element
  43246. */
  43247. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43248. /**
  43249. * This method will return the name of the full name of the class, including its owning module (if any).
  43250. * 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).
  43251. * @param object the object to get the class name from
  43252. * @param isType defines if the object is actually a type
  43253. * @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.
  43254. * @ignorenaming
  43255. */
  43256. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43257. /**
  43258. * Returns a promise that resolves after the given amount of time.
  43259. * @param delay Number of milliseconds to delay
  43260. * @returns Promise that resolves after the given amount of time
  43261. */
  43262. static DelayAsync(delay: number): Promise<void>;
  43263. /**
  43264. * Utility function to detect if the current user agent is Safari
  43265. * @returns whether or not the current user agent is safari
  43266. */
  43267. static IsSafari(): boolean;
  43268. }
  43269. /**
  43270. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43271. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43272. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43273. * @param name The name of the class, case should be preserved
  43274. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43275. */
  43276. export function className(name: string, module?: string): (target: Object) => void;
  43277. /**
  43278. * An implementation of a loop for asynchronous functions.
  43279. */
  43280. export class AsyncLoop {
  43281. /**
  43282. * Defines the number of iterations for the loop
  43283. */
  43284. iterations: number;
  43285. /**
  43286. * Defines the current index of the loop.
  43287. */
  43288. index: number;
  43289. private _done;
  43290. private _fn;
  43291. private _successCallback;
  43292. /**
  43293. * Constructor.
  43294. * @param iterations the number of iterations.
  43295. * @param func the function to run each iteration
  43296. * @param successCallback the callback that will be called upon succesful execution
  43297. * @param offset starting offset.
  43298. */
  43299. constructor(
  43300. /**
  43301. * Defines the number of iterations for the loop
  43302. */
  43303. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43304. /**
  43305. * Execute the next iteration. Must be called after the last iteration was finished.
  43306. */
  43307. executeNext(): void;
  43308. /**
  43309. * Break the loop and run the success callback.
  43310. */
  43311. breakLoop(): void;
  43312. /**
  43313. * Create and run an async loop.
  43314. * @param iterations the number of iterations.
  43315. * @param fn the function to run each iteration
  43316. * @param successCallback the callback that will be called upon succesful execution
  43317. * @param offset starting offset.
  43318. * @returns the created async loop object
  43319. */
  43320. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43321. /**
  43322. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43323. * @param iterations total number of iterations
  43324. * @param syncedIterations number of synchronous iterations in each async iteration.
  43325. * @param fn the function to call each iteration.
  43326. * @param callback a success call back that will be called when iterating stops.
  43327. * @param breakFunction a break condition (optional)
  43328. * @param timeout timeout settings for the setTimeout function. default - 0.
  43329. * @returns the created async loop object
  43330. */
  43331. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43332. }
  43333. }
  43334. declare module "babylonjs/Misc/stringDictionary" {
  43335. import { Nullable } from "babylonjs/types";
  43336. /**
  43337. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43338. * The underlying implementation relies on an associative array to ensure the best performances.
  43339. * The value can be anything including 'null' but except 'undefined'
  43340. */
  43341. export class StringDictionary<T> {
  43342. /**
  43343. * This will clear this dictionary and copy the content from the 'source' one.
  43344. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43345. * @param source the dictionary to take the content from and copy to this dictionary
  43346. */
  43347. copyFrom(source: StringDictionary<T>): void;
  43348. /**
  43349. * Get a value based from its key
  43350. * @param key the given key to get the matching value from
  43351. * @return the value if found, otherwise undefined is returned
  43352. */
  43353. get(key: string): T | undefined;
  43354. /**
  43355. * Get a value from its key or add it if it doesn't exist.
  43356. * This method will ensure you that a given key/data will be present in the dictionary.
  43357. * @param key the given key to get the matching value from
  43358. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43359. * The factory will only be invoked if there's no data for the given key.
  43360. * @return the value corresponding to the key.
  43361. */
  43362. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43363. /**
  43364. * Get a value from its key if present in the dictionary otherwise add it
  43365. * @param key the key to get the value from
  43366. * @param val if there's no such key/value pair in the dictionary add it with this value
  43367. * @return the value corresponding to the key
  43368. */
  43369. getOrAdd(key: string, val: T): T;
  43370. /**
  43371. * Check if there's a given key in the dictionary
  43372. * @param key the key to check for
  43373. * @return true if the key is present, false otherwise
  43374. */
  43375. contains(key: string): boolean;
  43376. /**
  43377. * Add a new key and its corresponding value
  43378. * @param key the key to add
  43379. * @param value the value corresponding to the key
  43380. * @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
  43381. */
  43382. add(key: string, value: T): boolean;
  43383. /**
  43384. * Update a specific value associated to a key
  43385. * @param key defines the key to use
  43386. * @param value defines the value to store
  43387. * @returns true if the value was updated (or false if the key was not found)
  43388. */
  43389. set(key: string, value: T): boolean;
  43390. /**
  43391. * Get the element of the given key and remove it from the dictionary
  43392. * @param key defines the key to search
  43393. * @returns the value associated with the key or null if not found
  43394. */
  43395. getAndRemove(key: string): Nullable<T>;
  43396. /**
  43397. * Remove a key/value from the dictionary.
  43398. * @param key the key to remove
  43399. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43400. */
  43401. remove(key: string): boolean;
  43402. /**
  43403. * Clear the whole content of the dictionary
  43404. */
  43405. clear(): void;
  43406. /**
  43407. * Gets the current count
  43408. */
  43409. get count(): number;
  43410. /**
  43411. * Execute a callback on each key/val of the dictionary.
  43412. * Note that you can remove any element in this dictionary in the callback implementation
  43413. * @param callback the callback to execute on a given key/value pair
  43414. */
  43415. forEach(callback: (key: string, val: T) => void): void;
  43416. /**
  43417. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43418. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43419. * Note that you can remove any element in this dictionary in the callback implementation
  43420. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43421. * @returns the first item
  43422. */
  43423. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43424. private _count;
  43425. private _data;
  43426. }
  43427. }
  43428. declare module "babylonjs/Collisions/collisionCoordinator" {
  43429. import { Nullable } from "babylonjs/types";
  43430. import { Scene } from "babylonjs/scene";
  43431. import { Vector3 } from "babylonjs/Maths/math.vector";
  43432. import { Collider } from "babylonjs/Collisions/collider";
  43433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43434. /** @hidden */
  43435. export interface ICollisionCoordinator {
  43436. createCollider(): Collider;
  43437. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43438. init(scene: Scene): void;
  43439. }
  43440. /** @hidden */
  43441. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43442. private _scene;
  43443. private _scaledPosition;
  43444. private _scaledVelocity;
  43445. private _finalPosition;
  43446. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43447. createCollider(): Collider;
  43448. init(scene: Scene): void;
  43449. private _collideWithWorld;
  43450. }
  43451. }
  43452. declare module "babylonjs/Inputs/scene.inputManager" {
  43453. import { Nullable } from "babylonjs/types";
  43454. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43455. import { Vector2 } from "babylonjs/Maths/math.vector";
  43456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43457. import { Scene } from "babylonjs/scene";
  43458. /**
  43459. * Class used to manage all inputs for the scene.
  43460. */
  43461. export class InputManager {
  43462. /** The distance in pixel that you have to move to prevent some events */
  43463. static DragMovementThreshold: number;
  43464. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43465. static LongPressDelay: number;
  43466. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43467. static DoubleClickDelay: number;
  43468. /** If you need to check double click without raising a single click at first click, enable this flag */
  43469. static ExclusiveDoubleClickMode: boolean;
  43470. /** 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. */
  43471. private _alreadyAttached;
  43472. private _wheelEventName;
  43473. private _onPointerMove;
  43474. private _onPointerDown;
  43475. private _onPointerUp;
  43476. private _initClickEvent;
  43477. private _initActionManager;
  43478. private _delayedSimpleClick;
  43479. private _delayedSimpleClickTimeout;
  43480. private _previousDelayedSimpleClickTimeout;
  43481. private _meshPickProceed;
  43482. private _previousButtonPressed;
  43483. private _currentPickResult;
  43484. private _previousPickResult;
  43485. private _totalPointersPressed;
  43486. private _doubleClickOccured;
  43487. private _pointerOverMesh;
  43488. private _pickedDownMesh;
  43489. private _pickedUpMesh;
  43490. private _pointerX;
  43491. private _pointerY;
  43492. private _unTranslatedPointerX;
  43493. private _unTranslatedPointerY;
  43494. private _startingPointerPosition;
  43495. private _previousStartingPointerPosition;
  43496. private _startingPointerTime;
  43497. private _previousStartingPointerTime;
  43498. private _pointerCaptures;
  43499. private _meshUnderPointerId;
  43500. private _onKeyDown;
  43501. private _onKeyUp;
  43502. private _onCanvasFocusObserver;
  43503. private _onCanvasBlurObserver;
  43504. private _scene;
  43505. /**
  43506. * Creates a new InputManager
  43507. * @param scene defines the hosting scene
  43508. */
  43509. constructor(scene: Scene);
  43510. /**
  43511. * Gets the mesh that is currently under the pointer
  43512. */
  43513. get meshUnderPointer(): Nullable<AbstractMesh>;
  43514. /**
  43515. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43516. * @param pointerId the pointer id to use
  43517. * @returns The mesh under this pointer id or null if not found
  43518. */
  43519. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43520. /**
  43521. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43522. */
  43523. get unTranslatedPointer(): Vector2;
  43524. /**
  43525. * Gets or sets the current on-screen X position of the pointer
  43526. */
  43527. get pointerX(): number;
  43528. set pointerX(value: number);
  43529. /**
  43530. * Gets or sets the current on-screen Y position of the pointer
  43531. */
  43532. get pointerY(): number;
  43533. set pointerY(value: number);
  43534. private _updatePointerPosition;
  43535. private _processPointerMove;
  43536. private _setRayOnPointerInfo;
  43537. private _checkPrePointerObservable;
  43538. /**
  43539. * Use this method to simulate a pointer move on a mesh
  43540. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43541. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43542. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43543. */
  43544. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43545. /**
  43546. * Use this method to simulate a pointer down on a mesh
  43547. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43548. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43549. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43550. */
  43551. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43552. private _processPointerDown;
  43553. /** @hidden */
  43554. _isPointerSwiping(): boolean;
  43555. /**
  43556. * Use this method to simulate a pointer up on a mesh
  43557. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43558. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43559. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43560. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43561. */
  43562. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43563. private _processPointerUp;
  43564. /**
  43565. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43566. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43567. * @returns true if the pointer was captured
  43568. */
  43569. isPointerCaptured(pointerId?: number): boolean;
  43570. /**
  43571. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43572. * @param attachUp defines if you want to attach events to pointerup
  43573. * @param attachDown defines if you want to attach events to pointerdown
  43574. * @param attachMove defines if you want to attach events to pointermove
  43575. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43576. */
  43577. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43578. /**
  43579. * Detaches all event handlers
  43580. */
  43581. detachControl(): void;
  43582. /**
  43583. * Force the value of meshUnderPointer
  43584. * @param mesh defines the mesh to use
  43585. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43586. */
  43587. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43588. /**
  43589. * Gets the mesh under the pointer
  43590. * @returns a Mesh or null if no mesh is under the pointer
  43591. */
  43592. getPointerOverMesh(): Nullable<AbstractMesh>;
  43593. }
  43594. }
  43595. declare module "babylonjs/Animations/animationGroup" {
  43596. import { Animatable } from "babylonjs/Animations/animatable";
  43597. import { Animation } from "babylonjs/Animations/animation";
  43598. import { Scene, IDisposable } from "babylonjs/scene";
  43599. import { Observable } from "babylonjs/Misc/observable";
  43600. import { Nullable } from "babylonjs/types";
  43601. import "babylonjs/Animations/animatable";
  43602. /**
  43603. * This class defines the direct association between an animation and a target
  43604. */
  43605. export class TargetedAnimation {
  43606. /**
  43607. * Animation to perform
  43608. */
  43609. animation: Animation;
  43610. /**
  43611. * Target to animate
  43612. */
  43613. target: any;
  43614. /**
  43615. * Returns the string "TargetedAnimation"
  43616. * @returns "TargetedAnimation"
  43617. */
  43618. getClassName(): string;
  43619. /**
  43620. * Serialize the object
  43621. * @returns the JSON object representing the current entity
  43622. */
  43623. serialize(): any;
  43624. }
  43625. /**
  43626. * Use this class to create coordinated animations on multiple targets
  43627. */
  43628. export class AnimationGroup implements IDisposable {
  43629. /** The name of the animation group */
  43630. name: string;
  43631. private _scene;
  43632. private _targetedAnimations;
  43633. private _animatables;
  43634. private _from;
  43635. private _to;
  43636. private _isStarted;
  43637. private _isPaused;
  43638. private _speedRatio;
  43639. private _loopAnimation;
  43640. private _isAdditive;
  43641. /**
  43642. * Gets or sets the unique id of the node
  43643. */
  43644. uniqueId: number;
  43645. /**
  43646. * This observable will notify when one animation have ended
  43647. */
  43648. onAnimationEndObservable: Observable<TargetedAnimation>;
  43649. /**
  43650. * Observer raised when one animation loops
  43651. */
  43652. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43653. /**
  43654. * Observer raised when all animations have looped
  43655. */
  43656. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43657. /**
  43658. * This observable will notify when all animations have ended.
  43659. */
  43660. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43661. /**
  43662. * This observable will notify when all animations have paused.
  43663. */
  43664. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43665. /**
  43666. * This observable will notify when all animations are playing.
  43667. */
  43668. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43669. /**
  43670. * Gets the first frame
  43671. */
  43672. get from(): number;
  43673. /**
  43674. * Gets the last frame
  43675. */
  43676. get to(): number;
  43677. /**
  43678. * Define if the animations are started
  43679. */
  43680. get isStarted(): boolean;
  43681. /**
  43682. * Gets a value indicating that the current group is playing
  43683. */
  43684. get isPlaying(): boolean;
  43685. /**
  43686. * Gets or sets the speed ratio to use for all animations
  43687. */
  43688. get speedRatio(): number;
  43689. /**
  43690. * Gets or sets the speed ratio to use for all animations
  43691. */
  43692. set speedRatio(value: number);
  43693. /**
  43694. * Gets or sets if all animations should loop or not
  43695. */
  43696. get loopAnimation(): boolean;
  43697. set loopAnimation(value: boolean);
  43698. /**
  43699. * Gets or sets if all animations should be evaluated additively
  43700. */
  43701. get isAdditive(): boolean;
  43702. set isAdditive(value: boolean);
  43703. /**
  43704. * Gets the targeted animations for this animation group
  43705. */
  43706. get targetedAnimations(): Array<TargetedAnimation>;
  43707. /**
  43708. * returning the list of animatables controlled by this animation group.
  43709. */
  43710. get animatables(): Array<Animatable>;
  43711. /**
  43712. * Gets the list of target animations
  43713. */
  43714. get children(): TargetedAnimation[];
  43715. /**
  43716. * Instantiates a new Animation Group.
  43717. * This helps managing several animations at once.
  43718. * @see https://doc.babylonjs.com/how_to/group
  43719. * @param name Defines the name of the group
  43720. * @param scene Defines the scene the group belongs to
  43721. */
  43722. constructor(
  43723. /** The name of the animation group */
  43724. name: string, scene?: Nullable<Scene>);
  43725. /**
  43726. * Add an animation (with its target) in the group
  43727. * @param animation defines the animation we want to add
  43728. * @param target defines the target of the animation
  43729. * @returns the TargetedAnimation object
  43730. */
  43731. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43732. /**
  43733. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43734. * It can add constant keys at begin or end
  43735. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43736. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43737. * @returns the animation group
  43738. */
  43739. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43740. private _animationLoopCount;
  43741. private _animationLoopFlags;
  43742. private _processLoop;
  43743. /**
  43744. * Start all animations on given targets
  43745. * @param loop defines if animations must loop
  43746. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43747. * @param from defines the from key (optional)
  43748. * @param to defines the to key (optional)
  43749. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43750. * @returns the current animation group
  43751. */
  43752. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43753. /**
  43754. * Pause all animations
  43755. * @returns the animation group
  43756. */
  43757. pause(): AnimationGroup;
  43758. /**
  43759. * Play all animations to initial state
  43760. * This function will start() the animations if they were not started or will restart() them if they were paused
  43761. * @param loop defines if animations must loop
  43762. * @returns the animation group
  43763. */
  43764. play(loop?: boolean): AnimationGroup;
  43765. /**
  43766. * Reset all animations to initial state
  43767. * @returns the animation group
  43768. */
  43769. reset(): AnimationGroup;
  43770. /**
  43771. * Restart animations from key 0
  43772. * @returns the animation group
  43773. */
  43774. restart(): AnimationGroup;
  43775. /**
  43776. * Stop all animations
  43777. * @returns the animation group
  43778. */
  43779. stop(): AnimationGroup;
  43780. /**
  43781. * Set animation weight for all animatables
  43782. * @param weight defines the weight to use
  43783. * @return the animationGroup
  43784. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43785. */
  43786. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43787. /**
  43788. * Synchronize and normalize all animatables with a source animatable
  43789. * @param root defines the root animatable to synchronize with
  43790. * @return the animationGroup
  43791. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43792. */
  43793. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43794. /**
  43795. * Goes to a specific frame in this animation group
  43796. * @param frame the frame number to go to
  43797. * @return the animationGroup
  43798. */
  43799. goToFrame(frame: number): AnimationGroup;
  43800. /**
  43801. * Dispose all associated resources
  43802. */
  43803. dispose(): void;
  43804. private _checkAnimationGroupEnded;
  43805. /**
  43806. * Clone the current animation group and returns a copy
  43807. * @param newName defines the name of the new group
  43808. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43809. * @returns the new aniamtion group
  43810. */
  43811. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43812. /**
  43813. * Serializes the animationGroup to an object
  43814. * @returns Serialized object
  43815. */
  43816. serialize(): any;
  43817. /**
  43818. * Returns a new AnimationGroup object parsed from the source provided.
  43819. * @param parsedAnimationGroup defines the source
  43820. * @param scene defines the scene that will receive the animationGroup
  43821. * @returns a new AnimationGroup
  43822. */
  43823. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43824. /**
  43825. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43826. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43827. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43828. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43829. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43830. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43831. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43832. */
  43833. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43834. /**
  43835. * Returns the string "AnimationGroup"
  43836. * @returns "AnimationGroup"
  43837. */
  43838. getClassName(): string;
  43839. /**
  43840. * Creates a detailled string about the object
  43841. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43842. * @returns a string representing the object
  43843. */
  43844. toString(fullDetails?: boolean): string;
  43845. }
  43846. }
  43847. declare module "babylonjs/scene" {
  43848. import { Nullable } from "babylonjs/types";
  43849. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  43850. import { Observable } from "babylonjs/Misc/observable";
  43851. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43852. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  43853. import { Geometry } from "babylonjs/Meshes/geometry";
  43854. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43857. import { Mesh } from "babylonjs/Meshes/mesh";
  43858. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43859. import { Bone } from "babylonjs/Bones/bone";
  43860. import { Skeleton } from "babylonjs/Bones/skeleton";
  43861. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  43862. import { Camera } from "babylonjs/Cameras/camera";
  43863. import { AbstractScene } from "babylonjs/abstractScene";
  43864. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43865. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43866. import { Material } from "babylonjs/Materials/material";
  43867. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43868. import { Effect } from "babylonjs/Materials/effect";
  43869. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  43870. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  43871. import { Light } from "babylonjs/Lights/light";
  43872. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43873. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  43874. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  43875. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  43876. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  43877. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43878. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  43879. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  43880. import { Engine } from "babylonjs/Engines/engine";
  43881. import { Node } from "babylonjs/node";
  43882. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  43883. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  43884. import { WebRequest } from "babylonjs/Misc/webRequest";
  43885. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  43886. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43887. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43888. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  43889. import { Plane } from "babylonjs/Maths/math.plane";
  43890. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  43891. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  43892. import { Ray } from "babylonjs/Culling/ray";
  43893. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  43894. import { Animation } from "babylonjs/Animations/animation";
  43895. import { Animatable } from "babylonjs/Animations/animatable";
  43896. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43897. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  43898. import { Collider } from "babylonjs/Collisions/collider";
  43899. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43900. /**
  43901. * Define an interface for all classes that will hold resources
  43902. */
  43903. export interface IDisposable {
  43904. /**
  43905. * Releases all held resources
  43906. */
  43907. dispose(): void;
  43908. }
  43909. /** Interface defining initialization parameters for Scene class */
  43910. export interface SceneOptions {
  43911. /**
  43912. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  43913. * It will improve performance when the number of geometries becomes important.
  43914. */
  43915. useGeometryUniqueIdsMap?: boolean;
  43916. /**
  43917. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  43918. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43919. */
  43920. useMaterialMeshMap?: boolean;
  43921. /**
  43922. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  43923. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43924. */
  43925. useClonedMeshMap?: boolean;
  43926. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  43927. virtual?: boolean;
  43928. }
  43929. /**
  43930. * Represents a scene to be rendered by the engine.
  43931. * @see https://doc.babylonjs.com/features/scene
  43932. */
  43933. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  43934. /** The fog is deactivated */
  43935. static readonly FOGMODE_NONE: number;
  43936. /** The fog density is following an exponential function */
  43937. static readonly FOGMODE_EXP: number;
  43938. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  43939. static readonly FOGMODE_EXP2: number;
  43940. /** The fog density is following a linear function. */
  43941. static readonly FOGMODE_LINEAR: number;
  43942. /**
  43943. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  43944. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43945. */
  43946. static MinDeltaTime: number;
  43947. /**
  43948. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  43949. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43950. */
  43951. static MaxDeltaTime: number;
  43952. /**
  43953. * Factory used to create the default material.
  43954. * @param name The name of the material to create
  43955. * @param scene The scene to create the material for
  43956. * @returns The default material
  43957. */
  43958. static DefaultMaterialFactory(scene: Scene): Material;
  43959. /**
  43960. * Factory used to create the a collision coordinator.
  43961. * @returns The collision coordinator
  43962. */
  43963. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  43964. /** @hidden */
  43965. _inputManager: InputManager;
  43966. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  43967. cameraToUseForPointers: Nullable<Camera>;
  43968. /** @hidden */
  43969. readonly _isScene: boolean;
  43970. /** @hidden */
  43971. _blockEntityCollection: boolean;
  43972. /**
  43973. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  43974. */
  43975. autoClear: boolean;
  43976. /**
  43977. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  43978. */
  43979. autoClearDepthAndStencil: boolean;
  43980. /**
  43981. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  43982. */
  43983. clearColor: Color4;
  43984. /**
  43985. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  43986. */
  43987. ambientColor: Color3;
  43988. /**
  43989. * This is use to store the default BRDF lookup for PBR materials in your scene.
  43990. * It should only be one of the following (if not the default embedded one):
  43991. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  43992. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  43993. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  43994. * The material properties need to be setup according to the type of texture in use.
  43995. */
  43996. environmentBRDFTexture: BaseTexture;
  43997. /**
  43998. * Texture used in all pbr material as the reflection texture.
  43999. * As in the majority of the scene they are the same (exception for multi room and so on),
  44000. * this is easier to reference from here than from all the materials.
  44001. */
  44002. get environmentTexture(): Nullable<BaseTexture>;
  44003. /**
  44004. * Texture used in all pbr material as the reflection texture.
  44005. * As in the majority of the scene they are the same (exception for multi room and so on),
  44006. * this is easier to set here than in all the materials.
  44007. */
  44008. set environmentTexture(value: Nullable<BaseTexture>);
  44009. /** @hidden */
  44010. protected _environmentIntensity: number;
  44011. /**
  44012. * Intensity of the environment in all pbr material.
  44013. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44014. * As in the majority of the scene they are the same (exception for multi room and so on),
  44015. * this is easier to reference from here than from all the materials.
  44016. */
  44017. get environmentIntensity(): number;
  44018. /**
  44019. * Intensity of the environment in all pbr material.
  44020. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44021. * As in the majority of the scene they are the same (exception for multi room and so on),
  44022. * this is easier to set here than in all the materials.
  44023. */
  44024. set environmentIntensity(value: number);
  44025. /** @hidden */
  44026. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44027. /**
  44028. * Default image processing configuration used either in the rendering
  44029. * Forward main pass or through the imageProcessingPostProcess if present.
  44030. * As in the majority of the scene they are the same (exception for multi camera),
  44031. * this is easier to reference from here than from all the materials and post process.
  44032. *
  44033. * No setter as we it is a shared configuration, you can set the values instead.
  44034. */
  44035. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44036. private _forceWireframe;
  44037. /**
  44038. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44039. */
  44040. set forceWireframe(value: boolean);
  44041. get forceWireframe(): boolean;
  44042. private _skipFrustumClipping;
  44043. /**
  44044. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44045. */
  44046. set skipFrustumClipping(value: boolean);
  44047. get skipFrustumClipping(): boolean;
  44048. private _forcePointsCloud;
  44049. /**
  44050. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44051. */
  44052. set forcePointsCloud(value: boolean);
  44053. get forcePointsCloud(): boolean;
  44054. /**
  44055. * Gets or sets the active clipplane 1
  44056. */
  44057. clipPlane: Nullable<Plane>;
  44058. /**
  44059. * Gets or sets the active clipplane 2
  44060. */
  44061. clipPlane2: Nullable<Plane>;
  44062. /**
  44063. * Gets or sets the active clipplane 3
  44064. */
  44065. clipPlane3: Nullable<Plane>;
  44066. /**
  44067. * Gets or sets the active clipplane 4
  44068. */
  44069. clipPlane4: Nullable<Plane>;
  44070. /**
  44071. * Gets or sets the active clipplane 5
  44072. */
  44073. clipPlane5: Nullable<Plane>;
  44074. /**
  44075. * Gets or sets the active clipplane 6
  44076. */
  44077. clipPlane6: Nullable<Plane>;
  44078. /**
  44079. * Gets or sets a boolean indicating if animations are enabled
  44080. */
  44081. animationsEnabled: boolean;
  44082. private _animationPropertiesOverride;
  44083. /**
  44084. * Gets or sets the animation properties override
  44085. */
  44086. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44087. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44088. /**
  44089. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44090. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44091. */
  44092. useConstantAnimationDeltaTime: boolean;
  44093. /**
  44094. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44095. * Please note that it requires to run a ray cast through the scene on every frame
  44096. */
  44097. constantlyUpdateMeshUnderPointer: boolean;
  44098. /**
  44099. * Defines the HTML cursor to use when hovering over interactive elements
  44100. */
  44101. hoverCursor: string;
  44102. /**
  44103. * Defines the HTML default cursor to use (empty by default)
  44104. */
  44105. defaultCursor: string;
  44106. /**
  44107. * Defines whether cursors are handled by the scene.
  44108. */
  44109. doNotHandleCursors: boolean;
  44110. /**
  44111. * This is used to call preventDefault() on pointer down
  44112. * in order to block unwanted artifacts like system double clicks
  44113. */
  44114. preventDefaultOnPointerDown: boolean;
  44115. /**
  44116. * This is used to call preventDefault() on pointer up
  44117. * in order to block unwanted artifacts like system double clicks
  44118. */
  44119. preventDefaultOnPointerUp: boolean;
  44120. /**
  44121. * Gets or sets user defined metadata
  44122. */
  44123. metadata: any;
  44124. /**
  44125. * For internal use only. Please do not use.
  44126. */
  44127. reservedDataStore: any;
  44128. /**
  44129. * Gets the name of the plugin used to load this scene (null by default)
  44130. */
  44131. loadingPluginName: string;
  44132. /**
  44133. * Use this array to add regular expressions used to disable offline support for specific urls
  44134. */
  44135. disableOfflineSupportExceptionRules: RegExp[];
  44136. /**
  44137. * An event triggered when the scene is disposed.
  44138. */
  44139. onDisposeObservable: Observable<Scene>;
  44140. private _onDisposeObserver;
  44141. /** Sets a function to be executed when this scene is disposed. */
  44142. set onDispose(callback: () => void);
  44143. /**
  44144. * An event triggered before rendering the scene (right after animations and physics)
  44145. */
  44146. onBeforeRenderObservable: Observable<Scene>;
  44147. private _onBeforeRenderObserver;
  44148. /** Sets a function to be executed before rendering this scene */
  44149. set beforeRender(callback: Nullable<() => void>);
  44150. /**
  44151. * An event triggered after rendering the scene
  44152. */
  44153. onAfterRenderObservable: Observable<Scene>;
  44154. /**
  44155. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44156. */
  44157. onAfterRenderCameraObservable: Observable<Camera>;
  44158. private _onAfterRenderObserver;
  44159. /** Sets a function to be executed after rendering this scene */
  44160. set afterRender(callback: Nullable<() => void>);
  44161. /**
  44162. * An event triggered before animating the scene
  44163. */
  44164. onBeforeAnimationsObservable: Observable<Scene>;
  44165. /**
  44166. * An event triggered after animations processing
  44167. */
  44168. onAfterAnimationsObservable: Observable<Scene>;
  44169. /**
  44170. * An event triggered before draw calls are ready to be sent
  44171. */
  44172. onBeforeDrawPhaseObservable: Observable<Scene>;
  44173. /**
  44174. * An event triggered after draw calls have been sent
  44175. */
  44176. onAfterDrawPhaseObservable: Observable<Scene>;
  44177. /**
  44178. * An event triggered when the scene is ready
  44179. */
  44180. onReadyObservable: Observable<Scene>;
  44181. /**
  44182. * An event triggered before rendering a camera
  44183. */
  44184. onBeforeCameraRenderObservable: Observable<Camera>;
  44185. private _onBeforeCameraRenderObserver;
  44186. /** Sets a function to be executed before rendering a camera*/
  44187. set beforeCameraRender(callback: () => void);
  44188. /**
  44189. * An event triggered after rendering a camera
  44190. */
  44191. onAfterCameraRenderObservable: Observable<Camera>;
  44192. private _onAfterCameraRenderObserver;
  44193. /** Sets a function to be executed after rendering a camera*/
  44194. set afterCameraRender(callback: () => void);
  44195. /**
  44196. * An event triggered when active meshes evaluation is about to start
  44197. */
  44198. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44199. /**
  44200. * An event triggered when active meshes evaluation is done
  44201. */
  44202. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44203. /**
  44204. * An event triggered when particles rendering is about to start
  44205. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44206. */
  44207. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44208. /**
  44209. * An event triggered when particles rendering is done
  44210. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44211. */
  44212. onAfterParticlesRenderingObservable: Observable<Scene>;
  44213. /**
  44214. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44215. */
  44216. onDataLoadedObservable: Observable<Scene>;
  44217. /**
  44218. * An event triggered when a camera is created
  44219. */
  44220. onNewCameraAddedObservable: Observable<Camera>;
  44221. /**
  44222. * An event triggered when a camera is removed
  44223. */
  44224. onCameraRemovedObservable: Observable<Camera>;
  44225. /**
  44226. * An event triggered when a light is created
  44227. */
  44228. onNewLightAddedObservable: Observable<Light>;
  44229. /**
  44230. * An event triggered when a light is removed
  44231. */
  44232. onLightRemovedObservable: Observable<Light>;
  44233. /**
  44234. * An event triggered when a geometry is created
  44235. */
  44236. onNewGeometryAddedObservable: Observable<Geometry>;
  44237. /**
  44238. * An event triggered when a geometry is removed
  44239. */
  44240. onGeometryRemovedObservable: Observable<Geometry>;
  44241. /**
  44242. * An event triggered when a transform node is created
  44243. */
  44244. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44245. /**
  44246. * An event triggered when a transform node is removed
  44247. */
  44248. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44249. /**
  44250. * An event triggered when a mesh is created
  44251. */
  44252. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44253. /**
  44254. * An event triggered when a mesh is removed
  44255. */
  44256. onMeshRemovedObservable: Observable<AbstractMesh>;
  44257. /**
  44258. * An event triggered when a skeleton is created
  44259. */
  44260. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44261. /**
  44262. * An event triggered when a skeleton is removed
  44263. */
  44264. onSkeletonRemovedObservable: Observable<Skeleton>;
  44265. /**
  44266. * An event triggered when a material is created
  44267. */
  44268. onNewMaterialAddedObservable: Observable<Material>;
  44269. /**
  44270. * An event triggered when a material is removed
  44271. */
  44272. onMaterialRemovedObservable: Observable<Material>;
  44273. /**
  44274. * An event triggered when a texture is created
  44275. */
  44276. onNewTextureAddedObservable: Observable<BaseTexture>;
  44277. /**
  44278. * An event triggered when a texture is removed
  44279. */
  44280. onTextureRemovedObservable: Observable<BaseTexture>;
  44281. /**
  44282. * An event triggered when render targets are about to be rendered
  44283. * Can happen multiple times per frame.
  44284. */
  44285. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44286. /**
  44287. * An event triggered when render targets were rendered.
  44288. * Can happen multiple times per frame.
  44289. */
  44290. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44291. /**
  44292. * An event triggered before calculating deterministic simulation step
  44293. */
  44294. onBeforeStepObservable: Observable<Scene>;
  44295. /**
  44296. * An event triggered after calculating deterministic simulation step
  44297. */
  44298. onAfterStepObservable: Observable<Scene>;
  44299. /**
  44300. * An event triggered when the activeCamera property is updated
  44301. */
  44302. onActiveCameraChanged: Observable<Scene>;
  44303. /**
  44304. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44305. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44306. * 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)
  44307. */
  44308. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44309. /**
  44310. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44311. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44312. * 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)
  44313. */
  44314. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44315. /**
  44316. * This Observable will when a mesh has been imported into the scene.
  44317. */
  44318. onMeshImportedObservable: Observable<AbstractMesh>;
  44319. /**
  44320. * This Observable will when an animation file has been imported into the scene.
  44321. */
  44322. onAnimationFileImportedObservable: Observable<Scene>;
  44323. /**
  44324. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44325. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44326. */
  44327. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44328. /** @hidden */
  44329. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44330. /**
  44331. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44332. */
  44333. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44334. /**
  44335. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44336. */
  44337. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44338. /**
  44339. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44340. */
  44341. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44342. /** Callback called when a pointer move is detected */
  44343. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44344. /** Callback called when a pointer down is detected */
  44345. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44346. /** Callback called when a pointer up is detected */
  44347. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44348. /** Callback called when a pointer pick is detected */
  44349. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44350. /**
  44351. * 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).
  44352. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44353. */
  44354. onPrePointerObservable: Observable<PointerInfoPre>;
  44355. /**
  44356. * Observable event triggered each time an input event is received from the rendering canvas
  44357. */
  44358. onPointerObservable: Observable<PointerInfo>;
  44359. /**
  44360. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44361. */
  44362. get unTranslatedPointer(): Vector2;
  44363. /**
  44364. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44365. */
  44366. static get DragMovementThreshold(): number;
  44367. static set DragMovementThreshold(value: number);
  44368. /**
  44369. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44370. */
  44371. static get LongPressDelay(): number;
  44372. static set LongPressDelay(value: number);
  44373. /**
  44374. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44375. */
  44376. static get DoubleClickDelay(): number;
  44377. static set DoubleClickDelay(value: number);
  44378. /** If you need to check double click without raising a single click at first click, enable this flag */
  44379. static get ExclusiveDoubleClickMode(): boolean;
  44380. static set ExclusiveDoubleClickMode(value: boolean);
  44381. /** @hidden */
  44382. _mirroredCameraPosition: Nullable<Vector3>;
  44383. /**
  44384. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44385. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44386. */
  44387. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44388. /**
  44389. * Observable event triggered each time an keyboard event is received from the hosting window
  44390. */
  44391. onKeyboardObservable: Observable<KeyboardInfo>;
  44392. private _useRightHandedSystem;
  44393. /**
  44394. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44395. */
  44396. set useRightHandedSystem(value: boolean);
  44397. get useRightHandedSystem(): boolean;
  44398. private _timeAccumulator;
  44399. private _currentStepId;
  44400. private _currentInternalStep;
  44401. /**
  44402. * Sets the step Id used by deterministic lock step
  44403. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44404. * @param newStepId defines the step Id
  44405. */
  44406. setStepId(newStepId: number): void;
  44407. /**
  44408. * Gets the step Id used by deterministic lock step
  44409. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44410. * @returns the step Id
  44411. */
  44412. getStepId(): number;
  44413. /**
  44414. * Gets the internal step used by deterministic lock step
  44415. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44416. * @returns the internal step
  44417. */
  44418. getInternalStep(): number;
  44419. private _fogEnabled;
  44420. /**
  44421. * Gets or sets a boolean indicating if fog is enabled on this scene
  44422. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44423. * (Default is true)
  44424. */
  44425. set fogEnabled(value: boolean);
  44426. get fogEnabled(): boolean;
  44427. private _fogMode;
  44428. /**
  44429. * Gets or sets the fog mode to use
  44430. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44431. * | mode | value |
  44432. * | --- | --- |
  44433. * | FOGMODE_NONE | 0 |
  44434. * | FOGMODE_EXP | 1 |
  44435. * | FOGMODE_EXP2 | 2 |
  44436. * | FOGMODE_LINEAR | 3 |
  44437. */
  44438. set fogMode(value: number);
  44439. get fogMode(): number;
  44440. /**
  44441. * Gets or sets the fog color to use
  44442. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44443. * (Default is Color3(0.2, 0.2, 0.3))
  44444. */
  44445. fogColor: Color3;
  44446. /**
  44447. * Gets or sets the fog density to use
  44448. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44449. * (Default is 0.1)
  44450. */
  44451. fogDensity: number;
  44452. /**
  44453. * Gets or sets the fog start distance to use
  44454. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44455. * (Default is 0)
  44456. */
  44457. fogStart: number;
  44458. /**
  44459. * Gets or sets the fog end distance to use
  44460. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44461. * (Default is 1000)
  44462. */
  44463. fogEnd: number;
  44464. /**
  44465. * Flag indicating that the frame buffer binding is handled by another component
  44466. */
  44467. prePass: boolean;
  44468. private _shadowsEnabled;
  44469. /**
  44470. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44471. */
  44472. set shadowsEnabled(value: boolean);
  44473. get shadowsEnabled(): boolean;
  44474. private _lightsEnabled;
  44475. /**
  44476. * Gets or sets a boolean indicating if lights are enabled on this scene
  44477. */
  44478. set lightsEnabled(value: boolean);
  44479. get lightsEnabled(): boolean;
  44480. /** All of the active cameras added to this scene. */
  44481. activeCameras: Camera[];
  44482. /** @hidden */
  44483. _activeCamera: Nullable<Camera>;
  44484. /** Gets or sets the current active camera */
  44485. get activeCamera(): Nullable<Camera>;
  44486. set activeCamera(value: Nullable<Camera>);
  44487. private _defaultMaterial;
  44488. /** The default material used on meshes when no material is affected */
  44489. get defaultMaterial(): Material;
  44490. /** The default material used on meshes when no material is affected */
  44491. set defaultMaterial(value: Material);
  44492. private _texturesEnabled;
  44493. /**
  44494. * Gets or sets a boolean indicating if textures are enabled on this scene
  44495. */
  44496. set texturesEnabled(value: boolean);
  44497. get texturesEnabled(): boolean;
  44498. /**
  44499. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44500. */
  44501. physicsEnabled: boolean;
  44502. /**
  44503. * Gets or sets a boolean indicating if particles are enabled on this scene
  44504. */
  44505. particlesEnabled: boolean;
  44506. /**
  44507. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44508. */
  44509. spritesEnabled: boolean;
  44510. private _skeletonsEnabled;
  44511. /**
  44512. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44513. */
  44514. set skeletonsEnabled(value: boolean);
  44515. get skeletonsEnabled(): boolean;
  44516. /**
  44517. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44518. */
  44519. lensFlaresEnabled: boolean;
  44520. /**
  44521. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44522. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44523. */
  44524. collisionsEnabled: boolean;
  44525. private _collisionCoordinator;
  44526. /** @hidden */
  44527. get collisionCoordinator(): ICollisionCoordinator;
  44528. /**
  44529. * Defines the gravity applied to this scene (used only for collisions)
  44530. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44531. */
  44532. gravity: Vector3;
  44533. /**
  44534. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44535. */
  44536. postProcessesEnabled: boolean;
  44537. /**
  44538. * Gets the current postprocess manager
  44539. */
  44540. postProcessManager: PostProcessManager;
  44541. /**
  44542. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44543. */
  44544. renderTargetsEnabled: boolean;
  44545. /**
  44546. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44547. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44548. */
  44549. dumpNextRenderTargets: boolean;
  44550. /**
  44551. * The list of user defined render targets added to the scene
  44552. */
  44553. customRenderTargets: RenderTargetTexture[];
  44554. /**
  44555. * Defines if texture loading must be delayed
  44556. * If true, textures will only be loaded when they need to be rendered
  44557. */
  44558. useDelayedTextureLoading: boolean;
  44559. /**
  44560. * Gets the list of meshes imported to the scene through SceneLoader
  44561. */
  44562. importedMeshesFiles: String[];
  44563. /**
  44564. * Gets or sets a boolean indicating if probes are enabled on this scene
  44565. */
  44566. probesEnabled: boolean;
  44567. /**
  44568. * Gets or sets the current offline provider to use to store scene data
  44569. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44570. */
  44571. offlineProvider: IOfflineProvider;
  44572. /**
  44573. * Gets or sets the action manager associated with the scene
  44574. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44575. */
  44576. actionManager: AbstractActionManager;
  44577. private _meshesForIntersections;
  44578. /**
  44579. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44580. */
  44581. proceduralTexturesEnabled: boolean;
  44582. private _engine;
  44583. private _totalVertices;
  44584. /** @hidden */
  44585. _activeIndices: PerfCounter;
  44586. /** @hidden */
  44587. _activeParticles: PerfCounter;
  44588. /** @hidden */
  44589. _activeBones: PerfCounter;
  44590. private _animationRatio;
  44591. /** @hidden */
  44592. _animationTimeLast: number;
  44593. /** @hidden */
  44594. _animationTime: number;
  44595. /**
  44596. * Gets or sets a general scale for animation speed
  44597. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44598. */
  44599. animationTimeScale: number;
  44600. /** @hidden */
  44601. _cachedMaterial: Nullable<Material>;
  44602. /** @hidden */
  44603. _cachedEffect: Nullable<Effect>;
  44604. /** @hidden */
  44605. _cachedVisibility: Nullable<number>;
  44606. private _renderId;
  44607. private _frameId;
  44608. private _executeWhenReadyTimeoutId;
  44609. private _intermediateRendering;
  44610. private _viewUpdateFlag;
  44611. private _projectionUpdateFlag;
  44612. /** @hidden */
  44613. _toBeDisposed: Nullable<IDisposable>[];
  44614. private _activeRequests;
  44615. /** @hidden */
  44616. _pendingData: any[];
  44617. private _isDisposed;
  44618. /**
  44619. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44620. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44621. */
  44622. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44623. private _activeMeshes;
  44624. private _processedMaterials;
  44625. private _renderTargets;
  44626. /** @hidden */
  44627. _activeParticleSystems: SmartArray<IParticleSystem>;
  44628. private _activeSkeletons;
  44629. private _softwareSkinnedMeshes;
  44630. private _renderingManager;
  44631. /** @hidden */
  44632. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44633. private _transformMatrix;
  44634. private _sceneUbo;
  44635. /** @hidden */
  44636. _viewMatrix: Matrix;
  44637. private _projectionMatrix;
  44638. /** @hidden */
  44639. _forcedViewPosition: Nullable<Vector3>;
  44640. /** @hidden */
  44641. _frustumPlanes: Plane[];
  44642. /**
  44643. * Gets the list of frustum planes (built from the active camera)
  44644. */
  44645. get frustumPlanes(): Plane[];
  44646. /**
  44647. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44648. * This is useful if there are more lights that the maximum simulteanous authorized
  44649. */
  44650. requireLightSorting: boolean;
  44651. /** @hidden */
  44652. readonly useMaterialMeshMap: boolean;
  44653. /** @hidden */
  44654. readonly useClonedMeshMap: boolean;
  44655. private _externalData;
  44656. private _uid;
  44657. /**
  44658. * @hidden
  44659. * Backing store of defined scene components.
  44660. */
  44661. _components: ISceneComponent[];
  44662. /**
  44663. * @hidden
  44664. * Backing store of defined scene components.
  44665. */
  44666. _serializableComponents: ISceneSerializableComponent[];
  44667. /**
  44668. * List of components to register on the next registration step.
  44669. */
  44670. private _transientComponents;
  44671. /**
  44672. * Registers the transient components if needed.
  44673. */
  44674. private _registerTransientComponents;
  44675. /**
  44676. * @hidden
  44677. * Add a component to the scene.
  44678. * Note that the ccomponent could be registered on th next frame if this is called after
  44679. * the register component stage.
  44680. * @param component Defines the component to add to the scene
  44681. */
  44682. _addComponent(component: ISceneComponent): void;
  44683. /**
  44684. * @hidden
  44685. * Gets a component from the scene.
  44686. * @param name defines the name of the component to retrieve
  44687. * @returns the component or null if not present
  44688. */
  44689. _getComponent(name: string): Nullable<ISceneComponent>;
  44690. /**
  44691. * @hidden
  44692. * Defines the actions happening before camera updates.
  44693. */
  44694. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  44695. /**
  44696. * @hidden
  44697. * Defines the actions happening before clear the canvas.
  44698. */
  44699. _beforeClearStage: Stage<SimpleStageAction>;
  44700. /**
  44701. * @hidden
  44702. * Defines the actions when collecting render targets for the frame.
  44703. */
  44704. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44705. /**
  44706. * @hidden
  44707. * Defines the actions happening for one camera in the frame.
  44708. */
  44709. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44710. /**
  44711. * @hidden
  44712. * Defines the actions happening during the per mesh ready checks.
  44713. */
  44714. _isReadyForMeshStage: Stage<MeshStageAction>;
  44715. /**
  44716. * @hidden
  44717. * Defines the actions happening before evaluate active mesh checks.
  44718. */
  44719. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  44720. /**
  44721. * @hidden
  44722. * Defines the actions happening during the evaluate sub mesh checks.
  44723. */
  44724. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  44725. /**
  44726. * @hidden
  44727. * Defines the actions happening during the active mesh stage.
  44728. */
  44729. _activeMeshStage: Stage<ActiveMeshStageAction>;
  44730. /**
  44731. * @hidden
  44732. * Defines the actions happening during the per camera render target step.
  44733. */
  44734. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  44735. /**
  44736. * @hidden
  44737. * Defines the actions happening just before the active camera is drawing.
  44738. */
  44739. _beforeCameraDrawStage: Stage<CameraStageAction>;
  44740. /**
  44741. * @hidden
  44742. * Defines the actions happening just before a render target is drawing.
  44743. */
  44744. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44745. /**
  44746. * @hidden
  44747. * Defines the actions happening just before a rendering group is drawing.
  44748. */
  44749. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44750. /**
  44751. * @hidden
  44752. * Defines the actions happening just before a mesh is drawing.
  44753. */
  44754. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44755. /**
  44756. * @hidden
  44757. * Defines the actions happening just after a mesh has been drawn.
  44758. */
  44759. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44760. /**
  44761. * @hidden
  44762. * Defines the actions happening just after a rendering group has been drawn.
  44763. */
  44764. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44765. /**
  44766. * @hidden
  44767. * Defines the actions happening just after the active camera has been drawn.
  44768. */
  44769. _afterCameraDrawStage: Stage<CameraStageAction>;
  44770. /**
  44771. * @hidden
  44772. * Defines the actions happening just after a render target has been drawn.
  44773. */
  44774. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44775. /**
  44776. * @hidden
  44777. * Defines the actions happening just after rendering all cameras and computing intersections.
  44778. */
  44779. _afterRenderStage: Stage<SimpleStageAction>;
  44780. /**
  44781. * @hidden
  44782. * Defines the actions happening when a pointer move event happens.
  44783. */
  44784. _pointerMoveStage: Stage<PointerMoveStageAction>;
  44785. /**
  44786. * @hidden
  44787. * Defines the actions happening when a pointer down event happens.
  44788. */
  44789. _pointerDownStage: Stage<PointerUpDownStageAction>;
  44790. /**
  44791. * @hidden
  44792. * Defines the actions happening when a pointer up event happens.
  44793. */
  44794. _pointerUpStage: Stage<PointerUpDownStageAction>;
  44795. /**
  44796. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  44797. */
  44798. private geometriesByUniqueId;
  44799. /**
  44800. * Creates a new Scene
  44801. * @param engine defines the engine to use to render this scene
  44802. * @param options defines the scene options
  44803. */
  44804. constructor(engine: Engine, options?: SceneOptions);
  44805. /**
  44806. * Gets a string identifying the name of the class
  44807. * @returns "Scene" string
  44808. */
  44809. getClassName(): string;
  44810. private _defaultMeshCandidates;
  44811. /**
  44812. * @hidden
  44813. */
  44814. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44815. private _defaultSubMeshCandidates;
  44816. /**
  44817. * @hidden
  44818. */
  44819. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44820. /**
  44821. * Sets the default candidate providers for the scene.
  44822. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  44823. * and getCollidingSubMeshCandidates to their default function
  44824. */
  44825. setDefaultCandidateProviders(): void;
  44826. /**
  44827. * Gets the mesh that is currently under the pointer
  44828. */
  44829. get meshUnderPointer(): Nullable<AbstractMesh>;
  44830. /**
  44831. * Gets or sets the current on-screen X position of the pointer
  44832. */
  44833. get pointerX(): number;
  44834. set pointerX(value: number);
  44835. /**
  44836. * Gets or sets the current on-screen Y position of the pointer
  44837. */
  44838. get pointerY(): number;
  44839. set pointerY(value: number);
  44840. /**
  44841. * Gets the cached material (ie. the latest rendered one)
  44842. * @returns the cached material
  44843. */
  44844. getCachedMaterial(): Nullable<Material>;
  44845. /**
  44846. * Gets the cached effect (ie. the latest rendered one)
  44847. * @returns the cached effect
  44848. */
  44849. getCachedEffect(): Nullable<Effect>;
  44850. /**
  44851. * Gets the cached visibility state (ie. the latest rendered one)
  44852. * @returns the cached visibility state
  44853. */
  44854. getCachedVisibility(): Nullable<number>;
  44855. /**
  44856. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  44857. * @param material defines the current material
  44858. * @param effect defines the current effect
  44859. * @param visibility defines the current visibility state
  44860. * @returns true if one parameter is not cached
  44861. */
  44862. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  44863. /**
  44864. * Gets the engine associated with the scene
  44865. * @returns an Engine
  44866. */
  44867. getEngine(): Engine;
  44868. /**
  44869. * Gets the total number of vertices rendered per frame
  44870. * @returns the total number of vertices rendered per frame
  44871. */
  44872. getTotalVertices(): number;
  44873. /**
  44874. * Gets the performance counter for total vertices
  44875. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44876. */
  44877. get totalVerticesPerfCounter(): PerfCounter;
  44878. /**
  44879. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  44880. * @returns the total number of active indices rendered per frame
  44881. */
  44882. getActiveIndices(): number;
  44883. /**
  44884. * Gets the performance counter for active indices
  44885. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44886. */
  44887. get totalActiveIndicesPerfCounter(): PerfCounter;
  44888. /**
  44889. * Gets the total number of active particles rendered per frame
  44890. * @returns the total number of active particles rendered per frame
  44891. */
  44892. getActiveParticles(): number;
  44893. /**
  44894. * Gets the performance counter for active particles
  44895. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44896. */
  44897. get activeParticlesPerfCounter(): PerfCounter;
  44898. /**
  44899. * Gets the total number of active bones rendered per frame
  44900. * @returns the total number of active bones rendered per frame
  44901. */
  44902. getActiveBones(): number;
  44903. /**
  44904. * Gets the performance counter for active bones
  44905. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44906. */
  44907. get activeBonesPerfCounter(): PerfCounter;
  44908. /**
  44909. * Gets the array of active meshes
  44910. * @returns an array of AbstractMesh
  44911. */
  44912. getActiveMeshes(): SmartArray<AbstractMesh>;
  44913. /**
  44914. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  44915. * @returns a number
  44916. */
  44917. getAnimationRatio(): number;
  44918. /**
  44919. * Gets an unique Id for the current render phase
  44920. * @returns a number
  44921. */
  44922. getRenderId(): number;
  44923. /**
  44924. * Gets an unique Id for the current frame
  44925. * @returns a number
  44926. */
  44927. getFrameId(): number;
  44928. /** Call this function if you want to manually increment the render Id*/
  44929. incrementRenderId(): void;
  44930. private _createUbo;
  44931. /**
  44932. * Use this method to simulate a pointer move on a mesh
  44933. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44934. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44935. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44936. * @returns the current scene
  44937. */
  44938. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44939. /**
  44940. * Use this method to simulate a pointer down on a mesh
  44941. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44942. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44943. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44944. * @returns the current scene
  44945. */
  44946. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44947. /**
  44948. * Use this method to simulate a pointer up on a mesh
  44949. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44950. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44951. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44952. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44953. * @returns the current scene
  44954. */
  44955. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  44956. /**
  44957. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44958. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44959. * @returns true if the pointer was captured
  44960. */
  44961. isPointerCaptured(pointerId?: number): boolean;
  44962. /**
  44963. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44964. * @param attachUp defines if you want to attach events to pointerup
  44965. * @param attachDown defines if you want to attach events to pointerdown
  44966. * @param attachMove defines if you want to attach events to pointermove
  44967. */
  44968. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  44969. /** Detaches all event handlers*/
  44970. detachControl(): void;
  44971. /**
  44972. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  44973. * Delay loaded resources are not taking in account
  44974. * @return true if all required resources are ready
  44975. */
  44976. isReady(): boolean;
  44977. /** Resets all cached information relative to material (including effect and visibility) */
  44978. resetCachedMaterial(): void;
  44979. /**
  44980. * Registers a function to be called before every frame render
  44981. * @param func defines the function to register
  44982. */
  44983. registerBeforeRender(func: () => void): void;
  44984. /**
  44985. * Unregisters a function called before every frame render
  44986. * @param func defines the function to unregister
  44987. */
  44988. unregisterBeforeRender(func: () => void): void;
  44989. /**
  44990. * Registers a function to be called after every frame render
  44991. * @param func defines the function to register
  44992. */
  44993. registerAfterRender(func: () => void): void;
  44994. /**
  44995. * Unregisters a function called after every frame render
  44996. * @param func defines the function to unregister
  44997. */
  44998. unregisterAfterRender(func: () => void): void;
  44999. private _executeOnceBeforeRender;
  45000. /**
  45001. * The provided function will run before render once and will be disposed afterwards.
  45002. * A timeout delay can be provided so that the function will be executed in N ms.
  45003. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45004. * @param func The function to be executed.
  45005. * @param timeout optional delay in ms
  45006. */
  45007. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45008. /** @hidden */
  45009. _addPendingData(data: any): void;
  45010. /** @hidden */
  45011. _removePendingData(data: any): void;
  45012. /**
  45013. * Returns the number of items waiting to be loaded
  45014. * @returns the number of items waiting to be loaded
  45015. */
  45016. getWaitingItemsCount(): number;
  45017. /**
  45018. * Returns a boolean indicating if the scene is still loading data
  45019. */
  45020. get isLoading(): boolean;
  45021. /**
  45022. * Registers a function to be executed when the scene is ready
  45023. * @param {Function} func - the function to be executed
  45024. */
  45025. executeWhenReady(func: () => void): void;
  45026. /**
  45027. * Returns a promise that resolves when the scene is ready
  45028. * @returns A promise that resolves when the scene is ready
  45029. */
  45030. whenReadyAsync(): Promise<void>;
  45031. /** @hidden */
  45032. _checkIsReady(): void;
  45033. /**
  45034. * Gets all animatable attached to the scene
  45035. */
  45036. get animatables(): Animatable[];
  45037. /**
  45038. * Resets the last animation time frame.
  45039. * Useful to override when animations start running when loading a scene for the first time.
  45040. */
  45041. resetLastAnimationTimeFrame(): void;
  45042. /**
  45043. * Gets the current view matrix
  45044. * @returns a Matrix
  45045. */
  45046. getViewMatrix(): Matrix;
  45047. /**
  45048. * Gets the current projection matrix
  45049. * @returns a Matrix
  45050. */
  45051. getProjectionMatrix(): Matrix;
  45052. /**
  45053. * Gets the current transform matrix
  45054. * @returns a Matrix made of View * Projection
  45055. */
  45056. getTransformMatrix(): Matrix;
  45057. /**
  45058. * Sets the current transform matrix
  45059. * @param viewL defines the View matrix to use
  45060. * @param projectionL defines the Projection matrix to use
  45061. * @param viewR defines the right View matrix to use (if provided)
  45062. * @param projectionR defines the right Projection matrix to use (if provided)
  45063. */
  45064. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45065. /**
  45066. * Gets the uniform buffer used to store scene data
  45067. * @returns a UniformBuffer
  45068. */
  45069. getSceneUniformBuffer(): UniformBuffer;
  45070. /**
  45071. * Gets an unique (relatively to the current scene) Id
  45072. * @returns an unique number for the scene
  45073. */
  45074. getUniqueId(): number;
  45075. /**
  45076. * Add a mesh to the list of scene's meshes
  45077. * @param newMesh defines the mesh to add
  45078. * @param recursive if all child meshes should also be added to the scene
  45079. */
  45080. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45081. /**
  45082. * Remove a mesh for the list of scene's meshes
  45083. * @param toRemove defines the mesh to remove
  45084. * @param recursive if all child meshes should also be removed from the scene
  45085. * @returns the index where the mesh was in the mesh list
  45086. */
  45087. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45088. /**
  45089. * Add a transform node to the list of scene's transform nodes
  45090. * @param newTransformNode defines the transform node to add
  45091. */
  45092. addTransformNode(newTransformNode: TransformNode): void;
  45093. /**
  45094. * Remove a transform node for the list of scene's transform nodes
  45095. * @param toRemove defines the transform node to remove
  45096. * @returns the index where the transform node was in the transform node list
  45097. */
  45098. removeTransformNode(toRemove: TransformNode): number;
  45099. /**
  45100. * Remove a skeleton for the list of scene's skeletons
  45101. * @param toRemove defines the skeleton to remove
  45102. * @returns the index where the skeleton was in the skeleton list
  45103. */
  45104. removeSkeleton(toRemove: Skeleton): number;
  45105. /**
  45106. * Remove a morph target for the list of scene's morph targets
  45107. * @param toRemove defines the morph target to remove
  45108. * @returns the index where the morph target was in the morph target list
  45109. */
  45110. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45111. /**
  45112. * Remove a light for the list of scene's lights
  45113. * @param toRemove defines the light to remove
  45114. * @returns the index where the light was in the light list
  45115. */
  45116. removeLight(toRemove: Light): number;
  45117. /**
  45118. * Remove a camera for the list of scene's cameras
  45119. * @param toRemove defines the camera to remove
  45120. * @returns the index where the camera was in the camera list
  45121. */
  45122. removeCamera(toRemove: Camera): number;
  45123. /**
  45124. * Remove a particle system for the list of scene's particle systems
  45125. * @param toRemove defines the particle system to remove
  45126. * @returns the index where the particle system was in the particle system list
  45127. */
  45128. removeParticleSystem(toRemove: IParticleSystem): number;
  45129. /**
  45130. * Remove a animation for the list of scene's animations
  45131. * @param toRemove defines the animation to remove
  45132. * @returns the index where the animation was in the animation list
  45133. */
  45134. removeAnimation(toRemove: Animation): number;
  45135. /**
  45136. * Will stop the animation of the given target
  45137. * @param target - the target
  45138. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45139. * @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)
  45140. */
  45141. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45142. /**
  45143. * Removes the given animation group from this scene.
  45144. * @param toRemove The animation group to remove
  45145. * @returns The index of the removed animation group
  45146. */
  45147. removeAnimationGroup(toRemove: AnimationGroup): number;
  45148. /**
  45149. * Removes the given multi-material from this scene.
  45150. * @param toRemove The multi-material to remove
  45151. * @returns The index of the removed multi-material
  45152. */
  45153. removeMultiMaterial(toRemove: MultiMaterial): number;
  45154. /**
  45155. * Removes the given material from this scene.
  45156. * @param toRemove The material to remove
  45157. * @returns The index of the removed material
  45158. */
  45159. removeMaterial(toRemove: Material): number;
  45160. /**
  45161. * Removes the given action manager from this scene.
  45162. * @param toRemove The action manager to remove
  45163. * @returns The index of the removed action manager
  45164. */
  45165. removeActionManager(toRemove: AbstractActionManager): number;
  45166. /**
  45167. * Removes the given texture from this scene.
  45168. * @param toRemove The texture to remove
  45169. * @returns The index of the removed texture
  45170. */
  45171. removeTexture(toRemove: BaseTexture): number;
  45172. /**
  45173. * Adds the given light to this scene
  45174. * @param newLight The light to add
  45175. */
  45176. addLight(newLight: Light): void;
  45177. /**
  45178. * Sorts the list list based on light priorities
  45179. */
  45180. sortLightsByPriority(): void;
  45181. /**
  45182. * Adds the given camera to this scene
  45183. * @param newCamera The camera to add
  45184. */
  45185. addCamera(newCamera: Camera): void;
  45186. /**
  45187. * Adds the given skeleton to this scene
  45188. * @param newSkeleton The skeleton to add
  45189. */
  45190. addSkeleton(newSkeleton: Skeleton): void;
  45191. /**
  45192. * Adds the given particle system to this scene
  45193. * @param newParticleSystem The particle system to add
  45194. */
  45195. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45196. /**
  45197. * Adds the given animation to this scene
  45198. * @param newAnimation The animation to add
  45199. */
  45200. addAnimation(newAnimation: Animation): void;
  45201. /**
  45202. * Adds the given animation group to this scene.
  45203. * @param newAnimationGroup The animation group to add
  45204. */
  45205. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45206. /**
  45207. * Adds the given multi-material to this scene
  45208. * @param newMultiMaterial The multi-material to add
  45209. */
  45210. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45211. /**
  45212. * Adds the given material to this scene
  45213. * @param newMaterial The material to add
  45214. */
  45215. addMaterial(newMaterial: Material): void;
  45216. /**
  45217. * Adds the given morph target to this scene
  45218. * @param newMorphTargetManager The morph target to add
  45219. */
  45220. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45221. /**
  45222. * Adds the given geometry to this scene
  45223. * @param newGeometry The geometry to add
  45224. */
  45225. addGeometry(newGeometry: Geometry): void;
  45226. /**
  45227. * Adds the given action manager to this scene
  45228. * @param newActionManager The action manager to add
  45229. */
  45230. addActionManager(newActionManager: AbstractActionManager): void;
  45231. /**
  45232. * Adds the given texture to this scene.
  45233. * @param newTexture The texture to add
  45234. */
  45235. addTexture(newTexture: BaseTexture): void;
  45236. /**
  45237. * Switch active camera
  45238. * @param newCamera defines the new active camera
  45239. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45240. */
  45241. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45242. /**
  45243. * sets the active camera of the scene using its ID
  45244. * @param id defines the camera's ID
  45245. * @return the new active camera or null if none found.
  45246. */
  45247. setActiveCameraByID(id: string): Nullable<Camera>;
  45248. /**
  45249. * sets the active camera of the scene using its name
  45250. * @param name defines the camera's name
  45251. * @returns the new active camera or null if none found.
  45252. */
  45253. setActiveCameraByName(name: string): Nullable<Camera>;
  45254. /**
  45255. * get an animation group using its name
  45256. * @param name defines the material's name
  45257. * @return the animation group or null if none found.
  45258. */
  45259. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45260. /**
  45261. * Get a material using its unique id
  45262. * @param uniqueId defines the material's unique id
  45263. * @return the material or null if none found.
  45264. */
  45265. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45266. /**
  45267. * get a material using its id
  45268. * @param id defines the material's ID
  45269. * @return the material or null if none found.
  45270. */
  45271. getMaterialByID(id: string): Nullable<Material>;
  45272. /**
  45273. * Gets a the last added material using a given id
  45274. * @param id defines the material's ID
  45275. * @return the last material with the given id or null if none found.
  45276. */
  45277. getLastMaterialByID(id: string): Nullable<Material>;
  45278. /**
  45279. * Gets a material using its name
  45280. * @param name defines the material's name
  45281. * @return the material or null if none found.
  45282. */
  45283. getMaterialByName(name: string): Nullable<Material>;
  45284. /**
  45285. * Get a texture using its unique id
  45286. * @param uniqueId defines the texture's unique id
  45287. * @return the texture or null if none found.
  45288. */
  45289. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45290. /**
  45291. * Gets a camera using its id
  45292. * @param id defines the id to look for
  45293. * @returns the camera or null if not found
  45294. */
  45295. getCameraByID(id: string): Nullable<Camera>;
  45296. /**
  45297. * Gets a camera using its unique id
  45298. * @param uniqueId defines the unique id to look for
  45299. * @returns the camera or null if not found
  45300. */
  45301. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45302. /**
  45303. * Gets a camera using its name
  45304. * @param name defines the camera's name
  45305. * @return the camera or null if none found.
  45306. */
  45307. getCameraByName(name: string): Nullable<Camera>;
  45308. /**
  45309. * Gets a bone using its id
  45310. * @param id defines the bone's id
  45311. * @return the bone or null if not found
  45312. */
  45313. getBoneByID(id: string): Nullable<Bone>;
  45314. /**
  45315. * Gets a bone using its id
  45316. * @param name defines the bone's name
  45317. * @return the bone or null if not found
  45318. */
  45319. getBoneByName(name: string): Nullable<Bone>;
  45320. /**
  45321. * Gets a light node using its name
  45322. * @param name defines the the light's name
  45323. * @return the light or null if none found.
  45324. */
  45325. getLightByName(name: string): Nullable<Light>;
  45326. /**
  45327. * Gets a light node using its id
  45328. * @param id defines the light's id
  45329. * @return the light or null if none found.
  45330. */
  45331. getLightByID(id: string): Nullable<Light>;
  45332. /**
  45333. * Gets a light node using its scene-generated unique ID
  45334. * @param uniqueId defines the light's unique id
  45335. * @return the light or null if none found.
  45336. */
  45337. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45338. /**
  45339. * Gets a particle system by id
  45340. * @param id defines the particle system id
  45341. * @return the corresponding system or null if none found
  45342. */
  45343. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45344. /**
  45345. * Gets a geometry using its ID
  45346. * @param id defines the geometry's id
  45347. * @return the geometry or null if none found.
  45348. */
  45349. getGeometryByID(id: string): Nullable<Geometry>;
  45350. private _getGeometryByUniqueID;
  45351. /**
  45352. * Add a new geometry to this scene
  45353. * @param geometry defines the geometry to be added to the scene.
  45354. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45355. * @return a boolean defining if the geometry was added or not
  45356. */
  45357. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45358. /**
  45359. * Removes an existing geometry
  45360. * @param geometry defines the geometry to be removed from the scene
  45361. * @return a boolean defining if the geometry was removed or not
  45362. */
  45363. removeGeometry(geometry: Geometry): boolean;
  45364. /**
  45365. * Gets the list of geometries attached to the scene
  45366. * @returns an array of Geometry
  45367. */
  45368. getGeometries(): Geometry[];
  45369. /**
  45370. * Gets the first added mesh found of a given ID
  45371. * @param id defines the id to search for
  45372. * @return the mesh found or null if not found at all
  45373. */
  45374. getMeshByID(id: string): Nullable<AbstractMesh>;
  45375. /**
  45376. * Gets a list of meshes using their id
  45377. * @param id defines the id to search for
  45378. * @returns a list of meshes
  45379. */
  45380. getMeshesByID(id: string): Array<AbstractMesh>;
  45381. /**
  45382. * Gets the first added transform node found of a given ID
  45383. * @param id defines the id to search for
  45384. * @return the found transform node or null if not found at all.
  45385. */
  45386. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45387. /**
  45388. * Gets a transform node with its auto-generated unique id
  45389. * @param uniqueId efines the unique id to search for
  45390. * @return the found transform node or null if not found at all.
  45391. */
  45392. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45393. /**
  45394. * Gets a list of transform nodes using their id
  45395. * @param id defines the id to search for
  45396. * @returns a list of transform nodes
  45397. */
  45398. getTransformNodesByID(id: string): Array<TransformNode>;
  45399. /**
  45400. * Gets a mesh with its auto-generated unique id
  45401. * @param uniqueId defines the unique id to search for
  45402. * @return the found mesh or null if not found at all.
  45403. */
  45404. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45405. /**
  45406. * Gets a the last added mesh using a given id
  45407. * @param id defines the id to search for
  45408. * @return the found mesh or null if not found at all.
  45409. */
  45410. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45411. /**
  45412. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45413. * @param id defines the id to search for
  45414. * @return the found node or null if not found at all
  45415. */
  45416. getLastEntryByID(id: string): Nullable<Node>;
  45417. /**
  45418. * Gets a node (Mesh, Camera, Light) using a given id
  45419. * @param id defines the id to search for
  45420. * @return the found node or null if not found at all
  45421. */
  45422. getNodeByID(id: string): Nullable<Node>;
  45423. /**
  45424. * Gets a node (Mesh, Camera, Light) using a given name
  45425. * @param name defines the name to search for
  45426. * @return the found node or null if not found at all.
  45427. */
  45428. getNodeByName(name: string): Nullable<Node>;
  45429. /**
  45430. * Gets a mesh using a given name
  45431. * @param name defines the name to search for
  45432. * @return the found mesh or null if not found at all.
  45433. */
  45434. getMeshByName(name: string): Nullable<AbstractMesh>;
  45435. /**
  45436. * Gets a transform node using a given name
  45437. * @param name defines the name to search for
  45438. * @return the found transform node or null if not found at all.
  45439. */
  45440. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45441. /**
  45442. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45443. * @param id defines the id to search for
  45444. * @return the found skeleton or null if not found at all.
  45445. */
  45446. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45447. /**
  45448. * Gets a skeleton using a given auto generated unique id
  45449. * @param uniqueId defines the unique id to search for
  45450. * @return the found skeleton or null if not found at all.
  45451. */
  45452. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45453. /**
  45454. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45455. * @param id defines the id to search for
  45456. * @return the found skeleton or null if not found at all.
  45457. */
  45458. getSkeletonById(id: string): Nullable<Skeleton>;
  45459. /**
  45460. * Gets a skeleton using a given name
  45461. * @param name defines the name to search for
  45462. * @return the found skeleton or null if not found at all.
  45463. */
  45464. getSkeletonByName(name: string): Nullable<Skeleton>;
  45465. /**
  45466. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45467. * @param id defines the id to search for
  45468. * @return the found morph target manager or null if not found at all.
  45469. */
  45470. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45471. /**
  45472. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45473. * @param id defines the id to search for
  45474. * @return the found morph target or null if not found at all.
  45475. */
  45476. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45477. /**
  45478. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45479. * @param name defines the name to search for
  45480. * @return the found morph target or null if not found at all.
  45481. */
  45482. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45483. /**
  45484. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45485. * @param name defines the name to search for
  45486. * @return the found post process or null if not found at all.
  45487. */
  45488. getPostProcessByName(name: string): Nullable<PostProcess>;
  45489. /**
  45490. * Gets a boolean indicating if the given mesh is active
  45491. * @param mesh defines the mesh to look for
  45492. * @returns true if the mesh is in the active list
  45493. */
  45494. isActiveMesh(mesh: AbstractMesh): boolean;
  45495. /**
  45496. * Return a unique id as a string which can serve as an identifier for the scene
  45497. */
  45498. get uid(): string;
  45499. /**
  45500. * Add an externaly attached data from its key.
  45501. * This method call will fail and return false, if such key already exists.
  45502. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45503. * @param key the unique key that identifies the data
  45504. * @param data the data object to associate to the key for this Engine instance
  45505. * @return true if no such key were already present and the data was added successfully, false otherwise
  45506. */
  45507. addExternalData<T>(key: string, data: T): boolean;
  45508. /**
  45509. * Get an externaly attached data from its key
  45510. * @param key the unique key that identifies the data
  45511. * @return the associated data, if present (can be null), or undefined if not present
  45512. */
  45513. getExternalData<T>(key: string): Nullable<T>;
  45514. /**
  45515. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45516. * @param key the unique key that identifies the data
  45517. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45518. * @return the associated data, can be null if the factory returned null.
  45519. */
  45520. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45521. /**
  45522. * Remove an externaly attached data from the Engine instance
  45523. * @param key the unique key that identifies the data
  45524. * @return true if the data was successfully removed, false if it doesn't exist
  45525. */
  45526. removeExternalData(key: string): boolean;
  45527. private _evaluateSubMesh;
  45528. /**
  45529. * Clear the processed materials smart array preventing retention point in material dispose.
  45530. */
  45531. freeProcessedMaterials(): void;
  45532. private _preventFreeActiveMeshesAndRenderingGroups;
  45533. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45534. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45535. * when disposing several meshes in a row or a hierarchy of meshes.
  45536. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45537. */
  45538. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45539. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45540. /**
  45541. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45542. */
  45543. freeActiveMeshes(): void;
  45544. /**
  45545. * Clear the info related to rendering groups preventing retention points during dispose.
  45546. */
  45547. freeRenderingGroups(): void;
  45548. /** @hidden */
  45549. _isInIntermediateRendering(): boolean;
  45550. /**
  45551. * Lambda returning the list of potentially active meshes.
  45552. */
  45553. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45554. /**
  45555. * Lambda returning the list of potentially active sub meshes.
  45556. */
  45557. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45558. /**
  45559. * Lambda returning the list of potentially intersecting sub meshes.
  45560. */
  45561. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45562. /**
  45563. * Lambda returning the list of potentially colliding sub meshes.
  45564. */
  45565. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45566. private _activeMeshesFrozen;
  45567. private _skipEvaluateActiveMeshesCompletely;
  45568. /**
  45569. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45570. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45571. * @param onSuccess optional success callback
  45572. * @param onError optional error callback
  45573. * @returns the current scene
  45574. */
  45575. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45576. /**
  45577. * Use this function to restart evaluating active meshes on every frame
  45578. * @returns the current scene
  45579. */
  45580. unfreezeActiveMeshes(): Scene;
  45581. private _evaluateActiveMeshes;
  45582. private _activeMesh;
  45583. /**
  45584. * Update the transform matrix to update from the current active camera
  45585. * @param force defines a boolean used to force the update even if cache is up to date
  45586. */
  45587. updateTransformMatrix(force?: boolean): void;
  45588. private _bindFrameBuffer;
  45589. /** @hidden */
  45590. _allowPostProcessClearColor: boolean;
  45591. /** @hidden */
  45592. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45593. private _processSubCameras;
  45594. private _checkIntersections;
  45595. /** @hidden */
  45596. _advancePhysicsEngineStep(step: number): void;
  45597. /**
  45598. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45599. */
  45600. getDeterministicFrameTime: () => number;
  45601. /** @hidden */
  45602. _animate(): void;
  45603. /** Execute all animations (for a frame) */
  45604. animate(): void;
  45605. /**
  45606. * Render the scene
  45607. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45608. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45609. */
  45610. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45611. /**
  45612. * Freeze all materials
  45613. * A frozen material will not be updatable but should be faster to render
  45614. */
  45615. freezeMaterials(): void;
  45616. /**
  45617. * Unfreeze all materials
  45618. * A frozen material will not be updatable but should be faster to render
  45619. */
  45620. unfreezeMaterials(): void;
  45621. /**
  45622. * Releases all held ressources
  45623. */
  45624. dispose(): void;
  45625. /**
  45626. * Gets if the scene is already disposed
  45627. */
  45628. get isDisposed(): boolean;
  45629. /**
  45630. * Call this function to reduce memory footprint of the scene.
  45631. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45632. */
  45633. clearCachedVertexData(): void;
  45634. /**
  45635. * This function will remove the local cached buffer data from texture.
  45636. * It will save memory but will prevent the texture from being rebuilt
  45637. */
  45638. cleanCachedTextureBuffer(): void;
  45639. /**
  45640. * Get the world extend vectors with an optional filter
  45641. *
  45642. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45643. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45644. */
  45645. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45646. min: Vector3;
  45647. max: Vector3;
  45648. };
  45649. /**
  45650. * Creates a ray that can be used to pick in the scene
  45651. * @param x defines the x coordinate of the origin (on-screen)
  45652. * @param y defines the y coordinate of the origin (on-screen)
  45653. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45654. * @param camera defines the camera to use for the picking
  45655. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45656. * @returns a Ray
  45657. */
  45658. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45659. /**
  45660. * Creates a ray that can be used to pick in the scene
  45661. * @param x defines the x coordinate of the origin (on-screen)
  45662. * @param y defines the y coordinate of the origin (on-screen)
  45663. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45664. * @param result defines the ray where to store the picking ray
  45665. * @param camera defines the camera to use for the picking
  45666. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45667. * @returns the current scene
  45668. */
  45669. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  45670. /**
  45671. * Creates a ray that can be used to pick in the scene
  45672. * @param x defines the x coordinate of the origin (on-screen)
  45673. * @param y defines the y coordinate of the origin (on-screen)
  45674. * @param camera defines the camera to use for the picking
  45675. * @returns a Ray
  45676. */
  45677. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  45678. /**
  45679. * Creates a ray that can be used to pick in the scene
  45680. * @param x defines the x coordinate of the origin (on-screen)
  45681. * @param y defines the y coordinate of the origin (on-screen)
  45682. * @param result defines the ray where to store the picking ray
  45683. * @param camera defines the camera to use for the picking
  45684. * @returns the current scene
  45685. */
  45686. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  45687. /** Launch a ray to try to pick a mesh in the scene
  45688. * @param x position on screen
  45689. * @param y position on screen
  45690. * @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
  45691. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45692. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45693. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45694. * @returns a PickingInfo
  45695. */
  45696. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45697. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  45698. * @param x position on screen
  45699. * @param y position on screen
  45700. * @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
  45701. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45702. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45703. * @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)
  45704. */
  45705. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  45706. /** Use the given ray to pick a mesh in the scene
  45707. * @param ray The ray to use to pick meshes
  45708. * @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
  45709. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45710. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45711. * @returns a PickingInfo
  45712. */
  45713. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45714. /**
  45715. * Launch a ray to try to pick a mesh in the scene
  45716. * @param x X position on screen
  45717. * @param y Y position on screen
  45718. * @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
  45719. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45720. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45721. * @returns an array of PickingInfo
  45722. */
  45723. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45724. /**
  45725. * Launch a ray to try to pick a mesh in the scene
  45726. * @param ray Ray to use
  45727. * @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
  45728. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45729. * @returns an array of PickingInfo
  45730. */
  45731. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45732. /**
  45733. * Force the value of meshUnderPointer
  45734. * @param mesh defines the mesh to use
  45735. * @param pointerId optional pointer id when using more than one pointer
  45736. */
  45737. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45738. /**
  45739. * Gets the mesh under the pointer
  45740. * @returns a Mesh or null if no mesh is under the pointer
  45741. */
  45742. getPointerOverMesh(): Nullable<AbstractMesh>;
  45743. /** @hidden */
  45744. _rebuildGeometries(): void;
  45745. /** @hidden */
  45746. _rebuildTextures(): void;
  45747. private _getByTags;
  45748. /**
  45749. * Get a list of meshes by tags
  45750. * @param tagsQuery defines the tags query to use
  45751. * @param forEach defines a predicate used to filter results
  45752. * @returns an array of Mesh
  45753. */
  45754. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  45755. /**
  45756. * Get a list of cameras by tags
  45757. * @param tagsQuery defines the tags query to use
  45758. * @param forEach defines a predicate used to filter results
  45759. * @returns an array of Camera
  45760. */
  45761. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  45762. /**
  45763. * Get a list of lights by tags
  45764. * @param tagsQuery defines the tags query to use
  45765. * @param forEach defines a predicate used to filter results
  45766. * @returns an array of Light
  45767. */
  45768. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  45769. /**
  45770. * Get a list of materials by tags
  45771. * @param tagsQuery defines the tags query to use
  45772. * @param forEach defines a predicate used to filter results
  45773. * @returns an array of Material
  45774. */
  45775. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  45776. /**
  45777. * Get a list of transform nodes by tags
  45778. * @param tagsQuery defines the tags query to use
  45779. * @param forEach defines a predicate used to filter results
  45780. * @returns an array of TransformNode
  45781. */
  45782. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  45783. /**
  45784. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  45785. * This allowed control for front to back rendering or reversly depending of the special needs.
  45786. *
  45787. * @param renderingGroupId The rendering group id corresponding to its index
  45788. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  45789. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  45790. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  45791. */
  45792. 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;
  45793. /**
  45794. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  45795. *
  45796. * @param renderingGroupId The rendering group id corresponding to its index
  45797. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45798. * @param depth Automatically clears depth between groups if true and autoClear is true.
  45799. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  45800. */
  45801. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  45802. /**
  45803. * Gets the current auto clear configuration for one rendering group of the rendering
  45804. * manager.
  45805. * @param index the rendering group index to get the information for
  45806. * @returns The auto clear setup for the requested rendering group
  45807. */
  45808. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  45809. private _blockMaterialDirtyMechanism;
  45810. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  45811. get blockMaterialDirtyMechanism(): boolean;
  45812. set blockMaterialDirtyMechanism(value: boolean);
  45813. /**
  45814. * Will flag all materials as dirty to trigger new shader compilation
  45815. * @param flag defines the flag used to specify which material part must be marked as dirty
  45816. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  45817. */
  45818. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  45819. /** @hidden */
  45820. _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;
  45821. /** @hidden */
  45822. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45823. /** @hidden */
  45824. _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;
  45825. /** @hidden */
  45826. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  45827. /** @hidden */
  45828. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  45829. /** @hidden */
  45830. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45831. }
  45832. }
  45833. declare module "babylonjs/assetContainer" {
  45834. import { AbstractScene } from "babylonjs/abstractScene";
  45835. import { Scene } from "babylonjs/scene";
  45836. import { Mesh } from "babylonjs/Meshes/mesh";
  45837. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45838. import { Skeleton } from "babylonjs/Bones/skeleton";
  45839. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45840. import { Animatable } from "babylonjs/Animations/animatable";
  45841. import { Nullable } from "babylonjs/types";
  45842. import { Node } from "babylonjs/node";
  45843. /**
  45844. * Set of assets to keep when moving a scene into an asset container.
  45845. */
  45846. export class KeepAssets extends AbstractScene {
  45847. }
  45848. /**
  45849. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  45850. */
  45851. export class InstantiatedEntries {
  45852. /**
  45853. * List of new root nodes (eg. nodes with no parent)
  45854. */
  45855. rootNodes: TransformNode[];
  45856. /**
  45857. * List of new skeletons
  45858. */
  45859. skeletons: Skeleton[];
  45860. /**
  45861. * List of new animation groups
  45862. */
  45863. animationGroups: AnimationGroup[];
  45864. }
  45865. /**
  45866. * Container with a set of assets that can be added or removed from a scene.
  45867. */
  45868. export class AssetContainer extends AbstractScene {
  45869. private _wasAddedToScene;
  45870. /**
  45871. * The scene the AssetContainer belongs to.
  45872. */
  45873. scene: Scene;
  45874. /**
  45875. * Instantiates an AssetContainer.
  45876. * @param scene The scene the AssetContainer belongs to.
  45877. */
  45878. constructor(scene: Scene);
  45879. /**
  45880. * Instantiate or clone all meshes and add the new ones to the scene.
  45881. * Skeletons and animation groups will all be cloned
  45882. * @param nameFunction defines an optional function used to get new names for clones
  45883. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  45884. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  45885. */
  45886. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  45887. /**
  45888. * Adds all the assets from the container to the scene.
  45889. */
  45890. addAllToScene(): void;
  45891. /**
  45892. * Removes all the assets in the container from the scene
  45893. */
  45894. removeAllFromScene(): void;
  45895. /**
  45896. * Disposes all the assets in the container
  45897. */
  45898. dispose(): void;
  45899. private _moveAssets;
  45900. /**
  45901. * Removes all the assets contained in the scene and adds them to the container.
  45902. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  45903. */
  45904. moveAllFromScene(keepAssets?: KeepAssets): void;
  45905. /**
  45906. * 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.
  45907. * @returns the root mesh
  45908. */
  45909. createRootMesh(): Mesh;
  45910. /**
  45911. * Merge animations (direct and animation groups) from this asset container into a scene
  45912. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45913. * @param animatables set of animatables to retarget to a node from the scene
  45914. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  45915. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  45916. */
  45917. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  45918. }
  45919. }
  45920. declare module "babylonjs/abstractScene" {
  45921. import { Scene } from "babylonjs/scene";
  45922. import { Nullable } from "babylonjs/types";
  45923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45924. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45925. import { Geometry } from "babylonjs/Meshes/geometry";
  45926. import { Skeleton } from "babylonjs/Bones/skeleton";
  45927. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  45928. import { AssetContainer } from "babylonjs/assetContainer";
  45929. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45930. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45932. import { Material } from "babylonjs/Materials/material";
  45933. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  45934. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  45935. import { Camera } from "babylonjs/Cameras/camera";
  45936. import { Light } from "babylonjs/Lights/light";
  45937. import { Node } from "babylonjs/node";
  45938. import { Animation } from "babylonjs/Animations/animation";
  45939. /**
  45940. * Defines how the parser contract is defined.
  45941. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  45942. */
  45943. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  45944. /**
  45945. * Defines how the individual parser contract is defined.
  45946. * These parser can parse an individual asset
  45947. */
  45948. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  45949. /**
  45950. * Base class of the scene acting as a container for the different elements composing a scene.
  45951. * This class is dynamically extended by the different components of the scene increasing
  45952. * flexibility and reducing coupling
  45953. */
  45954. export abstract class AbstractScene {
  45955. /**
  45956. * Stores the list of available parsers in the application.
  45957. */
  45958. private static _BabylonFileParsers;
  45959. /**
  45960. * Stores the list of available individual parsers in the application.
  45961. */
  45962. private static _IndividualBabylonFileParsers;
  45963. /**
  45964. * Adds a parser in the list of available ones
  45965. * @param name Defines the name of the parser
  45966. * @param parser Defines the parser to add
  45967. */
  45968. static AddParser(name: string, parser: BabylonFileParser): void;
  45969. /**
  45970. * Gets a general parser from the list of avaialble ones
  45971. * @param name Defines the name of the parser
  45972. * @returns the requested parser or null
  45973. */
  45974. static GetParser(name: string): Nullable<BabylonFileParser>;
  45975. /**
  45976. * Adds n individual parser in the list of available ones
  45977. * @param name Defines the name of the parser
  45978. * @param parser Defines the parser to add
  45979. */
  45980. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  45981. /**
  45982. * Gets an individual parser from the list of avaialble ones
  45983. * @param name Defines the name of the parser
  45984. * @returns the requested parser or null
  45985. */
  45986. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  45987. /**
  45988. * Parser json data and populate both a scene and its associated container object
  45989. * @param jsonData Defines the data to parse
  45990. * @param scene Defines the scene to parse the data for
  45991. * @param container Defines the container attached to the parsing sequence
  45992. * @param rootUrl Defines the root url of the data
  45993. */
  45994. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  45995. /**
  45996. * Gets the list of root nodes (ie. nodes with no parent)
  45997. */
  45998. rootNodes: Node[];
  45999. /** All of the cameras added to this scene
  46000. * @see https://doc.babylonjs.com/babylon101/cameras
  46001. */
  46002. cameras: Camera[];
  46003. /**
  46004. * All of the lights added to this scene
  46005. * @see https://doc.babylonjs.com/babylon101/lights
  46006. */
  46007. lights: Light[];
  46008. /**
  46009. * All of the (abstract) meshes added to this scene
  46010. */
  46011. meshes: AbstractMesh[];
  46012. /**
  46013. * The list of skeletons added to the scene
  46014. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46015. */
  46016. skeletons: Skeleton[];
  46017. /**
  46018. * All of the particle systems added to this scene
  46019. * @see https://doc.babylonjs.com/babylon101/particles
  46020. */
  46021. particleSystems: IParticleSystem[];
  46022. /**
  46023. * Gets a list of Animations associated with the scene
  46024. */
  46025. animations: Animation[];
  46026. /**
  46027. * All of the animation groups added to this scene
  46028. * @see https://doc.babylonjs.com/how_to/group
  46029. */
  46030. animationGroups: AnimationGroup[];
  46031. /**
  46032. * All of the multi-materials added to this scene
  46033. * @see https://doc.babylonjs.com/how_to/multi_materials
  46034. */
  46035. multiMaterials: MultiMaterial[];
  46036. /**
  46037. * All of the materials added to this scene
  46038. * In the context of a Scene, it is not supposed to be modified manually.
  46039. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46040. * Note also that the order of the Material within the array is not significant and might change.
  46041. * @see https://doc.babylonjs.com/babylon101/materials
  46042. */
  46043. materials: Material[];
  46044. /**
  46045. * The list of morph target managers added to the scene
  46046. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46047. */
  46048. morphTargetManagers: MorphTargetManager[];
  46049. /**
  46050. * The list of geometries used in the scene.
  46051. */
  46052. geometries: Geometry[];
  46053. /**
  46054. * All of the tranform nodes added to this scene
  46055. * In the context of a Scene, it is not supposed to be modified manually.
  46056. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46057. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46058. * @see https://doc.babylonjs.com/how_to/transformnode
  46059. */
  46060. transformNodes: TransformNode[];
  46061. /**
  46062. * ActionManagers available on the scene.
  46063. */
  46064. actionManagers: AbstractActionManager[];
  46065. /**
  46066. * Textures to keep.
  46067. */
  46068. textures: BaseTexture[];
  46069. /** @hidden */
  46070. protected _environmentTexture: Nullable<BaseTexture>;
  46071. /**
  46072. * Texture used in all pbr material as the reflection texture.
  46073. * As in the majority of the scene they are the same (exception for multi room and so on),
  46074. * this is easier to reference from here than from all the materials.
  46075. */
  46076. get environmentTexture(): Nullable<BaseTexture>;
  46077. set environmentTexture(value: Nullable<BaseTexture>);
  46078. /**
  46079. * The list of postprocesses added to the scene
  46080. */
  46081. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46082. /**
  46083. * @returns all meshes, lights, cameras, transformNodes and bones
  46084. */
  46085. getNodes(): Array<Node>;
  46086. }
  46087. }
  46088. declare module "babylonjs/Audio/sound" {
  46089. import { Observable } from "babylonjs/Misc/observable";
  46090. import { Vector3 } from "babylonjs/Maths/math.vector";
  46091. import { Nullable } from "babylonjs/types";
  46092. import { Scene } from "babylonjs/scene";
  46093. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46094. /**
  46095. * Interface used to define options for Sound class
  46096. */
  46097. export interface ISoundOptions {
  46098. /**
  46099. * Does the sound autoplay once loaded.
  46100. */
  46101. autoplay?: boolean;
  46102. /**
  46103. * Does the sound loop after it finishes playing once.
  46104. */
  46105. loop?: boolean;
  46106. /**
  46107. * Sound's volume
  46108. */
  46109. volume?: number;
  46110. /**
  46111. * Is it a spatial sound?
  46112. */
  46113. spatialSound?: boolean;
  46114. /**
  46115. * Maximum distance to hear that sound
  46116. */
  46117. maxDistance?: number;
  46118. /**
  46119. * Uses user defined attenuation function
  46120. */
  46121. useCustomAttenuation?: boolean;
  46122. /**
  46123. * Define the roll off factor of spatial sounds.
  46124. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46125. */
  46126. rolloffFactor?: number;
  46127. /**
  46128. * Define the reference distance the sound should be heard perfectly.
  46129. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46130. */
  46131. refDistance?: number;
  46132. /**
  46133. * Define the distance attenuation model the sound will follow.
  46134. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46135. */
  46136. distanceModel?: string;
  46137. /**
  46138. * Defines the playback speed (1 by default)
  46139. */
  46140. playbackRate?: number;
  46141. /**
  46142. * Defines if the sound is from a streaming source
  46143. */
  46144. streaming?: boolean;
  46145. /**
  46146. * Defines an optional length (in seconds) inside the sound file
  46147. */
  46148. length?: number;
  46149. /**
  46150. * Defines an optional offset (in seconds) inside the sound file
  46151. */
  46152. offset?: number;
  46153. /**
  46154. * If true, URLs will not be required to state the audio file codec to use.
  46155. */
  46156. skipCodecCheck?: boolean;
  46157. }
  46158. /**
  46159. * Defines a sound that can be played in the application.
  46160. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46161. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46162. */
  46163. export class Sound {
  46164. /**
  46165. * The name of the sound in the scene.
  46166. */
  46167. name: string;
  46168. /**
  46169. * Does the sound autoplay once loaded.
  46170. */
  46171. autoplay: boolean;
  46172. /**
  46173. * Does the sound loop after it finishes playing once.
  46174. */
  46175. loop: boolean;
  46176. /**
  46177. * Does the sound use a custom attenuation curve to simulate the falloff
  46178. * happening when the source gets further away from the camera.
  46179. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46180. */
  46181. useCustomAttenuation: boolean;
  46182. /**
  46183. * The sound track id this sound belongs to.
  46184. */
  46185. soundTrackId: number;
  46186. /**
  46187. * Is this sound currently played.
  46188. */
  46189. isPlaying: boolean;
  46190. /**
  46191. * Is this sound currently paused.
  46192. */
  46193. isPaused: boolean;
  46194. /**
  46195. * Does this sound enables spatial sound.
  46196. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46197. */
  46198. spatialSound: boolean;
  46199. /**
  46200. * Define the reference distance the sound should be heard perfectly.
  46201. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46202. */
  46203. refDistance: number;
  46204. /**
  46205. * Define the roll off factor of spatial sounds.
  46206. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46207. */
  46208. rolloffFactor: number;
  46209. /**
  46210. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46211. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46212. */
  46213. maxDistance: number;
  46214. /**
  46215. * Define the distance attenuation model the sound will follow.
  46216. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46217. */
  46218. distanceModel: string;
  46219. /**
  46220. * @hidden
  46221. * Back Compat
  46222. **/
  46223. onended: () => any;
  46224. /**
  46225. * Gets or sets an object used to store user defined information for the sound.
  46226. */
  46227. metadata: any;
  46228. /**
  46229. * Observable event when the current playing sound finishes.
  46230. */
  46231. onEndedObservable: Observable<Sound>;
  46232. private _panningModel;
  46233. private _playbackRate;
  46234. private _streaming;
  46235. private _startTime;
  46236. private _startOffset;
  46237. private _position;
  46238. /** @hidden */
  46239. _positionInEmitterSpace: boolean;
  46240. private _localDirection;
  46241. private _volume;
  46242. private _isReadyToPlay;
  46243. private _isDirectional;
  46244. private _readyToPlayCallback;
  46245. private _audioBuffer;
  46246. private _soundSource;
  46247. private _streamingSource;
  46248. private _soundPanner;
  46249. private _soundGain;
  46250. private _inputAudioNode;
  46251. private _outputAudioNode;
  46252. private _coneInnerAngle;
  46253. private _coneOuterAngle;
  46254. private _coneOuterGain;
  46255. private _scene;
  46256. private _connectedTransformNode;
  46257. private _customAttenuationFunction;
  46258. private _registerFunc;
  46259. private _isOutputConnected;
  46260. private _htmlAudioElement;
  46261. private _urlType;
  46262. private _length?;
  46263. private _offset?;
  46264. /** @hidden */
  46265. static _SceneComponentInitialization: (scene: Scene) => void;
  46266. /**
  46267. * Create a sound and attach it to a scene
  46268. * @param name Name of your sound
  46269. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46270. * @param scene defines the scene the sound belongs to
  46271. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46272. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46273. */
  46274. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46275. /**
  46276. * Release the sound and its associated resources
  46277. */
  46278. dispose(): void;
  46279. /**
  46280. * Gets if the sounds is ready to be played or not.
  46281. * @returns true if ready, otherwise false
  46282. */
  46283. isReady(): boolean;
  46284. private _soundLoaded;
  46285. /**
  46286. * Sets the data of the sound from an audiobuffer
  46287. * @param audioBuffer The audioBuffer containing the data
  46288. */
  46289. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46290. /**
  46291. * Updates the current sounds options such as maxdistance, loop...
  46292. * @param options A JSON object containing values named as the object properties
  46293. */
  46294. updateOptions(options: ISoundOptions): void;
  46295. private _createSpatialParameters;
  46296. private _updateSpatialParameters;
  46297. /**
  46298. * Switch the panning model to HRTF:
  46299. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46300. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46301. */
  46302. switchPanningModelToHRTF(): void;
  46303. /**
  46304. * Switch the panning model to Equal Power:
  46305. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46306. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46307. */
  46308. switchPanningModelToEqualPower(): void;
  46309. private _switchPanningModel;
  46310. /**
  46311. * Connect this sound to a sound track audio node like gain...
  46312. * @param soundTrackAudioNode the sound track audio node to connect to
  46313. */
  46314. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46315. /**
  46316. * Transform this sound into a directional source
  46317. * @param coneInnerAngle Size of the inner cone in degree
  46318. * @param coneOuterAngle Size of the outer cone in degree
  46319. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46320. */
  46321. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46322. /**
  46323. * Gets or sets the inner angle for the directional cone.
  46324. */
  46325. get directionalConeInnerAngle(): number;
  46326. /**
  46327. * Gets or sets the inner angle for the directional cone.
  46328. */
  46329. set directionalConeInnerAngle(value: number);
  46330. /**
  46331. * Gets or sets the outer angle for the directional cone.
  46332. */
  46333. get directionalConeOuterAngle(): number;
  46334. /**
  46335. * Gets or sets the outer angle for the directional cone.
  46336. */
  46337. set directionalConeOuterAngle(value: number);
  46338. /**
  46339. * Sets the position of the emitter if spatial sound is enabled
  46340. * @param newPosition Defines the new posisiton
  46341. */
  46342. setPosition(newPosition: Vector3): void;
  46343. /**
  46344. * Sets the local direction of the emitter if spatial sound is enabled
  46345. * @param newLocalDirection Defines the new local direction
  46346. */
  46347. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46348. private _updateDirection;
  46349. /** @hidden */
  46350. updateDistanceFromListener(): void;
  46351. /**
  46352. * Sets a new custom attenuation function for the sound.
  46353. * @param callback Defines the function used for the attenuation
  46354. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46355. */
  46356. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46357. /**
  46358. * Play the sound
  46359. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46360. * @param offset (optional) Start the sound at a specific time in seconds
  46361. * @param length (optional) Sound duration (in seconds)
  46362. */
  46363. play(time?: number, offset?: number, length?: number): void;
  46364. private _onended;
  46365. /**
  46366. * Stop the sound
  46367. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46368. */
  46369. stop(time?: number): void;
  46370. /**
  46371. * Put the sound in pause
  46372. */
  46373. pause(): void;
  46374. /**
  46375. * Sets a dedicated volume for this sounds
  46376. * @param newVolume Define the new volume of the sound
  46377. * @param time Define time for gradual change to new volume
  46378. */
  46379. setVolume(newVolume: number, time?: number): void;
  46380. /**
  46381. * Set the sound play back rate
  46382. * @param newPlaybackRate Define the playback rate the sound should be played at
  46383. */
  46384. setPlaybackRate(newPlaybackRate: number): void;
  46385. /**
  46386. * Gets the volume of the sound.
  46387. * @returns the volume of the sound
  46388. */
  46389. getVolume(): number;
  46390. /**
  46391. * Attach the sound to a dedicated mesh
  46392. * @param transformNode The transform node to connect the sound with
  46393. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46394. */
  46395. attachToMesh(transformNode: TransformNode): void;
  46396. /**
  46397. * Detach the sound from the previously attached mesh
  46398. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46399. */
  46400. detachFromMesh(): void;
  46401. private _onRegisterAfterWorldMatrixUpdate;
  46402. /**
  46403. * Clone the current sound in the scene.
  46404. * @returns the new sound clone
  46405. */
  46406. clone(): Nullable<Sound>;
  46407. /**
  46408. * Gets the current underlying audio buffer containing the data
  46409. * @returns the audio buffer
  46410. */
  46411. getAudioBuffer(): Nullable<AudioBuffer>;
  46412. /**
  46413. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46414. * @returns the source node
  46415. */
  46416. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46417. /**
  46418. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46419. * @returns the gain node
  46420. */
  46421. getSoundGain(): Nullable<GainNode>;
  46422. /**
  46423. * Serializes the Sound in a JSON representation
  46424. * @returns the JSON representation of the sound
  46425. */
  46426. serialize(): any;
  46427. /**
  46428. * Parse a JSON representation of a sound to innstantiate in a given scene
  46429. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46430. * @param scene Define the scene the new parsed sound should be created in
  46431. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46432. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46433. * @returns the newly parsed sound
  46434. */
  46435. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46436. }
  46437. }
  46438. declare module "babylonjs/Actions/directAudioActions" {
  46439. import { Action } from "babylonjs/Actions/action";
  46440. import { Condition } from "babylonjs/Actions/condition";
  46441. import { Sound } from "babylonjs/Audio/sound";
  46442. /**
  46443. * This defines an action helpful to play a defined sound on a triggered action.
  46444. */
  46445. export class PlaySoundAction extends Action {
  46446. private _sound;
  46447. /**
  46448. * Instantiate the action
  46449. * @param triggerOptions defines the trigger options
  46450. * @param sound defines the sound to play
  46451. * @param condition defines the trigger related conditions
  46452. */
  46453. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46454. /** @hidden */
  46455. _prepare(): void;
  46456. /**
  46457. * Execute the action and play the sound.
  46458. */
  46459. execute(): void;
  46460. /**
  46461. * Serializes the actions and its related information.
  46462. * @param parent defines the object to serialize in
  46463. * @returns the serialized object
  46464. */
  46465. serialize(parent: any): any;
  46466. }
  46467. /**
  46468. * This defines an action helpful to stop a defined sound on a triggered action.
  46469. */
  46470. export class StopSoundAction extends Action {
  46471. private _sound;
  46472. /**
  46473. * Instantiate the action
  46474. * @param triggerOptions defines the trigger options
  46475. * @param sound defines the sound to stop
  46476. * @param condition defines the trigger related conditions
  46477. */
  46478. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46479. /** @hidden */
  46480. _prepare(): void;
  46481. /**
  46482. * Execute the action and stop the sound.
  46483. */
  46484. execute(): void;
  46485. /**
  46486. * Serializes the actions and its related information.
  46487. * @param parent defines the object to serialize in
  46488. * @returns the serialized object
  46489. */
  46490. serialize(parent: any): any;
  46491. }
  46492. }
  46493. declare module "babylonjs/Actions/interpolateValueAction" {
  46494. import { Action } from "babylonjs/Actions/action";
  46495. import { Condition } from "babylonjs/Actions/condition";
  46496. import { Observable } from "babylonjs/Misc/observable";
  46497. /**
  46498. * This defines an action responsible to change the value of a property
  46499. * by interpolating between its current value and the newly set one once triggered.
  46500. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46501. */
  46502. export class InterpolateValueAction extends Action {
  46503. /**
  46504. * Defines the path of the property where the value should be interpolated
  46505. */
  46506. propertyPath: string;
  46507. /**
  46508. * Defines the target value at the end of the interpolation.
  46509. */
  46510. value: any;
  46511. /**
  46512. * Defines the time it will take for the property to interpolate to the value.
  46513. */
  46514. duration: number;
  46515. /**
  46516. * Defines if the other scene animations should be stopped when the action has been triggered
  46517. */
  46518. stopOtherAnimations?: boolean;
  46519. /**
  46520. * Defines a callback raised once the interpolation animation has been done.
  46521. */
  46522. onInterpolationDone?: () => void;
  46523. /**
  46524. * Observable triggered once the interpolation animation has been done.
  46525. */
  46526. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46527. private _target;
  46528. private _effectiveTarget;
  46529. private _property;
  46530. /**
  46531. * Instantiate the action
  46532. * @param triggerOptions defines the trigger options
  46533. * @param target defines the object containing the value to interpolate
  46534. * @param propertyPath defines the path to the property in the target object
  46535. * @param value defines the target value at the end of the interpolation
  46536. * @param duration deines the time it will take for the property to interpolate to the value.
  46537. * @param condition defines the trigger related conditions
  46538. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46539. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46540. */
  46541. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46542. /** @hidden */
  46543. _prepare(): void;
  46544. /**
  46545. * Execute the action starts the value interpolation.
  46546. */
  46547. execute(): void;
  46548. /**
  46549. * Serializes the actions and its related information.
  46550. * @param parent defines the object to serialize in
  46551. * @returns the serialized object
  46552. */
  46553. serialize(parent: any): any;
  46554. }
  46555. }
  46556. declare module "babylonjs/Actions/index" {
  46557. export * from "babylonjs/Actions/abstractActionManager";
  46558. export * from "babylonjs/Actions/action";
  46559. export * from "babylonjs/Actions/actionEvent";
  46560. export * from "babylonjs/Actions/actionManager";
  46561. export * from "babylonjs/Actions/condition";
  46562. export * from "babylonjs/Actions/directActions";
  46563. export * from "babylonjs/Actions/directAudioActions";
  46564. export * from "babylonjs/Actions/interpolateValueAction";
  46565. }
  46566. declare module "babylonjs/Animations/index" {
  46567. export * from "babylonjs/Animations/animatable";
  46568. export * from "babylonjs/Animations/animation";
  46569. export * from "babylonjs/Animations/animationGroup";
  46570. export * from "babylonjs/Animations/animationPropertiesOverride";
  46571. export * from "babylonjs/Animations/easing";
  46572. export * from "babylonjs/Animations/runtimeAnimation";
  46573. export * from "babylonjs/Animations/animationEvent";
  46574. export * from "babylonjs/Animations/animationGroup";
  46575. export * from "babylonjs/Animations/animationKey";
  46576. export * from "babylonjs/Animations/animationRange";
  46577. export * from "babylonjs/Animations/animatable.interface";
  46578. }
  46579. declare module "babylonjs/Audio/soundTrack" {
  46580. import { Sound } from "babylonjs/Audio/sound";
  46581. import { Analyser } from "babylonjs/Audio/analyser";
  46582. import { Scene } from "babylonjs/scene";
  46583. /**
  46584. * Options allowed during the creation of a sound track.
  46585. */
  46586. export interface ISoundTrackOptions {
  46587. /**
  46588. * The volume the sound track should take during creation
  46589. */
  46590. volume?: number;
  46591. /**
  46592. * Define if the sound track is the main sound track of the scene
  46593. */
  46594. mainTrack?: boolean;
  46595. }
  46596. /**
  46597. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46598. * It will be also used in a future release to apply effects on a specific track.
  46599. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46600. */
  46601. export class SoundTrack {
  46602. /**
  46603. * The unique identifier of the sound track in the scene.
  46604. */
  46605. id: number;
  46606. /**
  46607. * The list of sounds included in the sound track.
  46608. */
  46609. soundCollection: Array<Sound>;
  46610. private _outputAudioNode;
  46611. private _scene;
  46612. private _connectedAnalyser;
  46613. private _options;
  46614. private _isInitialized;
  46615. /**
  46616. * Creates a new sound track.
  46617. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46618. * @param scene Define the scene the sound track belongs to
  46619. * @param options
  46620. */
  46621. constructor(scene: Scene, options?: ISoundTrackOptions);
  46622. private _initializeSoundTrackAudioGraph;
  46623. /**
  46624. * Release the sound track and its associated resources
  46625. */
  46626. dispose(): void;
  46627. /**
  46628. * Adds a sound to this sound track
  46629. * @param sound define the cound to add
  46630. * @ignoreNaming
  46631. */
  46632. AddSound(sound: Sound): void;
  46633. /**
  46634. * Removes a sound to this sound track
  46635. * @param sound define the cound to remove
  46636. * @ignoreNaming
  46637. */
  46638. RemoveSound(sound: Sound): void;
  46639. /**
  46640. * Set a global volume for the full sound track.
  46641. * @param newVolume Define the new volume of the sound track
  46642. */
  46643. setVolume(newVolume: number): void;
  46644. /**
  46645. * Switch the panning model to HRTF:
  46646. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46648. */
  46649. switchPanningModelToHRTF(): void;
  46650. /**
  46651. * Switch the panning model to Equal Power:
  46652. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46654. */
  46655. switchPanningModelToEqualPower(): void;
  46656. /**
  46657. * Connect the sound track to an audio analyser allowing some amazing
  46658. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46659. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46660. * @param analyser The analyser to connect to the engine
  46661. */
  46662. connectToAnalyser(analyser: Analyser): void;
  46663. }
  46664. }
  46665. declare module "babylonjs/Audio/audioSceneComponent" {
  46666. import { Sound } from "babylonjs/Audio/sound";
  46667. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  46668. import { Nullable } from "babylonjs/types";
  46669. import { Vector3 } from "babylonjs/Maths/math.vector";
  46670. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46671. import { Scene } from "babylonjs/scene";
  46672. import { AbstractScene } from "babylonjs/abstractScene";
  46673. import "babylonjs/Audio/audioEngine";
  46674. module "babylonjs/abstractScene" {
  46675. interface AbstractScene {
  46676. /**
  46677. * The list of sounds used in the scene.
  46678. */
  46679. sounds: Nullable<Array<Sound>>;
  46680. }
  46681. }
  46682. module "babylonjs/scene" {
  46683. interface Scene {
  46684. /**
  46685. * @hidden
  46686. * Backing field
  46687. */
  46688. _mainSoundTrack: SoundTrack;
  46689. /**
  46690. * The main sound track played by the scene.
  46691. * It cotains your primary collection of sounds.
  46692. */
  46693. mainSoundTrack: SoundTrack;
  46694. /**
  46695. * The list of sound tracks added to the scene
  46696. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46697. */
  46698. soundTracks: Nullable<Array<SoundTrack>>;
  46699. /**
  46700. * Gets a sound using a given name
  46701. * @param name defines the name to search for
  46702. * @return the found sound or null if not found at all.
  46703. */
  46704. getSoundByName(name: string): Nullable<Sound>;
  46705. /**
  46706. * Gets or sets if audio support is enabled
  46707. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46708. */
  46709. audioEnabled: boolean;
  46710. /**
  46711. * Gets or sets if audio will be output to headphones
  46712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46713. */
  46714. headphone: boolean;
  46715. /**
  46716. * Gets or sets custom audio listener position provider
  46717. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46718. */
  46719. audioListenerPositionProvider: Nullable<() => Vector3>;
  46720. /**
  46721. * Gets or sets a refresh rate when using 3D audio positioning
  46722. */
  46723. audioPositioningRefreshRate: number;
  46724. }
  46725. }
  46726. /**
  46727. * Defines the sound scene component responsible to manage any sounds
  46728. * in a given scene.
  46729. */
  46730. export class AudioSceneComponent implements ISceneSerializableComponent {
  46731. private static _CameraDirectionLH;
  46732. private static _CameraDirectionRH;
  46733. /**
  46734. * The component name helpfull to identify the component in the list of scene components.
  46735. */
  46736. readonly name: string;
  46737. /**
  46738. * The scene the component belongs to.
  46739. */
  46740. scene: Scene;
  46741. private _audioEnabled;
  46742. /**
  46743. * Gets whether audio is enabled or not.
  46744. * Please use related enable/disable method to switch state.
  46745. */
  46746. get audioEnabled(): boolean;
  46747. private _headphone;
  46748. /**
  46749. * Gets whether audio is outputing to headphone or not.
  46750. * Please use the according Switch methods to change output.
  46751. */
  46752. get headphone(): boolean;
  46753. /**
  46754. * Gets or sets a refresh rate when using 3D audio positioning
  46755. */
  46756. audioPositioningRefreshRate: number;
  46757. private _audioListenerPositionProvider;
  46758. /**
  46759. * Gets the current audio listener position provider
  46760. */
  46761. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  46762. /**
  46763. * Sets a custom listener position for all sounds in the scene
  46764. * By default, this is the position of the first active camera
  46765. */
  46766. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  46767. /**
  46768. * Creates a new instance of the component for the given scene
  46769. * @param scene Defines the scene to register the component in
  46770. */
  46771. constructor(scene: Scene);
  46772. /**
  46773. * Registers the component in a given scene
  46774. */
  46775. register(): void;
  46776. /**
  46777. * Rebuilds the elements related to this component in case of
  46778. * context lost for instance.
  46779. */
  46780. rebuild(): void;
  46781. /**
  46782. * Serializes the component data to the specified json object
  46783. * @param serializationObject The object to serialize to
  46784. */
  46785. serialize(serializationObject: any): void;
  46786. /**
  46787. * Adds all the elements from the container to the scene
  46788. * @param container the container holding the elements
  46789. */
  46790. addFromContainer(container: AbstractScene): void;
  46791. /**
  46792. * Removes all the elements in the container from the scene
  46793. * @param container contains the elements to remove
  46794. * @param dispose if the removed element should be disposed (default: false)
  46795. */
  46796. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46797. /**
  46798. * Disposes the component and the associated ressources.
  46799. */
  46800. dispose(): void;
  46801. /**
  46802. * Disables audio in the associated scene.
  46803. */
  46804. disableAudio(): void;
  46805. /**
  46806. * Enables audio in the associated scene.
  46807. */
  46808. enableAudio(): void;
  46809. /**
  46810. * Switch audio to headphone output.
  46811. */
  46812. switchAudioModeForHeadphones(): void;
  46813. /**
  46814. * Switch audio to normal speakers.
  46815. */
  46816. switchAudioModeForNormalSpeakers(): void;
  46817. private _cachedCameraDirection;
  46818. private _cachedCameraPosition;
  46819. private _lastCheck;
  46820. private _afterRender;
  46821. }
  46822. }
  46823. declare module "babylonjs/Audio/weightedsound" {
  46824. import { Sound } from "babylonjs/Audio/sound";
  46825. /**
  46826. * Wraps one or more Sound objects and selects one with random weight for playback.
  46827. */
  46828. export class WeightedSound {
  46829. /** When true a Sound will be selected and played when the current playing Sound completes. */
  46830. loop: boolean;
  46831. private _coneInnerAngle;
  46832. private _coneOuterAngle;
  46833. private _volume;
  46834. /** A Sound is currently playing. */
  46835. isPlaying: boolean;
  46836. /** A Sound is currently paused. */
  46837. isPaused: boolean;
  46838. private _sounds;
  46839. private _weights;
  46840. private _currentIndex?;
  46841. /**
  46842. * Creates a new WeightedSound from the list of sounds given.
  46843. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  46844. * @param sounds Array of Sounds that will be selected from.
  46845. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  46846. */
  46847. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  46848. /**
  46849. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  46850. */
  46851. get directionalConeInnerAngle(): number;
  46852. /**
  46853. * The size of cone in degress for a directional sound in which there will be no attenuation.
  46854. */
  46855. set directionalConeInnerAngle(value: number);
  46856. /**
  46857. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46858. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46859. */
  46860. get directionalConeOuterAngle(): number;
  46861. /**
  46862. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46863. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46864. */
  46865. set directionalConeOuterAngle(value: number);
  46866. /**
  46867. * Playback volume.
  46868. */
  46869. get volume(): number;
  46870. /**
  46871. * Playback volume.
  46872. */
  46873. set volume(value: number);
  46874. private _onended;
  46875. /**
  46876. * Suspend playback
  46877. */
  46878. pause(): void;
  46879. /**
  46880. * Stop playback
  46881. */
  46882. stop(): void;
  46883. /**
  46884. * Start playback.
  46885. * @param startOffset Position the clip head at a specific time in seconds.
  46886. */
  46887. play(startOffset?: number): void;
  46888. }
  46889. }
  46890. declare module "babylonjs/Audio/index" {
  46891. export * from "babylonjs/Audio/analyser";
  46892. export * from "babylonjs/Audio/audioEngine";
  46893. export * from "babylonjs/Audio/audioSceneComponent";
  46894. export * from "babylonjs/Audio/sound";
  46895. export * from "babylonjs/Audio/soundTrack";
  46896. export * from "babylonjs/Audio/weightedsound";
  46897. }
  46898. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  46899. import { Behavior } from "babylonjs/Behaviors/behavior";
  46900. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46901. import { BackEase } from "babylonjs/Animations/easing";
  46902. /**
  46903. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  46904. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46905. */
  46906. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  46907. /**
  46908. * Gets the name of the behavior.
  46909. */
  46910. get name(): string;
  46911. /**
  46912. * The easing function used by animations
  46913. */
  46914. static EasingFunction: BackEase;
  46915. /**
  46916. * The easing mode used by animations
  46917. */
  46918. static EasingMode: number;
  46919. /**
  46920. * The duration of the animation, in milliseconds
  46921. */
  46922. transitionDuration: number;
  46923. /**
  46924. * Length of the distance animated by the transition when lower radius is reached
  46925. */
  46926. lowerRadiusTransitionRange: number;
  46927. /**
  46928. * Length of the distance animated by the transition when upper radius is reached
  46929. */
  46930. upperRadiusTransitionRange: number;
  46931. private _autoTransitionRange;
  46932. /**
  46933. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46934. */
  46935. get autoTransitionRange(): boolean;
  46936. /**
  46937. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46938. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  46939. */
  46940. set autoTransitionRange(value: boolean);
  46941. private _attachedCamera;
  46942. private _onAfterCheckInputsObserver;
  46943. private _onMeshTargetChangedObserver;
  46944. /**
  46945. * Initializes the behavior.
  46946. */
  46947. init(): void;
  46948. /**
  46949. * Attaches the behavior to its arc rotate camera.
  46950. * @param camera Defines the camera to attach the behavior to
  46951. */
  46952. attach(camera: ArcRotateCamera): void;
  46953. /**
  46954. * Detaches the behavior from its current arc rotate camera.
  46955. */
  46956. detach(): void;
  46957. private _radiusIsAnimating;
  46958. private _radiusBounceTransition;
  46959. private _animatables;
  46960. private _cachedWheelPrecision;
  46961. /**
  46962. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  46963. * @param radiusLimit The limit to check against.
  46964. * @return Bool to indicate if at limit.
  46965. */
  46966. private _isRadiusAtLimit;
  46967. /**
  46968. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  46969. * @param radiusDelta The delta by which to animate to. Can be negative.
  46970. */
  46971. private _applyBoundRadiusAnimation;
  46972. /**
  46973. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  46974. */
  46975. protected _clearAnimationLocks(): void;
  46976. /**
  46977. * Stops and removes all animations that have been applied to the camera
  46978. */
  46979. stopAllAnimations(): void;
  46980. }
  46981. }
  46982. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  46983. import { Behavior } from "babylonjs/Behaviors/behavior";
  46984. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46985. import { ExponentialEase } from "babylonjs/Animations/easing";
  46986. import { Nullable } from "babylonjs/types";
  46987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46988. import { Vector3 } from "babylonjs/Maths/math.vector";
  46989. /**
  46990. * 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.
  46991. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46992. */
  46993. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  46994. /**
  46995. * Gets the name of the behavior.
  46996. */
  46997. get name(): string;
  46998. private _mode;
  46999. private _radiusScale;
  47000. private _positionScale;
  47001. private _defaultElevation;
  47002. private _elevationReturnTime;
  47003. private _elevationReturnWaitTime;
  47004. private _zoomStopsAnimation;
  47005. private _framingTime;
  47006. /**
  47007. * The easing function used by animations
  47008. */
  47009. static EasingFunction: ExponentialEase;
  47010. /**
  47011. * The easing mode used by animations
  47012. */
  47013. static EasingMode: number;
  47014. /**
  47015. * Sets the current mode used by the behavior
  47016. */
  47017. set mode(mode: number);
  47018. /**
  47019. * Gets current mode used by the behavior.
  47020. */
  47021. get mode(): number;
  47022. /**
  47023. * Sets the scale applied to the radius (1 by default)
  47024. */
  47025. set radiusScale(radius: number);
  47026. /**
  47027. * Gets the scale applied to the radius
  47028. */
  47029. get radiusScale(): number;
  47030. /**
  47031. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47032. */
  47033. set positionScale(scale: number);
  47034. /**
  47035. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47036. */
  47037. get positionScale(): number;
  47038. /**
  47039. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47040. * behaviour is triggered, in radians.
  47041. */
  47042. set defaultElevation(elevation: number);
  47043. /**
  47044. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47045. * behaviour is triggered, in radians.
  47046. */
  47047. get defaultElevation(): number;
  47048. /**
  47049. * Sets the time (in milliseconds) taken to return to the default beta position.
  47050. * Negative value indicates camera should not return to default.
  47051. */
  47052. set elevationReturnTime(speed: number);
  47053. /**
  47054. * Gets the time (in milliseconds) taken to return to the default beta position.
  47055. * Negative value indicates camera should not return to default.
  47056. */
  47057. get elevationReturnTime(): number;
  47058. /**
  47059. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47060. */
  47061. set elevationReturnWaitTime(time: number);
  47062. /**
  47063. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47064. */
  47065. get elevationReturnWaitTime(): number;
  47066. /**
  47067. * Sets the flag that indicates if user zooming should stop animation.
  47068. */
  47069. set zoomStopsAnimation(flag: boolean);
  47070. /**
  47071. * Gets the flag that indicates if user zooming should stop animation.
  47072. */
  47073. get zoomStopsAnimation(): boolean;
  47074. /**
  47075. * Sets the transition time when framing the mesh, in milliseconds
  47076. */
  47077. set framingTime(time: number);
  47078. /**
  47079. * Gets the transition time when framing the mesh, in milliseconds
  47080. */
  47081. get framingTime(): number;
  47082. /**
  47083. * Define if the behavior should automatically change the configured
  47084. * camera limits and sensibilities.
  47085. */
  47086. autoCorrectCameraLimitsAndSensibility: boolean;
  47087. private _onPrePointerObservableObserver;
  47088. private _onAfterCheckInputsObserver;
  47089. private _onMeshTargetChangedObserver;
  47090. private _attachedCamera;
  47091. private _isPointerDown;
  47092. private _lastInteractionTime;
  47093. /**
  47094. * Initializes the behavior.
  47095. */
  47096. init(): void;
  47097. /**
  47098. * Attaches the behavior to its arc rotate camera.
  47099. * @param camera Defines the camera to attach the behavior to
  47100. */
  47101. attach(camera: ArcRotateCamera): void;
  47102. /**
  47103. * Detaches the behavior from its current arc rotate camera.
  47104. */
  47105. detach(): void;
  47106. private _animatables;
  47107. private _betaIsAnimating;
  47108. private _betaTransition;
  47109. private _radiusTransition;
  47110. private _vectorTransition;
  47111. /**
  47112. * Targets the given mesh and updates zoom level accordingly.
  47113. * @param mesh The mesh to target.
  47114. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47115. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47116. */
  47117. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47118. /**
  47119. * Targets the given mesh with its children and updates zoom level accordingly.
  47120. * @param mesh The mesh to target.
  47121. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47122. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47123. */
  47124. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47125. /**
  47126. * Targets the given meshes with their children and updates zoom level accordingly.
  47127. * @param meshes The mesh to target.
  47128. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47129. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47130. */
  47131. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47132. /**
  47133. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47134. * @param minimumWorld Determines the smaller position of the bounding box extend
  47135. * @param maximumWorld Determines the bigger position of the bounding box extend
  47136. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47137. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47138. */
  47139. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47140. /**
  47141. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47142. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47143. * frustum width.
  47144. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47145. * to fully enclose the mesh in the viewing frustum.
  47146. */
  47147. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47148. /**
  47149. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47150. * is automatically returned to its default position (expected to be above ground plane).
  47151. */
  47152. private _maintainCameraAboveGround;
  47153. /**
  47154. * Returns the frustum slope based on the canvas ratio and camera FOV
  47155. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47156. */
  47157. private _getFrustumSlope;
  47158. /**
  47159. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47160. */
  47161. private _clearAnimationLocks;
  47162. /**
  47163. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47164. */
  47165. private _applyUserInteraction;
  47166. /**
  47167. * Stops and removes all animations that have been applied to the camera
  47168. */
  47169. stopAllAnimations(): void;
  47170. /**
  47171. * Gets a value indicating if the user is moving the camera
  47172. */
  47173. get isUserIsMoving(): boolean;
  47174. /**
  47175. * The camera can move all the way towards the mesh.
  47176. */
  47177. static IgnoreBoundsSizeMode: number;
  47178. /**
  47179. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47180. */
  47181. static FitFrustumSidesMode: number;
  47182. }
  47183. }
  47184. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47185. import { Nullable } from "babylonjs/types";
  47186. import { Camera } from "babylonjs/Cameras/camera";
  47187. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47188. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47189. /**
  47190. * Base class for Camera Pointer Inputs.
  47191. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47192. * for example usage.
  47193. */
  47194. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47195. /**
  47196. * Defines the camera the input is attached to.
  47197. */
  47198. abstract camera: Camera;
  47199. /**
  47200. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47201. */
  47202. protected _altKey: boolean;
  47203. protected _ctrlKey: boolean;
  47204. protected _metaKey: boolean;
  47205. protected _shiftKey: boolean;
  47206. /**
  47207. * Which mouse buttons were pressed at time of last mouse event.
  47208. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47209. */
  47210. protected _buttonsPressed: number;
  47211. /**
  47212. * Defines the buttons associated with the input to handle camera move.
  47213. */
  47214. buttons: number[];
  47215. /**
  47216. * Attach the input controls to a specific dom element to get the input from.
  47217. * @param element Defines the element the controls should be listened from
  47218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47219. */
  47220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47221. /**
  47222. * Detach the current controls from the specified dom element.
  47223. * @param element Defines the element to stop listening the inputs from
  47224. */
  47225. detachControl(element: Nullable<HTMLElement>): void;
  47226. /**
  47227. * Gets the class name of the current input.
  47228. * @returns the class name
  47229. */
  47230. getClassName(): string;
  47231. /**
  47232. * Get the friendly name associated with the input class.
  47233. * @returns the input friendly name
  47234. */
  47235. getSimpleName(): string;
  47236. /**
  47237. * Called on pointer POINTERDOUBLETAP event.
  47238. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47239. */
  47240. protected onDoubleTap(type: string): void;
  47241. /**
  47242. * Called on pointer POINTERMOVE event if only a single touch is active.
  47243. * Override this method to provide functionality.
  47244. */
  47245. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47246. /**
  47247. * Called on pointer POINTERMOVE event if multiple touches are active.
  47248. * Override this method to provide functionality.
  47249. */
  47250. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47251. /**
  47252. * Called on JS contextmenu event.
  47253. * Override this method to provide functionality.
  47254. */
  47255. protected onContextMenu(evt: PointerEvent): void;
  47256. /**
  47257. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47258. * press.
  47259. * Override this method to provide functionality.
  47260. */
  47261. protected onButtonDown(evt: PointerEvent): void;
  47262. /**
  47263. * Called each time a new POINTERUP event occurs. Ie, for each button
  47264. * release.
  47265. * Override this method to provide functionality.
  47266. */
  47267. protected onButtonUp(evt: PointerEvent): void;
  47268. /**
  47269. * Called when window becomes inactive.
  47270. * Override this method to provide functionality.
  47271. */
  47272. protected onLostFocus(): void;
  47273. private _pointerInput;
  47274. private _observer;
  47275. private _onLostFocus;
  47276. private pointA;
  47277. private pointB;
  47278. }
  47279. }
  47280. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47281. import { Nullable } from "babylonjs/types";
  47282. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47283. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47284. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47285. /**
  47286. * Manage the pointers inputs to control an arc rotate camera.
  47287. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47288. */
  47289. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47290. /**
  47291. * Defines the camera the input is attached to.
  47292. */
  47293. camera: ArcRotateCamera;
  47294. /**
  47295. * Gets the class name of the current input.
  47296. * @returns the class name
  47297. */
  47298. getClassName(): string;
  47299. /**
  47300. * Defines the buttons associated with the input to handle camera move.
  47301. */
  47302. buttons: number[];
  47303. /**
  47304. * Defines the pointer angular sensibility along the X axis or how fast is
  47305. * the camera rotating.
  47306. */
  47307. angularSensibilityX: number;
  47308. /**
  47309. * Defines the pointer angular sensibility along the Y axis or how fast is
  47310. * the camera rotating.
  47311. */
  47312. angularSensibilityY: number;
  47313. /**
  47314. * Defines the pointer pinch precision or how fast is the camera zooming.
  47315. */
  47316. pinchPrecision: number;
  47317. /**
  47318. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47319. * from 0.
  47320. * It defines the percentage of current camera.radius to use as delta when
  47321. * pinch zoom is used.
  47322. */
  47323. pinchDeltaPercentage: number;
  47324. /**
  47325. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47326. * that any object in the plane at the camera's target point will scale
  47327. * perfectly with finger motion.
  47328. * Overrides pinchDeltaPercentage and pinchPrecision.
  47329. */
  47330. useNaturalPinchZoom: boolean;
  47331. /**
  47332. * Defines the pointer panning sensibility or how fast is the camera moving.
  47333. */
  47334. panningSensibility: number;
  47335. /**
  47336. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47337. */
  47338. multiTouchPanning: boolean;
  47339. /**
  47340. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47341. * zoom (pinch) through multitouch.
  47342. */
  47343. multiTouchPanAndZoom: boolean;
  47344. /**
  47345. * Revers pinch action direction.
  47346. */
  47347. pinchInwards: boolean;
  47348. private _isPanClick;
  47349. private _twoFingerActivityCount;
  47350. private _isPinching;
  47351. /**
  47352. * Called on pointer POINTERMOVE event if only a single touch is active.
  47353. */
  47354. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47355. /**
  47356. * Called on pointer POINTERDOUBLETAP event.
  47357. */
  47358. protected onDoubleTap(type: string): void;
  47359. /**
  47360. * Called on pointer POINTERMOVE event if multiple touches are active.
  47361. */
  47362. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47363. /**
  47364. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47365. * press.
  47366. */
  47367. protected onButtonDown(evt: PointerEvent): void;
  47368. /**
  47369. * Called each time a new POINTERUP event occurs. Ie, for each button
  47370. * release.
  47371. */
  47372. protected onButtonUp(evt: PointerEvent): void;
  47373. /**
  47374. * Called when window becomes inactive.
  47375. */
  47376. protected onLostFocus(): void;
  47377. }
  47378. }
  47379. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47380. import { Nullable } from "babylonjs/types";
  47381. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47382. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47383. /**
  47384. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47385. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47386. */
  47387. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47388. /**
  47389. * Defines the camera the input is attached to.
  47390. */
  47391. camera: ArcRotateCamera;
  47392. /**
  47393. * Defines the list of key codes associated with the up action (increase alpha)
  47394. */
  47395. keysUp: number[];
  47396. /**
  47397. * Defines the list of key codes associated with the down action (decrease alpha)
  47398. */
  47399. keysDown: number[];
  47400. /**
  47401. * Defines the list of key codes associated with the left action (increase beta)
  47402. */
  47403. keysLeft: number[];
  47404. /**
  47405. * Defines the list of key codes associated with the right action (decrease beta)
  47406. */
  47407. keysRight: number[];
  47408. /**
  47409. * Defines the list of key codes associated with the reset action.
  47410. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47411. */
  47412. keysReset: number[];
  47413. /**
  47414. * Defines the panning sensibility of the inputs.
  47415. * (How fast is the camera panning)
  47416. */
  47417. panningSensibility: number;
  47418. /**
  47419. * Defines the zooming sensibility of the inputs.
  47420. * (How fast is the camera zooming)
  47421. */
  47422. zoomingSensibility: number;
  47423. /**
  47424. * Defines whether maintaining the alt key down switch the movement mode from
  47425. * orientation to zoom.
  47426. */
  47427. useAltToZoom: boolean;
  47428. /**
  47429. * Rotation speed of the camera
  47430. */
  47431. angularSpeed: number;
  47432. private _keys;
  47433. private _ctrlPressed;
  47434. private _altPressed;
  47435. private _onCanvasBlurObserver;
  47436. private _onKeyboardObserver;
  47437. private _engine;
  47438. private _scene;
  47439. /**
  47440. * Attach the input controls to a specific dom element to get the input from.
  47441. * @param element Defines the element the controls should be listened from
  47442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47443. */
  47444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47445. /**
  47446. * Detach the current controls from the specified dom element.
  47447. * @param element Defines the element to stop listening the inputs from
  47448. */
  47449. detachControl(element: Nullable<HTMLElement>): void;
  47450. /**
  47451. * Update the current camera state depending on the inputs that have been used this frame.
  47452. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47453. */
  47454. checkInputs(): void;
  47455. /**
  47456. * Gets the class name of the current intput.
  47457. * @returns the class name
  47458. */
  47459. getClassName(): string;
  47460. /**
  47461. * Get the friendly name associated with the input class.
  47462. * @returns the input friendly name
  47463. */
  47464. getSimpleName(): string;
  47465. }
  47466. }
  47467. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47468. import { Nullable } from "babylonjs/types";
  47469. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47470. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47471. /**
  47472. * Manage the mouse wheel inputs to control an arc rotate camera.
  47473. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47474. */
  47475. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47476. /**
  47477. * Defines the camera the input is attached to.
  47478. */
  47479. camera: ArcRotateCamera;
  47480. /**
  47481. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47482. */
  47483. wheelPrecision: number;
  47484. /**
  47485. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47486. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47487. */
  47488. wheelDeltaPercentage: number;
  47489. private _wheel;
  47490. private _observer;
  47491. private computeDeltaFromMouseWheelLegacyEvent;
  47492. /**
  47493. * Attach the input controls to a specific dom element to get the input from.
  47494. * @param element Defines the element the controls should be listened from
  47495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47496. */
  47497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47498. /**
  47499. * Detach the current controls from the specified dom element.
  47500. * @param element Defines the element to stop listening the inputs from
  47501. */
  47502. detachControl(element: Nullable<HTMLElement>): void;
  47503. /**
  47504. * Gets the class name of the current intput.
  47505. * @returns the class name
  47506. */
  47507. getClassName(): string;
  47508. /**
  47509. * Get the friendly name associated with the input class.
  47510. * @returns the input friendly name
  47511. */
  47512. getSimpleName(): string;
  47513. }
  47514. }
  47515. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47516. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47517. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47518. /**
  47519. * Default Inputs manager for the ArcRotateCamera.
  47520. * It groups all the default supported inputs for ease of use.
  47521. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47522. */
  47523. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47524. /**
  47525. * Instantiates a new ArcRotateCameraInputsManager.
  47526. * @param camera Defines the camera the inputs belong to
  47527. */
  47528. constructor(camera: ArcRotateCamera);
  47529. /**
  47530. * Add mouse wheel input support to the input manager.
  47531. * @returns the current input manager
  47532. */
  47533. addMouseWheel(): ArcRotateCameraInputsManager;
  47534. /**
  47535. * Add pointers input support to the input manager.
  47536. * @returns the current input manager
  47537. */
  47538. addPointers(): ArcRotateCameraInputsManager;
  47539. /**
  47540. * Add keyboard input support to the input manager.
  47541. * @returns the current input manager
  47542. */
  47543. addKeyboard(): ArcRotateCameraInputsManager;
  47544. }
  47545. }
  47546. declare module "babylonjs/Cameras/arcRotateCamera" {
  47547. import { Observable } from "babylonjs/Misc/observable";
  47548. import { Nullable } from "babylonjs/types";
  47549. import { Scene } from "babylonjs/scene";
  47550. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47552. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47553. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47554. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47555. import { Camera } from "babylonjs/Cameras/camera";
  47556. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47557. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47558. import { Collider } from "babylonjs/Collisions/collider";
  47559. /**
  47560. * This represents an orbital type of camera.
  47561. *
  47562. * 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.
  47563. * 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.
  47564. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47565. */
  47566. export class ArcRotateCamera extends TargetCamera {
  47567. /**
  47568. * Defines the rotation angle of the camera along the longitudinal axis.
  47569. */
  47570. alpha: number;
  47571. /**
  47572. * Defines the rotation angle of the camera along the latitudinal axis.
  47573. */
  47574. beta: number;
  47575. /**
  47576. * Defines the radius of the camera from it s target point.
  47577. */
  47578. radius: number;
  47579. protected _target: Vector3;
  47580. protected _targetHost: Nullable<AbstractMesh>;
  47581. /**
  47582. * Defines the target point of the camera.
  47583. * The camera looks towards it form the radius distance.
  47584. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47585. */
  47586. get target(): Vector3;
  47587. set target(value: Vector3);
  47588. /**
  47589. * Define the current local position of the camera in the scene
  47590. */
  47591. get position(): Vector3;
  47592. set position(newPosition: Vector3);
  47593. protected _upToYMatrix: Matrix;
  47594. protected _YToUpMatrix: Matrix;
  47595. /**
  47596. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47597. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47598. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47599. */
  47600. set upVector(vec: Vector3);
  47601. get upVector(): Vector3;
  47602. /**
  47603. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47604. */
  47605. setMatUp(): void;
  47606. /**
  47607. * Current inertia value on the longitudinal axis.
  47608. * The bigger this number the longer it will take for the camera to stop.
  47609. */
  47610. inertialAlphaOffset: number;
  47611. /**
  47612. * Current inertia value on the latitudinal axis.
  47613. * The bigger this number the longer it will take for the camera to stop.
  47614. */
  47615. inertialBetaOffset: number;
  47616. /**
  47617. * Current inertia value on the radius axis.
  47618. * The bigger this number the longer it will take for the camera to stop.
  47619. */
  47620. inertialRadiusOffset: number;
  47621. /**
  47622. * Minimum allowed angle on the longitudinal axis.
  47623. * This can help limiting how the Camera is able to move in the scene.
  47624. */
  47625. lowerAlphaLimit: Nullable<number>;
  47626. /**
  47627. * Maximum allowed angle on the longitudinal axis.
  47628. * This can help limiting how the Camera is able to move in the scene.
  47629. */
  47630. upperAlphaLimit: Nullable<number>;
  47631. /**
  47632. * Minimum allowed angle on the latitudinal axis.
  47633. * This can help limiting how the Camera is able to move in the scene.
  47634. */
  47635. lowerBetaLimit: number;
  47636. /**
  47637. * Maximum allowed angle on the latitudinal axis.
  47638. * This can help limiting how the Camera is able to move in the scene.
  47639. */
  47640. upperBetaLimit: number;
  47641. /**
  47642. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  47643. * This can help limiting how the Camera is able to move in the scene.
  47644. */
  47645. lowerRadiusLimit: Nullable<number>;
  47646. /**
  47647. * Maximum allowed distance of the camera to the target (The camera can not get further).
  47648. * This can help limiting how the Camera is able to move in the scene.
  47649. */
  47650. upperRadiusLimit: Nullable<number>;
  47651. /**
  47652. * Defines the current inertia value used during panning of the camera along the X axis.
  47653. */
  47654. inertialPanningX: number;
  47655. /**
  47656. * Defines the current inertia value used during panning of the camera along the Y axis.
  47657. */
  47658. inertialPanningY: number;
  47659. /**
  47660. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  47661. * Basically if your fingers moves away from more than this distance you will be considered
  47662. * in pinch mode.
  47663. */
  47664. pinchToPanMaxDistance: number;
  47665. /**
  47666. * Defines the maximum distance the camera can pan.
  47667. * This could help keeping the cammera always in your scene.
  47668. */
  47669. panningDistanceLimit: Nullable<number>;
  47670. /**
  47671. * Defines the target of the camera before paning.
  47672. */
  47673. panningOriginTarget: Vector3;
  47674. /**
  47675. * Defines the value of the inertia used during panning.
  47676. * 0 would mean stop inertia and one would mean no decelleration at all.
  47677. */
  47678. panningInertia: number;
  47679. /**
  47680. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  47681. */
  47682. get angularSensibilityX(): number;
  47683. set angularSensibilityX(value: number);
  47684. /**
  47685. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  47686. */
  47687. get angularSensibilityY(): number;
  47688. set angularSensibilityY(value: number);
  47689. /**
  47690. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  47691. */
  47692. get pinchPrecision(): number;
  47693. set pinchPrecision(value: number);
  47694. /**
  47695. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  47696. * It will be used instead of pinchDeltaPrecision if different from 0.
  47697. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47698. */
  47699. get pinchDeltaPercentage(): number;
  47700. set pinchDeltaPercentage(value: number);
  47701. /**
  47702. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  47703. * and pinch delta percentage.
  47704. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47705. * that any object in the plane at the camera's target point will scale
  47706. * perfectly with finger motion.
  47707. */
  47708. get useNaturalPinchZoom(): boolean;
  47709. set useNaturalPinchZoom(value: boolean);
  47710. /**
  47711. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  47712. */
  47713. get panningSensibility(): number;
  47714. set panningSensibility(value: number);
  47715. /**
  47716. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  47717. */
  47718. get keysUp(): number[];
  47719. set keysUp(value: number[]);
  47720. /**
  47721. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  47722. */
  47723. get keysDown(): number[];
  47724. set keysDown(value: number[]);
  47725. /**
  47726. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  47727. */
  47728. get keysLeft(): number[];
  47729. set keysLeft(value: number[]);
  47730. /**
  47731. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  47732. */
  47733. get keysRight(): number[];
  47734. set keysRight(value: number[]);
  47735. /**
  47736. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47737. */
  47738. get wheelPrecision(): number;
  47739. set wheelPrecision(value: number);
  47740. /**
  47741. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  47742. * It will be used instead of pinchDeltaPrecision if different from 0.
  47743. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47744. */
  47745. get wheelDeltaPercentage(): number;
  47746. set wheelDeltaPercentage(value: number);
  47747. /**
  47748. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  47749. */
  47750. zoomOnFactor: number;
  47751. /**
  47752. * Defines a screen offset for the camera position.
  47753. */
  47754. targetScreenOffset: Vector2;
  47755. /**
  47756. * Allows the camera to be completely reversed.
  47757. * If false the camera can not arrive upside down.
  47758. */
  47759. allowUpsideDown: boolean;
  47760. /**
  47761. * Define if double tap/click is used to restore the previously saved state of the camera.
  47762. */
  47763. useInputToRestoreState: boolean;
  47764. /** @hidden */
  47765. _viewMatrix: Matrix;
  47766. /** @hidden */
  47767. _useCtrlForPanning: boolean;
  47768. /** @hidden */
  47769. _panningMouseButton: number;
  47770. /**
  47771. * Defines the input associated to the camera.
  47772. */
  47773. inputs: ArcRotateCameraInputsManager;
  47774. /** @hidden */
  47775. _reset: () => void;
  47776. /**
  47777. * Defines the allowed panning axis.
  47778. */
  47779. panningAxis: Vector3;
  47780. protected _localDirection: Vector3;
  47781. protected _transformedDirection: Vector3;
  47782. private _bouncingBehavior;
  47783. /**
  47784. * Gets the bouncing behavior of the camera if it has been enabled.
  47785. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47786. */
  47787. get bouncingBehavior(): Nullable<BouncingBehavior>;
  47788. /**
  47789. * Defines if the bouncing behavior of the camera is enabled on the camera.
  47790. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47791. */
  47792. get useBouncingBehavior(): boolean;
  47793. set useBouncingBehavior(value: boolean);
  47794. private _framingBehavior;
  47795. /**
  47796. * Gets the framing behavior of the camera if it has been enabled.
  47797. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47798. */
  47799. get framingBehavior(): Nullable<FramingBehavior>;
  47800. /**
  47801. * Defines if the framing behavior of the camera is enabled on the camera.
  47802. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47803. */
  47804. get useFramingBehavior(): boolean;
  47805. set useFramingBehavior(value: boolean);
  47806. private _autoRotationBehavior;
  47807. /**
  47808. * Gets the auto rotation behavior of the camera if it has been enabled.
  47809. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47810. */
  47811. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  47812. /**
  47813. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  47814. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47815. */
  47816. get useAutoRotationBehavior(): boolean;
  47817. set useAutoRotationBehavior(value: boolean);
  47818. /**
  47819. * Observable triggered when the mesh target has been changed on the camera.
  47820. */
  47821. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  47822. /**
  47823. * Event raised when the camera is colliding with a mesh.
  47824. */
  47825. onCollide: (collidedMesh: AbstractMesh) => void;
  47826. /**
  47827. * Defines whether the camera should check collision with the objects oh the scene.
  47828. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  47829. */
  47830. checkCollisions: boolean;
  47831. /**
  47832. * Defines the collision radius of the camera.
  47833. * This simulates a sphere around the camera.
  47834. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47835. */
  47836. collisionRadius: Vector3;
  47837. protected _collider: Collider;
  47838. protected _previousPosition: Vector3;
  47839. protected _collisionVelocity: Vector3;
  47840. protected _newPosition: Vector3;
  47841. protected _previousAlpha: number;
  47842. protected _previousBeta: number;
  47843. protected _previousRadius: number;
  47844. protected _collisionTriggered: boolean;
  47845. protected _targetBoundingCenter: Nullable<Vector3>;
  47846. private _computationVector;
  47847. /**
  47848. * Instantiates a new ArcRotateCamera in a given scene
  47849. * @param name Defines the name of the camera
  47850. * @param alpha Defines the camera rotation along the logitudinal axis
  47851. * @param beta Defines the camera rotation along the latitudinal axis
  47852. * @param radius Defines the camera distance from its target
  47853. * @param target Defines the camera target
  47854. * @param scene Defines the scene the camera belongs to
  47855. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  47856. */
  47857. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47858. /** @hidden */
  47859. _initCache(): void;
  47860. /** @hidden */
  47861. _updateCache(ignoreParentClass?: boolean): void;
  47862. protected _getTargetPosition(): Vector3;
  47863. private _storedAlpha;
  47864. private _storedBeta;
  47865. private _storedRadius;
  47866. private _storedTarget;
  47867. private _storedTargetScreenOffset;
  47868. /**
  47869. * Stores the current state of the camera (alpha, beta, radius and target)
  47870. * @returns the camera itself
  47871. */
  47872. storeState(): Camera;
  47873. /**
  47874. * @hidden
  47875. * Restored camera state. You must call storeState() first
  47876. */
  47877. _restoreStateValues(): boolean;
  47878. /** @hidden */
  47879. _isSynchronizedViewMatrix(): boolean;
  47880. /**
  47881. * Attached controls to the current camera.
  47882. * @param element Defines the element the controls should be listened from
  47883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47884. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  47885. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  47886. */
  47887. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  47888. /**
  47889. * Detach the current controls from the camera.
  47890. * The camera will stop reacting to inputs.
  47891. * @param element Defines the element to stop listening the inputs from
  47892. */
  47893. detachControl(element: HTMLElement): void;
  47894. /** @hidden */
  47895. _checkInputs(): void;
  47896. protected _checkLimits(): void;
  47897. /**
  47898. * Rebuilds angles (alpha, beta) and radius from the give position and target
  47899. */
  47900. rebuildAnglesAndRadius(): void;
  47901. /**
  47902. * Use a position to define the current camera related information like alpha, beta and radius
  47903. * @param position Defines the position to set the camera at
  47904. */
  47905. setPosition(position: Vector3): void;
  47906. /**
  47907. * Defines the target the camera should look at.
  47908. * This will automatically adapt alpha beta and radius to fit within the new target.
  47909. * @param target Defines the new target as a Vector or a mesh
  47910. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  47911. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  47912. */
  47913. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  47914. /** @hidden */
  47915. _getViewMatrix(): Matrix;
  47916. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  47917. /**
  47918. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  47919. * @param meshes Defines the mesh to zoom on
  47920. * @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)
  47921. */
  47922. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  47923. /**
  47924. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  47925. * The target will be changed but the radius
  47926. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  47927. * @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)
  47928. */
  47929. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  47930. min: Vector3;
  47931. max: Vector3;
  47932. distance: number;
  47933. }, doNotUpdateMaxZ?: boolean): void;
  47934. /**
  47935. * @override
  47936. * Override Camera.createRigCamera
  47937. */
  47938. createRigCamera(name: string, cameraIndex: number): Camera;
  47939. /**
  47940. * @hidden
  47941. * @override
  47942. * Override Camera._updateRigCameras
  47943. */
  47944. _updateRigCameras(): void;
  47945. /**
  47946. * Destroy the camera and release the current resources hold by it.
  47947. */
  47948. dispose(): void;
  47949. /**
  47950. * Gets the current object class name.
  47951. * @return the class name
  47952. */
  47953. getClassName(): string;
  47954. }
  47955. }
  47956. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  47957. import { Behavior } from "babylonjs/Behaviors/behavior";
  47958. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47959. /**
  47960. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  47961. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47962. */
  47963. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  47964. /**
  47965. * Gets the name of the behavior.
  47966. */
  47967. get name(): string;
  47968. private _zoomStopsAnimation;
  47969. private _idleRotationSpeed;
  47970. private _idleRotationWaitTime;
  47971. private _idleRotationSpinupTime;
  47972. /**
  47973. * Sets the flag that indicates if user zooming should stop animation.
  47974. */
  47975. set zoomStopsAnimation(flag: boolean);
  47976. /**
  47977. * Gets the flag that indicates if user zooming should stop animation.
  47978. */
  47979. get zoomStopsAnimation(): boolean;
  47980. /**
  47981. * Sets the default speed at which the camera rotates around the model.
  47982. */
  47983. set idleRotationSpeed(speed: number);
  47984. /**
  47985. * Gets the default speed at which the camera rotates around the model.
  47986. */
  47987. get idleRotationSpeed(): number;
  47988. /**
  47989. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  47990. */
  47991. set idleRotationWaitTime(time: number);
  47992. /**
  47993. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  47994. */
  47995. get idleRotationWaitTime(): number;
  47996. /**
  47997. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  47998. */
  47999. set idleRotationSpinupTime(time: number);
  48000. /**
  48001. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48002. */
  48003. get idleRotationSpinupTime(): number;
  48004. /**
  48005. * Gets a value indicating if the camera is currently rotating because of this behavior
  48006. */
  48007. get rotationInProgress(): boolean;
  48008. private _onPrePointerObservableObserver;
  48009. private _onAfterCheckInputsObserver;
  48010. private _attachedCamera;
  48011. private _isPointerDown;
  48012. private _lastFrameTime;
  48013. private _lastInteractionTime;
  48014. private _cameraRotationSpeed;
  48015. /**
  48016. * Initializes the behavior.
  48017. */
  48018. init(): void;
  48019. /**
  48020. * Attaches the behavior to its arc rotate camera.
  48021. * @param camera Defines the camera to attach the behavior to
  48022. */
  48023. attach(camera: ArcRotateCamera): void;
  48024. /**
  48025. * Detaches the behavior from its current arc rotate camera.
  48026. */
  48027. detach(): void;
  48028. /**
  48029. * Returns true if user is scrolling.
  48030. * @return true if user is scrolling.
  48031. */
  48032. private _userIsZooming;
  48033. private _lastFrameRadius;
  48034. private _shouldAnimationStopForInteraction;
  48035. /**
  48036. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48037. */
  48038. private _applyUserInteraction;
  48039. private _userIsMoving;
  48040. }
  48041. }
  48042. declare module "babylonjs/Behaviors/Cameras/index" {
  48043. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48044. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48045. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48046. }
  48047. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48048. import { Mesh } from "babylonjs/Meshes/mesh";
  48049. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48050. import { Behavior } from "babylonjs/Behaviors/behavior";
  48051. /**
  48052. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48053. */
  48054. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48055. private ui;
  48056. /**
  48057. * The name of the behavior
  48058. */
  48059. name: string;
  48060. /**
  48061. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48062. */
  48063. distanceAwayFromFace: number;
  48064. /**
  48065. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48066. */
  48067. distanceAwayFromBottomOfFace: number;
  48068. private _faceVectors;
  48069. private _target;
  48070. private _scene;
  48071. private _onRenderObserver;
  48072. private _tmpMatrix;
  48073. private _tmpVector;
  48074. /**
  48075. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48076. * @param ui The transform node that should be attched to the mesh
  48077. */
  48078. constructor(ui: TransformNode);
  48079. /**
  48080. * Initializes the behavior
  48081. */
  48082. init(): void;
  48083. private _closestFace;
  48084. private _zeroVector;
  48085. private _lookAtTmpMatrix;
  48086. private _lookAtToRef;
  48087. /**
  48088. * Attaches the AttachToBoxBehavior to the passed in mesh
  48089. * @param target The mesh that the specified node will be attached to
  48090. */
  48091. attach(target: Mesh): void;
  48092. /**
  48093. * Detaches the behavior from the mesh
  48094. */
  48095. detach(): void;
  48096. }
  48097. }
  48098. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48099. import { Behavior } from "babylonjs/Behaviors/behavior";
  48100. import { Mesh } from "babylonjs/Meshes/mesh";
  48101. /**
  48102. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48103. */
  48104. export class FadeInOutBehavior implements Behavior<Mesh> {
  48105. /**
  48106. * Time in milliseconds to delay before fading in (Default: 0)
  48107. */
  48108. delay: number;
  48109. /**
  48110. * Time in milliseconds for the mesh to fade in (Default: 300)
  48111. */
  48112. fadeInTime: number;
  48113. private _millisecondsPerFrame;
  48114. private _hovered;
  48115. private _hoverValue;
  48116. private _ownerNode;
  48117. /**
  48118. * Instatiates the FadeInOutBehavior
  48119. */
  48120. constructor();
  48121. /**
  48122. * The name of the behavior
  48123. */
  48124. get name(): string;
  48125. /**
  48126. * Initializes the behavior
  48127. */
  48128. init(): void;
  48129. /**
  48130. * Attaches the fade behavior on the passed in mesh
  48131. * @param ownerNode The mesh that will be faded in/out once attached
  48132. */
  48133. attach(ownerNode: Mesh): void;
  48134. /**
  48135. * Detaches the behavior from the mesh
  48136. */
  48137. detach(): void;
  48138. /**
  48139. * Triggers the mesh to begin fading in or out
  48140. * @param value if the object should fade in or out (true to fade in)
  48141. */
  48142. fadeIn(value: boolean): void;
  48143. private _update;
  48144. private _setAllVisibility;
  48145. }
  48146. }
  48147. declare module "babylonjs/Misc/pivotTools" {
  48148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48149. /**
  48150. * Class containing a set of static utilities functions for managing Pivots
  48151. * @hidden
  48152. */
  48153. export class PivotTools {
  48154. private static _PivotCached;
  48155. private static _OldPivotPoint;
  48156. private static _PivotTranslation;
  48157. private static _PivotTmpVector;
  48158. private static _PivotPostMultiplyPivotMatrix;
  48159. /** @hidden */
  48160. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48161. /** @hidden */
  48162. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48163. }
  48164. }
  48165. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48166. import { Scene } from "babylonjs/scene";
  48167. import { Vector4 } from "babylonjs/Maths/math.vector";
  48168. import { Mesh } from "babylonjs/Meshes/mesh";
  48169. import { Nullable } from "babylonjs/types";
  48170. import { Plane } from "babylonjs/Maths/math.plane";
  48171. /**
  48172. * Class containing static functions to help procedurally build meshes
  48173. */
  48174. export class PlaneBuilder {
  48175. /**
  48176. * Creates a plane mesh
  48177. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48178. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48179. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48183. * @param name defines the name of the mesh
  48184. * @param options defines the options used to create the mesh
  48185. * @param scene defines the hosting scene
  48186. * @returns the plane mesh
  48187. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48188. */
  48189. static CreatePlane(name: string, options: {
  48190. size?: number;
  48191. width?: number;
  48192. height?: number;
  48193. sideOrientation?: number;
  48194. frontUVs?: Vector4;
  48195. backUVs?: Vector4;
  48196. updatable?: boolean;
  48197. sourcePlane?: Plane;
  48198. }, scene?: Nullable<Scene>): Mesh;
  48199. }
  48200. }
  48201. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48202. import { Behavior } from "babylonjs/Behaviors/behavior";
  48203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48204. import { Observable } from "babylonjs/Misc/observable";
  48205. import { Vector3 } from "babylonjs/Maths/math.vector";
  48206. import { Ray } from "babylonjs/Culling/ray";
  48207. import "babylonjs/Meshes/Builders/planeBuilder";
  48208. /**
  48209. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48210. */
  48211. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48212. private static _AnyMouseID;
  48213. /**
  48214. * Abstract mesh the behavior is set on
  48215. */
  48216. attachedNode: AbstractMesh;
  48217. private _dragPlane;
  48218. private _scene;
  48219. private _pointerObserver;
  48220. private _beforeRenderObserver;
  48221. private static _planeScene;
  48222. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48223. /**
  48224. * 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)
  48225. */
  48226. maxDragAngle: number;
  48227. /**
  48228. * @hidden
  48229. */
  48230. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48231. /**
  48232. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48233. */
  48234. currentDraggingPointerID: number;
  48235. /**
  48236. * The last position where the pointer hit the drag plane in world space
  48237. */
  48238. lastDragPosition: Vector3;
  48239. /**
  48240. * If the behavior is currently in a dragging state
  48241. */
  48242. dragging: boolean;
  48243. /**
  48244. * 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)
  48245. */
  48246. dragDeltaRatio: number;
  48247. /**
  48248. * If the drag plane orientation should be updated during the dragging (Default: true)
  48249. */
  48250. updateDragPlane: boolean;
  48251. private _debugMode;
  48252. private _moving;
  48253. /**
  48254. * Fires each time the attached mesh is dragged with the pointer
  48255. * * delta between last drag position and current drag position in world space
  48256. * * dragDistance along the drag axis
  48257. * * dragPlaneNormal normal of the current drag plane used during the drag
  48258. * * dragPlanePoint in world space where the drag intersects the drag plane
  48259. */
  48260. onDragObservable: Observable<{
  48261. delta: Vector3;
  48262. dragPlanePoint: Vector3;
  48263. dragPlaneNormal: Vector3;
  48264. dragDistance: number;
  48265. pointerId: number;
  48266. }>;
  48267. /**
  48268. * Fires each time a drag begins (eg. mouse down on mesh)
  48269. */
  48270. onDragStartObservable: Observable<{
  48271. dragPlanePoint: Vector3;
  48272. pointerId: number;
  48273. }>;
  48274. /**
  48275. * Fires each time a drag ends (eg. mouse release after drag)
  48276. */
  48277. onDragEndObservable: Observable<{
  48278. dragPlanePoint: Vector3;
  48279. pointerId: number;
  48280. }>;
  48281. /**
  48282. * If the attached mesh should be moved when dragged
  48283. */
  48284. moveAttached: boolean;
  48285. /**
  48286. * If the drag behavior will react to drag events (Default: true)
  48287. */
  48288. enabled: boolean;
  48289. /**
  48290. * If pointer events should start and release the drag (Default: true)
  48291. */
  48292. startAndReleaseDragOnPointerEvents: boolean;
  48293. /**
  48294. * If camera controls should be detached during the drag
  48295. */
  48296. detachCameraControls: boolean;
  48297. /**
  48298. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48299. */
  48300. useObjectOrientationForDragging: boolean;
  48301. private _options;
  48302. /**
  48303. * Gets the options used by the behavior
  48304. */
  48305. get options(): {
  48306. dragAxis?: Vector3;
  48307. dragPlaneNormal?: Vector3;
  48308. };
  48309. /**
  48310. * Sets the options used by the behavior
  48311. */
  48312. set options(options: {
  48313. dragAxis?: Vector3;
  48314. dragPlaneNormal?: Vector3;
  48315. });
  48316. /**
  48317. * Creates a pointer drag behavior that can be attached to a mesh
  48318. * @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)
  48319. */
  48320. constructor(options?: {
  48321. dragAxis?: Vector3;
  48322. dragPlaneNormal?: Vector3;
  48323. });
  48324. /**
  48325. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48326. */
  48327. validateDrag: (targetPosition: Vector3) => boolean;
  48328. /**
  48329. * The name of the behavior
  48330. */
  48331. get name(): string;
  48332. /**
  48333. * Initializes the behavior
  48334. */
  48335. init(): void;
  48336. private _tmpVector;
  48337. private _alternatePickedPoint;
  48338. private _worldDragAxis;
  48339. private _targetPosition;
  48340. private _attachedElement;
  48341. /**
  48342. * Attaches the drag behavior the passed in mesh
  48343. * @param ownerNode The mesh that will be dragged around once attached
  48344. * @param predicate Predicate to use for pick filtering
  48345. */
  48346. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48347. /**
  48348. * Force relase the drag action by code.
  48349. */
  48350. releaseDrag(): void;
  48351. private _startDragRay;
  48352. private _lastPointerRay;
  48353. /**
  48354. * Simulates the start of a pointer drag event on the behavior
  48355. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48356. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48357. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48358. */
  48359. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48360. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48361. private _dragDelta;
  48362. protected _moveDrag(ray: Ray): void;
  48363. private _pickWithRayOnDragPlane;
  48364. private _pointA;
  48365. private _pointC;
  48366. private _localAxis;
  48367. private _lookAt;
  48368. private _updateDragPlanePosition;
  48369. /**
  48370. * Detaches the behavior from the mesh
  48371. */
  48372. detach(): void;
  48373. }
  48374. }
  48375. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48376. import { Mesh } from "babylonjs/Meshes/mesh";
  48377. import { Behavior } from "babylonjs/Behaviors/behavior";
  48378. /**
  48379. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48380. */
  48381. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48382. private _dragBehaviorA;
  48383. private _dragBehaviorB;
  48384. private _startDistance;
  48385. private _initialScale;
  48386. private _targetScale;
  48387. private _ownerNode;
  48388. private _sceneRenderObserver;
  48389. /**
  48390. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48391. */
  48392. constructor();
  48393. /**
  48394. * The name of the behavior
  48395. */
  48396. get name(): string;
  48397. /**
  48398. * Initializes the behavior
  48399. */
  48400. init(): void;
  48401. private _getCurrentDistance;
  48402. /**
  48403. * Attaches the scale behavior the passed in mesh
  48404. * @param ownerNode The mesh that will be scaled around once attached
  48405. */
  48406. attach(ownerNode: Mesh): void;
  48407. /**
  48408. * Detaches the behavior from the mesh
  48409. */
  48410. detach(): void;
  48411. }
  48412. }
  48413. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48414. import { Behavior } from "babylonjs/Behaviors/behavior";
  48415. import { Mesh } from "babylonjs/Meshes/mesh";
  48416. import { Observable } from "babylonjs/Misc/observable";
  48417. /**
  48418. * 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
  48419. */
  48420. export class SixDofDragBehavior implements Behavior<Mesh> {
  48421. private static _virtualScene;
  48422. private _ownerNode;
  48423. private _sceneRenderObserver;
  48424. private _scene;
  48425. private _targetPosition;
  48426. private _virtualOriginMesh;
  48427. private _virtualDragMesh;
  48428. private _pointerObserver;
  48429. private _moving;
  48430. private _startingOrientation;
  48431. private _attachedElement;
  48432. /**
  48433. * 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)
  48434. */
  48435. private zDragFactor;
  48436. /**
  48437. * If the object should rotate to face the drag origin
  48438. */
  48439. rotateDraggedObject: boolean;
  48440. /**
  48441. * If the behavior is currently in a dragging state
  48442. */
  48443. dragging: boolean;
  48444. /**
  48445. * 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)
  48446. */
  48447. dragDeltaRatio: number;
  48448. /**
  48449. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48450. */
  48451. currentDraggingPointerID: number;
  48452. /**
  48453. * If camera controls should be detached during the drag
  48454. */
  48455. detachCameraControls: boolean;
  48456. /**
  48457. * Fires each time a drag starts
  48458. */
  48459. onDragStartObservable: Observable<{}>;
  48460. /**
  48461. * Fires each time a drag ends (eg. mouse release after drag)
  48462. */
  48463. onDragEndObservable: Observable<{}>;
  48464. /**
  48465. * 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
  48466. */
  48467. constructor();
  48468. /**
  48469. * The name of the behavior
  48470. */
  48471. get name(): string;
  48472. /**
  48473. * Initializes the behavior
  48474. */
  48475. init(): void;
  48476. /**
  48477. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48478. */
  48479. private get _pointerCamera();
  48480. /**
  48481. * Attaches the scale behavior the passed in mesh
  48482. * @param ownerNode The mesh that will be scaled around once attached
  48483. */
  48484. attach(ownerNode: Mesh): void;
  48485. /**
  48486. * Detaches the behavior from the mesh
  48487. */
  48488. detach(): void;
  48489. }
  48490. }
  48491. declare module "babylonjs/Behaviors/Meshes/index" {
  48492. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48493. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48494. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48495. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48496. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48497. }
  48498. declare module "babylonjs/Behaviors/index" {
  48499. export * from "babylonjs/Behaviors/behavior";
  48500. export * from "babylonjs/Behaviors/Cameras/index";
  48501. export * from "babylonjs/Behaviors/Meshes/index";
  48502. }
  48503. declare module "babylonjs/Bones/boneIKController" {
  48504. import { Bone } from "babylonjs/Bones/bone";
  48505. import { Vector3 } from "babylonjs/Maths/math.vector";
  48506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48507. import { Nullable } from "babylonjs/types";
  48508. /**
  48509. * Class used to apply inverse kinematics to bones
  48510. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48511. */
  48512. export class BoneIKController {
  48513. private static _tmpVecs;
  48514. private static _tmpQuat;
  48515. private static _tmpMats;
  48516. /**
  48517. * Gets or sets the target mesh
  48518. */
  48519. targetMesh: AbstractMesh;
  48520. /** Gets or sets the mesh used as pole */
  48521. poleTargetMesh: AbstractMesh;
  48522. /**
  48523. * Gets or sets the bone used as pole
  48524. */
  48525. poleTargetBone: Nullable<Bone>;
  48526. /**
  48527. * Gets or sets the target position
  48528. */
  48529. targetPosition: Vector3;
  48530. /**
  48531. * Gets or sets the pole target position
  48532. */
  48533. poleTargetPosition: Vector3;
  48534. /**
  48535. * Gets or sets the pole target local offset
  48536. */
  48537. poleTargetLocalOffset: Vector3;
  48538. /**
  48539. * Gets or sets the pole angle
  48540. */
  48541. poleAngle: number;
  48542. /**
  48543. * Gets or sets the mesh associated with the controller
  48544. */
  48545. mesh: AbstractMesh;
  48546. /**
  48547. * 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)
  48548. */
  48549. slerpAmount: number;
  48550. private _bone1Quat;
  48551. private _bone1Mat;
  48552. private _bone2Ang;
  48553. private _bone1;
  48554. private _bone2;
  48555. private _bone1Length;
  48556. private _bone2Length;
  48557. private _maxAngle;
  48558. private _maxReach;
  48559. private _rightHandedSystem;
  48560. private _bendAxis;
  48561. private _slerping;
  48562. private _adjustRoll;
  48563. /**
  48564. * Gets or sets maximum allowed angle
  48565. */
  48566. get maxAngle(): number;
  48567. set maxAngle(value: number);
  48568. /**
  48569. * Creates a new BoneIKController
  48570. * @param mesh defines the mesh to control
  48571. * @param bone defines the bone to control
  48572. * @param options defines options to set up the controller
  48573. */
  48574. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48575. targetMesh?: AbstractMesh;
  48576. poleTargetMesh?: AbstractMesh;
  48577. poleTargetBone?: Bone;
  48578. poleTargetLocalOffset?: Vector3;
  48579. poleAngle?: number;
  48580. bendAxis?: Vector3;
  48581. maxAngle?: number;
  48582. slerpAmount?: number;
  48583. });
  48584. private _setMaxAngle;
  48585. /**
  48586. * Force the controller to update the bones
  48587. */
  48588. update(): void;
  48589. }
  48590. }
  48591. declare module "babylonjs/Bones/boneLookController" {
  48592. import { Vector3 } from "babylonjs/Maths/math.vector";
  48593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48594. import { Bone } from "babylonjs/Bones/bone";
  48595. import { Space } from "babylonjs/Maths/math.axis";
  48596. /**
  48597. * Class used to make a bone look toward a point in space
  48598. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48599. */
  48600. export class BoneLookController {
  48601. private static _tmpVecs;
  48602. private static _tmpQuat;
  48603. private static _tmpMats;
  48604. /**
  48605. * The target Vector3 that the bone will look at
  48606. */
  48607. target: Vector3;
  48608. /**
  48609. * The mesh that the bone is attached to
  48610. */
  48611. mesh: AbstractMesh;
  48612. /**
  48613. * The bone that will be looking to the target
  48614. */
  48615. bone: Bone;
  48616. /**
  48617. * The up axis of the coordinate system that is used when the bone is rotated
  48618. */
  48619. upAxis: Vector3;
  48620. /**
  48621. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  48622. */
  48623. upAxisSpace: Space;
  48624. /**
  48625. * Used to make an adjustment to the yaw of the bone
  48626. */
  48627. adjustYaw: number;
  48628. /**
  48629. * Used to make an adjustment to the pitch of the bone
  48630. */
  48631. adjustPitch: number;
  48632. /**
  48633. * Used to make an adjustment to the roll of the bone
  48634. */
  48635. adjustRoll: number;
  48636. /**
  48637. * 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)
  48638. */
  48639. slerpAmount: number;
  48640. private _minYaw;
  48641. private _maxYaw;
  48642. private _minPitch;
  48643. private _maxPitch;
  48644. private _minYawSin;
  48645. private _minYawCos;
  48646. private _maxYawSin;
  48647. private _maxYawCos;
  48648. private _midYawConstraint;
  48649. private _minPitchTan;
  48650. private _maxPitchTan;
  48651. private _boneQuat;
  48652. private _slerping;
  48653. private _transformYawPitch;
  48654. private _transformYawPitchInv;
  48655. private _firstFrameSkipped;
  48656. private _yawRange;
  48657. private _fowardAxis;
  48658. /**
  48659. * Gets or sets the minimum yaw angle that the bone can look to
  48660. */
  48661. get minYaw(): number;
  48662. set minYaw(value: number);
  48663. /**
  48664. * Gets or sets the maximum yaw angle that the bone can look to
  48665. */
  48666. get maxYaw(): number;
  48667. set maxYaw(value: number);
  48668. /**
  48669. * Gets or sets the minimum pitch angle that the bone can look to
  48670. */
  48671. get minPitch(): number;
  48672. set minPitch(value: number);
  48673. /**
  48674. * Gets or sets the maximum pitch angle that the bone can look to
  48675. */
  48676. get maxPitch(): number;
  48677. set maxPitch(value: number);
  48678. /**
  48679. * Create a BoneLookController
  48680. * @param mesh the mesh that the bone belongs to
  48681. * @param bone the bone that will be looking to the target
  48682. * @param target the target Vector3 to look at
  48683. * @param options optional settings:
  48684. * * maxYaw: the maximum angle the bone will yaw to
  48685. * * minYaw: the minimum angle the bone will yaw to
  48686. * * maxPitch: the maximum angle the bone will pitch to
  48687. * * minPitch: the minimum angle the bone will yaw to
  48688. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  48689. * * upAxis: the up axis of the coordinate system
  48690. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  48691. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  48692. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  48693. * * adjustYaw: used to make an adjustment to the yaw of the bone
  48694. * * adjustPitch: used to make an adjustment to the pitch of the bone
  48695. * * adjustRoll: used to make an adjustment to the roll of the bone
  48696. **/
  48697. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  48698. maxYaw?: number;
  48699. minYaw?: number;
  48700. maxPitch?: number;
  48701. minPitch?: number;
  48702. slerpAmount?: number;
  48703. upAxis?: Vector3;
  48704. upAxisSpace?: Space;
  48705. yawAxis?: Vector3;
  48706. pitchAxis?: Vector3;
  48707. adjustYaw?: number;
  48708. adjustPitch?: number;
  48709. adjustRoll?: number;
  48710. });
  48711. /**
  48712. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  48713. */
  48714. update(): void;
  48715. private _getAngleDiff;
  48716. private _getAngleBetween;
  48717. private _isAngleBetween;
  48718. }
  48719. }
  48720. declare module "babylonjs/Bones/index" {
  48721. export * from "babylonjs/Bones/bone";
  48722. export * from "babylonjs/Bones/boneIKController";
  48723. export * from "babylonjs/Bones/boneLookController";
  48724. export * from "babylonjs/Bones/skeleton";
  48725. }
  48726. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  48727. import { Nullable } from "babylonjs/types";
  48728. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48729. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48730. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  48731. /**
  48732. * Manage the gamepad inputs to control an arc rotate camera.
  48733. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48734. */
  48735. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  48736. /**
  48737. * Defines the camera the input is attached to.
  48738. */
  48739. camera: ArcRotateCamera;
  48740. /**
  48741. * Defines the gamepad the input is gathering event from.
  48742. */
  48743. gamepad: Nullable<Gamepad>;
  48744. /**
  48745. * Defines the gamepad rotation sensiblity.
  48746. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48747. */
  48748. gamepadRotationSensibility: number;
  48749. /**
  48750. * Defines the gamepad move sensiblity.
  48751. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48752. */
  48753. gamepadMoveSensibility: number;
  48754. private _yAxisScale;
  48755. /**
  48756. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48757. */
  48758. get invertYAxis(): boolean;
  48759. set invertYAxis(value: boolean);
  48760. private _onGamepadConnectedObserver;
  48761. private _onGamepadDisconnectedObserver;
  48762. /**
  48763. * Attach the input controls to a specific dom element to get the input from.
  48764. * @param element Defines the element the controls should be listened from
  48765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48766. */
  48767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48768. /**
  48769. * Detach the current controls from the specified dom element.
  48770. * @param element Defines the element to stop listening the inputs from
  48771. */
  48772. detachControl(element: Nullable<HTMLElement>): void;
  48773. /**
  48774. * Update the current camera state depending on the inputs that have been used this frame.
  48775. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48776. */
  48777. checkInputs(): void;
  48778. /**
  48779. * Gets the class name of the current intput.
  48780. * @returns the class name
  48781. */
  48782. getClassName(): string;
  48783. /**
  48784. * Get the friendly name associated with the input class.
  48785. * @returns the input friendly name
  48786. */
  48787. getSimpleName(): string;
  48788. }
  48789. }
  48790. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  48791. import { Nullable } from "babylonjs/types";
  48792. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48794. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48795. interface ArcRotateCameraInputsManager {
  48796. /**
  48797. * Add orientation input support to the input manager.
  48798. * @returns the current input manager
  48799. */
  48800. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  48801. }
  48802. }
  48803. /**
  48804. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  48805. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48806. */
  48807. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  48808. /**
  48809. * Defines the camera the input is attached to.
  48810. */
  48811. camera: ArcRotateCamera;
  48812. /**
  48813. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  48814. */
  48815. alphaCorrection: number;
  48816. /**
  48817. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  48818. */
  48819. gammaCorrection: number;
  48820. private _alpha;
  48821. private _gamma;
  48822. private _dirty;
  48823. private _deviceOrientationHandler;
  48824. /**
  48825. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  48826. */
  48827. constructor();
  48828. /**
  48829. * Attach the input controls to a specific dom element to get the input from.
  48830. * @param element Defines the element the controls should be listened from
  48831. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48832. */
  48833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48834. /** @hidden */
  48835. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  48836. /**
  48837. * Update the current camera state depending on the inputs that have been used this frame.
  48838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48839. */
  48840. checkInputs(): void;
  48841. /**
  48842. * Detach the current controls from the specified dom element.
  48843. * @param element Defines the element to stop listening the inputs from
  48844. */
  48845. detachControl(element: Nullable<HTMLElement>): void;
  48846. /**
  48847. * Gets the class name of the current intput.
  48848. * @returns the class name
  48849. */
  48850. getClassName(): string;
  48851. /**
  48852. * Get the friendly name associated with the input class.
  48853. * @returns the input friendly name
  48854. */
  48855. getSimpleName(): string;
  48856. }
  48857. }
  48858. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  48859. import { Nullable } from "babylonjs/types";
  48860. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48861. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48862. /**
  48863. * Listen to mouse events to control the camera.
  48864. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48865. */
  48866. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  48867. /**
  48868. * Defines the camera the input is attached to.
  48869. */
  48870. camera: FlyCamera;
  48871. /**
  48872. * Defines if touch is enabled. (Default is true.)
  48873. */
  48874. touchEnabled: boolean;
  48875. /**
  48876. * Defines the buttons associated with the input to handle camera rotation.
  48877. */
  48878. buttons: number[];
  48879. /**
  48880. * Assign buttons for Yaw control.
  48881. */
  48882. buttonsYaw: number[];
  48883. /**
  48884. * Assign buttons for Pitch control.
  48885. */
  48886. buttonsPitch: number[];
  48887. /**
  48888. * Assign buttons for Roll control.
  48889. */
  48890. buttonsRoll: number[];
  48891. /**
  48892. * Detect if any button is being pressed while mouse is moved.
  48893. * -1 = Mouse locked.
  48894. * 0 = Left button.
  48895. * 1 = Middle Button.
  48896. * 2 = Right Button.
  48897. */
  48898. activeButton: number;
  48899. /**
  48900. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  48901. * Higher values reduce its sensitivity.
  48902. */
  48903. angularSensibility: number;
  48904. private _observer;
  48905. private _rollObserver;
  48906. private previousPosition;
  48907. private noPreventDefault;
  48908. private element;
  48909. /**
  48910. * Listen to mouse events to control the camera.
  48911. * @param touchEnabled Define if touch is enabled. (Default is true.)
  48912. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48913. */
  48914. constructor(touchEnabled?: boolean);
  48915. /**
  48916. * Attach the mouse control to the HTML DOM element.
  48917. * @param element Defines the element that listens to the input events.
  48918. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  48919. */
  48920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48921. /**
  48922. * Detach the current controls from the specified dom element.
  48923. * @param element Defines the element to stop listening the inputs from
  48924. */
  48925. detachControl(element: Nullable<HTMLElement>): void;
  48926. /**
  48927. * Gets the class name of the current input.
  48928. * @returns the class name.
  48929. */
  48930. getClassName(): string;
  48931. /**
  48932. * Get the friendly name associated with the input class.
  48933. * @returns the input's friendly name.
  48934. */
  48935. getSimpleName(): string;
  48936. private _pointerInput;
  48937. private _onMouseMove;
  48938. /**
  48939. * Rotate camera by mouse offset.
  48940. */
  48941. private rotateCamera;
  48942. }
  48943. }
  48944. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  48945. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48946. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48947. /**
  48948. * Default Inputs manager for the FlyCamera.
  48949. * It groups all the default supported inputs for ease of use.
  48950. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48951. */
  48952. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  48953. /**
  48954. * Instantiates a new FlyCameraInputsManager.
  48955. * @param camera Defines the camera the inputs belong to.
  48956. */
  48957. constructor(camera: FlyCamera);
  48958. /**
  48959. * Add keyboard input support to the input manager.
  48960. * @returns the new FlyCameraKeyboardMoveInput().
  48961. */
  48962. addKeyboard(): FlyCameraInputsManager;
  48963. /**
  48964. * Add mouse input support to the input manager.
  48965. * @param touchEnabled Enable touch screen support.
  48966. * @returns the new FlyCameraMouseInput().
  48967. */
  48968. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  48969. }
  48970. }
  48971. declare module "babylonjs/Cameras/flyCamera" {
  48972. import { Scene } from "babylonjs/scene";
  48973. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  48974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48975. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  48976. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  48977. /**
  48978. * This is a flying camera, designed for 3D movement and rotation in all directions,
  48979. * such as in a 3D Space Shooter or a Flight Simulator.
  48980. */
  48981. export class FlyCamera extends TargetCamera {
  48982. /**
  48983. * Define the collision ellipsoid of the camera.
  48984. * This is helpful for simulating a camera body, like a player's body.
  48985. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48986. */
  48987. ellipsoid: Vector3;
  48988. /**
  48989. * Define an offset for the position of the ellipsoid around the camera.
  48990. * This can be helpful if the camera is attached away from the player's body center,
  48991. * such as at its head.
  48992. */
  48993. ellipsoidOffset: Vector3;
  48994. /**
  48995. * Enable or disable collisions of the camera with the rest of the scene objects.
  48996. */
  48997. checkCollisions: boolean;
  48998. /**
  48999. * Enable or disable gravity on the camera.
  49000. */
  49001. applyGravity: boolean;
  49002. /**
  49003. * Define the current direction the camera is moving to.
  49004. */
  49005. cameraDirection: Vector3;
  49006. /**
  49007. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49008. * This overrides and empties cameraRotation.
  49009. */
  49010. rotationQuaternion: Quaternion;
  49011. /**
  49012. * Track Roll to maintain the wanted Rolling when looking around.
  49013. */
  49014. _trackRoll: number;
  49015. /**
  49016. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49017. */
  49018. rollCorrect: number;
  49019. /**
  49020. * Mimic a banked turn, Rolling the camera when Yawing.
  49021. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49022. */
  49023. bankedTurn: boolean;
  49024. /**
  49025. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49026. */
  49027. bankedTurnLimit: number;
  49028. /**
  49029. * Value of 0 disables the banked Roll.
  49030. * Value of 1 is equal to the Yaw angle in radians.
  49031. */
  49032. bankedTurnMultiplier: number;
  49033. /**
  49034. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49035. */
  49036. inputs: FlyCameraInputsManager;
  49037. /**
  49038. * Gets the input sensibility for mouse input.
  49039. * Higher values reduce sensitivity.
  49040. */
  49041. get angularSensibility(): number;
  49042. /**
  49043. * Sets the input sensibility for a mouse input.
  49044. * Higher values reduce sensitivity.
  49045. */
  49046. set angularSensibility(value: number);
  49047. /**
  49048. * Get the keys for camera movement forward.
  49049. */
  49050. get keysForward(): number[];
  49051. /**
  49052. * Set the keys for camera movement forward.
  49053. */
  49054. set keysForward(value: number[]);
  49055. /**
  49056. * Get the keys for camera movement backward.
  49057. */
  49058. get keysBackward(): number[];
  49059. set keysBackward(value: number[]);
  49060. /**
  49061. * Get the keys for camera movement up.
  49062. */
  49063. get keysUp(): number[];
  49064. /**
  49065. * Set the keys for camera movement up.
  49066. */
  49067. set keysUp(value: number[]);
  49068. /**
  49069. * Get the keys for camera movement down.
  49070. */
  49071. get keysDown(): number[];
  49072. /**
  49073. * Set the keys for camera movement down.
  49074. */
  49075. set keysDown(value: number[]);
  49076. /**
  49077. * Get the keys for camera movement left.
  49078. */
  49079. get keysLeft(): number[];
  49080. /**
  49081. * Set the keys for camera movement left.
  49082. */
  49083. set keysLeft(value: number[]);
  49084. /**
  49085. * Set the keys for camera movement right.
  49086. */
  49087. get keysRight(): number[];
  49088. /**
  49089. * Set the keys for camera movement right.
  49090. */
  49091. set keysRight(value: number[]);
  49092. /**
  49093. * Event raised when the camera collides with a mesh in the scene.
  49094. */
  49095. onCollide: (collidedMesh: AbstractMesh) => void;
  49096. private _collider;
  49097. private _needMoveForGravity;
  49098. private _oldPosition;
  49099. private _diffPosition;
  49100. private _newPosition;
  49101. /** @hidden */
  49102. _localDirection: Vector3;
  49103. /** @hidden */
  49104. _transformedDirection: Vector3;
  49105. /**
  49106. * Instantiates a FlyCamera.
  49107. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49108. * such as in a 3D Space Shooter or a Flight Simulator.
  49109. * @param name Define the name of the camera in the scene.
  49110. * @param position Define the starting position of the camera in the scene.
  49111. * @param scene Define the scene the camera belongs to.
  49112. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49113. */
  49114. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49115. /**
  49116. * Attach a control to the HTML DOM element.
  49117. * @param element Defines the element that listens to the input events.
  49118. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  49119. */
  49120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49121. /**
  49122. * Detach a control from the HTML DOM element.
  49123. * The camera will stop reacting to that input.
  49124. * @param element Defines the element that listens to the input events.
  49125. */
  49126. detachControl(element: HTMLElement): void;
  49127. private _collisionMask;
  49128. /**
  49129. * Get the mask that the camera ignores in collision events.
  49130. */
  49131. get collisionMask(): number;
  49132. /**
  49133. * Set the mask that the camera ignores in collision events.
  49134. */
  49135. set collisionMask(mask: number);
  49136. /** @hidden */
  49137. _collideWithWorld(displacement: Vector3): void;
  49138. /** @hidden */
  49139. private _onCollisionPositionChange;
  49140. /** @hidden */
  49141. _checkInputs(): void;
  49142. /** @hidden */
  49143. _decideIfNeedsToMove(): boolean;
  49144. /** @hidden */
  49145. _updatePosition(): void;
  49146. /**
  49147. * Restore the Roll to its target value at the rate specified.
  49148. * @param rate - Higher means slower restoring.
  49149. * @hidden
  49150. */
  49151. restoreRoll(rate: number): void;
  49152. /**
  49153. * Destroy the camera and release the current resources held by it.
  49154. */
  49155. dispose(): void;
  49156. /**
  49157. * Get the current object class name.
  49158. * @returns the class name.
  49159. */
  49160. getClassName(): string;
  49161. }
  49162. }
  49163. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49164. import { Nullable } from "babylonjs/types";
  49165. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49166. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49167. /**
  49168. * Listen to keyboard events to control the camera.
  49169. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49170. */
  49171. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49172. /**
  49173. * Defines the camera the input is attached to.
  49174. */
  49175. camera: FlyCamera;
  49176. /**
  49177. * The list of keyboard keys used to control the forward move of the camera.
  49178. */
  49179. keysForward: number[];
  49180. /**
  49181. * The list of keyboard keys used to control the backward move of the camera.
  49182. */
  49183. keysBackward: number[];
  49184. /**
  49185. * The list of keyboard keys used to control the forward move of the camera.
  49186. */
  49187. keysUp: number[];
  49188. /**
  49189. * The list of keyboard keys used to control the backward move of the camera.
  49190. */
  49191. keysDown: number[];
  49192. /**
  49193. * The list of keyboard keys used to control the right strafe move of the camera.
  49194. */
  49195. keysRight: number[];
  49196. /**
  49197. * The list of keyboard keys used to control the left strafe move of the camera.
  49198. */
  49199. keysLeft: number[];
  49200. private _keys;
  49201. private _onCanvasBlurObserver;
  49202. private _onKeyboardObserver;
  49203. private _engine;
  49204. private _scene;
  49205. /**
  49206. * Attach the input controls to a specific dom element to get the input from.
  49207. * @param element Defines the element the controls should be listened from
  49208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49209. */
  49210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49211. /**
  49212. * Detach the current controls from the specified dom element.
  49213. * @param element Defines the element to stop listening the inputs from
  49214. */
  49215. detachControl(element: Nullable<HTMLElement>): void;
  49216. /**
  49217. * Gets the class name of the current intput.
  49218. * @returns the class name
  49219. */
  49220. getClassName(): string;
  49221. /** @hidden */
  49222. _onLostFocus(e: FocusEvent): void;
  49223. /**
  49224. * Get the friendly name associated with the input class.
  49225. * @returns the input friendly name
  49226. */
  49227. getSimpleName(): string;
  49228. /**
  49229. * Update the current camera state depending on the inputs that have been used this frame.
  49230. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49231. */
  49232. checkInputs(): void;
  49233. }
  49234. }
  49235. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49236. import { Nullable } from "babylonjs/types";
  49237. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49238. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49239. /**
  49240. * Manage the mouse wheel inputs to control a follow camera.
  49241. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49242. */
  49243. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49244. /**
  49245. * Defines the camera the input is attached to.
  49246. */
  49247. camera: FollowCamera;
  49248. /**
  49249. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49250. */
  49251. axisControlRadius: boolean;
  49252. /**
  49253. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49254. */
  49255. axisControlHeight: boolean;
  49256. /**
  49257. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49258. */
  49259. axisControlRotation: boolean;
  49260. /**
  49261. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49262. * relation to mouseWheel events.
  49263. */
  49264. wheelPrecision: number;
  49265. /**
  49266. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49267. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49268. */
  49269. wheelDeltaPercentage: number;
  49270. private _wheel;
  49271. private _observer;
  49272. /**
  49273. * Attach the input controls to a specific dom element to get the input from.
  49274. * @param element Defines the element the controls should be listened from
  49275. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49276. */
  49277. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49278. /**
  49279. * Detach the current controls from the specified dom element.
  49280. * @param element Defines the element to stop listening the inputs from
  49281. */
  49282. detachControl(element: Nullable<HTMLElement>): void;
  49283. /**
  49284. * Gets the class name of the current intput.
  49285. * @returns the class name
  49286. */
  49287. getClassName(): string;
  49288. /**
  49289. * Get the friendly name associated with the input class.
  49290. * @returns the input friendly name
  49291. */
  49292. getSimpleName(): string;
  49293. }
  49294. }
  49295. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49296. import { Nullable } from "babylonjs/types";
  49297. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49298. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49299. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49300. /**
  49301. * Manage the pointers inputs to control an follow camera.
  49302. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49303. */
  49304. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49305. /**
  49306. * Defines the camera the input is attached to.
  49307. */
  49308. camera: FollowCamera;
  49309. /**
  49310. * Gets the class name of the current input.
  49311. * @returns the class name
  49312. */
  49313. getClassName(): string;
  49314. /**
  49315. * Defines the pointer angular sensibility along the X axis or how fast is
  49316. * the camera rotating.
  49317. * A negative number will reverse the axis direction.
  49318. */
  49319. angularSensibilityX: number;
  49320. /**
  49321. * Defines the pointer angular sensibility along the Y axis or how fast is
  49322. * the camera rotating.
  49323. * A negative number will reverse the axis direction.
  49324. */
  49325. angularSensibilityY: number;
  49326. /**
  49327. * Defines the pointer pinch precision or how fast is the camera zooming.
  49328. * A negative number will reverse the axis direction.
  49329. */
  49330. pinchPrecision: number;
  49331. /**
  49332. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49333. * from 0.
  49334. * It defines the percentage of current camera.radius to use as delta when
  49335. * pinch zoom is used.
  49336. */
  49337. pinchDeltaPercentage: number;
  49338. /**
  49339. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49340. */
  49341. axisXControlRadius: boolean;
  49342. /**
  49343. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49344. */
  49345. axisXControlHeight: boolean;
  49346. /**
  49347. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49348. */
  49349. axisXControlRotation: boolean;
  49350. /**
  49351. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49352. */
  49353. axisYControlRadius: boolean;
  49354. /**
  49355. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49356. */
  49357. axisYControlHeight: boolean;
  49358. /**
  49359. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49360. */
  49361. axisYControlRotation: boolean;
  49362. /**
  49363. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49364. */
  49365. axisPinchControlRadius: boolean;
  49366. /**
  49367. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49368. */
  49369. axisPinchControlHeight: boolean;
  49370. /**
  49371. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49372. */
  49373. axisPinchControlRotation: boolean;
  49374. /**
  49375. * Log error messages if basic misconfiguration has occurred.
  49376. */
  49377. warningEnable: boolean;
  49378. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49379. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49380. private _warningCounter;
  49381. private _warning;
  49382. }
  49383. }
  49384. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49385. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49386. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49387. /**
  49388. * Default Inputs manager for the FollowCamera.
  49389. * It groups all the default supported inputs for ease of use.
  49390. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49391. */
  49392. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49393. /**
  49394. * Instantiates a new FollowCameraInputsManager.
  49395. * @param camera Defines the camera the inputs belong to
  49396. */
  49397. constructor(camera: FollowCamera);
  49398. /**
  49399. * Add keyboard input support to the input manager.
  49400. * @returns the current input manager
  49401. */
  49402. addKeyboard(): FollowCameraInputsManager;
  49403. /**
  49404. * Add mouse wheel input support to the input manager.
  49405. * @returns the current input manager
  49406. */
  49407. addMouseWheel(): FollowCameraInputsManager;
  49408. /**
  49409. * Add pointers input support to the input manager.
  49410. * @returns the current input manager
  49411. */
  49412. addPointers(): FollowCameraInputsManager;
  49413. /**
  49414. * Add orientation input support to the input manager.
  49415. * @returns the current input manager
  49416. */
  49417. addVRDeviceOrientation(): FollowCameraInputsManager;
  49418. }
  49419. }
  49420. declare module "babylonjs/Cameras/followCamera" {
  49421. import { Nullable } from "babylonjs/types";
  49422. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49423. import { Scene } from "babylonjs/scene";
  49424. import { Vector3 } from "babylonjs/Maths/math.vector";
  49425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49426. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49427. /**
  49428. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49429. * an arc rotate version arcFollowCamera are available.
  49430. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49431. */
  49432. export class FollowCamera extends TargetCamera {
  49433. /**
  49434. * Distance the follow camera should follow an object at
  49435. */
  49436. radius: number;
  49437. /**
  49438. * Minimum allowed distance of the camera to the axis of rotation
  49439. * (The camera can not get closer).
  49440. * This can help limiting how the Camera is able to move in the scene.
  49441. */
  49442. lowerRadiusLimit: Nullable<number>;
  49443. /**
  49444. * Maximum allowed distance of the camera to the axis of rotation
  49445. * (The camera can not get further).
  49446. * This can help limiting how the Camera is able to move in the scene.
  49447. */
  49448. upperRadiusLimit: Nullable<number>;
  49449. /**
  49450. * Define a rotation offset between the camera and the object it follows
  49451. */
  49452. rotationOffset: number;
  49453. /**
  49454. * Minimum allowed angle to camera position relative to target object.
  49455. * This can help limiting how the Camera is able to move in the scene.
  49456. */
  49457. lowerRotationOffsetLimit: Nullable<number>;
  49458. /**
  49459. * Maximum allowed angle to camera position relative to target object.
  49460. * This can help limiting how the Camera is able to move in the scene.
  49461. */
  49462. upperRotationOffsetLimit: Nullable<number>;
  49463. /**
  49464. * Define a height offset between the camera and the object it follows.
  49465. * It can help following an object from the top (like a car chaing a plane)
  49466. */
  49467. heightOffset: number;
  49468. /**
  49469. * Minimum allowed height of camera position relative to target object.
  49470. * This can help limiting how the Camera is able to move in the scene.
  49471. */
  49472. lowerHeightOffsetLimit: Nullable<number>;
  49473. /**
  49474. * Maximum allowed height of camera position relative to target object.
  49475. * This can help limiting how the Camera is able to move in the scene.
  49476. */
  49477. upperHeightOffsetLimit: Nullable<number>;
  49478. /**
  49479. * Define how fast the camera can accelerate to follow it s target.
  49480. */
  49481. cameraAcceleration: number;
  49482. /**
  49483. * Define the speed limit of the camera following an object.
  49484. */
  49485. maxCameraSpeed: number;
  49486. /**
  49487. * Define the target of the camera.
  49488. */
  49489. lockedTarget: Nullable<AbstractMesh>;
  49490. /**
  49491. * Defines the input associated with the camera.
  49492. */
  49493. inputs: FollowCameraInputsManager;
  49494. /**
  49495. * Instantiates the follow camera.
  49496. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49497. * @param name Define the name of the camera in the scene
  49498. * @param position Define the position of the camera
  49499. * @param scene Define the scene the camera belong to
  49500. * @param lockedTarget Define the target of the camera
  49501. */
  49502. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49503. private _follow;
  49504. /**
  49505. * Attached controls to the current camera.
  49506. * @param element Defines the element the controls should be listened from
  49507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49508. */
  49509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49510. /**
  49511. * Detach the current controls from the camera.
  49512. * The camera will stop reacting to inputs.
  49513. * @param element Defines the element to stop listening the inputs from
  49514. */
  49515. detachControl(element: HTMLElement): void;
  49516. /** @hidden */
  49517. _checkInputs(): void;
  49518. private _checkLimits;
  49519. /**
  49520. * Gets the camera class name.
  49521. * @returns the class name
  49522. */
  49523. getClassName(): string;
  49524. }
  49525. /**
  49526. * Arc Rotate version of the follow camera.
  49527. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49528. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49529. */
  49530. export class ArcFollowCamera extends TargetCamera {
  49531. /** The longitudinal angle of the camera */
  49532. alpha: number;
  49533. /** The latitudinal angle of the camera */
  49534. beta: number;
  49535. /** The radius of the camera from its target */
  49536. radius: number;
  49537. private _cartesianCoordinates;
  49538. /** Define the camera target (the mesh it should follow) */
  49539. private _meshTarget;
  49540. /**
  49541. * Instantiates a new ArcFollowCamera
  49542. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49543. * @param name Define the name of the camera
  49544. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49545. * @param beta Define the rotation angle of the camera around the elevation axis
  49546. * @param radius Define the radius of the camera from its target point
  49547. * @param target Define the target of the camera
  49548. * @param scene Define the scene the camera belongs to
  49549. */
  49550. constructor(name: string,
  49551. /** The longitudinal angle of the camera */
  49552. alpha: number,
  49553. /** The latitudinal angle of the camera */
  49554. beta: number,
  49555. /** The radius of the camera from its target */
  49556. radius: number,
  49557. /** Define the camera target (the mesh it should follow) */
  49558. target: Nullable<AbstractMesh>, scene: Scene);
  49559. private _follow;
  49560. /** @hidden */
  49561. _checkInputs(): void;
  49562. /**
  49563. * Returns the class name of the object.
  49564. * It is mostly used internally for serialization purposes.
  49565. */
  49566. getClassName(): string;
  49567. }
  49568. }
  49569. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49570. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49571. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49572. import { Nullable } from "babylonjs/types";
  49573. /**
  49574. * Manage the keyboard inputs to control the movement of a follow camera.
  49575. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49576. */
  49577. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49578. /**
  49579. * Defines the camera the input is attached to.
  49580. */
  49581. camera: FollowCamera;
  49582. /**
  49583. * Defines the list of key codes associated with the up action (increase heightOffset)
  49584. */
  49585. keysHeightOffsetIncr: number[];
  49586. /**
  49587. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49588. */
  49589. keysHeightOffsetDecr: number[];
  49590. /**
  49591. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49592. */
  49593. keysHeightOffsetModifierAlt: boolean;
  49594. /**
  49595. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49596. */
  49597. keysHeightOffsetModifierCtrl: boolean;
  49598. /**
  49599. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49600. */
  49601. keysHeightOffsetModifierShift: boolean;
  49602. /**
  49603. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49604. */
  49605. keysRotationOffsetIncr: number[];
  49606. /**
  49607. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49608. */
  49609. keysRotationOffsetDecr: number[];
  49610. /**
  49611. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49612. */
  49613. keysRotationOffsetModifierAlt: boolean;
  49614. /**
  49615. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49616. */
  49617. keysRotationOffsetModifierCtrl: boolean;
  49618. /**
  49619. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49620. */
  49621. keysRotationOffsetModifierShift: boolean;
  49622. /**
  49623. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49624. */
  49625. keysRadiusIncr: number[];
  49626. /**
  49627. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49628. */
  49629. keysRadiusDecr: number[];
  49630. /**
  49631. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49632. */
  49633. keysRadiusModifierAlt: boolean;
  49634. /**
  49635. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  49636. */
  49637. keysRadiusModifierCtrl: boolean;
  49638. /**
  49639. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  49640. */
  49641. keysRadiusModifierShift: boolean;
  49642. /**
  49643. * Defines the rate of change of heightOffset.
  49644. */
  49645. heightSensibility: number;
  49646. /**
  49647. * Defines the rate of change of rotationOffset.
  49648. */
  49649. rotationSensibility: number;
  49650. /**
  49651. * Defines the rate of change of radius.
  49652. */
  49653. radiusSensibility: number;
  49654. private _keys;
  49655. private _ctrlPressed;
  49656. private _altPressed;
  49657. private _shiftPressed;
  49658. private _onCanvasBlurObserver;
  49659. private _onKeyboardObserver;
  49660. private _engine;
  49661. private _scene;
  49662. /**
  49663. * Attach the input controls to a specific dom element to get the input from.
  49664. * @param element Defines the element the controls should be listened from
  49665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49666. */
  49667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49668. /**
  49669. * Detach the current controls from the specified dom element.
  49670. * @param element Defines the element to stop listening the inputs from
  49671. */
  49672. detachControl(element: Nullable<HTMLElement>): void;
  49673. /**
  49674. * Update the current camera state depending on the inputs that have been used this frame.
  49675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49676. */
  49677. checkInputs(): void;
  49678. /**
  49679. * Gets the class name of the current input.
  49680. * @returns the class name
  49681. */
  49682. getClassName(): string;
  49683. /**
  49684. * Get the friendly name associated with the input class.
  49685. * @returns the input friendly name
  49686. */
  49687. getSimpleName(): string;
  49688. /**
  49689. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49690. * allow modification of the heightOffset value.
  49691. */
  49692. private _modifierHeightOffset;
  49693. /**
  49694. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49695. * allow modification of the rotationOffset value.
  49696. */
  49697. private _modifierRotationOffset;
  49698. /**
  49699. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49700. * allow modification of the radius value.
  49701. */
  49702. private _modifierRadius;
  49703. }
  49704. }
  49705. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  49706. import { Nullable } from "babylonjs/types";
  49707. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49708. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49709. import { Observable } from "babylonjs/Misc/observable";
  49710. module "babylonjs/Cameras/freeCameraInputsManager" {
  49711. interface FreeCameraInputsManager {
  49712. /**
  49713. * @hidden
  49714. */
  49715. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  49716. /**
  49717. * Add orientation input support to the input manager.
  49718. * @returns the current input manager
  49719. */
  49720. addDeviceOrientation(): FreeCameraInputsManager;
  49721. }
  49722. }
  49723. /**
  49724. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  49725. * Screen rotation is taken into account.
  49726. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49727. */
  49728. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  49729. private _camera;
  49730. private _screenOrientationAngle;
  49731. private _constantTranform;
  49732. private _screenQuaternion;
  49733. private _alpha;
  49734. private _beta;
  49735. private _gamma;
  49736. /**
  49737. * Can be used to detect if a device orientation sensor is available on a device
  49738. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  49739. * @returns a promise that will resolve on orientation change
  49740. */
  49741. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  49742. /**
  49743. * @hidden
  49744. */
  49745. _onDeviceOrientationChangedObservable: Observable<void>;
  49746. /**
  49747. * Instantiates a new input
  49748. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49749. */
  49750. constructor();
  49751. /**
  49752. * Define the camera controlled by the input.
  49753. */
  49754. get camera(): FreeCamera;
  49755. set camera(camera: FreeCamera);
  49756. /**
  49757. * Attach the input controls to a specific dom element to get the input from.
  49758. * @param element Defines the element the controls should be listened from
  49759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49760. */
  49761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49762. private _orientationChanged;
  49763. private _deviceOrientation;
  49764. /**
  49765. * Detach the current controls from the specified dom element.
  49766. * @param element Defines the element to stop listening the inputs from
  49767. */
  49768. detachControl(element: Nullable<HTMLElement>): void;
  49769. /**
  49770. * Update the current camera state depending on the inputs that have been used this frame.
  49771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49772. */
  49773. checkInputs(): void;
  49774. /**
  49775. * Gets the class name of the current intput.
  49776. * @returns the class name
  49777. */
  49778. getClassName(): string;
  49779. /**
  49780. * Get the friendly name associated with the input class.
  49781. * @returns the input friendly name
  49782. */
  49783. getSimpleName(): string;
  49784. }
  49785. }
  49786. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  49787. import { Nullable } from "babylonjs/types";
  49788. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49789. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49790. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49791. /**
  49792. * Manage the gamepad inputs to control a free camera.
  49793. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49794. */
  49795. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  49796. /**
  49797. * Define the camera the input is attached to.
  49798. */
  49799. camera: FreeCamera;
  49800. /**
  49801. * Define the Gamepad controlling the input
  49802. */
  49803. gamepad: Nullable<Gamepad>;
  49804. /**
  49805. * Defines the gamepad rotation sensiblity.
  49806. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49807. */
  49808. gamepadAngularSensibility: number;
  49809. /**
  49810. * Defines the gamepad move sensiblity.
  49811. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49812. */
  49813. gamepadMoveSensibility: number;
  49814. private _yAxisScale;
  49815. /**
  49816. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49817. */
  49818. get invertYAxis(): boolean;
  49819. set invertYAxis(value: boolean);
  49820. private _onGamepadConnectedObserver;
  49821. private _onGamepadDisconnectedObserver;
  49822. private _cameraTransform;
  49823. private _deltaTransform;
  49824. private _vector3;
  49825. private _vector2;
  49826. /**
  49827. * Attach the input controls to a specific dom element to get the input from.
  49828. * @param element Defines the element the controls should be listened from
  49829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49830. */
  49831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49832. /**
  49833. * Detach the current controls from the specified dom element.
  49834. * @param element Defines the element to stop listening the inputs from
  49835. */
  49836. detachControl(element: Nullable<HTMLElement>): void;
  49837. /**
  49838. * Update the current camera state depending on the inputs that have been used this frame.
  49839. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49840. */
  49841. checkInputs(): void;
  49842. /**
  49843. * Gets the class name of the current intput.
  49844. * @returns the class name
  49845. */
  49846. getClassName(): string;
  49847. /**
  49848. * Get the friendly name associated with the input class.
  49849. * @returns the input friendly name
  49850. */
  49851. getSimpleName(): string;
  49852. }
  49853. }
  49854. declare module "babylonjs/Misc/virtualJoystick" {
  49855. import { Nullable } from "babylonjs/types";
  49856. import { Vector3 } from "babylonjs/Maths/math.vector";
  49857. /**
  49858. * Defines the potential axis of a Joystick
  49859. */
  49860. export enum JoystickAxis {
  49861. /** X axis */
  49862. X = 0,
  49863. /** Y axis */
  49864. Y = 1,
  49865. /** Z axis */
  49866. Z = 2
  49867. }
  49868. /**
  49869. * Represents the different customization options available
  49870. * for VirtualJoystick
  49871. */
  49872. interface VirtualJoystickCustomizations {
  49873. /**
  49874. * Size of the joystick's puck
  49875. */
  49876. puckSize: number;
  49877. /**
  49878. * Size of the joystick's container
  49879. */
  49880. containerSize: number;
  49881. /**
  49882. * Color of the joystick && puck
  49883. */
  49884. color: string;
  49885. /**
  49886. * Image URL for the joystick's puck
  49887. */
  49888. puckImage?: string;
  49889. /**
  49890. * Image URL for the joystick's container
  49891. */
  49892. containerImage?: string;
  49893. /**
  49894. * Defines the unmoving position of the joystick container
  49895. */
  49896. position?: {
  49897. x: number;
  49898. y: number;
  49899. };
  49900. /**
  49901. * Defines whether or not the joystick container is always visible
  49902. */
  49903. alwaysVisible: boolean;
  49904. /**
  49905. * Defines whether or not to limit the movement of the puck to the joystick's container
  49906. */
  49907. limitToContainer: boolean;
  49908. }
  49909. /**
  49910. * Class used to define virtual joystick (used in touch mode)
  49911. */
  49912. export class VirtualJoystick {
  49913. /**
  49914. * Gets or sets a boolean indicating that left and right values must be inverted
  49915. */
  49916. reverseLeftRight: boolean;
  49917. /**
  49918. * Gets or sets a boolean indicating that up and down values must be inverted
  49919. */
  49920. reverseUpDown: boolean;
  49921. /**
  49922. * Gets the offset value for the position (ie. the change of the position value)
  49923. */
  49924. deltaPosition: Vector3;
  49925. /**
  49926. * Gets a boolean indicating if the virtual joystick was pressed
  49927. */
  49928. pressed: boolean;
  49929. /**
  49930. * Canvas the virtual joystick will render onto, default z-index of this is 5
  49931. */
  49932. static Canvas: Nullable<HTMLCanvasElement>;
  49933. /**
  49934. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  49935. */
  49936. limitToContainer: boolean;
  49937. private static _globalJoystickIndex;
  49938. private static _alwaysVisibleSticks;
  49939. private static vjCanvasContext;
  49940. private static vjCanvasWidth;
  49941. private static vjCanvasHeight;
  49942. private static halfWidth;
  49943. private static _GetDefaultOptions;
  49944. private _action;
  49945. private _axisTargetedByLeftAndRight;
  49946. private _axisTargetedByUpAndDown;
  49947. private _joystickSensibility;
  49948. private _inversedSensibility;
  49949. private _joystickPointerID;
  49950. private _joystickColor;
  49951. private _joystickPointerPos;
  49952. private _joystickPreviousPointerPos;
  49953. private _joystickPointerStartPos;
  49954. private _deltaJoystickVector;
  49955. private _leftJoystick;
  49956. private _touches;
  49957. private _joystickPosition;
  49958. private _alwaysVisible;
  49959. private _puckImage;
  49960. private _containerImage;
  49961. private _joystickPuckSize;
  49962. private _joystickContainerSize;
  49963. private _clearPuckSize;
  49964. private _clearContainerSize;
  49965. private _clearPuckSizeOffset;
  49966. private _clearContainerSizeOffset;
  49967. private _onPointerDownHandlerRef;
  49968. private _onPointerMoveHandlerRef;
  49969. private _onPointerUpHandlerRef;
  49970. private _onResize;
  49971. /**
  49972. * Creates a new virtual joystick
  49973. * @param leftJoystick defines that the joystick is for left hand (false by default)
  49974. * @param customizations Defines the options we want to customize the VirtualJoystick
  49975. */
  49976. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  49977. /**
  49978. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  49979. * @param newJoystickSensibility defines the new sensibility
  49980. */
  49981. setJoystickSensibility(newJoystickSensibility: number): void;
  49982. private _onPointerDown;
  49983. private _onPointerMove;
  49984. private _onPointerUp;
  49985. /**
  49986. * Change the color of the virtual joystick
  49987. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  49988. */
  49989. setJoystickColor(newColor: string): void;
  49990. /**
  49991. * Size of the joystick's container
  49992. */
  49993. set containerSize(newSize: number);
  49994. get containerSize(): number;
  49995. /**
  49996. * Size of the joystick's puck
  49997. */
  49998. set puckSize(newSize: number);
  49999. get puckSize(): number;
  50000. /**
  50001. * Clears the set position of the joystick
  50002. */
  50003. clearPosition(): void;
  50004. /**
  50005. * Defines whether or not the joystick container is always visible
  50006. */
  50007. set alwaysVisible(value: boolean);
  50008. get alwaysVisible(): boolean;
  50009. /**
  50010. * Sets the constant position of the Joystick container
  50011. * @param x X axis coordinate
  50012. * @param y Y axis coordinate
  50013. */
  50014. setPosition(x: number, y: number): void;
  50015. /**
  50016. * Defines a callback to call when the joystick is touched
  50017. * @param action defines the callback
  50018. */
  50019. setActionOnTouch(action: () => any): void;
  50020. /**
  50021. * Defines which axis you'd like to control for left & right
  50022. * @param axis defines the axis to use
  50023. */
  50024. setAxisForLeftRight(axis: JoystickAxis): void;
  50025. /**
  50026. * Defines which axis you'd like to control for up & down
  50027. * @param axis defines the axis to use
  50028. */
  50029. setAxisForUpDown(axis: JoystickAxis): void;
  50030. /**
  50031. * Clears the canvas from the previous puck / container draw
  50032. */
  50033. private _clearPreviousDraw;
  50034. /**
  50035. * Loads `urlPath` to be used for the container's image
  50036. * @param urlPath defines the urlPath of an image to use
  50037. */
  50038. setContainerImage(urlPath: string): void;
  50039. /**
  50040. * Loads `urlPath` to be used for the puck's image
  50041. * @param urlPath defines the urlPath of an image to use
  50042. */
  50043. setPuckImage(urlPath: string): void;
  50044. /**
  50045. * Draws the Virtual Joystick's container
  50046. */
  50047. private _drawContainer;
  50048. /**
  50049. * Draws the Virtual Joystick's puck
  50050. */
  50051. private _drawPuck;
  50052. private _drawVirtualJoystick;
  50053. /**
  50054. * Release internal HTML canvas
  50055. */
  50056. releaseCanvas(): void;
  50057. }
  50058. }
  50059. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50060. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50061. import { Nullable } from "babylonjs/types";
  50062. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50063. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50064. module "babylonjs/Cameras/freeCameraInputsManager" {
  50065. interface FreeCameraInputsManager {
  50066. /**
  50067. * Add virtual joystick input support to the input manager.
  50068. * @returns the current input manager
  50069. */
  50070. addVirtualJoystick(): FreeCameraInputsManager;
  50071. }
  50072. }
  50073. /**
  50074. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50075. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50076. */
  50077. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50078. /**
  50079. * Defines the camera the input is attached to.
  50080. */
  50081. camera: FreeCamera;
  50082. private _leftjoystick;
  50083. private _rightjoystick;
  50084. /**
  50085. * Gets the left stick of the virtual joystick.
  50086. * @returns The virtual Joystick
  50087. */
  50088. getLeftJoystick(): VirtualJoystick;
  50089. /**
  50090. * Gets the right stick of the virtual joystick.
  50091. * @returns The virtual Joystick
  50092. */
  50093. getRightJoystick(): VirtualJoystick;
  50094. /**
  50095. * Update the current camera state depending on the inputs that have been used this frame.
  50096. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50097. */
  50098. checkInputs(): void;
  50099. /**
  50100. * Attach the input controls to a specific dom element to get the input from.
  50101. * @param element Defines the element the controls should be listened from
  50102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50103. */
  50104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50105. /**
  50106. * Detach the current controls from the specified dom element.
  50107. * @param element Defines the element to stop listening the inputs from
  50108. */
  50109. detachControl(element: Nullable<HTMLElement>): void;
  50110. /**
  50111. * Gets the class name of the current intput.
  50112. * @returns the class name
  50113. */
  50114. getClassName(): string;
  50115. /**
  50116. * Get the friendly name associated with the input class.
  50117. * @returns the input friendly name
  50118. */
  50119. getSimpleName(): string;
  50120. }
  50121. }
  50122. declare module "babylonjs/Cameras/Inputs/index" {
  50123. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50124. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50125. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50126. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50127. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50128. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50129. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50130. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50131. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50132. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50133. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50134. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50135. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50136. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50137. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50138. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50139. }
  50140. declare module "babylonjs/Cameras/touchCamera" {
  50141. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50142. import { Scene } from "babylonjs/scene";
  50143. import { Vector3 } from "babylonjs/Maths/math.vector";
  50144. /**
  50145. * This represents a FPS type of camera controlled by touch.
  50146. * This is like a universal camera minus the Gamepad controls.
  50147. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50148. */
  50149. export class TouchCamera extends FreeCamera {
  50150. /**
  50151. * Defines the touch sensibility for rotation.
  50152. * The higher the faster.
  50153. */
  50154. get touchAngularSensibility(): number;
  50155. set touchAngularSensibility(value: number);
  50156. /**
  50157. * Defines the touch sensibility for move.
  50158. * The higher the faster.
  50159. */
  50160. get touchMoveSensibility(): number;
  50161. set touchMoveSensibility(value: number);
  50162. /**
  50163. * Instantiates a new touch camera.
  50164. * This represents a FPS type of camera controlled by touch.
  50165. * This is like a universal camera minus the Gamepad controls.
  50166. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50167. * @param name Define the name of the camera in the scene
  50168. * @param position Define the start position of the camera in the scene
  50169. * @param scene Define the scene the camera belongs to
  50170. */
  50171. constructor(name: string, position: Vector3, scene: Scene);
  50172. /**
  50173. * Gets the current object class name.
  50174. * @return the class name
  50175. */
  50176. getClassName(): string;
  50177. /** @hidden */
  50178. _setupInputs(): void;
  50179. }
  50180. }
  50181. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50182. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50183. import { Scene } from "babylonjs/scene";
  50184. import { Vector3 } from "babylonjs/Maths/math.vector";
  50185. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50186. import { Axis } from "babylonjs/Maths/math.axis";
  50187. /**
  50188. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50189. * being tilted forward or back and left or right.
  50190. */
  50191. export class DeviceOrientationCamera extends FreeCamera {
  50192. private _initialQuaternion;
  50193. private _quaternionCache;
  50194. private _tmpDragQuaternion;
  50195. private _disablePointerInputWhenUsingDeviceOrientation;
  50196. /**
  50197. * Creates a new device orientation camera
  50198. * @param name The name of the camera
  50199. * @param position The start position camera
  50200. * @param scene The scene the camera belongs to
  50201. */
  50202. constructor(name: string, position: Vector3, scene: Scene);
  50203. /**
  50204. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50205. */
  50206. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50207. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50208. private _dragFactor;
  50209. /**
  50210. * Enabled turning on the y axis when the orientation sensor is active
  50211. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50212. */
  50213. enableHorizontalDragging(dragFactor?: number): void;
  50214. /**
  50215. * Gets the current instance class name ("DeviceOrientationCamera").
  50216. * This helps avoiding instanceof at run time.
  50217. * @returns the class name
  50218. */
  50219. getClassName(): string;
  50220. /**
  50221. * @hidden
  50222. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50223. */
  50224. _checkInputs(): void;
  50225. /**
  50226. * Reset the camera to its default orientation on the specified axis only.
  50227. * @param axis The axis to reset
  50228. */
  50229. resetToCurrentRotation(axis?: Axis): void;
  50230. }
  50231. }
  50232. declare module "babylonjs/Gamepads/xboxGamepad" {
  50233. import { Observable } from "babylonjs/Misc/observable";
  50234. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50235. /**
  50236. * Defines supported buttons for XBox360 compatible gamepads
  50237. */
  50238. export enum Xbox360Button {
  50239. /** A */
  50240. A = 0,
  50241. /** B */
  50242. B = 1,
  50243. /** X */
  50244. X = 2,
  50245. /** Y */
  50246. Y = 3,
  50247. /** Left button */
  50248. LB = 4,
  50249. /** Right button */
  50250. RB = 5,
  50251. /** Back */
  50252. Back = 8,
  50253. /** Start */
  50254. Start = 9,
  50255. /** Left stick */
  50256. LeftStick = 10,
  50257. /** Right stick */
  50258. RightStick = 11
  50259. }
  50260. /** Defines values for XBox360 DPad */
  50261. export enum Xbox360Dpad {
  50262. /** Up */
  50263. Up = 12,
  50264. /** Down */
  50265. Down = 13,
  50266. /** Left */
  50267. Left = 14,
  50268. /** Right */
  50269. Right = 15
  50270. }
  50271. /**
  50272. * Defines a XBox360 gamepad
  50273. */
  50274. export class Xbox360Pad extends Gamepad {
  50275. private _leftTrigger;
  50276. private _rightTrigger;
  50277. private _onlefttriggerchanged;
  50278. private _onrighttriggerchanged;
  50279. private _onbuttondown;
  50280. private _onbuttonup;
  50281. private _ondpaddown;
  50282. private _ondpadup;
  50283. /** Observable raised when a button is pressed */
  50284. onButtonDownObservable: Observable<Xbox360Button>;
  50285. /** Observable raised when a button is released */
  50286. onButtonUpObservable: Observable<Xbox360Button>;
  50287. /** Observable raised when a pad is pressed */
  50288. onPadDownObservable: Observable<Xbox360Dpad>;
  50289. /** Observable raised when a pad is released */
  50290. onPadUpObservable: Observable<Xbox360Dpad>;
  50291. private _buttonA;
  50292. private _buttonB;
  50293. private _buttonX;
  50294. private _buttonY;
  50295. private _buttonBack;
  50296. private _buttonStart;
  50297. private _buttonLB;
  50298. private _buttonRB;
  50299. private _buttonLeftStick;
  50300. private _buttonRightStick;
  50301. private _dPadUp;
  50302. private _dPadDown;
  50303. private _dPadLeft;
  50304. private _dPadRight;
  50305. private _isXboxOnePad;
  50306. /**
  50307. * Creates a new XBox360 gamepad object
  50308. * @param id defines the id of this gamepad
  50309. * @param index defines its index
  50310. * @param gamepad defines the internal HTML gamepad object
  50311. * @param xboxOne defines if it is a XBox One gamepad
  50312. */
  50313. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50314. /**
  50315. * Defines the callback to call when left trigger is pressed
  50316. * @param callback defines the callback to use
  50317. */
  50318. onlefttriggerchanged(callback: (value: number) => void): void;
  50319. /**
  50320. * Defines the callback to call when right trigger is pressed
  50321. * @param callback defines the callback to use
  50322. */
  50323. onrighttriggerchanged(callback: (value: number) => void): void;
  50324. /**
  50325. * Gets the left trigger value
  50326. */
  50327. get leftTrigger(): number;
  50328. /**
  50329. * Sets the left trigger value
  50330. */
  50331. set leftTrigger(newValue: number);
  50332. /**
  50333. * Gets the right trigger value
  50334. */
  50335. get rightTrigger(): number;
  50336. /**
  50337. * Sets the right trigger value
  50338. */
  50339. set rightTrigger(newValue: number);
  50340. /**
  50341. * Defines the callback to call when a button is pressed
  50342. * @param callback defines the callback to use
  50343. */
  50344. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50345. /**
  50346. * Defines the callback to call when a button is released
  50347. * @param callback defines the callback to use
  50348. */
  50349. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50350. /**
  50351. * Defines the callback to call when a pad is pressed
  50352. * @param callback defines the callback to use
  50353. */
  50354. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50355. /**
  50356. * Defines the callback to call when a pad is released
  50357. * @param callback defines the callback to use
  50358. */
  50359. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50360. private _setButtonValue;
  50361. private _setDPadValue;
  50362. /**
  50363. * Gets the value of the `A` button
  50364. */
  50365. get buttonA(): number;
  50366. /**
  50367. * Sets the value of the `A` button
  50368. */
  50369. set buttonA(value: number);
  50370. /**
  50371. * Gets the value of the `B` button
  50372. */
  50373. get buttonB(): number;
  50374. /**
  50375. * Sets the value of the `B` button
  50376. */
  50377. set buttonB(value: number);
  50378. /**
  50379. * Gets the value of the `X` button
  50380. */
  50381. get buttonX(): number;
  50382. /**
  50383. * Sets the value of the `X` button
  50384. */
  50385. set buttonX(value: number);
  50386. /**
  50387. * Gets the value of the `Y` button
  50388. */
  50389. get buttonY(): number;
  50390. /**
  50391. * Sets the value of the `Y` button
  50392. */
  50393. set buttonY(value: number);
  50394. /**
  50395. * Gets the value of the `Start` button
  50396. */
  50397. get buttonStart(): number;
  50398. /**
  50399. * Sets the value of the `Start` button
  50400. */
  50401. set buttonStart(value: number);
  50402. /**
  50403. * Gets the value of the `Back` button
  50404. */
  50405. get buttonBack(): number;
  50406. /**
  50407. * Sets the value of the `Back` button
  50408. */
  50409. set buttonBack(value: number);
  50410. /**
  50411. * Gets the value of the `Left` button
  50412. */
  50413. get buttonLB(): number;
  50414. /**
  50415. * Sets the value of the `Left` button
  50416. */
  50417. set buttonLB(value: number);
  50418. /**
  50419. * Gets the value of the `Right` button
  50420. */
  50421. get buttonRB(): number;
  50422. /**
  50423. * Sets the value of the `Right` button
  50424. */
  50425. set buttonRB(value: number);
  50426. /**
  50427. * Gets the value of the Left joystick
  50428. */
  50429. get buttonLeftStick(): number;
  50430. /**
  50431. * Sets the value of the Left joystick
  50432. */
  50433. set buttonLeftStick(value: number);
  50434. /**
  50435. * Gets the value of the Right joystick
  50436. */
  50437. get buttonRightStick(): number;
  50438. /**
  50439. * Sets the value of the Right joystick
  50440. */
  50441. set buttonRightStick(value: number);
  50442. /**
  50443. * Gets the value of D-pad up
  50444. */
  50445. get dPadUp(): number;
  50446. /**
  50447. * Sets the value of D-pad up
  50448. */
  50449. set dPadUp(value: number);
  50450. /**
  50451. * Gets the value of D-pad down
  50452. */
  50453. get dPadDown(): number;
  50454. /**
  50455. * Sets the value of D-pad down
  50456. */
  50457. set dPadDown(value: number);
  50458. /**
  50459. * Gets the value of D-pad left
  50460. */
  50461. get dPadLeft(): number;
  50462. /**
  50463. * Sets the value of D-pad left
  50464. */
  50465. set dPadLeft(value: number);
  50466. /**
  50467. * Gets the value of D-pad right
  50468. */
  50469. get dPadRight(): number;
  50470. /**
  50471. * Sets the value of D-pad right
  50472. */
  50473. set dPadRight(value: number);
  50474. /**
  50475. * Force the gamepad to synchronize with device values
  50476. */
  50477. update(): void;
  50478. /**
  50479. * Disposes the gamepad
  50480. */
  50481. dispose(): void;
  50482. }
  50483. }
  50484. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50485. import { Observable } from "babylonjs/Misc/observable";
  50486. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50487. /**
  50488. * Defines supported buttons for DualShock compatible gamepads
  50489. */
  50490. export enum DualShockButton {
  50491. /** Cross */
  50492. Cross = 0,
  50493. /** Circle */
  50494. Circle = 1,
  50495. /** Square */
  50496. Square = 2,
  50497. /** Triangle */
  50498. Triangle = 3,
  50499. /** L1 */
  50500. L1 = 4,
  50501. /** R1 */
  50502. R1 = 5,
  50503. /** Share */
  50504. Share = 8,
  50505. /** Options */
  50506. Options = 9,
  50507. /** Left stick */
  50508. LeftStick = 10,
  50509. /** Right stick */
  50510. RightStick = 11
  50511. }
  50512. /** Defines values for DualShock DPad */
  50513. export enum DualShockDpad {
  50514. /** Up */
  50515. Up = 12,
  50516. /** Down */
  50517. Down = 13,
  50518. /** Left */
  50519. Left = 14,
  50520. /** Right */
  50521. Right = 15
  50522. }
  50523. /**
  50524. * Defines a DualShock gamepad
  50525. */
  50526. export class DualShockPad extends Gamepad {
  50527. private _leftTrigger;
  50528. private _rightTrigger;
  50529. private _onlefttriggerchanged;
  50530. private _onrighttriggerchanged;
  50531. private _onbuttondown;
  50532. private _onbuttonup;
  50533. private _ondpaddown;
  50534. private _ondpadup;
  50535. /** Observable raised when a button is pressed */
  50536. onButtonDownObservable: Observable<DualShockButton>;
  50537. /** Observable raised when a button is released */
  50538. onButtonUpObservable: Observable<DualShockButton>;
  50539. /** Observable raised when a pad is pressed */
  50540. onPadDownObservable: Observable<DualShockDpad>;
  50541. /** Observable raised when a pad is released */
  50542. onPadUpObservable: Observable<DualShockDpad>;
  50543. private _buttonCross;
  50544. private _buttonCircle;
  50545. private _buttonSquare;
  50546. private _buttonTriangle;
  50547. private _buttonShare;
  50548. private _buttonOptions;
  50549. private _buttonL1;
  50550. private _buttonR1;
  50551. private _buttonLeftStick;
  50552. private _buttonRightStick;
  50553. private _dPadUp;
  50554. private _dPadDown;
  50555. private _dPadLeft;
  50556. private _dPadRight;
  50557. /**
  50558. * Creates a new DualShock gamepad object
  50559. * @param id defines the id of this gamepad
  50560. * @param index defines its index
  50561. * @param gamepad defines the internal HTML gamepad object
  50562. */
  50563. constructor(id: string, index: number, gamepad: any);
  50564. /**
  50565. * Defines the callback to call when left trigger is pressed
  50566. * @param callback defines the callback to use
  50567. */
  50568. onlefttriggerchanged(callback: (value: number) => void): void;
  50569. /**
  50570. * Defines the callback to call when right trigger is pressed
  50571. * @param callback defines the callback to use
  50572. */
  50573. onrighttriggerchanged(callback: (value: number) => void): void;
  50574. /**
  50575. * Gets the left trigger value
  50576. */
  50577. get leftTrigger(): number;
  50578. /**
  50579. * Sets the left trigger value
  50580. */
  50581. set leftTrigger(newValue: number);
  50582. /**
  50583. * Gets the right trigger value
  50584. */
  50585. get rightTrigger(): number;
  50586. /**
  50587. * Sets the right trigger value
  50588. */
  50589. set rightTrigger(newValue: number);
  50590. /**
  50591. * Defines the callback to call when a button is pressed
  50592. * @param callback defines the callback to use
  50593. */
  50594. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50595. /**
  50596. * Defines the callback to call when a button is released
  50597. * @param callback defines the callback to use
  50598. */
  50599. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50600. /**
  50601. * Defines the callback to call when a pad is pressed
  50602. * @param callback defines the callback to use
  50603. */
  50604. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50605. /**
  50606. * Defines the callback to call when a pad is released
  50607. * @param callback defines the callback to use
  50608. */
  50609. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50610. private _setButtonValue;
  50611. private _setDPadValue;
  50612. /**
  50613. * Gets the value of the `Cross` button
  50614. */
  50615. get buttonCross(): number;
  50616. /**
  50617. * Sets the value of the `Cross` button
  50618. */
  50619. set buttonCross(value: number);
  50620. /**
  50621. * Gets the value of the `Circle` button
  50622. */
  50623. get buttonCircle(): number;
  50624. /**
  50625. * Sets the value of the `Circle` button
  50626. */
  50627. set buttonCircle(value: number);
  50628. /**
  50629. * Gets the value of the `Square` button
  50630. */
  50631. get buttonSquare(): number;
  50632. /**
  50633. * Sets the value of the `Square` button
  50634. */
  50635. set buttonSquare(value: number);
  50636. /**
  50637. * Gets the value of the `Triangle` button
  50638. */
  50639. get buttonTriangle(): number;
  50640. /**
  50641. * Sets the value of the `Triangle` button
  50642. */
  50643. set buttonTriangle(value: number);
  50644. /**
  50645. * Gets the value of the `Options` button
  50646. */
  50647. get buttonOptions(): number;
  50648. /**
  50649. * Sets the value of the `Options` button
  50650. */
  50651. set buttonOptions(value: number);
  50652. /**
  50653. * Gets the value of the `Share` button
  50654. */
  50655. get buttonShare(): number;
  50656. /**
  50657. * Sets the value of the `Share` button
  50658. */
  50659. set buttonShare(value: number);
  50660. /**
  50661. * Gets the value of the `L1` button
  50662. */
  50663. get buttonL1(): number;
  50664. /**
  50665. * Sets the value of the `L1` button
  50666. */
  50667. set buttonL1(value: number);
  50668. /**
  50669. * Gets the value of the `R1` button
  50670. */
  50671. get buttonR1(): number;
  50672. /**
  50673. * Sets the value of the `R1` button
  50674. */
  50675. set buttonR1(value: number);
  50676. /**
  50677. * Gets the value of the Left joystick
  50678. */
  50679. get buttonLeftStick(): number;
  50680. /**
  50681. * Sets the value of the Left joystick
  50682. */
  50683. set buttonLeftStick(value: number);
  50684. /**
  50685. * Gets the value of the Right joystick
  50686. */
  50687. get buttonRightStick(): number;
  50688. /**
  50689. * Sets the value of the Right joystick
  50690. */
  50691. set buttonRightStick(value: number);
  50692. /**
  50693. * Gets the value of D-pad up
  50694. */
  50695. get dPadUp(): number;
  50696. /**
  50697. * Sets the value of D-pad up
  50698. */
  50699. set dPadUp(value: number);
  50700. /**
  50701. * Gets the value of D-pad down
  50702. */
  50703. get dPadDown(): number;
  50704. /**
  50705. * Sets the value of D-pad down
  50706. */
  50707. set dPadDown(value: number);
  50708. /**
  50709. * Gets the value of D-pad left
  50710. */
  50711. get dPadLeft(): number;
  50712. /**
  50713. * Sets the value of D-pad left
  50714. */
  50715. set dPadLeft(value: number);
  50716. /**
  50717. * Gets the value of D-pad right
  50718. */
  50719. get dPadRight(): number;
  50720. /**
  50721. * Sets the value of D-pad right
  50722. */
  50723. set dPadRight(value: number);
  50724. /**
  50725. * Force the gamepad to synchronize with device values
  50726. */
  50727. update(): void;
  50728. /**
  50729. * Disposes the gamepad
  50730. */
  50731. dispose(): void;
  50732. }
  50733. }
  50734. declare module "babylonjs/Gamepads/gamepadManager" {
  50735. import { Observable } from "babylonjs/Misc/observable";
  50736. import { Nullable } from "babylonjs/types";
  50737. import { Scene } from "babylonjs/scene";
  50738. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50739. /**
  50740. * Manager for handling gamepads
  50741. */
  50742. export class GamepadManager {
  50743. private _scene?;
  50744. private _babylonGamepads;
  50745. private _oneGamepadConnected;
  50746. /** @hidden */
  50747. _isMonitoring: boolean;
  50748. private _gamepadEventSupported;
  50749. private _gamepadSupport?;
  50750. /**
  50751. * observable to be triggered when the gamepad controller has been connected
  50752. */
  50753. onGamepadConnectedObservable: Observable<Gamepad>;
  50754. /**
  50755. * observable to be triggered when the gamepad controller has been disconnected
  50756. */
  50757. onGamepadDisconnectedObservable: Observable<Gamepad>;
  50758. private _onGamepadConnectedEvent;
  50759. private _onGamepadDisconnectedEvent;
  50760. /**
  50761. * Initializes the gamepad manager
  50762. * @param _scene BabylonJS scene
  50763. */
  50764. constructor(_scene?: Scene | undefined);
  50765. /**
  50766. * The gamepads in the game pad manager
  50767. */
  50768. get gamepads(): Gamepad[];
  50769. /**
  50770. * Get the gamepad controllers based on type
  50771. * @param type The type of gamepad controller
  50772. * @returns Nullable gamepad
  50773. */
  50774. getGamepadByType(type?: number): Nullable<Gamepad>;
  50775. /**
  50776. * Disposes the gamepad manager
  50777. */
  50778. dispose(): void;
  50779. private _addNewGamepad;
  50780. private _startMonitoringGamepads;
  50781. private _stopMonitoringGamepads;
  50782. /** @hidden */
  50783. _checkGamepadsStatus(): void;
  50784. private _updateGamepadObjects;
  50785. }
  50786. }
  50787. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  50788. import { Nullable } from "babylonjs/types";
  50789. import { Scene } from "babylonjs/scene";
  50790. import { ISceneComponent } from "babylonjs/sceneComponent";
  50791. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  50792. module "babylonjs/scene" {
  50793. interface Scene {
  50794. /** @hidden */
  50795. _gamepadManager: Nullable<GamepadManager>;
  50796. /**
  50797. * Gets the gamepad manager associated with the scene
  50798. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  50799. */
  50800. gamepadManager: GamepadManager;
  50801. }
  50802. }
  50803. module "babylonjs/Cameras/freeCameraInputsManager" {
  50804. /**
  50805. * Interface representing a free camera inputs manager
  50806. */
  50807. interface FreeCameraInputsManager {
  50808. /**
  50809. * Adds gamepad input support to the FreeCameraInputsManager.
  50810. * @returns the FreeCameraInputsManager
  50811. */
  50812. addGamepad(): FreeCameraInputsManager;
  50813. }
  50814. }
  50815. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  50816. /**
  50817. * Interface representing an arc rotate camera inputs manager
  50818. */
  50819. interface ArcRotateCameraInputsManager {
  50820. /**
  50821. * Adds gamepad input support to the ArcRotateCamera InputManager.
  50822. * @returns the camera inputs manager
  50823. */
  50824. addGamepad(): ArcRotateCameraInputsManager;
  50825. }
  50826. }
  50827. /**
  50828. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  50829. */
  50830. export class GamepadSystemSceneComponent implements ISceneComponent {
  50831. /**
  50832. * The component name helpfull to identify the component in the list of scene components.
  50833. */
  50834. readonly name: string;
  50835. /**
  50836. * The scene the component belongs to.
  50837. */
  50838. scene: Scene;
  50839. /**
  50840. * Creates a new instance of the component for the given scene
  50841. * @param scene Defines the scene to register the component in
  50842. */
  50843. constructor(scene: Scene);
  50844. /**
  50845. * Registers the component in a given scene
  50846. */
  50847. register(): void;
  50848. /**
  50849. * Rebuilds the elements related to this component in case of
  50850. * context lost for instance.
  50851. */
  50852. rebuild(): void;
  50853. /**
  50854. * Disposes the component and the associated ressources
  50855. */
  50856. dispose(): void;
  50857. private _beforeCameraUpdate;
  50858. }
  50859. }
  50860. declare module "babylonjs/Cameras/universalCamera" {
  50861. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  50862. import { Scene } from "babylonjs/scene";
  50863. import { Vector3 } from "babylonjs/Maths/math.vector";
  50864. import "babylonjs/Gamepads/gamepadSceneComponent";
  50865. /**
  50866. * 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,
  50867. * which still works and will still be found in many Playgrounds.
  50868. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50869. */
  50870. export class UniversalCamera extends TouchCamera {
  50871. /**
  50872. * Defines the gamepad rotation sensiblity.
  50873. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50874. */
  50875. get gamepadAngularSensibility(): number;
  50876. set gamepadAngularSensibility(value: number);
  50877. /**
  50878. * Defines the gamepad move sensiblity.
  50879. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50880. */
  50881. get gamepadMoveSensibility(): number;
  50882. set gamepadMoveSensibility(value: number);
  50883. /**
  50884. * 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,
  50885. * which still works and will still be found in many Playgrounds.
  50886. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50887. * @param name Define the name of the camera in the scene
  50888. * @param position Define the start position of the camera in the scene
  50889. * @param scene Define the scene the camera belongs to
  50890. */
  50891. constructor(name: string, position: Vector3, scene: Scene);
  50892. /**
  50893. * Gets the current object class name.
  50894. * @return the class name
  50895. */
  50896. getClassName(): string;
  50897. }
  50898. }
  50899. declare module "babylonjs/Cameras/gamepadCamera" {
  50900. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  50901. import { Scene } from "babylonjs/scene";
  50902. import { Vector3 } from "babylonjs/Maths/math.vector";
  50903. /**
  50904. * This represents a FPS type of camera. This is only here for back compat purpose.
  50905. * Please use the UniversalCamera instead as both are identical.
  50906. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50907. */
  50908. export class GamepadCamera extends UniversalCamera {
  50909. /**
  50910. * Instantiates a new Gamepad Camera
  50911. * This represents a FPS type of camera. This is only here for back compat purpose.
  50912. * Please use the UniversalCamera instead as both are identical.
  50913. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50914. * @param name Define the name of the camera in the scene
  50915. * @param position Define the start position of the camera in the scene
  50916. * @param scene Define the scene the camera belongs to
  50917. */
  50918. constructor(name: string, position: Vector3, scene: Scene);
  50919. /**
  50920. * Gets the current object class name.
  50921. * @return the class name
  50922. */
  50923. getClassName(): string;
  50924. }
  50925. }
  50926. declare module "babylonjs/Shaders/pass.fragment" {
  50927. /** @hidden */
  50928. export var passPixelShader: {
  50929. name: string;
  50930. shader: string;
  50931. };
  50932. }
  50933. declare module "babylonjs/Shaders/passCube.fragment" {
  50934. /** @hidden */
  50935. export var passCubePixelShader: {
  50936. name: string;
  50937. shader: string;
  50938. };
  50939. }
  50940. declare module "babylonjs/PostProcesses/passPostProcess" {
  50941. import { Nullable } from "babylonjs/types";
  50942. import { Camera } from "babylonjs/Cameras/camera";
  50943. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50944. import { Engine } from "babylonjs/Engines/engine";
  50945. import "babylonjs/Shaders/pass.fragment";
  50946. import "babylonjs/Shaders/passCube.fragment";
  50947. import { Scene } from "babylonjs/scene";
  50948. /**
  50949. * PassPostProcess which produces an output the same as it's input
  50950. */
  50951. export class PassPostProcess extends PostProcess {
  50952. /**
  50953. * Gets a string identifying the name of the class
  50954. * @returns "PassPostProcess" string
  50955. */
  50956. getClassName(): string;
  50957. /**
  50958. * Creates the PassPostProcess
  50959. * @param name The name of the effect.
  50960. * @param options The required width/height ratio to downsize to before computing the render pass.
  50961. * @param camera The camera to apply the render pass to.
  50962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50963. * @param engine The engine which the post process will be applied. (default: current engine)
  50964. * @param reusable If the post process can be reused on the same frame. (default: false)
  50965. * @param textureType The type of texture to be used when performing the post processing.
  50966. * @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)
  50967. */
  50968. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50969. /** @hidden */
  50970. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  50971. }
  50972. /**
  50973. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  50974. */
  50975. export class PassCubePostProcess extends PostProcess {
  50976. private _face;
  50977. /**
  50978. * Gets or sets the cube face to display.
  50979. * * 0 is +X
  50980. * * 1 is -X
  50981. * * 2 is +Y
  50982. * * 3 is -Y
  50983. * * 4 is +Z
  50984. * * 5 is -Z
  50985. */
  50986. get face(): number;
  50987. set face(value: number);
  50988. /**
  50989. * Gets a string identifying the name of the class
  50990. * @returns "PassCubePostProcess" string
  50991. */
  50992. getClassName(): string;
  50993. /**
  50994. * Creates the PassCubePostProcess
  50995. * @param name The name of the effect.
  50996. * @param options The required width/height ratio to downsize to before computing the render pass.
  50997. * @param camera The camera to apply the render pass to.
  50998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50999. * @param engine The engine which the post process will be applied. (default: current engine)
  51000. * @param reusable If the post process can be reused on the same frame. (default: false)
  51001. * @param textureType The type of texture to be used when performing the post processing.
  51002. * @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)
  51003. */
  51004. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51005. /** @hidden */
  51006. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51007. }
  51008. }
  51009. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51010. /** @hidden */
  51011. export var anaglyphPixelShader: {
  51012. name: string;
  51013. shader: string;
  51014. };
  51015. }
  51016. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51017. import { Engine } from "babylonjs/Engines/engine";
  51018. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51019. import { Camera } from "babylonjs/Cameras/camera";
  51020. import "babylonjs/Shaders/anaglyph.fragment";
  51021. /**
  51022. * Postprocess used to generate anaglyphic rendering
  51023. */
  51024. export class AnaglyphPostProcess extends PostProcess {
  51025. private _passedProcess;
  51026. /**
  51027. * Gets a string identifying the name of the class
  51028. * @returns "AnaglyphPostProcess" string
  51029. */
  51030. getClassName(): string;
  51031. /**
  51032. * Creates a new AnaglyphPostProcess
  51033. * @param name defines postprocess name
  51034. * @param options defines creation options or target ratio scale
  51035. * @param rigCameras defines cameras using this postprocess
  51036. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51037. * @param engine defines hosting engine
  51038. * @param reusable defines if the postprocess will be reused multiple times per frame
  51039. */
  51040. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51041. }
  51042. }
  51043. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51044. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51045. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51046. import { Scene } from "babylonjs/scene";
  51047. import { Vector3 } from "babylonjs/Maths/math.vector";
  51048. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51049. /**
  51050. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51051. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51052. */
  51053. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51054. /**
  51055. * Creates a new AnaglyphArcRotateCamera
  51056. * @param name defines camera name
  51057. * @param alpha defines alpha angle (in radians)
  51058. * @param beta defines beta angle (in radians)
  51059. * @param radius defines radius
  51060. * @param target defines camera target
  51061. * @param interaxialDistance defines distance between each color axis
  51062. * @param scene defines the hosting scene
  51063. */
  51064. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51065. /**
  51066. * Gets camera class name
  51067. * @returns AnaglyphArcRotateCamera
  51068. */
  51069. getClassName(): string;
  51070. }
  51071. }
  51072. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51073. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51074. import { Scene } from "babylonjs/scene";
  51075. import { Vector3 } from "babylonjs/Maths/math.vector";
  51076. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51077. /**
  51078. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51079. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51080. */
  51081. export class AnaglyphFreeCamera extends FreeCamera {
  51082. /**
  51083. * Creates a new AnaglyphFreeCamera
  51084. * @param name defines camera name
  51085. * @param position defines initial position
  51086. * @param interaxialDistance defines distance between each color axis
  51087. * @param scene defines the hosting scene
  51088. */
  51089. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51090. /**
  51091. * Gets camera class name
  51092. * @returns AnaglyphFreeCamera
  51093. */
  51094. getClassName(): string;
  51095. }
  51096. }
  51097. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51098. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51099. import { Scene } from "babylonjs/scene";
  51100. import { Vector3 } from "babylonjs/Maths/math.vector";
  51101. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51102. /**
  51103. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51104. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51105. */
  51106. export class AnaglyphGamepadCamera extends GamepadCamera {
  51107. /**
  51108. * Creates a new AnaglyphGamepadCamera
  51109. * @param name defines camera name
  51110. * @param position defines initial position
  51111. * @param interaxialDistance defines distance between each color axis
  51112. * @param scene defines the hosting scene
  51113. */
  51114. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51115. /**
  51116. * Gets camera class name
  51117. * @returns AnaglyphGamepadCamera
  51118. */
  51119. getClassName(): string;
  51120. }
  51121. }
  51122. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51123. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51124. import { Scene } from "babylonjs/scene";
  51125. import { Vector3 } from "babylonjs/Maths/math.vector";
  51126. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51127. /**
  51128. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51129. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51130. */
  51131. export class AnaglyphUniversalCamera extends UniversalCamera {
  51132. /**
  51133. * Creates a new AnaglyphUniversalCamera
  51134. * @param name defines camera name
  51135. * @param position defines initial position
  51136. * @param interaxialDistance defines distance between each color axis
  51137. * @param scene defines the hosting scene
  51138. */
  51139. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51140. /**
  51141. * Gets camera class name
  51142. * @returns AnaglyphUniversalCamera
  51143. */
  51144. getClassName(): string;
  51145. }
  51146. }
  51147. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51148. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51149. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51150. import { Scene } from "babylonjs/scene";
  51151. import { Vector3 } from "babylonjs/Maths/math.vector";
  51152. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51153. /**
  51154. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51155. * @see https://doc.babylonjs.com/features/cameras
  51156. */
  51157. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51158. /**
  51159. * Creates a new StereoscopicArcRotateCamera
  51160. * @param name defines camera name
  51161. * @param alpha defines alpha angle (in radians)
  51162. * @param beta defines beta angle (in radians)
  51163. * @param radius defines radius
  51164. * @param target defines camera target
  51165. * @param interaxialDistance defines distance between each color axis
  51166. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51167. * @param scene defines the hosting scene
  51168. */
  51169. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51170. /**
  51171. * Gets camera class name
  51172. * @returns StereoscopicArcRotateCamera
  51173. */
  51174. getClassName(): string;
  51175. }
  51176. }
  51177. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51178. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51179. import { Scene } from "babylonjs/scene";
  51180. import { Vector3 } from "babylonjs/Maths/math.vector";
  51181. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51182. /**
  51183. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51184. * @see https://doc.babylonjs.com/features/cameras
  51185. */
  51186. export class StereoscopicFreeCamera extends FreeCamera {
  51187. /**
  51188. * Creates a new StereoscopicFreeCamera
  51189. * @param name defines camera name
  51190. * @param position defines initial position
  51191. * @param interaxialDistance defines distance between each color axis
  51192. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51193. * @param scene defines the hosting scene
  51194. */
  51195. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51196. /**
  51197. * Gets camera class name
  51198. * @returns StereoscopicFreeCamera
  51199. */
  51200. getClassName(): string;
  51201. }
  51202. }
  51203. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51204. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51205. import { Scene } from "babylonjs/scene";
  51206. import { Vector3 } from "babylonjs/Maths/math.vector";
  51207. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51208. /**
  51209. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51210. * @see https://doc.babylonjs.com/features/cameras
  51211. */
  51212. export class StereoscopicGamepadCamera extends GamepadCamera {
  51213. /**
  51214. * Creates a new StereoscopicGamepadCamera
  51215. * @param name defines camera name
  51216. * @param position defines initial position
  51217. * @param interaxialDistance defines distance between each color axis
  51218. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51219. * @param scene defines the hosting scene
  51220. */
  51221. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51222. /**
  51223. * Gets camera class name
  51224. * @returns StereoscopicGamepadCamera
  51225. */
  51226. getClassName(): string;
  51227. }
  51228. }
  51229. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51230. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51231. import { Scene } from "babylonjs/scene";
  51232. import { Vector3 } from "babylonjs/Maths/math.vector";
  51233. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51234. /**
  51235. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51236. * @see https://doc.babylonjs.com/features/cameras
  51237. */
  51238. export class StereoscopicUniversalCamera extends UniversalCamera {
  51239. /**
  51240. * Creates a new StereoscopicUniversalCamera
  51241. * @param name defines camera name
  51242. * @param position defines initial position
  51243. * @param interaxialDistance defines distance between each color axis
  51244. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51245. * @param scene defines the hosting scene
  51246. */
  51247. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51248. /**
  51249. * Gets camera class name
  51250. * @returns StereoscopicUniversalCamera
  51251. */
  51252. getClassName(): string;
  51253. }
  51254. }
  51255. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51256. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51257. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51258. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51259. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51260. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51261. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51262. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51263. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51264. }
  51265. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51266. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51267. import { Scene } from "babylonjs/scene";
  51268. import { Vector3 } from "babylonjs/Maths/math.vector";
  51269. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51270. /**
  51271. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51272. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51273. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51274. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51275. */
  51276. export class VirtualJoysticksCamera extends FreeCamera {
  51277. /**
  51278. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51279. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51280. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51281. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51282. * @param name Define the name of the camera in the scene
  51283. * @param position Define the start position of the camera in the scene
  51284. * @param scene Define the scene the camera belongs to
  51285. */
  51286. constructor(name: string, position: Vector3, scene: Scene);
  51287. /**
  51288. * Gets the current object class name.
  51289. * @return the class name
  51290. */
  51291. getClassName(): string;
  51292. }
  51293. }
  51294. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51295. import { Matrix } from "babylonjs/Maths/math.vector";
  51296. /**
  51297. * This represents all the required metrics to create a VR camera.
  51298. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51299. */
  51300. export class VRCameraMetrics {
  51301. /**
  51302. * Define the horizontal resolution off the screen.
  51303. */
  51304. hResolution: number;
  51305. /**
  51306. * Define the vertical resolution off the screen.
  51307. */
  51308. vResolution: number;
  51309. /**
  51310. * Define the horizontal screen size.
  51311. */
  51312. hScreenSize: number;
  51313. /**
  51314. * Define the vertical screen size.
  51315. */
  51316. vScreenSize: number;
  51317. /**
  51318. * Define the vertical screen center position.
  51319. */
  51320. vScreenCenter: number;
  51321. /**
  51322. * Define the distance of the eyes to the screen.
  51323. */
  51324. eyeToScreenDistance: number;
  51325. /**
  51326. * Define the distance between both lenses
  51327. */
  51328. lensSeparationDistance: number;
  51329. /**
  51330. * Define the distance between both viewer's eyes.
  51331. */
  51332. interpupillaryDistance: number;
  51333. /**
  51334. * Define the distortion factor of the VR postprocess.
  51335. * Please, touch with care.
  51336. */
  51337. distortionK: number[];
  51338. /**
  51339. * Define the chromatic aberration correction factors for the VR post process.
  51340. */
  51341. chromaAbCorrection: number[];
  51342. /**
  51343. * Define the scale factor of the post process.
  51344. * The smaller the better but the slower.
  51345. */
  51346. postProcessScaleFactor: number;
  51347. /**
  51348. * Define an offset for the lens center.
  51349. */
  51350. lensCenterOffset: number;
  51351. /**
  51352. * Define if the current vr camera should compensate the distortion of the lense or not.
  51353. */
  51354. compensateDistortion: boolean;
  51355. /**
  51356. * Defines if multiview should be enabled when rendering (Default: false)
  51357. */
  51358. multiviewEnabled: boolean;
  51359. /**
  51360. * Gets the rendering aspect ratio based on the provided resolutions.
  51361. */
  51362. get aspectRatio(): number;
  51363. /**
  51364. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51365. */
  51366. get aspectRatioFov(): number;
  51367. /**
  51368. * @hidden
  51369. */
  51370. get leftHMatrix(): Matrix;
  51371. /**
  51372. * @hidden
  51373. */
  51374. get rightHMatrix(): Matrix;
  51375. /**
  51376. * @hidden
  51377. */
  51378. get leftPreViewMatrix(): Matrix;
  51379. /**
  51380. * @hidden
  51381. */
  51382. get rightPreViewMatrix(): Matrix;
  51383. /**
  51384. * Get the default VRMetrics based on the most generic setup.
  51385. * @returns the default vr metrics
  51386. */
  51387. static GetDefault(): VRCameraMetrics;
  51388. }
  51389. }
  51390. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51391. /** @hidden */
  51392. export var vrDistortionCorrectionPixelShader: {
  51393. name: string;
  51394. shader: string;
  51395. };
  51396. }
  51397. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51398. import { Camera } from "babylonjs/Cameras/camera";
  51399. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51400. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51401. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51402. /**
  51403. * VRDistortionCorrectionPostProcess used for mobile VR
  51404. */
  51405. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51406. private _isRightEye;
  51407. private _distortionFactors;
  51408. private _postProcessScaleFactor;
  51409. private _lensCenterOffset;
  51410. private _scaleIn;
  51411. private _scaleFactor;
  51412. private _lensCenter;
  51413. /**
  51414. * Gets a string identifying the name of the class
  51415. * @returns "VRDistortionCorrectionPostProcess" string
  51416. */
  51417. getClassName(): string;
  51418. /**
  51419. * Initializes the VRDistortionCorrectionPostProcess
  51420. * @param name The name of the effect.
  51421. * @param camera The camera to apply the render pass to.
  51422. * @param isRightEye If this is for the right eye distortion
  51423. * @param vrMetrics All the required metrics for the VR camera
  51424. */
  51425. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51426. }
  51427. }
  51428. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51429. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51430. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51431. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51432. import { Scene } from "babylonjs/scene";
  51433. import { Vector3 } from "babylonjs/Maths/math.vector";
  51434. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51435. import "babylonjs/Cameras/RigModes/vrRigMode";
  51436. /**
  51437. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51438. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51439. */
  51440. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51441. /**
  51442. * Creates a new VRDeviceOrientationArcRotateCamera
  51443. * @param name defines camera name
  51444. * @param alpha defines the camera rotation along the logitudinal axis
  51445. * @param beta defines the camera rotation along the latitudinal axis
  51446. * @param radius defines the camera distance from its target
  51447. * @param target defines the camera target
  51448. * @param scene defines the scene the camera belongs to
  51449. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51450. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51451. */
  51452. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51453. /**
  51454. * Gets camera class name
  51455. * @returns VRDeviceOrientationArcRotateCamera
  51456. */
  51457. getClassName(): string;
  51458. }
  51459. }
  51460. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51461. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51462. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51463. import { Scene } from "babylonjs/scene";
  51464. import { Vector3 } from "babylonjs/Maths/math.vector";
  51465. import "babylonjs/Cameras/RigModes/vrRigMode";
  51466. /**
  51467. * Camera used to simulate VR rendering (based on FreeCamera)
  51468. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51469. */
  51470. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51471. /**
  51472. * Creates a new VRDeviceOrientationFreeCamera
  51473. * @param name defines camera name
  51474. * @param position defines the start position of the camera
  51475. * @param scene defines the scene the camera belongs to
  51476. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51477. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51478. */
  51479. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51480. /**
  51481. * Gets camera class name
  51482. * @returns VRDeviceOrientationFreeCamera
  51483. */
  51484. getClassName(): string;
  51485. }
  51486. }
  51487. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51488. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51489. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51490. import { Scene } from "babylonjs/scene";
  51491. import { Vector3 } from "babylonjs/Maths/math.vector";
  51492. import "babylonjs/Gamepads/gamepadSceneComponent";
  51493. /**
  51494. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51495. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51496. */
  51497. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51498. /**
  51499. * Creates a new VRDeviceOrientationGamepadCamera
  51500. * @param name defines camera name
  51501. * @param position defines the start position of the camera
  51502. * @param scene defines the scene the camera belongs to
  51503. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51504. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51505. */
  51506. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51507. /**
  51508. * Gets camera class name
  51509. * @returns VRDeviceOrientationGamepadCamera
  51510. */
  51511. getClassName(): string;
  51512. }
  51513. }
  51514. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51515. import { Scene } from "babylonjs/scene";
  51516. import { Texture } from "babylonjs/Materials/Textures/texture";
  51517. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51518. /**
  51519. * A class extending Texture allowing drawing on a texture
  51520. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51521. */
  51522. export class DynamicTexture extends Texture {
  51523. private _generateMipMaps;
  51524. private _canvas;
  51525. private _context;
  51526. /**
  51527. * Creates a DynamicTexture
  51528. * @param name defines the name of the texture
  51529. * @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
  51530. * @param scene defines the scene where you want the texture
  51531. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51532. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51533. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51534. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51535. */
  51536. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51537. /**
  51538. * Get the current class name of the texture useful for serialization or dynamic coding.
  51539. * @returns "DynamicTexture"
  51540. */
  51541. getClassName(): string;
  51542. /**
  51543. * Gets the current state of canRescale
  51544. */
  51545. get canRescale(): boolean;
  51546. private _recreate;
  51547. /**
  51548. * Scales the texture
  51549. * @param ratio the scale factor to apply to both width and height
  51550. */
  51551. scale(ratio: number): void;
  51552. /**
  51553. * Resizes the texture
  51554. * @param width the new width
  51555. * @param height the new height
  51556. */
  51557. scaleTo(width: number, height: number): void;
  51558. /**
  51559. * Gets the context of the canvas used by the texture
  51560. * @returns the canvas context of the dynamic texture
  51561. */
  51562. getContext(): CanvasRenderingContext2D;
  51563. /**
  51564. * Clears the texture
  51565. */
  51566. clear(): void;
  51567. /**
  51568. * Updates the texture
  51569. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51570. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51571. */
  51572. update(invertY?: boolean, premulAlpha?: boolean): void;
  51573. /**
  51574. * Draws text onto the texture
  51575. * @param text defines the text to be drawn
  51576. * @param x defines the placement of the text from the left
  51577. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51578. * @param font defines the font to be used with font-style, font-size, font-name
  51579. * @param color defines the color used for the text
  51580. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51581. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51582. * @param update defines whether texture is immediately update (default is true)
  51583. */
  51584. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51585. /**
  51586. * Clones the texture
  51587. * @returns the clone of the texture.
  51588. */
  51589. clone(): DynamicTexture;
  51590. /**
  51591. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51592. * @returns a serialized dynamic texture object
  51593. */
  51594. serialize(): any;
  51595. private _IsCanvasElement;
  51596. /** @hidden */
  51597. _rebuild(): void;
  51598. }
  51599. }
  51600. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51601. import { Scene } from "babylonjs/scene";
  51602. import { Color3 } from "babylonjs/Maths/math.color";
  51603. import { Mesh } from "babylonjs/Meshes/mesh";
  51604. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51605. import { Nullable } from "babylonjs/types";
  51606. /**
  51607. * Class containing static functions to help procedurally build meshes
  51608. */
  51609. export class GroundBuilder {
  51610. /**
  51611. * Creates a ground mesh
  51612. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51613. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51615. * @param name defines the name of the mesh
  51616. * @param options defines the options used to create the mesh
  51617. * @param scene defines the hosting scene
  51618. * @returns the ground mesh
  51619. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51620. */
  51621. static CreateGround(name: string, options: {
  51622. width?: number;
  51623. height?: number;
  51624. subdivisions?: number;
  51625. subdivisionsX?: number;
  51626. subdivisionsY?: number;
  51627. updatable?: boolean;
  51628. }, scene: any): Mesh;
  51629. /**
  51630. * Creates a tiled ground mesh
  51631. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51632. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51633. * * 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
  51634. * * 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
  51635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51636. * @param name defines the name of the mesh
  51637. * @param options defines the options used to create the mesh
  51638. * @param scene defines the hosting scene
  51639. * @returns the tiled ground mesh
  51640. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51641. */
  51642. static CreateTiledGround(name: string, options: {
  51643. xmin: number;
  51644. zmin: number;
  51645. xmax: number;
  51646. zmax: number;
  51647. subdivisions?: {
  51648. w: number;
  51649. h: number;
  51650. };
  51651. precision?: {
  51652. w: number;
  51653. h: number;
  51654. };
  51655. updatable?: boolean;
  51656. }, scene?: Nullable<Scene>): Mesh;
  51657. /**
  51658. * Creates a ground mesh from a height map
  51659. * * The parameter `url` sets the URL of the height map image resource.
  51660. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51661. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51662. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51663. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51664. * * 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.
  51665. * * 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).
  51666. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51668. * @param name defines the name of the mesh
  51669. * @param url defines the url to the height map
  51670. * @param options defines the options used to create the mesh
  51671. * @param scene defines the hosting scene
  51672. * @returns the ground mesh
  51673. * @see https://doc.babylonjs.com/babylon101/height_map
  51674. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51675. */
  51676. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51677. width?: number;
  51678. height?: number;
  51679. subdivisions?: number;
  51680. minHeight?: number;
  51681. maxHeight?: number;
  51682. colorFilter?: Color3;
  51683. alphaFilter?: number;
  51684. updatable?: boolean;
  51685. onReady?: (mesh: GroundMesh) => void;
  51686. }, scene?: Nullable<Scene>): GroundMesh;
  51687. }
  51688. }
  51689. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  51690. import { Vector4 } from "babylonjs/Maths/math.vector";
  51691. import { Mesh } from "babylonjs/Meshes/mesh";
  51692. /**
  51693. * Class containing static functions to help procedurally build meshes
  51694. */
  51695. export class TorusBuilder {
  51696. /**
  51697. * Creates a torus mesh
  51698. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51699. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51700. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51704. * @param name defines the name of the mesh
  51705. * @param options defines the options used to create the mesh
  51706. * @param scene defines the hosting scene
  51707. * @returns the torus mesh
  51708. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51709. */
  51710. static CreateTorus(name: string, options: {
  51711. diameter?: number;
  51712. thickness?: number;
  51713. tessellation?: number;
  51714. updatable?: boolean;
  51715. sideOrientation?: number;
  51716. frontUVs?: Vector4;
  51717. backUVs?: Vector4;
  51718. }, scene: any): Mesh;
  51719. }
  51720. }
  51721. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  51722. import { Vector4 } from "babylonjs/Maths/math.vector";
  51723. import { Color4 } from "babylonjs/Maths/math.color";
  51724. import { Mesh } from "babylonjs/Meshes/mesh";
  51725. /**
  51726. * Class containing static functions to help procedurally build meshes
  51727. */
  51728. export class CylinderBuilder {
  51729. /**
  51730. * Creates a cylinder or a cone mesh
  51731. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51732. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51733. * * 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.
  51734. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51735. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51736. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51737. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51738. * * 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).
  51739. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51740. * * 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).
  51741. * * 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
  51742. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51743. * * 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
  51744. * * 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.
  51745. * * If `enclose` is false, a ring surface is one element.
  51746. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51747. * * 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
  51748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51751. * @param name defines the name of the mesh
  51752. * @param options defines the options used to create the mesh
  51753. * @param scene defines the hosting scene
  51754. * @returns the cylinder mesh
  51755. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51756. */
  51757. static CreateCylinder(name: string, options: {
  51758. height?: number;
  51759. diameterTop?: number;
  51760. diameterBottom?: number;
  51761. diameter?: number;
  51762. tessellation?: number;
  51763. subdivisions?: number;
  51764. arc?: number;
  51765. faceColors?: Color4[];
  51766. faceUV?: Vector4[];
  51767. updatable?: boolean;
  51768. hasRings?: boolean;
  51769. enclose?: boolean;
  51770. cap?: number;
  51771. sideOrientation?: number;
  51772. frontUVs?: Vector4;
  51773. backUVs?: Vector4;
  51774. }, scene: any): Mesh;
  51775. }
  51776. }
  51777. declare module "babylonjs/XR/webXRTypes" {
  51778. import { Nullable } from "babylonjs/types";
  51779. import { IDisposable } from "babylonjs/scene";
  51780. /**
  51781. * States of the webXR experience
  51782. */
  51783. export enum WebXRState {
  51784. /**
  51785. * Transitioning to being in XR mode
  51786. */
  51787. ENTERING_XR = 0,
  51788. /**
  51789. * Transitioning to non XR mode
  51790. */
  51791. EXITING_XR = 1,
  51792. /**
  51793. * In XR mode and presenting
  51794. */
  51795. IN_XR = 2,
  51796. /**
  51797. * Not entered XR mode
  51798. */
  51799. NOT_IN_XR = 3
  51800. }
  51801. /**
  51802. * Abstraction of the XR render target
  51803. */
  51804. export interface WebXRRenderTarget extends IDisposable {
  51805. /**
  51806. * xrpresent context of the canvas which can be used to display/mirror xr content
  51807. */
  51808. canvasContext: WebGLRenderingContext;
  51809. /**
  51810. * xr layer for the canvas
  51811. */
  51812. xrLayer: Nullable<XRWebGLLayer>;
  51813. /**
  51814. * Initializes the xr layer for the session
  51815. * @param xrSession xr session
  51816. * @returns a promise that will resolve once the XR Layer has been created
  51817. */
  51818. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51819. }
  51820. }
  51821. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  51822. import { Nullable } from "babylonjs/types";
  51823. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51824. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51825. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51826. import { Observable } from "babylonjs/Misc/observable";
  51827. /**
  51828. * COnfiguration object for WebXR output canvas
  51829. */
  51830. export class WebXRManagedOutputCanvasOptions {
  51831. /**
  51832. * An optional canvas in case you wish to create it yourself and provide it here.
  51833. * If not provided, a new canvas will be created
  51834. */
  51835. canvasElement?: HTMLCanvasElement;
  51836. /**
  51837. * Options for this XR Layer output
  51838. */
  51839. canvasOptions?: XRWebGLLayerOptions;
  51840. /**
  51841. * CSS styling for a newly created canvas (if not provided)
  51842. */
  51843. newCanvasCssStyle?: string;
  51844. /**
  51845. * Get the default values of the configuration object
  51846. * @param engine defines the engine to use (can be null)
  51847. * @returns default values of this configuration object
  51848. */
  51849. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  51850. }
  51851. /**
  51852. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  51853. */
  51854. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  51855. private _options;
  51856. private _canvas;
  51857. private _engine;
  51858. private _originalCanvasSize;
  51859. /**
  51860. * Rendering context of the canvas which can be used to display/mirror xr content
  51861. */
  51862. canvasContext: WebGLRenderingContext;
  51863. /**
  51864. * xr layer for the canvas
  51865. */
  51866. xrLayer: Nullable<XRWebGLLayer>;
  51867. /**
  51868. * Obseervers registered here will be triggered when the xr layer was initialized
  51869. */
  51870. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  51871. /**
  51872. * Initializes the canvas to be added/removed upon entering/exiting xr
  51873. * @param _xrSessionManager The XR Session manager
  51874. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  51875. */
  51876. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  51877. /**
  51878. * Disposes of the object
  51879. */
  51880. dispose(): void;
  51881. /**
  51882. * Initializes the xr layer for the session
  51883. * @param xrSession xr session
  51884. * @returns a promise that will resolve once the XR Layer has been created
  51885. */
  51886. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51887. private _addCanvas;
  51888. private _removeCanvas;
  51889. private _setCanvasSize;
  51890. private _setManagedOutputCanvas;
  51891. }
  51892. }
  51893. declare module "babylonjs/XR/webXRSessionManager" {
  51894. import { Observable } from "babylonjs/Misc/observable";
  51895. import { Nullable } from "babylonjs/types";
  51896. import { IDisposable, Scene } from "babylonjs/scene";
  51897. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51898. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51899. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51900. /**
  51901. * Manages an XRSession to work with Babylon's engine
  51902. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  51903. */
  51904. export class WebXRSessionManager implements IDisposable {
  51905. /** The scene which the session should be created for */
  51906. scene: Scene;
  51907. private _referenceSpace;
  51908. private _rttProvider;
  51909. private _sessionEnded;
  51910. private _xrNavigator;
  51911. private baseLayer;
  51912. /**
  51913. * The base reference space from which the session started. good if you want to reset your
  51914. * reference space
  51915. */
  51916. baseReferenceSpace: XRReferenceSpace;
  51917. /**
  51918. * Current XR frame
  51919. */
  51920. currentFrame: Nullable<XRFrame>;
  51921. /** WebXR timestamp updated every frame */
  51922. currentTimestamp: number;
  51923. /**
  51924. * Used just in case of a failure to initialize an immersive session.
  51925. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  51926. */
  51927. defaultHeightCompensation: number;
  51928. /**
  51929. * Fires every time a new xrFrame arrives which can be used to update the camera
  51930. */
  51931. onXRFrameObservable: Observable<XRFrame>;
  51932. /**
  51933. * Fires when the reference space changed
  51934. */
  51935. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  51936. /**
  51937. * Fires when the xr session is ended either by the device or manually done
  51938. */
  51939. onXRSessionEnded: Observable<any>;
  51940. /**
  51941. * Fires when the xr session is ended either by the device or manually done
  51942. */
  51943. onXRSessionInit: Observable<XRSession>;
  51944. /**
  51945. * Underlying xr session
  51946. */
  51947. session: XRSession;
  51948. /**
  51949. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  51950. * or get the offset the player is currently at.
  51951. */
  51952. viewerReferenceSpace: XRReferenceSpace;
  51953. /**
  51954. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  51955. * @param scene The scene which the session should be created for
  51956. */
  51957. constructor(
  51958. /** The scene which the session should be created for */
  51959. scene: Scene);
  51960. /**
  51961. * The current reference space used in this session. This reference space can constantly change!
  51962. * It is mainly used to offset the camera's position.
  51963. */
  51964. get referenceSpace(): XRReferenceSpace;
  51965. /**
  51966. * Set a new reference space and triggers the observable
  51967. */
  51968. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  51969. /**
  51970. * Disposes of the session manager
  51971. */
  51972. dispose(): void;
  51973. /**
  51974. * Stops the xrSession and restores the render loop
  51975. * @returns Promise which resolves after it exits XR
  51976. */
  51977. exitXRAsync(): Promise<void>;
  51978. /**
  51979. * Gets the correct render target texture to be rendered this frame for this eye
  51980. * @param eye the eye for which to get the render target
  51981. * @returns the render target for the specified eye
  51982. */
  51983. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  51984. /**
  51985. * Creates a WebXRRenderTarget object for the XR session
  51986. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  51987. * @param options optional options to provide when creating a new render target
  51988. * @returns a WebXR render target to which the session can render
  51989. */
  51990. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  51991. /**
  51992. * Initializes the manager
  51993. * After initialization enterXR can be called to start an XR session
  51994. * @returns Promise which resolves after it is initialized
  51995. */
  51996. initializeAsync(): Promise<void>;
  51997. /**
  51998. * Initializes an xr session
  51999. * @param xrSessionMode mode to initialize
  52000. * @param xrSessionInit defines optional and required values to pass to the session builder
  52001. * @returns a promise which will resolve once the session has been initialized
  52002. */
  52003. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52004. /**
  52005. * Checks if a session would be supported for the creation options specified
  52006. * @param sessionMode session mode to check if supported eg. immersive-vr
  52007. * @returns A Promise that resolves to true if supported and false if not
  52008. */
  52009. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52010. /**
  52011. * Resets the reference space to the one started the session
  52012. */
  52013. resetReferenceSpace(): void;
  52014. /**
  52015. * Starts rendering to the xr layer
  52016. */
  52017. runXRRenderLoop(): void;
  52018. /**
  52019. * Sets the reference space on the xr session
  52020. * @param referenceSpaceType space to set
  52021. * @returns a promise that will resolve once the reference space has been set
  52022. */
  52023. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52024. /**
  52025. * Updates the render state of the session
  52026. * @param state state to set
  52027. * @returns a promise that resolves once the render state has been updated
  52028. */
  52029. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52030. /**
  52031. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52032. * @param sessionMode defines the session to test
  52033. * @returns a promise with boolean as final value
  52034. */
  52035. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52036. private _createRenderTargetTexture;
  52037. }
  52038. }
  52039. declare module "babylonjs/XR/webXRCamera" {
  52040. import { Vector3 } from "babylonjs/Maths/math.vector";
  52041. import { Scene } from "babylonjs/scene";
  52042. import { Camera } from "babylonjs/Cameras/camera";
  52043. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52044. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52045. import { Observable } from "babylonjs/Misc/observable";
  52046. /**
  52047. * WebXR Camera which holds the views for the xrSession
  52048. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52049. */
  52050. export class WebXRCamera extends FreeCamera {
  52051. private _xrSessionManager;
  52052. private _firstFrame;
  52053. private _referenceQuaternion;
  52054. private _referencedPosition;
  52055. private _xrInvPositionCache;
  52056. private _xrInvQuaternionCache;
  52057. /**
  52058. * Observable raised before camera teleportation
  52059. */
  52060. onBeforeCameraTeleport: Observable<Vector3>;
  52061. /**
  52062. * Observable raised after camera teleportation
  52063. */
  52064. onAfterCameraTeleport: Observable<Vector3>;
  52065. /**
  52066. * Should position compensation execute on first frame.
  52067. * This is used when copying the position from a native (non XR) camera
  52068. */
  52069. compensateOnFirstFrame: boolean;
  52070. /**
  52071. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52072. * @param name the name of the camera
  52073. * @param scene the scene to add the camera to
  52074. * @param _xrSessionManager a constructed xr session manager
  52075. */
  52076. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52077. /**
  52078. * Return the user's height, unrelated to the current ground.
  52079. * This will be the y position of this camera, when ground level is 0.
  52080. */
  52081. get realWorldHeight(): number;
  52082. /** @hidden */
  52083. _updateForDualEyeDebugging(): void;
  52084. /**
  52085. * Sets this camera's transformation based on a non-vr camera
  52086. * @param otherCamera the non-vr camera to copy the transformation from
  52087. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52088. */
  52089. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52090. /**
  52091. * Gets the current instance class name ("WebXRCamera").
  52092. * @returns the class name
  52093. */
  52094. getClassName(): string;
  52095. private _rotate180;
  52096. private _updateFromXRSession;
  52097. private _updateNumberOfRigCameras;
  52098. private _updateReferenceSpace;
  52099. private _updateReferenceSpaceOffset;
  52100. }
  52101. }
  52102. declare module "babylonjs/XR/webXRFeaturesManager" {
  52103. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52104. import { IDisposable } from "babylonjs/scene";
  52105. /**
  52106. * Defining the interface required for a (webxr) feature
  52107. */
  52108. export interface IWebXRFeature extends IDisposable {
  52109. /**
  52110. * Is this feature attached
  52111. */
  52112. attached: boolean;
  52113. /**
  52114. * Should auto-attach be disabled?
  52115. */
  52116. disableAutoAttach: boolean;
  52117. /**
  52118. * Attach the feature to the session
  52119. * Will usually be called by the features manager
  52120. *
  52121. * @param force should attachment be forced (even when already attached)
  52122. * @returns true if successful.
  52123. */
  52124. attach(force?: boolean): boolean;
  52125. /**
  52126. * Detach the feature from the session
  52127. * Will usually be called by the features manager
  52128. *
  52129. * @returns true if successful.
  52130. */
  52131. detach(): boolean;
  52132. /**
  52133. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52134. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52135. *
  52136. * @returns whether or not the feature is compatible in this environment
  52137. */
  52138. isCompatible(): boolean;
  52139. /**
  52140. * Was this feature disposed;
  52141. */
  52142. isDisposed: boolean;
  52143. /**
  52144. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52145. */
  52146. xrNativeFeatureName?: string;
  52147. /**
  52148. * A list of (Babylon WebXR) features this feature depends on
  52149. */
  52150. dependsOn?: string[];
  52151. }
  52152. /**
  52153. * A list of the currently available features without referencing them
  52154. */
  52155. export class WebXRFeatureName {
  52156. /**
  52157. * The name of the anchor system feature
  52158. */
  52159. static readonly ANCHOR_SYSTEM: string;
  52160. /**
  52161. * The name of the background remover feature
  52162. */
  52163. static readonly BACKGROUND_REMOVER: string;
  52164. /**
  52165. * The name of the hit test feature
  52166. */
  52167. static readonly HIT_TEST: string;
  52168. /**
  52169. * physics impostors for xr controllers feature
  52170. */
  52171. static readonly PHYSICS_CONTROLLERS: string;
  52172. /**
  52173. * The name of the plane detection feature
  52174. */
  52175. static readonly PLANE_DETECTION: string;
  52176. /**
  52177. * The name of the pointer selection feature
  52178. */
  52179. static readonly POINTER_SELECTION: string;
  52180. /**
  52181. * The name of the teleportation feature
  52182. */
  52183. static readonly TELEPORTATION: string;
  52184. /**
  52185. * The name of the feature points feature.
  52186. */
  52187. static readonly FEATURE_POINTS: string;
  52188. /**
  52189. * The name of the hand tracking feature.
  52190. */
  52191. static readonly HAND_TRACKING: string;
  52192. }
  52193. /**
  52194. * Defining the constructor of a feature. Used to register the modules.
  52195. */
  52196. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52197. /**
  52198. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52199. * It is mainly used in AR sessions.
  52200. *
  52201. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52202. */
  52203. export class WebXRFeaturesManager implements IDisposable {
  52204. private _xrSessionManager;
  52205. private static readonly _AvailableFeatures;
  52206. private _features;
  52207. /**
  52208. * constructs a new features manages.
  52209. *
  52210. * @param _xrSessionManager an instance of WebXRSessionManager
  52211. */
  52212. constructor(_xrSessionManager: WebXRSessionManager);
  52213. /**
  52214. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52215. * Mainly used internally.
  52216. *
  52217. * @param featureName the name of the feature to register
  52218. * @param constructorFunction the function used to construct the module
  52219. * @param version the (babylon) version of the module
  52220. * @param stable is that a stable version of this module
  52221. */
  52222. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52223. /**
  52224. * Returns a constructor of a specific feature.
  52225. *
  52226. * @param featureName the name of the feature to construct
  52227. * @param version the version of the feature to load
  52228. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52229. * @param options optional options provided to the module.
  52230. * @returns a function that, when called, will return a new instance of this feature
  52231. */
  52232. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52233. /**
  52234. * Can be used to return the list of features currently registered
  52235. *
  52236. * @returns an Array of available features
  52237. */
  52238. static GetAvailableFeatures(): string[];
  52239. /**
  52240. * Gets the versions available for a specific feature
  52241. * @param featureName the name of the feature
  52242. * @returns an array with the available versions
  52243. */
  52244. static GetAvailableVersions(featureName: string): string[];
  52245. /**
  52246. * Return the latest unstable version of this feature
  52247. * @param featureName the name of the feature to search
  52248. * @returns the version number. if not found will return -1
  52249. */
  52250. static GetLatestVersionOfFeature(featureName: string): number;
  52251. /**
  52252. * Return the latest stable version of this feature
  52253. * @param featureName the name of the feature to search
  52254. * @returns the version number. if not found will return -1
  52255. */
  52256. static GetStableVersionOfFeature(featureName: string): number;
  52257. /**
  52258. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52259. * Can be used during a session to start a feature
  52260. * @param featureName the name of feature to attach
  52261. */
  52262. attachFeature(featureName: string): void;
  52263. /**
  52264. * Can be used inside a session or when the session ends to detach a specific feature
  52265. * @param featureName the name of the feature to detach
  52266. */
  52267. detachFeature(featureName: string): void;
  52268. /**
  52269. * Used to disable an already-enabled feature
  52270. * The feature will be disposed and will be recreated once enabled.
  52271. * @param featureName the feature to disable
  52272. * @returns true if disable was successful
  52273. */
  52274. disableFeature(featureName: string | {
  52275. Name: string;
  52276. }): boolean;
  52277. /**
  52278. * dispose this features manager
  52279. */
  52280. dispose(): void;
  52281. /**
  52282. * 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.
  52283. * 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.
  52284. *
  52285. * @param featureName the name of the feature to load or the class of the feature
  52286. * @param version optional version to load. if not provided the latest version will be enabled
  52287. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52288. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52289. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52290. * @returns a new constructed feature or throws an error if feature not found.
  52291. */
  52292. enableFeature(featureName: string | {
  52293. Name: string;
  52294. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52295. /**
  52296. * get the implementation of an enabled feature.
  52297. * @param featureName the name of the feature to load
  52298. * @returns the feature class, if found
  52299. */
  52300. getEnabledFeature(featureName: string): IWebXRFeature;
  52301. /**
  52302. * Get the list of enabled features
  52303. * @returns an array of enabled features
  52304. */
  52305. getEnabledFeatures(): string[];
  52306. /**
  52307. * This function will exten the session creation configuration object with enabled features.
  52308. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52309. * according to the defined "required" variable, provided during enableFeature call
  52310. * @param xrSessionInit the xr Session init object to extend
  52311. *
  52312. * @returns an extended XRSessionInit object
  52313. */
  52314. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52315. }
  52316. }
  52317. declare module "babylonjs/XR/webXRExperienceHelper" {
  52318. import { Observable } from "babylonjs/Misc/observable";
  52319. import { IDisposable, Scene } from "babylonjs/scene";
  52320. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52321. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52322. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52323. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52324. /**
  52325. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52326. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52327. */
  52328. export class WebXRExperienceHelper implements IDisposable {
  52329. private scene;
  52330. private _nonVRCamera;
  52331. private _originalSceneAutoClear;
  52332. private _supported;
  52333. /**
  52334. * Camera used to render xr content
  52335. */
  52336. camera: WebXRCamera;
  52337. /** A features manager for this xr session */
  52338. featuresManager: WebXRFeaturesManager;
  52339. /**
  52340. * Observers registered here will be triggered after the camera's initial transformation is set
  52341. * This can be used to set a different ground level or an extra rotation.
  52342. *
  52343. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52344. * to the position set after this observable is done executing.
  52345. */
  52346. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52347. /**
  52348. * Fires when the state of the experience helper has changed
  52349. */
  52350. onStateChangedObservable: Observable<WebXRState>;
  52351. /** Session manager used to keep track of xr session */
  52352. sessionManager: WebXRSessionManager;
  52353. /**
  52354. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52355. */
  52356. state: WebXRState;
  52357. /**
  52358. * Creates a WebXRExperienceHelper
  52359. * @param scene The scene the helper should be created in
  52360. */
  52361. private constructor();
  52362. /**
  52363. * Creates the experience helper
  52364. * @param scene the scene to attach the experience helper to
  52365. * @returns a promise for the experience helper
  52366. */
  52367. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52368. /**
  52369. * Disposes of the experience helper
  52370. */
  52371. dispose(): void;
  52372. /**
  52373. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52374. * @param sessionMode options for the XR session
  52375. * @param referenceSpaceType frame of reference of the XR session
  52376. * @param renderTarget the output canvas that will be used to enter XR mode
  52377. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52378. * @returns promise that resolves after xr mode has entered
  52379. */
  52380. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52381. /**
  52382. * Exits XR mode and returns the scene to its original state
  52383. * @returns promise that resolves after xr mode has exited
  52384. */
  52385. exitXRAsync(): Promise<void>;
  52386. private _nonXRToXRCamera;
  52387. private _setState;
  52388. }
  52389. }
  52390. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52391. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52392. import { Observable } from "babylonjs/Misc/observable";
  52393. import { IDisposable } from "babylonjs/scene";
  52394. /**
  52395. * X-Y values for axes in WebXR
  52396. */
  52397. export interface IWebXRMotionControllerAxesValue {
  52398. /**
  52399. * The value of the x axis
  52400. */
  52401. x: number;
  52402. /**
  52403. * The value of the y-axis
  52404. */
  52405. y: number;
  52406. }
  52407. /**
  52408. * changed / previous values for the values of this component
  52409. */
  52410. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52411. /**
  52412. * current (this frame) value
  52413. */
  52414. current: T;
  52415. /**
  52416. * previous (last change) value
  52417. */
  52418. previous: T;
  52419. }
  52420. /**
  52421. * Represents changes in the component between current frame and last values recorded
  52422. */
  52423. export interface IWebXRMotionControllerComponentChanges {
  52424. /**
  52425. * will be populated with previous and current values if axes changed
  52426. */
  52427. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52428. /**
  52429. * will be populated with previous and current values if pressed changed
  52430. */
  52431. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52432. /**
  52433. * will be populated with previous and current values if touched changed
  52434. */
  52435. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52436. /**
  52437. * will be populated with previous and current values if value changed
  52438. */
  52439. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52440. }
  52441. /**
  52442. * This class represents a single component (for example button or thumbstick) of a motion controller
  52443. */
  52444. export class WebXRControllerComponent implements IDisposable {
  52445. /**
  52446. * the id of this component
  52447. */
  52448. id: string;
  52449. /**
  52450. * the type of the component
  52451. */
  52452. type: MotionControllerComponentType;
  52453. private _buttonIndex;
  52454. private _axesIndices;
  52455. private _axes;
  52456. private _changes;
  52457. private _currentValue;
  52458. private _hasChanges;
  52459. private _pressed;
  52460. private _touched;
  52461. /**
  52462. * button component type
  52463. */
  52464. static BUTTON_TYPE: MotionControllerComponentType;
  52465. /**
  52466. * squeeze component type
  52467. */
  52468. static SQUEEZE_TYPE: MotionControllerComponentType;
  52469. /**
  52470. * Thumbstick component type
  52471. */
  52472. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52473. /**
  52474. * Touchpad component type
  52475. */
  52476. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52477. /**
  52478. * trigger component type
  52479. */
  52480. static TRIGGER_TYPE: MotionControllerComponentType;
  52481. /**
  52482. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52483. * the axes data changes
  52484. */
  52485. onAxisValueChangedObservable: Observable<{
  52486. x: number;
  52487. y: number;
  52488. }>;
  52489. /**
  52490. * Observers registered here will be triggered when the state of a button changes
  52491. * State change is either pressed / touched / value
  52492. */
  52493. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52494. /**
  52495. * Creates a new component for a motion controller.
  52496. * It is created by the motion controller itself
  52497. *
  52498. * @param id the id of this component
  52499. * @param type the type of the component
  52500. * @param _buttonIndex index in the buttons array of the gamepad
  52501. * @param _axesIndices indices of the values in the axes array of the gamepad
  52502. */
  52503. constructor(
  52504. /**
  52505. * the id of this component
  52506. */
  52507. id: string,
  52508. /**
  52509. * the type of the component
  52510. */
  52511. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52512. /**
  52513. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52514. */
  52515. get axes(): IWebXRMotionControllerAxesValue;
  52516. /**
  52517. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52518. */
  52519. get changes(): IWebXRMotionControllerComponentChanges;
  52520. /**
  52521. * Return whether or not the component changed the last frame
  52522. */
  52523. get hasChanges(): boolean;
  52524. /**
  52525. * is the button currently pressed
  52526. */
  52527. get pressed(): boolean;
  52528. /**
  52529. * is the button currently touched
  52530. */
  52531. get touched(): boolean;
  52532. /**
  52533. * Get the current value of this component
  52534. */
  52535. get value(): number;
  52536. /**
  52537. * Dispose this component
  52538. */
  52539. dispose(): void;
  52540. /**
  52541. * Are there axes correlating to this component
  52542. * @return true is axes data is available
  52543. */
  52544. isAxes(): boolean;
  52545. /**
  52546. * Is this component a button (hence - pressable)
  52547. * @returns true if can be pressed
  52548. */
  52549. isButton(): boolean;
  52550. /**
  52551. * update this component using the gamepad object it is in. Called on every frame
  52552. * @param nativeController the native gamepad controller object
  52553. */
  52554. update(nativeController: IMinimalMotionControllerObject): void;
  52555. }
  52556. }
  52557. declare module "babylonjs/Loading/sceneLoader" {
  52558. import { Observable } from "babylonjs/Misc/observable";
  52559. import { Nullable } from "babylonjs/types";
  52560. import { Scene } from "babylonjs/scene";
  52561. import { Engine } from "babylonjs/Engines/engine";
  52562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52563. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52564. import { AssetContainer } from "babylonjs/assetContainer";
  52565. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52566. import { Skeleton } from "babylonjs/Bones/skeleton";
  52567. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52568. import { WebRequest } from "babylonjs/Misc/webRequest";
  52569. /**
  52570. * Interface used to represent data loading progression
  52571. */
  52572. export interface ISceneLoaderProgressEvent {
  52573. /**
  52574. * Defines if data length to load can be evaluated
  52575. */
  52576. readonly lengthComputable: boolean;
  52577. /**
  52578. * Defines the loaded data length
  52579. */
  52580. readonly loaded: number;
  52581. /**
  52582. * Defines the data length to load
  52583. */
  52584. readonly total: number;
  52585. }
  52586. /**
  52587. * Interface used by SceneLoader plugins to define supported file extensions
  52588. */
  52589. export interface ISceneLoaderPluginExtensions {
  52590. /**
  52591. * Defines the list of supported extensions
  52592. */
  52593. [extension: string]: {
  52594. isBinary: boolean;
  52595. };
  52596. }
  52597. /**
  52598. * Interface used by SceneLoader plugin factory
  52599. */
  52600. export interface ISceneLoaderPluginFactory {
  52601. /**
  52602. * Defines the name of the factory
  52603. */
  52604. name: string;
  52605. /**
  52606. * Function called to create a new plugin
  52607. * @return the new plugin
  52608. */
  52609. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52610. /**
  52611. * The callback that returns true if the data can be directly loaded.
  52612. * @param data string containing the file data
  52613. * @returns if the data can be loaded directly
  52614. */
  52615. canDirectLoad?(data: string): boolean;
  52616. }
  52617. /**
  52618. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  52619. */
  52620. export interface ISceneLoaderPluginBase {
  52621. /**
  52622. * The friendly name of this plugin.
  52623. */
  52624. name: string;
  52625. /**
  52626. * The file extensions supported by this plugin.
  52627. */
  52628. extensions: string | ISceneLoaderPluginExtensions;
  52629. /**
  52630. * The callback called when loading from a url.
  52631. * @param scene scene loading this url
  52632. * @param url url to load
  52633. * @param onSuccess callback called when the file successfully loads
  52634. * @param onProgress callback called while file is loading (if the server supports this mode)
  52635. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  52636. * @param onError callback called when the file fails to load
  52637. * @returns a file request object
  52638. */
  52639. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52640. /**
  52641. * The callback called when loading from a file object.
  52642. * @param scene scene loading this file
  52643. * @param file defines the file to load
  52644. * @param onSuccess defines the callback to call when data is loaded
  52645. * @param onProgress defines the callback to call during loading process
  52646. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  52647. * @param onError defines the callback to call when an error occurs
  52648. * @returns a file request object
  52649. */
  52650. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52651. /**
  52652. * The callback that returns true if the data can be directly loaded.
  52653. * @param data string containing the file data
  52654. * @returns if the data can be loaded directly
  52655. */
  52656. canDirectLoad?(data: string): boolean;
  52657. /**
  52658. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  52659. * @param scene scene loading this data
  52660. * @param data string containing the data
  52661. * @returns data to pass to the plugin
  52662. */
  52663. directLoad?(scene: Scene, data: string): any;
  52664. /**
  52665. * The callback that allows custom handling of the root url based on the response url.
  52666. * @param rootUrl the original root url
  52667. * @param responseURL the response url if available
  52668. * @returns the new root url
  52669. */
  52670. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  52671. }
  52672. /**
  52673. * Interface used to define a SceneLoader plugin
  52674. */
  52675. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  52676. /**
  52677. * Import meshes into a scene.
  52678. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52679. * @param scene The scene to import into
  52680. * @param data The data to import
  52681. * @param rootUrl The root url for scene and resources
  52682. * @param meshes The meshes array to import into
  52683. * @param particleSystems The particle systems array to import into
  52684. * @param skeletons The skeletons array to import into
  52685. * @param onError The callback when import fails
  52686. * @returns True if successful or false otherwise
  52687. */
  52688. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  52689. /**
  52690. * Load into a scene.
  52691. * @param scene The scene to load into
  52692. * @param data The data to import
  52693. * @param rootUrl The root url for scene and resources
  52694. * @param onError The callback when import fails
  52695. * @returns True if successful or false otherwise
  52696. */
  52697. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  52698. /**
  52699. * Load into an asset container.
  52700. * @param scene The scene to load into
  52701. * @param data The data to import
  52702. * @param rootUrl The root url for scene and resources
  52703. * @param onError The callback when import fails
  52704. * @returns The loaded asset container
  52705. */
  52706. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  52707. }
  52708. /**
  52709. * Interface used to define an async SceneLoader plugin
  52710. */
  52711. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  52712. /**
  52713. * Import meshes into a scene.
  52714. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52715. * @param scene The scene to import into
  52716. * @param data The data to import
  52717. * @param rootUrl The root url for scene and resources
  52718. * @param onProgress The callback when the load progresses
  52719. * @param fileName Defines the name of the file to load
  52720. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  52721. */
  52722. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  52723. meshes: AbstractMesh[];
  52724. particleSystems: IParticleSystem[];
  52725. skeletons: Skeleton[];
  52726. animationGroups: AnimationGroup[];
  52727. }>;
  52728. /**
  52729. * Load into a scene.
  52730. * @param scene The scene to load into
  52731. * @param data The data to import
  52732. * @param rootUrl The root url for scene and resources
  52733. * @param onProgress The callback when the load progresses
  52734. * @param fileName Defines the name of the file to load
  52735. * @returns Nothing
  52736. */
  52737. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  52738. /**
  52739. * Load into an asset container.
  52740. * @param scene The scene to load into
  52741. * @param data The data to import
  52742. * @param rootUrl The root url for scene and resources
  52743. * @param onProgress The callback when the load progresses
  52744. * @param fileName Defines the name of the file to load
  52745. * @returns The loaded asset container
  52746. */
  52747. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  52748. }
  52749. /**
  52750. * Mode that determines how to handle old animation groups before loading new ones.
  52751. */
  52752. export enum SceneLoaderAnimationGroupLoadingMode {
  52753. /**
  52754. * Reset all old animations to initial state then dispose them.
  52755. */
  52756. Clean = 0,
  52757. /**
  52758. * Stop all old animations.
  52759. */
  52760. Stop = 1,
  52761. /**
  52762. * Restart old animations from first frame.
  52763. */
  52764. Sync = 2,
  52765. /**
  52766. * Old animations remains untouched.
  52767. */
  52768. NoSync = 3
  52769. }
  52770. /**
  52771. * Defines a plugin registered by the SceneLoader
  52772. */
  52773. interface IRegisteredPlugin {
  52774. /**
  52775. * Defines the plugin to use
  52776. */
  52777. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52778. /**
  52779. * Defines if the plugin supports binary data
  52780. */
  52781. isBinary: boolean;
  52782. }
  52783. /**
  52784. * Class used to load scene from various file formats using registered plugins
  52785. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  52786. */
  52787. export class SceneLoader {
  52788. /**
  52789. * No logging while loading
  52790. */
  52791. static readonly NO_LOGGING: number;
  52792. /**
  52793. * Minimal logging while loading
  52794. */
  52795. static readonly MINIMAL_LOGGING: number;
  52796. /**
  52797. * Summary logging while loading
  52798. */
  52799. static readonly SUMMARY_LOGGING: number;
  52800. /**
  52801. * Detailled logging while loading
  52802. */
  52803. static readonly DETAILED_LOGGING: number;
  52804. /**
  52805. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  52806. */
  52807. static get ForceFullSceneLoadingForIncremental(): boolean;
  52808. static set ForceFullSceneLoadingForIncremental(value: boolean);
  52809. /**
  52810. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  52811. */
  52812. static get ShowLoadingScreen(): boolean;
  52813. static set ShowLoadingScreen(value: boolean);
  52814. /**
  52815. * Defines the current logging level (while loading the scene)
  52816. * @ignorenaming
  52817. */
  52818. static get loggingLevel(): number;
  52819. static set loggingLevel(value: number);
  52820. /**
  52821. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  52822. */
  52823. static get CleanBoneMatrixWeights(): boolean;
  52824. static set CleanBoneMatrixWeights(value: boolean);
  52825. /**
  52826. * Event raised when a plugin is used to load a scene
  52827. */
  52828. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  52829. private static _registeredPlugins;
  52830. private static _showingLoadingScreen;
  52831. /**
  52832. * Gets the default plugin (used to load Babylon files)
  52833. * @returns the .babylon plugin
  52834. */
  52835. static GetDefaultPlugin(): IRegisteredPlugin;
  52836. private static _GetPluginForExtension;
  52837. private static _GetPluginForDirectLoad;
  52838. private static _GetPluginForFilename;
  52839. private static _GetDirectLoad;
  52840. private static _LoadData;
  52841. private static _GetFileInfo;
  52842. /**
  52843. * Gets a plugin that can load the given extension
  52844. * @param extension defines the extension to load
  52845. * @returns a plugin or null if none works
  52846. */
  52847. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52848. /**
  52849. * Gets a boolean indicating that the given extension can be loaded
  52850. * @param extension defines the extension to load
  52851. * @returns true if the extension is supported
  52852. */
  52853. static IsPluginForExtensionAvailable(extension: string): boolean;
  52854. /**
  52855. * Adds a new plugin to the list of registered plugins
  52856. * @param plugin defines the plugin to add
  52857. */
  52858. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  52859. /**
  52860. * Import meshes into a scene
  52861. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52862. * @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)
  52863. * @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)
  52864. * @param scene the instance of BABYLON.Scene to append to
  52865. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  52866. * @param onProgress a callback with a progress event for each file being loaded
  52867. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52868. * @param pluginExtension the extension used to determine the plugin
  52869. * @returns The loaded plugin
  52870. */
  52871. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  52872. /**
  52873. * Import meshes into a scene
  52874. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52875. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  52876. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  52877. * @param scene the instance of BABYLON.Scene to append to
  52878. * @param onProgress a callback with a progress event for each file being loaded
  52879. * @param pluginExtension the extension used to determine the plugin
  52880. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  52881. */
  52882. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  52883. meshes: AbstractMesh[];
  52884. particleSystems: IParticleSystem[];
  52885. skeletons: Skeleton[];
  52886. animationGroups: AnimationGroup[];
  52887. }>;
  52888. /**
  52889. * Load a scene
  52890. * @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)
  52891. * @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)
  52892. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52893. * @param onSuccess a callback with the scene when import succeeds
  52894. * @param onProgress a callback with a progress event for each file being loaded
  52895. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52896. * @param pluginExtension the extension used to determine the plugin
  52897. * @returns The loaded plugin
  52898. */
  52899. 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>;
  52900. /**
  52901. * Load a scene
  52902. * @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)
  52903. * @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)
  52904. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52905. * @param onProgress a callback with a progress event for each file being loaded
  52906. * @param pluginExtension the extension used to determine the plugin
  52907. * @returns The loaded scene
  52908. */
  52909. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52910. /**
  52911. * Append a scene
  52912. * @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)
  52913. * @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)
  52914. * @param scene is the instance of BABYLON.Scene to append to
  52915. * @param onSuccess a callback with the scene when import succeeds
  52916. * @param onProgress a callback with a progress event for each file being loaded
  52917. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52918. * @param pluginExtension the extension used to determine the plugin
  52919. * @returns The loaded plugin
  52920. */
  52921. 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>;
  52922. /**
  52923. * Append a scene
  52924. * @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)
  52925. * @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)
  52926. * @param scene is the instance of BABYLON.Scene to append to
  52927. * @param onProgress a callback with a progress event for each file being loaded
  52928. * @param pluginExtension the extension used to determine the plugin
  52929. * @returns The given scene
  52930. */
  52931. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52932. /**
  52933. * Load a scene into an asset container
  52934. * @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)
  52935. * @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)
  52936. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52937. * @param onSuccess a callback with the scene when import succeeds
  52938. * @param onProgress a callback with a progress event for each file being loaded
  52939. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52940. * @param pluginExtension the extension used to determine the plugin
  52941. * @returns The loaded plugin
  52942. */
  52943. 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>;
  52944. /**
  52945. * Load a scene into an asset container
  52946. * @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)
  52947. * @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)
  52948. * @param scene is the instance of Scene to append to
  52949. * @param onProgress a callback with a progress event for each file being loaded
  52950. * @param pluginExtension the extension used to determine the plugin
  52951. * @returns The loaded asset container
  52952. */
  52953. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  52954. /**
  52955. * Import animations from a file into a scene
  52956. * @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)
  52957. * @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)
  52958. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52959. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  52960. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  52961. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  52962. * @param onSuccess a callback with the scene when import succeeds
  52963. * @param onProgress a callback with a progress event for each file being loaded
  52964. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52965. * @param pluginExtension the extension used to determine the plugin
  52966. */
  52967. 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;
  52968. /**
  52969. * Import animations from a file into a scene
  52970. * @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)
  52971. * @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)
  52972. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52973. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  52974. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  52975. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  52976. * @param onSuccess a callback with the scene when import succeeds
  52977. * @param onProgress a callback with a progress event for each file being loaded
  52978. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52979. * @param pluginExtension the extension used to determine the plugin
  52980. * @returns the updated scene with imported animations
  52981. */
  52982. 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>;
  52983. }
  52984. }
  52985. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  52986. import { IDisposable, Scene } from "babylonjs/scene";
  52987. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  52988. import { Observable } from "babylonjs/Misc/observable";
  52989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52990. import { Nullable } from "babylonjs/types";
  52991. /**
  52992. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  52993. */
  52994. export type MotionControllerHandedness = "none" | "left" | "right";
  52995. /**
  52996. * The type of components available in motion controllers.
  52997. * This is not the name of the component.
  52998. */
  52999. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53000. /**
  53001. * The state of a controller component
  53002. */
  53003. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53004. /**
  53005. * The schema of motion controller layout.
  53006. * No object will be initialized using this interface
  53007. * This is used just to define the profile.
  53008. */
  53009. export interface IMotionControllerLayout {
  53010. /**
  53011. * Path to load the assets. Usually relative to the base path
  53012. */
  53013. assetPath: string;
  53014. /**
  53015. * Available components (unsorted)
  53016. */
  53017. components: {
  53018. /**
  53019. * A map of component Ids
  53020. */
  53021. [componentId: string]: {
  53022. /**
  53023. * The type of input the component outputs
  53024. */
  53025. type: MotionControllerComponentType;
  53026. /**
  53027. * The indices of this component in the gamepad object
  53028. */
  53029. gamepadIndices: {
  53030. /**
  53031. * Index of button
  53032. */
  53033. button?: number;
  53034. /**
  53035. * If available, index of x-axis
  53036. */
  53037. xAxis?: number;
  53038. /**
  53039. * If available, index of y-axis
  53040. */
  53041. yAxis?: number;
  53042. };
  53043. /**
  53044. * The mesh's root node name
  53045. */
  53046. rootNodeName: string;
  53047. /**
  53048. * Animation definitions for this model
  53049. */
  53050. visualResponses: {
  53051. [stateKey: string]: {
  53052. /**
  53053. * What property will be animated
  53054. */
  53055. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53056. /**
  53057. * What states influence this visual response
  53058. */
  53059. states: MotionControllerComponentStateType[];
  53060. /**
  53061. * Type of animation - movement or visibility
  53062. */
  53063. valueNodeProperty: "transform" | "visibility";
  53064. /**
  53065. * Base node name to move. Its position will be calculated according to the min and max nodes
  53066. */
  53067. valueNodeName?: string;
  53068. /**
  53069. * Minimum movement node
  53070. */
  53071. minNodeName?: string;
  53072. /**
  53073. * Max movement node
  53074. */
  53075. maxNodeName?: string;
  53076. };
  53077. };
  53078. /**
  53079. * If touch enabled, what is the name of node to display user feedback
  53080. */
  53081. touchPointNodeName?: string;
  53082. };
  53083. };
  53084. /**
  53085. * Is it xr standard mapping or not
  53086. */
  53087. gamepadMapping: "" | "xr-standard";
  53088. /**
  53089. * Base root node of this entire model
  53090. */
  53091. rootNodeName: string;
  53092. /**
  53093. * Defines the main button component id
  53094. */
  53095. selectComponentId: string;
  53096. }
  53097. /**
  53098. * A definition for the layout map in the input profile
  53099. */
  53100. export interface IMotionControllerLayoutMap {
  53101. /**
  53102. * Layouts with handedness type as a key
  53103. */
  53104. [handedness: string]: IMotionControllerLayout;
  53105. }
  53106. /**
  53107. * The XR Input profile schema
  53108. * Profiles can be found here:
  53109. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53110. */
  53111. export interface IMotionControllerProfile {
  53112. /**
  53113. * fallback profiles for this profileId
  53114. */
  53115. fallbackProfileIds: string[];
  53116. /**
  53117. * The layout map, with handedness as key
  53118. */
  53119. layouts: IMotionControllerLayoutMap;
  53120. /**
  53121. * The id of this profile
  53122. * correlates to the profile(s) in the xrInput.profiles array
  53123. */
  53124. profileId: string;
  53125. }
  53126. /**
  53127. * A helper-interface for the 3 meshes needed for controller button animation
  53128. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53129. */
  53130. export interface IMotionControllerButtonMeshMap {
  53131. /**
  53132. * the mesh that defines the pressed value mesh position.
  53133. * This is used to find the max-position of this button
  53134. */
  53135. pressedMesh: AbstractMesh;
  53136. /**
  53137. * the mesh that defines the unpressed value mesh position.
  53138. * This is used to find the min (or initial) position of this button
  53139. */
  53140. unpressedMesh: AbstractMesh;
  53141. /**
  53142. * The mesh that will be changed when value changes
  53143. */
  53144. valueMesh: AbstractMesh;
  53145. }
  53146. /**
  53147. * A helper-interface for the 3 meshes needed for controller axis animation.
  53148. * This will be expanded when touchpad animations are fully supported
  53149. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53150. */
  53151. export interface IMotionControllerMeshMap {
  53152. /**
  53153. * the mesh that defines the maximum value mesh position.
  53154. */
  53155. maxMesh?: AbstractMesh;
  53156. /**
  53157. * the mesh that defines the minimum value mesh position.
  53158. */
  53159. minMesh?: AbstractMesh;
  53160. /**
  53161. * The mesh that will be changed when axis value changes
  53162. */
  53163. valueMesh?: AbstractMesh;
  53164. }
  53165. /**
  53166. * The elements needed for change-detection of the gamepad objects in motion controllers
  53167. */
  53168. export interface IMinimalMotionControllerObject {
  53169. /**
  53170. * Available axes of this controller
  53171. */
  53172. axes: number[];
  53173. /**
  53174. * An array of available buttons
  53175. */
  53176. buttons: Array<{
  53177. /**
  53178. * Value of the button/trigger
  53179. */
  53180. value: number;
  53181. /**
  53182. * If the button/trigger is currently touched
  53183. */
  53184. touched: boolean;
  53185. /**
  53186. * If the button/trigger is currently pressed
  53187. */
  53188. pressed: boolean;
  53189. }>;
  53190. /**
  53191. * EXPERIMENTAL haptic support.
  53192. */
  53193. hapticActuators?: Array<{
  53194. pulse: (value: number, duration: number) => Promise<boolean>;
  53195. }>;
  53196. }
  53197. /**
  53198. * An Abstract Motion controller
  53199. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53200. * Each component has an observable to check for changes in value and state
  53201. */
  53202. export abstract class WebXRAbstractMotionController implements IDisposable {
  53203. protected scene: Scene;
  53204. protected layout: IMotionControllerLayout;
  53205. /**
  53206. * The gamepad object correlating to this controller
  53207. */
  53208. gamepadObject: IMinimalMotionControllerObject;
  53209. /**
  53210. * handedness (left/right/none) of this controller
  53211. */
  53212. handedness: MotionControllerHandedness;
  53213. private _initComponent;
  53214. private _modelReady;
  53215. /**
  53216. * A map of components (WebXRControllerComponent) in this motion controller
  53217. * Components have a ComponentType and can also have both button and axis definitions
  53218. */
  53219. readonly components: {
  53220. [id: string]: WebXRControllerComponent;
  53221. };
  53222. /**
  53223. * Disable the model's animation. Can be set at any time.
  53224. */
  53225. disableAnimation: boolean;
  53226. /**
  53227. * Observers registered here will be triggered when the model of this controller is done loading
  53228. */
  53229. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53230. /**
  53231. * The profile id of this motion controller
  53232. */
  53233. abstract profileId: string;
  53234. /**
  53235. * The root mesh of the model. It is null if the model was not yet initialized
  53236. */
  53237. rootMesh: Nullable<AbstractMesh>;
  53238. /**
  53239. * constructs a new abstract motion controller
  53240. * @param scene the scene to which the model of the controller will be added
  53241. * @param layout The profile layout to load
  53242. * @param gamepadObject The gamepad object correlating to this controller
  53243. * @param handedness handedness (left/right/none) of this controller
  53244. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53245. */
  53246. constructor(scene: Scene, layout: IMotionControllerLayout,
  53247. /**
  53248. * The gamepad object correlating to this controller
  53249. */
  53250. gamepadObject: IMinimalMotionControllerObject,
  53251. /**
  53252. * handedness (left/right/none) of this controller
  53253. */
  53254. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53255. /**
  53256. * Dispose this controller, the model mesh and all its components
  53257. */
  53258. dispose(): void;
  53259. /**
  53260. * Returns all components of specific type
  53261. * @param type the type to search for
  53262. * @return an array of components with this type
  53263. */
  53264. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53265. /**
  53266. * get a component based an its component id as defined in layout.components
  53267. * @param id the id of the component
  53268. * @returns the component correlates to the id or undefined if not found
  53269. */
  53270. getComponent(id: string): WebXRControllerComponent;
  53271. /**
  53272. * Get the list of components available in this motion controller
  53273. * @returns an array of strings correlating to available components
  53274. */
  53275. getComponentIds(): string[];
  53276. /**
  53277. * Get the first component of specific type
  53278. * @param type type of component to find
  53279. * @return a controller component or null if not found
  53280. */
  53281. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53282. /**
  53283. * Get the main (Select) component of this controller as defined in the layout
  53284. * @returns the main component of this controller
  53285. */
  53286. getMainComponent(): WebXRControllerComponent;
  53287. /**
  53288. * Loads the model correlating to this controller
  53289. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53290. * @returns A promise fulfilled with the result of the model loading
  53291. */
  53292. loadModel(): Promise<boolean>;
  53293. /**
  53294. * Update this model using the current XRFrame
  53295. * @param xrFrame the current xr frame to use and update the model
  53296. */
  53297. updateFromXRFrame(xrFrame: XRFrame): void;
  53298. /**
  53299. * Backwards compatibility due to a deeply-integrated typo
  53300. */
  53301. get handness(): XREye;
  53302. /**
  53303. * Pulse (vibrate) this controller
  53304. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53305. * Consecutive calls to this function will cancel the last pulse call
  53306. *
  53307. * @param value the strength of the pulse in 0.0...1.0 range
  53308. * @param duration Duration of the pulse in milliseconds
  53309. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53310. * @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
  53311. */
  53312. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53313. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53314. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53315. /**
  53316. * Moves the axis on the controller mesh based on its current state
  53317. * @param axis the index of the axis
  53318. * @param axisValue the value of the axis which determines the meshes new position
  53319. * @hidden
  53320. */
  53321. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53322. /**
  53323. * Update the model itself with the current frame data
  53324. * @param xrFrame the frame to use for updating the model mesh
  53325. */
  53326. protected updateModel(xrFrame: XRFrame): void;
  53327. /**
  53328. * Get the filename and path for this controller's model
  53329. * @returns a map of filename and path
  53330. */
  53331. protected abstract _getFilenameAndPath(): {
  53332. filename: string;
  53333. path: string;
  53334. };
  53335. /**
  53336. * This function is called before the mesh is loaded. It checks for loading constraints.
  53337. * For example, this function can check if the GLB loader is available
  53338. * If this function returns false, the generic controller will be loaded instead
  53339. * @returns Is the client ready to load the mesh
  53340. */
  53341. protected abstract _getModelLoadingConstraints(): boolean;
  53342. /**
  53343. * This function will be called after the model was successfully loaded and can be used
  53344. * for mesh transformations before it is available for the user
  53345. * @param meshes the loaded meshes
  53346. */
  53347. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53348. /**
  53349. * Set the root mesh for this controller. Important for the WebXR controller class
  53350. * @param meshes the loaded meshes
  53351. */
  53352. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53353. /**
  53354. * A function executed each frame that updates the mesh (if needed)
  53355. * @param xrFrame the current xrFrame
  53356. */
  53357. protected abstract _updateModel(xrFrame: XRFrame): void;
  53358. private _getGenericFilenameAndPath;
  53359. private _getGenericParentMesh;
  53360. }
  53361. }
  53362. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53363. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53365. import { Scene } from "babylonjs/scene";
  53366. /**
  53367. * A generic trigger-only motion controller for WebXR
  53368. */
  53369. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53370. /**
  53371. * Static version of the profile id of this controller
  53372. */
  53373. static ProfileId: string;
  53374. profileId: string;
  53375. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53376. protected _getFilenameAndPath(): {
  53377. filename: string;
  53378. path: string;
  53379. };
  53380. protected _getModelLoadingConstraints(): boolean;
  53381. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53382. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53383. protected _updateModel(): void;
  53384. }
  53385. }
  53386. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53387. import { Vector4 } from "babylonjs/Maths/math.vector";
  53388. import { Mesh } from "babylonjs/Meshes/mesh";
  53389. import { Scene } from "babylonjs/scene";
  53390. import { Nullable } from "babylonjs/types";
  53391. /**
  53392. * Class containing static functions to help procedurally build meshes
  53393. */
  53394. export class SphereBuilder {
  53395. /**
  53396. * Creates a sphere mesh
  53397. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53398. * * 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`)
  53399. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53400. * * 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
  53401. * * 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)
  53402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53405. * @param name defines the name of the mesh
  53406. * @param options defines the options used to create the mesh
  53407. * @param scene defines the hosting scene
  53408. * @returns the sphere mesh
  53409. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53410. */
  53411. static CreateSphere(name: string, options: {
  53412. segments?: number;
  53413. diameter?: number;
  53414. diameterX?: number;
  53415. diameterY?: number;
  53416. diameterZ?: number;
  53417. arc?: number;
  53418. slice?: number;
  53419. sideOrientation?: number;
  53420. frontUVs?: Vector4;
  53421. backUVs?: Vector4;
  53422. updatable?: boolean;
  53423. }, scene?: Nullable<Scene>): Mesh;
  53424. }
  53425. }
  53426. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53428. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53429. import { Scene } from "babylonjs/scene";
  53430. /**
  53431. * A profiled motion controller has its profile loaded from an online repository.
  53432. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53433. */
  53434. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53435. private _repositoryUrl;
  53436. private _buttonMeshMapping;
  53437. private _touchDots;
  53438. /**
  53439. * The profile ID of this controller. Will be populated when the controller initializes.
  53440. */
  53441. profileId: string;
  53442. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53443. dispose(): void;
  53444. protected _getFilenameAndPath(): {
  53445. filename: string;
  53446. path: string;
  53447. };
  53448. protected _getModelLoadingConstraints(): boolean;
  53449. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53450. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53451. protected _updateModel(_xrFrame: XRFrame): void;
  53452. }
  53453. }
  53454. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53455. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53456. import { Scene } from "babylonjs/scene";
  53457. /**
  53458. * A construction function type to create a new controller based on an xrInput object
  53459. */
  53460. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53461. /**
  53462. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53463. *
  53464. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53465. * it should be replaced with auto-loaded controllers.
  53466. *
  53467. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53468. */
  53469. export class WebXRMotionControllerManager {
  53470. private static _AvailableControllers;
  53471. private static _Fallbacks;
  53472. private static _ProfileLoadingPromises;
  53473. private static _ProfilesList;
  53474. /**
  53475. * The base URL of the online controller repository. Can be changed at any time.
  53476. */
  53477. static BaseRepositoryUrl: string;
  53478. /**
  53479. * Which repository gets priority - local or online
  53480. */
  53481. static PrioritizeOnlineRepository: boolean;
  53482. /**
  53483. * Use the online repository, or use only locally-defined controllers
  53484. */
  53485. static UseOnlineRepository: boolean;
  53486. /**
  53487. * Clear the cache used for profile loading and reload when requested again
  53488. */
  53489. static ClearProfilesCache(): void;
  53490. /**
  53491. * Register the default fallbacks.
  53492. * This function is called automatically when this file is imported.
  53493. */
  53494. static DefaultFallbacks(): void;
  53495. /**
  53496. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53497. * @param profileId the profile to which a fallback needs to be found
  53498. * @return an array with corresponding fallback profiles
  53499. */
  53500. static FindFallbackWithProfileId(profileId: string): string[];
  53501. /**
  53502. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53503. * The order of search:
  53504. *
  53505. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53506. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53507. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53508. * 4) return the generic trigger controller if none were found
  53509. *
  53510. * @param xrInput the xrInput to which a new controller is initialized
  53511. * @param scene the scene to which the model will be added
  53512. * @param forceProfile force a certain profile for this controller
  53513. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53514. */
  53515. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53516. /**
  53517. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53518. *
  53519. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53520. *
  53521. * @param type the profile type to register
  53522. * @param constructFunction the function to be called when loading this profile
  53523. */
  53524. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53525. /**
  53526. * Register a fallback to a specific profile.
  53527. * @param profileId the profileId that will receive the fallbacks
  53528. * @param fallbacks A list of fallback profiles
  53529. */
  53530. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53531. /**
  53532. * Will update the list of profiles available in the repository
  53533. * @return a promise that resolves to a map of profiles available online
  53534. */
  53535. static UpdateProfilesList(): Promise<{
  53536. [profile: string]: string;
  53537. }>;
  53538. private static _LoadProfileFromRepository;
  53539. private static _LoadProfilesFromAvailableControllers;
  53540. }
  53541. }
  53542. declare module "babylonjs/XR/webXRInputSource" {
  53543. import { Observable } from "babylonjs/Misc/observable";
  53544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53545. import { Ray } from "babylonjs/Culling/ray";
  53546. import { Scene } from "babylonjs/scene";
  53547. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53548. /**
  53549. * Configuration options for the WebXR controller creation
  53550. */
  53551. export interface IWebXRControllerOptions {
  53552. /**
  53553. * Should the controller mesh be animated when a user interacts with it
  53554. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53555. */
  53556. disableMotionControllerAnimation?: boolean;
  53557. /**
  53558. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53559. */
  53560. doNotLoadControllerMesh?: boolean;
  53561. /**
  53562. * Force a specific controller type for this controller.
  53563. * This can be used when creating your own profile or when testing different controllers
  53564. */
  53565. forceControllerProfile?: string;
  53566. /**
  53567. * Defines a rendering group ID for meshes that will be loaded.
  53568. * This is for the default controllers only.
  53569. */
  53570. renderingGroupId?: number;
  53571. }
  53572. /**
  53573. * Represents an XR controller
  53574. */
  53575. export class WebXRInputSource {
  53576. private _scene;
  53577. /** The underlying input source for the controller */
  53578. inputSource: XRInputSource;
  53579. private _options;
  53580. private _tmpVector;
  53581. private _uniqueId;
  53582. private _disposed;
  53583. /**
  53584. * 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
  53585. */
  53586. grip?: AbstractMesh;
  53587. /**
  53588. * If available, this is the gamepad object related to this controller.
  53589. * Using this object it is possible to get click events and trackpad changes of the
  53590. * webxr controller that is currently being used.
  53591. */
  53592. motionController?: WebXRAbstractMotionController;
  53593. /**
  53594. * Event that fires when the controller is removed/disposed.
  53595. * The object provided as event data is this controller, after associated assets were disposed.
  53596. * uniqueId is still available.
  53597. */
  53598. onDisposeObservable: Observable<WebXRInputSource>;
  53599. /**
  53600. * Will be triggered when the mesh associated with the motion controller is done loading.
  53601. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53602. * A shortened version of controller -> motion controller -> on mesh loaded.
  53603. */
  53604. onMeshLoadedObservable: Observable<AbstractMesh>;
  53605. /**
  53606. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53607. */
  53608. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53609. /**
  53610. * Pointer which can be used to select objects or attach a visible laser to
  53611. */
  53612. pointer: AbstractMesh;
  53613. /**
  53614. * Creates the input source object
  53615. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  53616. * @param _scene the scene which the controller should be associated to
  53617. * @param inputSource the underlying input source for the controller
  53618. * @param _options options for this controller creation
  53619. */
  53620. constructor(_scene: Scene,
  53621. /** The underlying input source for the controller */
  53622. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  53623. /**
  53624. * Get this controllers unique id
  53625. */
  53626. get uniqueId(): string;
  53627. /**
  53628. * Disposes of the object
  53629. */
  53630. dispose(): void;
  53631. /**
  53632. * Gets a world space ray coming from the pointer or grip
  53633. * @param result the resulting ray
  53634. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  53635. */
  53636. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  53637. /**
  53638. * Updates the controller pose based on the given XRFrame
  53639. * @param xrFrame xr frame to update the pose with
  53640. * @param referenceSpace reference space to use
  53641. */
  53642. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  53643. }
  53644. }
  53645. declare module "babylonjs/XR/webXRInput" {
  53646. import { Observable } from "babylonjs/Misc/observable";
  53647. import { IDisposable } from "babylonjs/scene";
  53648. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  53649. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53650. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53651. /**
  53652. * The schema for initialization options of the XR Input class
  53653. */
  53654. export interface IWebXRInputOptions {
  53655. /**
  53656. * If set to true no model will be automatically loaded
  53657. */
  53658. doNotLoadControllerMeshes?: boolean;
  53659. /**
  53660. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  53661. * If not found, the xr input profile data will be used.
  53662. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  53663. */
  53664. forceInputProfile?: string;
  53665. /**
  53666. * Do not send a request to the controller repository to load the profile.
  53667. *
  53668. * Instead, use the controllers available in babylon itself.
  53669. */
  53670. disableOnlineControllerRepository?: boolean;
  53671. /**
  53672. * A custom URL for the controllers repository
  53673. */
  53674. customControllersRepositoryURL?: string;
  53675. /**
  53676. * Should the controller model's components not move according to the user input
  53677. */
  53678. disableControllerAnimation?: boolean;
  53679. /**
  53680. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  53681. */
  53682. controllerOptions?: IWebXRControllerOptions;
  53683. }
  53684. /**
  53685. * XR input used to track XR inputs such as controllers/rays
  53686. */
  53687. export class WebXRInput implements IDisposable {
  53688. /**
  53689. * the xr session manager for this session
  53690. */
  53691. xrSessionManager: WebXRSessionManager;
  53692. /**
  53693. * the WebXR camera for this session. Mainly used for teleportation
  53694. */
  53695. xrCamera: WebXRCamera;
  53696. private readonly options;
  53697. /**
  53698. * XR controllers being tracked
  53699. */
  53700. controllers: Array<WebXRInputSource>;
  53701. private _frameObserver;
  53702. private _sessionEndedObserver;
  53703. private _sessionInitObserver;
  53704. /**
  53705. * Event when a controller has been connected/added
  53706. */
  53707. onControllerAddedObservable: Observable<WebXRInputSource>;
  53708. /**
  53709. * Event when a controller has been removed/disconnected
  53710. */
  53711. onControllerRemovedObservable: Observable<WebXRInputSource>;
  53712. /**
  53713. * Initializes the WebXRInput
  53714. * @param xrSessionManager the xr session manager for this session
  53715. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  53716. * @param options = initialization options for this xr input
  53717. */
  53718. constructor(
  53719. /**
  53720. * the xr session manager for this session
  53721. */
  53722. xrSessionManager: WebXRSessionManager,
  53723. /**
  53724. * the WebXR camera for this session. Mainly used for teleportation
  53725. */
  53726. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  53727. private _onInputSourcesChange;
  53728. private _addAndRemoveControllers;
  53729. /**
  53730. * Disposes of the object
  53731. */
  53732. dispose(): void;
  53733. }
  53734. }
  53735. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  53736. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  53737. import { Observable, EventState } from "babylonjs/Misc/observable";
  53738. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53739. /**
  53740. * This is the base class for all WebXR features.
  53741. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  53742. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  53743. */
  53744. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  53745. protected _xrSessionManager: WebXRSessionManager;
  53746. private _attached;
  53747. private _removeOnDetach;
  53748. /**
  53749. * Is this feature disposed?
  53750. */
  53751. isDisposed: boolean;
  53752. /**
  53753. * Should auto-attach be disabled?
  53754. */
  53755. disableAutoAttach: boolean;
  53756. /**
  53757. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  53758. */
  53759. xrNativeFeatureName: string;
  53760. /**
  53761. * Construct a new (abstract) WebXR feature
  53762. * @param _xrSessionManager the xr session manager for this feature
  53763. */
  53764. constructor(_xrSessionManager: WebXRSessionManager);
  53765. /**
  53766. * Is this feature attached
  53767. */
  53768. get attached(): boolean;
  53769. /**
  53770. * attach this feature
  53771. *
  53772. * @param force should attachment be forced (even when already attached)
  53773. * @returns true if successful, false is failed or already attached
  53774. */
  53775. attach(force?: boolean): boolean;
  53776. /**
  53777. * detach this feature.
  53778. *
  53779. * @returns true if successful, false if failed or already detached
  53780. */
  53781. detach(): boolean;
  53782. /**
  53783. * Dispose this feature and all of the resources attached
  53784. */
  53785. dispose(): void;
  53786. /**
  53787. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53788. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53789. *
  53790. * @returns whether or not the feature is compatible in this environment
  53791. */
  53792. isCompatible(): boolean;
  53793. /**
  53794. * This is used to register callbacks that will automatically be removed when detach is called.
  53795. * @param observable the observable to which the observer will be attached
  53796. * @param callback the callback to register
  53797. */
  53798. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  53799. /**
  53800. * Code in this function will be executed on each xrFrame received from the browser.
  53801. * This function will not execute after the feature is detached.
  53802. * @param _xrFrame the current frame
  53803. */
  53804. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  53805. }
  53806. }
  53807. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  53808. import { IDisposable, Scene } from "babylonjs/scene";
  53809. import { Nullable } from "babylonjs/types";
  53810. import { Observable } from "babylonjs/Misc/observable";
  53811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53812. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  53813. import { Camera } from "babylonjs/Cameras/camera";
  53814. /**
  53815. * Renders a layer on top of an existing scene
  53816. */
  53817. export class UtilityLayerRenderer implements IDisposable {
  53818. /** the original scene that will be rendered on top of */
  53819. originalScene: Scene;
  53820. private _pointerCaptures;
  53821. private _lastPointerEvents;
  53822. private static _DefaultUtilityLayer;
  53823. private static _DefaultKeepDepthUtilityLayer;
  53824. private _sharedGizmoLight;
  53825. private _renderCamera;
  53826. /**
  53827. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  53828. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  53829. * @returns the camera that is used when rendering the utility layer
  53830. */
  53831. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  53832. /**
  53833. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  53834. * @param cam the camera that should be used when rendering the utility layer
  53835. */
  53836. setRenderCamera(cam: Nullable<Camera>): void;
  53837. /**
  53838. * @hidden
  53839. * Light which used by gizmos to get light shading
  53840. */
  53841. _getSharedGizmoLight(): HemisphericLight;
  53842. /**
  53843. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  53844. */
  53845. pickUtilitySceneFirst: boolean;
  53846. /**
  53847. * 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)
  53848. */
  53849. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  53850. /**
  53851. * 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)
  53852. */
  53853. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  53854. /**
  53855. * The scene that is rendered on top of the original scene
  53856. */
  53857. utilityLayerScene: Scene;
  53858. /**
  53859. * If the utility layer should automatically be rendered on top of existing scene
  53860. */
  53861. shouldRender: boolean;
  53862. /**
  53863. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  53864. */
  53865. onlyCheckPointerDownEvents: boolean;
  53866. /**
  53867. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  53868. */
  53869. processAllEvents: boolean;
  53870. /**
  53871. * Observable raised when the pointer move from the utility layer scene to the main scene
  53872. */
  53873. onPointerOutObservable: Observable<number>;
  53874. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  53875. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  53876. private _afterRenderObserver;
  53877. private _sceneDisposeObserver;
  53878. private _originalPointerObserver;
  53879. /**
  53880. * Instantiates a UtilityLayerRenderer
  53881. * @param originalScene the original scene that will be rendered on top of
  53882. * @param handleEvents boolean indicating if the utility layer should handle events
  53883. */
  53884. constructor(
  53885. /** the original scene that will be rendered on top of */
  53886. originalScene: Scene, handleEvents?: boolean);
  53887. private _notifyObservers;
  53888. /**
  53889. * Renders the utility layers scene on top of the original scene
  53890. */
  53891. render(): void;
  53892. /**
  53893. * Disposes of the renderer
  53894. */
  53895. dispose(): void;
  53896. private _updateCamera;
  53897. }
  53898. }
  53899. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  53900. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53902. import { WebXRInput } from "babylonjs/XR/webXRInput";
  53903. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  53904. import { Scene } from "babylonjs/scene";
  53905. import { Nullable } from "babylonjs/types";
  53906. import { Color3 } from "babylonjs/Maths/math.color";
  53907. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  53908. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53909. /**
  53910. * Options interface for the pointer selection module
  53911. */
  53912. export interface IWebXRControllerPointerSelectionOptions {
  53913. /**
  53914. * if provided, this scene will be used to render meshes.
  53915. */
  53916. customUtilityLayerScene?: Scene;
  53917. /**
  53918. * 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)
  53919. * If not disabled, the last picked point will be used to execute a pointer up event
  53920. * If disabled, pointer up event will be triggered right after the pointer down event.
  53921. * Used in screen and gaze target ray mode only
  53922. */
  53923. disablePointerUpOnTouchOut: boolean;
  53924. /**
  53925. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  53926. */
  53927. forceGazeMode: boolean;
  53928. /**
  53929. * 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
  53930. * to start a new countdown to the pointer down event.
  53931. * Defaults to 1.
  53932. */
  53933. gazeModePointerMovedFactor?: number;
  53934. /**
  53935. * Different button type to use instead of the main component
  53936. */
  53937. overrideButtonId?: string;
  53938. /**
  53939. * use this rendering group id for the meshes (optional)
  53940. */
  53941. renderingGroupId?: number;
  53942. /**
  53943. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  53944. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  53945. * 3000 means 3 seconds between pointing at something and selecting it
  53946. */
  53947. timeToSelect?: number;
  53948. /**
  53949. * Should meshes created here be added to a utility layer or the main scene
  53950. */
  53951. useUtilityLayer?: boolean;
  53952. /**
  53953. * Optional WebXR camera to be used for gaze selection
  53954. */
  53955. gazeCamera?: WebXRCamera;
  53956. /**
  53957. * the xr input to use with this pointer selection
  53958. */
  53959. xrInput: WebXRInput;
  53960. }
  53961. /**
  53962. * A module that will enable pointer selection for motion controllers of XR Input Sources
  53963. */
  53964. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  53965. private readonly _options;
  53966. private static _idCounter;
  53967. private _attachController;
  53968. private _controllers;
  53969. private _scene;
  53970. private _tmpVectorForPickCompare;
  53971. /**
  53972. * The module's name
  53973. */
  53974. static readonly Name: string;
  53975. /**
  53976. * The (Babylon) version of this module.
  53977. * This is an integer representing the implementation version.
  53978. * This number does not correspond to the WebXR specs version
  53979. */
  53980. static readonly Version: number;
  53981. /**
  53982. * Disable lighting on the laser pointer (so it will always be visible)
  53983. */
  53984. disablePointerLighting: boolean;
  53985. /**
  53986. * Disable lighting on the selection mesh (so it will always be visible)
  53987. */
  53988. disableSelectionMeshLighting: boolean;
  53989. /**
  53990. * Should the laser pointer be displayed
  53991. */
  53992. displayLaserPointer: boolean;
  53993. /**
  53994. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  53995. */
  53996. displaySelectionMesh: boolean;
  53997. /**
  53998. * This color will be set to the laser pointer when selection is triggered
  53999. */
  54000. laserPointerPickedColor: Color3;
  54001. /**
  54002. * Default color of the laser pointer
  54003. */
  54004. laserPointerDefaultColor: Color3;
  54005. /**
  54006. * default color of the selection ring
  54007. */
  54008. selectionMeshDefaultColor: Color3;
  54009. /**
  54010. * This color will be applied to the selection ring when selection is triggered
  54011. */
  54012. selectionMeshPickedColor: Color3;
  54013. /**
  54014. * Optional filter to be used for ray selection. This predicate shares behavior with
  54015. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54016. */
  54017. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54018. /**
  54019. * constructs a new background remover module
  54020. * @param _xrSessionManager the session manager for this module
  54021. * @param _options read-only options to be used in this module
  54022. */
  54023. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54024. /**
  54025. * attach this feature
  54026. * Will usually be called by the features manager
  54027. *
  54028. * @returns true if successful.
  54029. */
  54030. attach(): boolean;
  54031. /**
  54032. * detach this feature.
  54033. * Will usually be called by the features manager
  54034. *
  54035. * @returns true if successful.
  54036. */
  54037. detach(): boolean;
  54038. /**
  54039. * Will get the mesh under a specific pointer.
  54040. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54041. * @param controllerId the controllerId to check
  54042. * @returns The mesh under pointer or null if no mesh is under the pointer
  54043. */
  54044. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54045. /**
  54046. * Get the xr controller that correlates to the pointer id in the pointer event
  54047. *
  54048. * @param id the pointer id to search for
  54049. * @returns the controller that correlates to this id or null if not found
  54050. */
  54051. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54052. protected _onXRFrame(_xrFrame: XRFrame): void;
  54053. private _attachGazeMode;
  54054. private _attachScreenRayMode;
  54055. private _attachTrackedPointerRayMode;
  54056. private _convertNormalToDirectionOfRay;
  54057. private _detachController;
  54058. private _generateNewMeshPair;
  54059. private _pickingMoved;
  54060. private _updatePointerDistance;
  54061. /** @hidden */
  54062. get lasterPointerDefaultColor(): Color3;
  54063. }
  54064. }
  54065. declare module "babylonjs/XR/webXREnterExitUI" {
  54066. import { Nullable } from "babylonjs/types";
  54067. import { Observable } from "babylonjs/Misc/observable";
  54068. import { IDisposable, Scene } from "babylonjs/scene";
  54069. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54070. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54071. /**
  54072. * Button which can be used to enter a different mode of XR
  54073. */
  54074. export class WebXREnterExitUIButton {
  54075. /** button element */
  54076. element: HTMLElement;
  54077. /** XR initialization options for the button */
  54078. sessionMode: XRSessionMode;
  54079. /** Reference space type */
  54080. referenceSpaceType: XRReferenceSpaceType;
  54081. /**
  54082. * Creates a WebXREnterExitUIButton
  54083. * @param element button element
  54084. * @param sessionMode XR initialization session mode
  54085. * @param referenceSpaceType the type of reference space to be used
  54086. */
  54087. constructor(
  54088. /** button element */
  54089. element: HTMLElement,
  54090. /** XR initialization options for the button */
  54091. sessionMode: XRSessionMode,
  54092. /** Reference space type */
  54093. referenceSpaceType: XRReferenceSpaceType);
  54094. /**
  54095. * Extendable function which can be used to update the button's visuals when the state changes
  54096. * @param activeButton the current active button in the UI
  54097. */
  54098. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54099. }
  54100. /**
  54101. * Options to create the webXR UI
  54102. */
  54103. export class WebXREnterExitUIOptions {
  54104. /**
  54105. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54106. */
  54107. customButtons?: Array<WebXREnterExitUIButton>;
  54108. /**
  54109. * A reference space type to use when creating the default button.
  54110. * Default is local-floor
  54111. */
  54112. referenceSpaceType?: XRReferenceSpaceType;
  54113. /**
  54114. * Context to enter xr with
  54115. */
  54116. renderTarget?: Nullable<WebXRRenderTarget>;
  54117. /**
  54118. * A session mode to use when creating the default button.
  54119. * Default is immersive-vr
  54120. */
  54121. sessionMode?: XRSessionMode;
  54122. /**
  54123. * A list of optional features to init the session with
  54124. */
  54125. optionalFeatures?: string[];
  54126. /**
  54127. * A list of optional features to init the session with
  54128. */
  54129. requiredFeatures?: string[];
  54130. }
  54131. /**
  54132. * UI to allow the user to enter/exit XR mode
  54133. */
  54134. export class WebXREnterExitUI implements IDisposable {
  54135. private scene;
  54136. /** version of the options passed to this UI */
  54137. options: WebXREnterExitUIOptions;
  54138. private _activeButton;
  54139. private _buttons;
  54140. /**
  54141. * The HTML Div Element to which buttons are added.
  54142. */
  54143. readonly overlay: HTMLDivElement;
  54144. /**
  54145. * Fired every time the active button is changed.
  54146. *
  54147. * When xr is entered via a button that launches xr that button will be the callback parameter
  54148. *
  54149. * When exiting xr the callback parameter will be null)
  54150. */
  54151. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54152. /**
  54153. *
  54154. * @param scene babylon scene object to use
  54155. * @param options (read-only) version of the options passed to this UI
  54156. */
  54157. private constructor();
  54158. /**
  54159. * Creates UI to allow the user to enter/exit XR mode
  54160. * @param scene the scene to add the ui to
  54161. * @param helper the xr experience helper to enter/exit xr with
  54162. * @param options options to configure the UI
  54163. * @returns the created ui
  54164. */
  54165. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54166. /**
  54167. * Disposes of the XR UI component
  54168. */
  54169. dispose(): void;
  54170. private _updateButtons;
  54171. }
  54172. }
  54173. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54174. import { Vector3 } from "babylonjs/Maths/math.vector";
  54175. import { Color4 } from "babylonjs/Maths/math.color";
  54176. import { Nullable } from "babylonjs/types";
  54177. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54178. import { Scene } from "babylonjs/scene";
  54179. /**
  54180. * Class containing static functions to help procedurally build meshes
  54181. */
  54182. export class LinesBuilder {
  54183. /**
  54184. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54185. * * 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
  54186. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54187. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54188. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54189. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54190. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54191. * * 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
  54192. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54194. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54195. * @param name defines the name of the new line system
  54196. * @param options defines the options used to create the line system
  54197. * @param scene defines the hosting scene
  54198. * @returns a new line system mesh
  54199. */
  54200. static CreateLineSystem(name: string, options: {
  54201. lines: Vector3[][];
  54202. updatable?: boolean;
  54203. instance?: Nullable<LinesMesh>;
  54204. colors?: Nullable<Color4[][]>;
  54205. useVertexAlpha?: boolean;
  54206. }, scene: Nullable<Scene>): LinesMesh;
  54207. /**
  54208. * Creates a line mesh
  54209. * 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
  54210. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54211. * * The parameter `points` is an array successive Vector3
  54212. * * 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
  54213. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54214. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54215. * * When updating an instance, remember that only point positions can change, not the number of points
  54216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54218. * @param name defines the name of the new line system
  54219. * @param options defines the options used to create the line system
  54220. * @param scene defines the hosting scene
  54221. * @returns a new line mesh
  54222. */
  54223. static CreateLines(name: string, options: {
  54224. points: Vector3[];
  54225. updatable?: boolean;
  54226. instance?: Nullable<LinesMesh>;
  54227. colors?: Color4[];
  54228. useVertexAlpha?: boolean;
  54229. }, scene?: Nullable<Scene>): LinesMesh;
  54230. /**
  54231. * Creates a dashed line mesh
  54232. * * 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
  54233. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54234. * * The parameter `points` is an array successive Vector3
  54235. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54236. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54237. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54238. * * 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
  54239. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54240. * * When updating an instance, remember that only point positions can change, not the number of points
  54241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54242. * @param name defines the name of the mesh
  54243. * @param options defines the options used to create the mesh
  54244. * @param scene defines the hosting scene
  54245. * @returns the dashed line mesh
  54246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54247. */
  54248. static CreateDashedLines(name: string, options: {
  54249. points: Vector3[];
  54250. dashSize?: number;
  54251. gapSize?: number;
  54252. dashNb?: number;
  54253. updatable?: boolean;
  54254. instance?: LinesMesh;
  54255. useVertexAlpha?: boolean;
  54256. }, scene?: Nullable<Scene>): LinesMesh;
  54257. }
  54258. }
  54259. declare module "babylonjs/Misc/timer" {
  54260. import { Observable, Observer } from "babylonjs/Misc/observable";
  54261. import { Nullable } from "babylonjs/types";
  54262. import { IDisposable } from "babylonjs/scene";
  54263. /**
  54264. * Construction options for a timer
  54265. */
  54266. export interface ITimerOptions<T> {
  54267. /**
  54268. * Time-to-end
  54269. */
  54270. timeout: number;
  54271. /**
  54272. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54273. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54274. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54275. */
  54276. contextObservable: Observable<T>;
  54277. /**
  54278. * Optional parameters when adding an observer to the observable
  54279. */
  54280. observableParameters?: {
  54281. mask?: number;
  54282. insertFirst?: boolean;
  54283. scope?: any;
  54284. };
  54285. /**
  54286. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54287. */
  54288. breakCondition?: (data?: ITimerData<T>) => boolean;
  54289. /**
  54290. * Will be triggered when the time condition has met
  54291. */
  54292. onEnded?: (data: ITimerData<any>) => void;
  54293. /**
  54294. * Will be triggered when the break condition has met (prematurely ended)
  54295. */
  54296. onAborted?: (data: ITimerData<any>) => void;
  54297. /**
  54298. * Optional function to execute on each tick (or count)
  54299. */
  54300. onTick?: (data: ITimerData<any>) => void;
  54301. }
  54302. /**
  54303. * An interface defining the data sent by the timer
  54304. */
  54305. export interface ITimerData<T> {
  54306. /**
  54307. * When did it start
  54308. */
  54309. startTime: number;
  54310. /**
  54311. * Time now
  54312. */
  54313. currentTime: number;
  54314. /**
  54315. * Time passed since started
  54316. */
  54317. deltaTime: number;
  54318. /**
  54319. * How much is completed, in [0.0...1.0].
  54320. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54321. */
  54322. completeRate: number;
  54323. /**
  54324. * What the registered observable sent in the last count
  54325. */
  54326. payload: T;
  54327. }
  54328. /**
  54329. * The current state of the timer
  54330. */
  54331. export enum TimerState {
  54332. /**
  54333. * Timer initialized, not yet started
  54334. */
  54335. INIT = 0,
  54336. /**
  54337. * Timer started and counting
  54338. */
  54339. STARTED = 1,
  54340. /**
  54341. * Timer ended (whether aborted or time reached)
  54342. */
  54343. ENDED = 2
  54344. }
  54345. /**
  54346. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54347. *
  54348. * @param options options with which to initialize this timer
  54349. */
  54350. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54351. /**
  54352. * An advanced implementation of a timer class
  54353. */
  54354. export class AdvancedTimer<T = any> implements IDisposable {
  54355. /**
  54356. * Will notify each time the timer calculates the remaining time
  54357. */
  54358. onEachCountObservable: Observable<ITimerData<T>>;
  54359. /**
  54360. * Will trigger when the timer was aborted due to the break condition
  54361. */
  54362. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54363. /**
  54364. * Will trigger when the timer ended successfully
  54365. */
  54366. onTimerEndedObservable: Observable<ITimerData<T>>;
  54367. /**
  54368. * Will trigger when the timer state has changed
  54369. */
  54370. onStateChangedObservable: Observable<TimerState>;
  54371. private _observer;
  54372. private _contextObservable;
  54373. private _observableParameters;
  54374. private _startTime;
  54375. private _timer;
  54376. private _state;
  54377. private _breakCondition;
  54378. private _timeToEnd;
  54379. private _breakOnNextTick;
  54380. /**
  54381. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54382. * @param options construction options for this advanced timer
  54383. */
  54384. constructor(options: ITimerOptions<T>);
  54385. /**
  54386. * set a breaking condition for this timer. Default is to never break during count
  54387. * @param predicate the new break condition. Returns true to break, false otherwise
  54388. */
  54389. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54390. /**
  54391. * Reset ALL associated observables in this advanced timer
  54392. */
  54393. clearObservables(): void;
  54394. /**
  54395. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54396. *
  54397. * @param timeToEnd how much time to measure until timer ended
  54398. */
  54399. start(timeToEnd?: number): void;
  54400. /**
  54401. * Will force a stop on the next tick.
  54402. */
  54403. stop(): void;
  54404. /**
  54405. * Dispose this timer, clearing all resources
  54406. */
  54407. dispose(): void;
  54408. private _setState;
  54409. private _tick;
  54410. private _stop;
  54411. }
  54412. }
  54413. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54414. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54415. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54416. import { Nullable } from "babylonjs/types";
  54417. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54419. import { Vector3 } from "babylonjs/Maths/math.vector";
  54420. import { Material } from "babylonjs/Materials/material";
  54421. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54422. import { Scene } from "babylonjs/scene";
  54423. /**
  54424. * The options container for the teleportation module
  54425. */
  54426. export interface IWebXRTeleportationOptions {
  54427. /**
  54428. * if provided, this scene will be used to render meshes.
  54429. */
  54430. customUtilityLayerScene?: Scene;
  54431. /**
  54432. * Values to configure the default target mesh
  54433. */
  54434. defaultTargetMeshOptions?: {
  54435. /**
  54436. * Fill color of the teleportation area
  54437. */
  54438. teleportationFillColor?: string;
  54439. /**
  54440. * Border color for the teleportation area
  54441. */
  54442. teleportationBorderColor?: string;
  54443. /**
  54444. * Disable the mesh's animation sequence
  54445. */
  54446. disableAnimation?: boolean;
  54447. /**
  54448. * Disable lighting on the material or the ring and arrow
  54449. */
  54450. disableLighting?: boolean;
  54451. /**
  54452. * Override the default material of the torus and arrow
  54453. */
  54454. torusArrowMaterial?: Material;
  54455. };
  54456. /**
  54457. * A list of meshes to use as floor meshes.
  54458. * Meshes can be added and removed after initializing the feature using the
  54459. * addFloorMesh and removeFloorMesh functions
  54460. * If empty, rotation will still work
  54461. */
  54462. floorMeshes?: AbstractMesh[];
  54463. /**
  54464. * use this rendering group id for the meshes (optional)
  54465. */
  54466. renderingGroupId?: number;
  54467. /**
  54468. * Should teleportation move only to snap points
  54469. */
  54470. snapPointsOnly?: boolean;
  54471. /**
  54472. * An array of points to which the teleportation will snap to.
  54473. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54474. */
  54475. snapPositions?: Vector3[];
  54476. /**
  54477. * How close should the teleportation ray be in order to snap to position.
  54478. * Default to 0.8 units (meters)
  54479. */
  54480. snapToPositionRadius?: number;
  54481. /**
  54482. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54483. * If you want to support rotation, make sure your mesh has a direction indicator.
  54484. *
  54485. * When left untouched, the default mesh will be initialized.
  54486. */
  54487. teleportationTargetMesh?: AbstractMesh;
  54488. /**
  54489. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54490. */
  54491. timeToTeleport?: number;
  54492. /**
  54493. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54494. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54495. */
  54496. useMainComponentOnly?: boolean;
  54497. /**
  54498. * Should meshes created here be added to a utility layer or the main scene
  54499. */
  54500. useUtilityLayer?: boolean;
  54501. /**
  54502. * Babylon XR Input class for controller
  54503. */
  54504. xrInput: WebXRInput;
  54505. /**
  54506. * Meshes that the teleportation ray cannot go through
  54507. */
  54508. pickBlockerMeshes?: AbstractMesh[];
  54509. }
  54510. /**
  54511. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54512. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54513. * the input of the attached controllers.
  54514. */
  54515. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54516. private _options;
  54517. private _controllers;
  54518. private _currentTeleportationControllerId;
  54519. private _floorMeshes;
  54520. private _quadraticBezierCurve;
  54521. private _selectionFeature;
  54522. private _snapToPositions;
  54523. private _snappedToPoint;
  54524. private _teleportationRingMaterial?;
  54525. private _tmpRay;
  54526. private _tmpVector;
  54527. private _tmpQuaternion;
  54528. /**
  54529. * The module's name
  54530. */
  54531. static readonly Name: string;
  54532. /**
  54533. * The (Babylon) version of this module.
  54534. * This is an integer representing the implementation version.
  54535. * This number does not correspond to the webxr specs version
  54536. */
  54537. static readonly Version: number;
  54538. /**
  54539. * Is movement backwards enabled
  54540. */
  54541. backwardsMovementEnabled: boolean;
  54542. /**
  54543. * Distance to travel when moving backwards
  54544. */
  54545. backwardsTeleportationDistance: number;
  54546. /**
  54547. * The distance from the user to the inspection point in the direction of the controller
  54548. * A higher number will allow the user to move further
  54549. * defaults to 5 (meters, in xr units)
  54550. */
  54551. parabolicCheckRadius: number;
  54552. /**
  54553. * Should the module support parabolic ray on top of direct ray
  54554. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54555. * Very helpful when moving between floors / different heights
  54556. */
  54557. parabolicRayEnabled: boolean;
  54558. /**
  54559. * How much rotation should be applied when rotating right and left
  54560. */
  54561. rotationAngle: number;
  54562. /**
  54563. * Is rotation enabled when moving forward?
  54564. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54565. */
  54566. rotationEnabled: boolean;
  54567. /**
  54568. * constructs a new anchor system
  54569. * @param _xrSessionManager an instance of WebXRSessionManager
  54570. * @param _options configuration object for this feature
  54571. */
  54572. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54573. /**
  54574. * Get the snapPointsOnly flag
  54575. */
  54576. get snapPointsOnly(): boolean;
  54577. /**
  54578. * Sets the snapPointsOnly flag
  54579. * @param snapToPoints should teleportation be exclusively to snap points
  54580. */
  54581. set snapPointsOnly(snapToPoints: boolean);
  54582. /**
  54583. * Add a new mesh to the floor meshes array
  54584. * @param mesh the mesh to use as floor mesh
  54585. */
  54586. addFloorMesh(mesh: AbstractMesh): void;
  54587. /**
  54588. * Add a new snap-to point to fix teleportation to this position
  54589. * @param newSnapPoint The new Snap-To point
  54590. */
  54591. addSnapPoint(newSnapPoint: Vector3): void;
  54592. attach(): boolean;
  54593. detach(): boolean;
  54594. dispose(): void;
  54595. /**
  54596. * Remove a mesh from the floor meshes array
  54597. * @param mesh the mesh to remove
  54598. */
  54599. removeFloorMesh(mesh: AbstractMesh): void;
  54600. /**
  54601. * Remove a mesh from the floor meshes array using its name
  54602. * @param name the mesh name to remove
  54603. */
  54604. removeFloorMeshByName(name: string): void;
  54605. /**
  54606. * 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
  54607. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  54608. * @returns was the point found and removed or not
  54609. */
  54610. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  54611. /**
  54612. * This function sets a selection feature that will be disabled when
  54613. * the forward ray is shown and will be reattached when hidden.
  54614. * This is used to remove the selection rays when moving.
  54615. * @param selectionFeature the feature to disable when forward movement is enabled
  54616. */
  54617. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  54618. protected _onXRFrame(_xrFrame: XRFrame): void;
  54619. private _attachController;
  54620. private _createDefaultTargetMesh;
  54621. private _detachController;
  54622. private _findClosestSnapPointWithRadius;
  54623. private _setTargetMeshPosition;
  54624. private _setTargetMeshVisibility;
  54625. private _showParabolicPath;
  54626. private _teleportForward;
  54627. }
  54628. }
  54629. declare module "babylonjs/XR/webXRDefaultExperience" {
  54630. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54631. import { Scene } from "babylonjs/scene";
  54632. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  54633. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  54634. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54635. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  54636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54637. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  54638. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  54639. /**
  54640. * Options for the default xr helper
  54641. */
  54642. export class WebXRDefaultExperienceOptions {
  54643. /**
  54644. * Enable or disable default UI to enter XR
  54645. */
  54646. disableDefaultUI?: boolean;
  54647. /**
  54648. * Should teleportation not initialize. defaults to false.
  54649. */
  54650. disableTeleportation?: boolean;
  54651. /**
  54652. * Floor meshes that will be used for teleport
  54653. */
  54654. floorMeshes?: Array<AbstractMesh>;
  54655. /**
  54656. * If set to true, the first frame will not be used to reset position
  54657. * The first frame is mainly used when copying transformation from the old camera
  54658. * Mainly used in AR
  54659. */
  54660. ignoreNativeCameraTransformation?: boolean;
  54661. /**
  54662. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  54663. */
  54664. inputOptions?: IWebXRInputOptions;
  54665. /**
  54666. * optional configuration for the output canvas
  54667. */
  54668. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  54669. /**
  54670. * optional UI options. This can be used among other to change session mode and reference space type
  54671. */
  54672. uiOptions?: WebXREnterExitUIOptions;
  54673. /**
  54674. * When loading teleportation and pointer select, use stable versions instead of latest.
  54675. */
  54676. useStablePlugins?: boolean;
  54677. /**
  54678. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  54679. */
  54680. renderingGroupId?: number;
  54681. /**
  54682. * A list of optional features to init the session with
  54683. * If set to true, all features we support will be added
  54684. */
  54685. optionalFeatures?: boolean | string[];
  54686. }
  54687. /**
  54688. * Default experience which provides a similar setup to the previous webVRExperience
  54689. */
  54690. export class WebXRDefaultExperience {
  54691. /**
  54692. * Base experience
  54693. */
  54694. baseExperience: WebXRExperienceHelper;
  54695. /**
  54696. * Enables ui for entering/exiting xr
  54697. */
  54698. enterExitUI: WebXREnterExitUI;
  54699. /**
  54700. * Input experience extension
  54701. */
  54702. input: WebXRInput;
  54703. /**
  54704. * Enables laser pointer and selection
  54705. */
  54706. pointerSelection: WebXRControllerPointerSelection;
  54707. /**
  54708. * Default target xr should render to
  54709. */
  54710. renderTarget: WebXRRenderTarget;
  54711. /**
  54712. * Enables teleportation
  54713. */
  54714. teleportation: WebXRMotionControllerTeleportation;
  54715. private constructor();
  54716. /**
  54717. * Creates the default xr experience
  54718. * @param scene scene
  54719. * @param options options for basic configuration
  54720. * @returns resulting WebXRDefaultExperience
  54721. */
  54722. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54723. /**
  54724. * DIsposes of the experience helper
  54725. */
  54726. dispose(): void;
  54727. }
  54728. }
  54729. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  54730. import { Observable } from "babylonjs/Misc/observable";
  54731. import { Nullable } from "babylonjs/types";
  54732. import { Camera } from "babylonjs/Cameras/camera";
  54733. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  54734. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  54735. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  54736. import { Scene } from "babylonjs/scene";
  54737. import { Vector3 } from "babylonjs/Maths/math.vector";
  54738. import { Color3 } from "babylonjs/Maths/math.color";
  54739. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54741. import { Mesh } from "babylonjs/Meshes/mesh";
  54742. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  54743. import { EasingFunction } from "babylonjs/Animations/easing";
  54744. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54745. import "babylonjs/Meshes/Builders/groundBuilder";
  54746. import "babylonjs/Meshes/Builders/torusBuilder";
  54747. import "babylonjs/Meshes/Builders/cylinderBuilder";
  54748. import "babylonjs/Gamepads/gamepadSceneComponent";
  54749. import "babylonjs/Animations/animatable";
  54750. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  54751. /**
  54752. * Options to modify the vr teleportation behavior.
  54753. */
  54754. export interface VRTeleportationOptions {
  54755. /**
  54756. * The name of the mesh which should be used as the teleportation floor. (default: null)
  54757. */
  54758. floorMeshName?: string;
  54759. /**
  54760. * A list of meshes to be used as the teleportation floor. (default: empty)
  54761. */
  54762. floorMeshes?: Mesh[];
  54763. /**
  54764. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  54765. */
  54766. teleportationMode?: number;
  54767. /**
  54768. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  54769. */
  54770. teleportationTime?: number;
  54771. /**
  54772. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  54773. */
  54774. teleportationSpeed?: number;
  54775. /**
  54776. * The easing function used in the animation or null for Linear. (default CircleEase)
  54777. */
  54778. easingFunction?: EasingFunction;
  54779. }
  54780. /**
  54781. * Options to modify the vr experience helper's behavior.
  54782. */
  54783. export interface VRExperienceHelperOptions extends WebVROptions {
  54784. /**
  54785. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  54786. */
  54787. createDeviceOrientationCamera?: boolean;
  54788. /**
  54789. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  54790. */
  54791. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  54792. /**
  54793. * Uses the main button on the controller to toggle the laser casted. (default: true)
  54794. */
  54795. laserToggle?: boolean;
  54796. /**
  54797. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  54798. */
  54799. floorMeshes?: Mesh[];
  54800. /**
  54801. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  54802. */
  54803. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  54804. /**
  54805. * Defines if WebXR should be used instead of WebVR (if available)
  54806. */
  54807. useXR?: boolean;
  54808. }
  54809. /**
  54810. * Event containing information after VR has been entered
  54811. */
  54812. export class OnAfterEnteringVRObservableEvent {
  54813. /**
  54814. * If entering vr was successful
  54815. */
  54816. success: boolean;
  54817. }
  54818. /**
  54819. * Helps to quickly add VR support to an existing scene.
  54820. * See https://doc.babylonjs.com/how_to/webvr_helper
  54821. */
  54822. export class VRExperienceHelper {
  54823. /** Options to modify the vr experience helper's behavior. */
  54824. webVROptions: VRExperienceHelperOptions;
  54825. private _scene;
  54826. private _position;
  54827. private _btnVR;
  54828. private _btnVRDisplayed;
  54829. private _webVRsupported;
  54830. private _webVRready;
  54831. private _webVRrequesting;
  54832. private _webVRpresenting;
  54833. private _hasEnteredVR;
  54834. private _fullscreenVRpresenting;
  54835. private _inputElement;
  54836. private _webVRCamera;
  54837. private _vrDeviceOrientationCamera;
  54838. private _deviceOrientationCamera;
  54839. private _existingCamera;
  54840. private _onKeyDown;
  54841. private _onVrDisplayPresentChange;
  54842. private _onVRDisplayChanged;
  54843. private _onVRRequestPresentStart;
  54844. private _onVRRequestPresentComplete;
  54845. /**
  54846. * 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)
  54847. */
  54848. enableGazeEvenWhenNoPointerLock: boolean;
  54849. /**
  54850. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  54851. */
  54852. exitVROnDoubleTap: boolean;
  54853. /**
  54854. * Observable raised right before entering VR.
  54855. */
  54856. onEnteringVRObservable: Observable<VRExperienceHelper>;
  54857. /**
  54858. * Observable raised when entering VR has completed.
  54859. */
  54860. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  54861. /**
  54862. * Observable raised when exiting VR.
  54863. */
  54864. onExitingVRObservable: Observable<VRExperienceHelper>;
  54865. /**
  54866. * Observable raised when controller mesh is loaded.
  54867. */
  54868. onControllerMeshLoadedObservable: Observable<WebVRController>;
  54869. /** Return this.onEnteringVRObservable
  54870. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  54871. */
  54872. get onEnteringVR(): Observable<VRExperienceHelper>;
  54873. /** Return this.onExitingVRObservable
  54874. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  54875. */
  54876. get onExitingVR(): Observable<VRExperienceHelper>;
  54877. /** Return this.onControllerMeshLoadedObservable
  54878. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  54879. */
  54880. get onControllerMeshLoaded(): Observable<WebVRController>;
  54881. private _rayLength;
  54882. private _useCustomVRButton;
  54883. private _teleportationRequested;
  54884. private _teleportActive;
  54885. private _floorMeshName;
  54886. private _floorMeshesCollection;
  54887. private _teleportationMode;
  54888. private _teleportationTime;
  54889. private _teleportationSpeed;
  54890. private _teleportationEasing;
  54891. private _rotationAllowed;
  54892. private _teleportBackwardsVector;
  54893. private _teleportationTarget;
  54894. private _isDefaultTeleportationTarget;
  54895. private _postProcessMove;
  54896. private _teleportationFillColor;
  54897. private _teleportationBorderColor;
  54898. private _rotationAngle;
  54899. private _haloCenter;
  54900. private _cameraGazer;
  54901. private _padSensibilityUp;
  54902. private _padSensibilityDown;
  54903. private _leftController;
  54904. private _rightController;
  54905. private _gazeColor;
  54906. private _laserColor;
  54907. private _pickedLaserColor;
  54908. private _pickedGazeColor;
  54909. /**
  54910. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  54911. */
  54912. onNewMeshSelected: Observable<AbstractMesh>;
  54913. /**
  54914. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  54915. * This observable will provide the mesh and the controller used to select the mesh
  54916. */
  54917. onMeshSelectedWithController: Observable<{
  54918. mesh: AbstractMesh;
  54919. controller: WebVRController;
  54920. }>;
  54921. /**
  54922. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  54923. */
  54924. onNewMeshPicked: Observable<PickingInfo>;
  54925. private _circleEase;
  54926. /**
  54927. * Observable raised before camera teleportation
  54928. */
  54929. onBeforeCameraTeleport: Observable<Vector3>;
  54930. /**
  54931. * Observable raised after camera teleportation
  54932. */
  54933. onAfterCameraTeleport: Observable<Vector3>;
  54934. /**
  54935. * Observable raised when current selected mesh gets unselected
  54936. */
  54937. onSelectedMeshUnselected: Observable<AbstractMesh>;
  54938. private _raySelectionPredicate;
  54939. /**
  54940. * To be optionaly changed by user to define custom ray selection
  54941. */
  54942. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54943. /**
  54944. * To be optionaly changed by user to define custom selection logic (after ray selection)
  54945. */
  54946. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54947. /**
  54948. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  54949. */
  54950. teleportationEnabled: boolean;
  54951. private _defaultHeight;
  54952. private _teleportationInitialized;
  54953. private _interactionsEnabled;
  54954. private _interactionsRequested;
  54955. private _displayGaze;
  54956. private _displayLaserPointer;
  54957. /**
  54958. * The mesh used to display where the user is going to teleport.
  54959. */
  54960. get teleportationTarget(): Mesh;
  54961. /**
  54962. * Sets the mesh to be used to display where the user is going to teleport.
  54963. */
  54964. set teleportationTarget(value: Mesh);
  54965. /**
  54966. * 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
  54967. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  54968. * See https://doc.babylonjs.com/resources/baking_transformations
  54969. */
  54970. get gazeTrackerMesh(): Mesh;
  54971. set gazeTrackerMesh(value: Mesh);
  54972. /**
  54973. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  54974. */
  54975. updateGazeTrackerScale: boolean;
  54976. /**
  54977. * If the gaze trackers color should be updated when selecting meshes
  54978. */
  54979. updateGazeTrackerColor: boolean;
  54980. /**
  54981. * If the controller laser color should be updated when selecting meshes
  54982. */
  54983. updateControllerLaserColor: boolean;
  54984. /**
  54985. * The gaze tracking mesh corresponding to the left controller
  54986. */
  54987. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  54988. /**
  54989. * The gaze tracking mesh corresponding to the right controller
  54990. */
  54991. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  54992. /**
  54993. * If the ray of the gaze should be displayed.
  54994. */
  54995. get displayGaze(): boolean;
  54996. /**
  54997. * Sets if the ray of the gaze should be displayed.
  54998. */
  54999. set displayGaze(value: boolean);
  55000. /**
  55001. * If the ray of the LaserPointer should be displayed.
  55002. */
  55003. get displayLaserPointer(): boolean;
  55004. /**
  55005. * Sets if the ray of the LaserPointer should be displayed.
  55006. */
  55007. set displayLaserPointer(value: boolean);
  55008. /**
  55009. * The deviceOrientationCamera used as the camera when not in VR.
  55010. */
  55011. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55012. /**
  55013. * Based on the current WebVR support, returns the current VR camera used.
  55014. */
  55015. get currentVRCamera(): Nullable<Camera>;
  55016. /**
  55017. * The webVRCamera which is used when in VR.
  55018. */
  55019. get webVRCamera(): WebVRFreeCamera;
  55020. /**
  55021. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55022. */
  55023. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55024. /**
  55025. * The html button that is used to trigger entering into VR.
  55026. */
  55027. get vrButton(): Nullable<HTMLButtonElement>;
  55028. private get _teleportationRequestInitiated();
  55029. /**
  55030. * Defines whether or not Pointer lock should be requested when switching to
  55031. * full screen.
  55032. */
  55033. requestPointerLockOnFullScreen: boolean;
  55034. /**
  55035. * If asking to force XR, this will be populated with the default xr experience
  55036. */
  55037. xr: WebXRDefaultExperience;
  55038. /**
  55039. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55040. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55041. */
  55042. xrTestDone: boolean;
  55043. /**
  55044. * Instantiates a VRExperienceHelper.
  55045. * Helps to quickly add VR support to an existing scene.
  55046. * @param scene The scene the VRExperienceHelper belongs to.
  55047. * @param webVROptions Options to modify the vr experience helper's behavior.
  55048. */
  55049. constructor(scene: Scene,
  55050. /** Options to modify the vr experience helper's behavior. */
  55051. webVROptions?: VRExperienceHelperOptions);
  55052. private completeVRInit;
  55053. private _onDefaultMeshLoaded;
  55054. private _onResize;
  55055. private _onFullscreenChange;
  55056. /**
  55057. * Gets a value indicating if we are currently in VR mode.
  55058. */
  55059. get isInVRMode(): boolean;
  55060. private onVrDisplayPresentChange;
  55061. private onVRDisplayChanged;
  55062. private moveButtonToBottomRight;
  55063. private displayVRButton;
  55064. private updateButtonVisibility;
  55065. private _cachedAngularSensibility;
  55066. /**
  55067. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55068. * Otherwise, will use the fullscreen API.
  55069. */
  55070. enterVR(): void;
  55071. /**
  55072. * Attempt to exit VR, or fullscreen.
  55073. */
  55074. exitVR(): void;
  55075. /**
  55076. * The position of the vr experience helper.
  55077. */
  55078. get position(): Vector3;
  55079. /**
  55080. * Sets the position of the vr experience helper.
  55081. */
  55082. set position(value: Vector3);
  55083. /**
  55084. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55085. */
  55086. enableInteractions(): void;
  55087. private get _noControllerIsActive();
  55088. private beforeRender;
  55089. private _isTeleportationFloor;
  55090. /**
  55091. * Adds a floor mesh to be used for teleportation.
  55092. * @param floorMesh the mesh to be used for teleportation.
  55093. */
  55094. addFloorMesh(floorMesh: Mesh): void;
  55095. /**
  55096. * Removes a floor mesh from being used for teleportation.
  55097. * @param floorMesh the mesh to be removed.
  55098. */
  55099. removeFloorMesh(floorMesh: Mesh): void;
  55100. /**
  55101. * Enables interactions and teleportation using the VR controllers and gaze.
  55102. * @param vrTeleportationOptions options to modify teleportation behavior.
  55103. */
  55104. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55105. private _onNewGamepadConnected;
  55106. private _tryEnableInteractionOnController;
  55107. private _onNewGamepadDisconnected;
  55108. private _enableInteractionOnController;
  55109. private _checkTeleportWithRay;
  55110. private _checkRotate;
  55111. private _checkTeleportBackwards;
  55112. private _enableTeleportationOnController;
  55113. private _createTeleportationCircles;
  55114. private _displayTeleportationTarget;
  55115. private _hideTeleportationTarget;
  55116. private _rotateCamera;
  55117. private _moveTeleportationSelectorTo;
  55118. private _workingVector;
  55119. private _workingQuaternion;
  55120. private _workingMatrix;
  55121. /**
  55122. * Time Constant Teleportation Mode
  55123. */
  55124. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55125. /**
  55126. * Speed Constant Teleportation Mode
  55127. */
  55128. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55129. /**
  55130. * Teleports the users feet to the desired location
  55131. * @param location The location where the user's feet should be placed
  55132. */
  55133. teleportCamera(location: Vector3): void;
  55134. private _convertNormalToDirectionOfRay;
  55135. private _castRayAndSelectObject;
  55136. private _notifySelectedMeshUnselected;
  55137. /**
  55138. * Permanently set new colors for the laser pointer
  55139. * @param color the new laser color
  55140. * @param pickedColor the new laser color when picked mesh detected
  55141. */
  55142. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55143. /**
  55144. * Set lighting enabled / disabled on the laser pointer of both controllers
  55145. * @param enabled should the lighting be enabled on the laser pointer
  55146. */
  55147. setLaserLightingState(enabled?: boolean): void;
  55148. /**
  55149. * Permanently set new colors for the gaze pointer
  55150. * @param color the new gaze color
  55151. * @param pickedColor the new gaze color when picked mesh detected
  55152. */
  55153. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55154. /**
  55155. * Sets the color of the laser ray from the vr controllers.
  55156. * @param color new color for the ray.
  55157. */
  55158. changeLaserColor(color: Color3): void;
  55159. /**
  55160. * Sets the color of the ray from the vr headsets gaze.
  55161. * @param color new color for the ray.
  55162. */
  55163. changeGazeColor(color: Color3): void;
  55164. /**
  55165. * Exits VR and disposes of the vr experience helper
  55166. */
  55167. dispose(): void;
  55168. /**
  55169. * Gets the name of the VRExperienceHelper class
  55170. * @returns "VRExperienceHelper"
  55171. */
  55172. getClassName(): string;
  55173. }
  55174. }
  55175. declare module "babylonjs/Cameras/VR/index" {
  55176. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55177. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55178. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55179. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55180. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55181. export * from "babylonjs/Cameras/VR/webVRCamera";
  55182. }
  55183. declare module "babylonjs/Cameras/RigModes/index" {
  55184. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55185. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55186. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55187. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55188. }
  55189. declare module "babylonjs/Cameras/index" {
  55190. export * from "babylonjs/Cameras/Inputs/index";
  55191. export * from "babylonjs/Cameras/cameraInputsManager";
  55192. export * from "babylonjs/Cameras/camera";
  55193. export * from "babylonjs/Cameras/targetCamera";
  55194. export * from "babylonjs/Cameras/freeCamera";
  55195. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55196. export * from "babylonjs/Cameras/touchCamera";
  55197. export * from "babylonjs/Cameras/arcRotateCamera";
  55198. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55199. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55200. export * from "babylonjs/Cameras/flyCamera";
  55201. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55202. export * from "babylonjs/Cameras/followCamera";
  55203. export * from "babylonjs/Cameras/followCameraInputsManager";
  55204. export * from "babylonjs/Cameras/gamepadCamera";
  55205. export * from "babylonjs/Cameras/Stereoscopic/index";
  55206. export * from "babylonjs/Cameras/universalCamera";
  55207. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55208. export * from "babylonjs/Cameras/VR/index";
  55209. export * from "babylonjs/Cameras/RigModes/index";
  55210. }
  55211. declare module "babylonjs/Collisions/index" {
  55212. export * from "babylonjs/Collisions/collider";
  55213. export * from "babylonjs/Collisions/collisionCoordinator";
  55214. export * from "babylonjs/Collisions/pickingInfo";
  55215. export * from "babylonjs/Collisions/intersectionInfo";
  55216. export * from "babylonjs/Collisions/meshCollisionData";
  55217. }
  55218. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55219. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55220. import { Vector3 } from "babylonjs/Maths/math.vector";
  55221. import { Ray } from "babylonjs/Culling/ray";
  55222. import { Plane } from "babylonjs/Maths/math.plane";
  55223. /**
  55224. * Contains an array of blocks representing the octree
  55225. */
  55226. export interface IOctreeContainer<T> {
  55227. /**
  55228. * Blocks within the octree
  55229. */
  55230. blocks: Array<OctreeBlock<T>>;
  55231. }
  55232. /**
  55233. * Class used to store a cell in an octree
  55234. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55235. */
  55236. export class OctreeBlock<T> {
  55237. /**
  55238. * Gets the content of the current block
  55239. */
  55240. entries: T[];
  55241. /**
  55242. * Gets the list of block children
  55243. */
  55244. blocks: Array<OctreeBlock<T>>;
  55245. private _depth;
  55246. private _maxDepth;
  55247. private _capacity;
  55248. private _minPoint;
  55249. private _maxPoint;
  55250. private _boundingVectors;
  55251. private _creationFunc;
  55252. /**
  55253. * Creates a new block
  55254. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55255. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55256. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55257. * @param depth defines the current depth of this block in the octree
  55258. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55259. * @param creationFunc defines a callback to call when an element is added to the block
  55260. */
  55261. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55262. /**
  55263. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55264. */
  55265. get capacity(): number;
  55266. /**
  55267. * Gets the minimum vector (in world space) of the block's bounding box
  55268. */
  55269. get minPoint(): Vector3;
  55270. /**
  55271. * Gets the maximum vector (in world space) of the block's bounding box
  55272. */
  55273. get maxPoint(): Vector3;
  55274. /**
  55275. * Add a new element to this block
  55276. * @param entry defines the element to add
  55277. */
  55278. addEntry(entry: T): void;
  55279. /**
  55280. * Remove an element from this block
  55281. * @param entry defines the element to remove
  55282. */
  55283. removeEntry(entry: T): void;
  55284. /**
  55285. * Add an array of elements to this block
  55286. * @param entries defines the array of elements to add
  55287. */
  55288. addEntries(entries: T[]): void;
  55289. /**
  55290. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55291. * @param frustumPlanes defines the frustum planes to test
  55292. * @param selection defines the array to store current content if selection is positive
  55293. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55294. */
  55295. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55296. /**
  55297. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55298. * @param sphereCenter defines the bounding sphere center
  55299. * @param sphereRadius defines the bounding sphere radius
  55300. * @param selection defines the array to store current content if selection is positive
  55301. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55302. */
  55303. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55304. /**
  55305. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55306. * @param ray defines the ray to test with
  55307. * @param selection defines the array to store current content if selection is positive
  55308. */
  55309. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55310. /**
  55311. * Subdivide the content into child blocks (this block will then be empty)
  55312. */
  55313. createInnerBlocks(): void;
  55314. /**
  55315. * @hidden
  55316. */
  55317. 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;
  55318. }
  55319. }
  55320. declare module "babylonjs/Culling/Octrees/octree" {
  55321. import { SmartArray } from "babylonjs/Misc/smartArray";
  55322. import { Vector3 } from "babylonjs/Maths/math.vector";
  55323. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55325. import { Ray } from "babylonjs/Culling/ray";
  55326. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55327. import { Plane } from "babylonjs/Maths/math.plane";
  55328. /**
  55329. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55330. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55331. */
  55332. export class Octree<T> {
  55333. /** 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.) */
  55334. maxDepth: number;
  55335. /**
  55336. * Blocks within the octree containing objects
  55337. */
  55338. blocks: Array<OctreeBlock<T>>;
  55339. /**
  55340. * Content stored in the octree
  55341. */
  55342. dynamicContent: T[];
  55343. private _maxBlockCapacity;
  55344. private _selectionContent;
  55345. private _creationFunc;
  55346. /**
  55347. * Creates a octree
  55348. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55349. * @param creationFunc function to be used to instatiate the octree
  55350. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55351. * @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.)
  55352. */
  55353. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55354. /** 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.) */
  55355. maxDepth?: number);
  55356. /**
  55357. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55358. * @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);
  55359. * @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);
  55360. * @param entries meshes to be added to the octree blocks
  55361. */
  55362. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55363. /**
  55364. * Adds a mesh to the octree
  55365. * @param entry Mesh to add to the octree
  55366. */
  55367. addMesh(entry: T): void;
  55368. /**
  55369. * Remove an element from the octree
  55370. * @param entry defines the element to remove
  55371. */
  55372. removeMesh(entry: T): void;
  55373. /**
  55374. * Selects an array of meshes within the frustum
  55375. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55376. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55377. * @returns array of meshes within the frustum
  55378. */
  55379. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55380. /**
  55381. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55382. * @param sphereCenter defines the bounding sphere center
  55383. * @param sphereRadius defines the bounding sphere radius
  55384. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55385. * @returns an array of objects that intersect the sphere
  55386. */
  55387. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55388. /**
  55389. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55390. * @param ray defines the ray to test with
  55391. * @returns array of intersected objects
  55392. */
  55393. intersectsRay(ray: Ray): SmartArray<T>;
  55394. /**
  55395. * Adds a mesh into the octree block if it intersects the block
  55396. */
  55397. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55398. /**
  55399. * Adds a submesh into the octree block if it intersects the block
  55400. */
  55401. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55402. }
  55403. }
  55404. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55405. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55406. import { Scene } from "babylonjs/scene";
  55407. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55409. import { Ray } from "babylonjs/Culling/ray";
  55410. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55411. import { Collider } from "babylonjs/Collisions/collider";
  55412. module "babylonjs/scene" {
  55413. interface Scene {
  55414. /**
  55415. * @hidden
  55416. * Backing Filed
  55417. */
  55418. _selectionOctree: Octree<AbstractMesh>;
  55419. /**
  55420. * Gets the octree used to boost mesh selection (picking)
  55421. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55422. */
  55423. selectionOctree: Octree<AbstractMesh>;
  55424. /**
  55425. * Creates or updates the octree used to boost selection (picking)
  55426. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55427. * @param maxCapacity defines the maximum capacity per leaf
  55428. * @param maxDepth defines the maximum depth of the octree
  55429. * @returns an octree of AbstractMesh
  55430. */
  55431. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55432. }
  55433. }
  55434. module "babylonjs/Meshes/abstractMesh" {
  55435. interface AbstractMesh {
  55436. /**
  55437. * @hidden
  55438. * Backing Field
  55439. */
  55440. _submeshesOctree: Octree<SubMesh>;
  55441. /**
  55442. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55443. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55444. * @param maxCapacity defines the maximum size of each block (64 by default)
  55445. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55446. * @returns the new octree
  55447. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55448. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55449. */
  55450. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55451. }
  55452. }
  55453. /**
  55454. * Defines the octree scene component responsible to manage any octrees
  55455. * in a given scene.
  55456. */
  55457. export class OctreeSceneComponent {
  55458. /**
  55459. * The component name help to identify the component in the list of scene components.
  55460. */
  55461. readonly name: string;
  55462. /**
  55463. * The scene the component belongs to.
  55464. */
  55465. scene: Scene;
  55466. /**
  55467. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55468. */
  55469. readonly checksIsEnabled: boolean;
  55470. /**
  55471. * Creates a new instance of the component for the given scene
  55472. * @param scene Defines the scene to register the component in
  55473. */
  55474. constructor(scene: Scene);
  55475. /**
  55476. * Registers the component in a given scene
  55477. */
  55478. register(): void;
  55479. /**
  55480. * Return the list of active meshes
  55481. * @returns the list of active meshes
  55482. */
  55483. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55484. /**
  55485. * Return the list of active sub meshes
  55486. * @param mesh The mesh to get the candidates sub meshes from
  55487. * @returns the list of active sub meshes
  55488. */
  55489. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55490. private _tempRay;
  55491. /**
  55492. * Return the list of sub meshes intersecting with a given local ray
  55493. * @param mesh defines the mesh to find the submesh for
  55494. * @param localRay defines the ray in local space
  55495. * @returns the list of intersecting sub meshes
  55496. */
  55497. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55498. /**
  55499. * Return the list of sub meshes colliding with a collider
  55500. * @param mesh defines the mesh to find the submesh for
  55501. * @param collider defines the collider to evaluate the collision against
  55502. * @returns the list of colliding sub meshes
  55503. */
  55504. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55505. /**
  55506. * Rebuilds the elements related to this component in case of
  55507. * context lost for instance.
  55508. */
  55509. rebuild(): void;
  55510. /**
  55511. * Disposes the component and the associated ressources.
  55512. */
  55513. dispose(): void;
  55514. }
  55515. }
  55516. declare module "babylonjs/Culling/Octrees/index" {
  55517. export * from "babylonjs/Culling/Octrees/octree";
  55518. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55519. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55520. }
  55521. declare module "babylonjs/Culling/index" {
  55522. export * from "babylonjs/Culling/boundingBox";
  55523. export * from "babylonjs/Culling/boundingInfo";
  55524. export * from "babylonjs/Culling/boundingSphere";
  55525. export * from "babylonjs/Culling/Octrees/index";
  55526. export * from "babylonjs/Culling/ray";
  55527. }
  55528. declare module "babylonjs/Gizmos/gizmo" {
  55529. import { Nullable } from "babylonjs/types";
  55530. import { IDisposable } from "babylonjs/scene";
  55531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55532. import { Mesh } from "babylonjs/Meshes/mesh";
  55533. import { Node } from "babylonjs/node";
  55534. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55535. /**
  55536. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55537. */
  55538. export class Gizmo implements IDisposable {
  55539. /** The utility layer the gizmo will be added to */
  55540. gizmoLayer: UtilityLayerRenderer;
  55541. /**
  55542. * The root mesh of the gizmo
  55543. */
  55544. _rootMesh: Mesh;
  55545. private _attachedMesh;
  55546. private _attachedNode;
  55547. /**
  55548. * Ratio for the scale of the gizmo (Default: 1)
  55549. */
  55550. protected _scaleRatio: number;
  55551. /**
  55552. * boolean updated by pointermove when a gizmo mesh is hovered
  55553. */
  55554. protected _isHovered: boolean;
  55555. /**
  55556. * Ratio for the scale of the gizmo (Default: 1)
  55557. */
  55558. set scaleRatio(value: number);
  55559. get scaleRatio(): number;
  55560. /**
  55561. * True when the mouse pointer is hovered a gizmo mesh
  55562. */
  55563. get isHovered(): boolean;
  55564. /**
  55565. * If a custom mesh has been set (Default: false)
  55566. */
  55567. protected _customMeshSet: boolean;
  55568. /**
  55569. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55570. * * When set, interactions will be enabled
  55571. */
  55572. get attachedMesh(): Nullable<AbstractMesh>;
  55573. set attachedMesh(value: Nullable<AbstractMesh>);
  55574. /**
  55575. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55576. * * When set, interactions will be enabled
  55577. */
  55578. get attachedNode(): Nullable<Node>;
  55579. set attachedNode(value: Nullable<Node>);
  55580. /**
  55581. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55582. * @param mesh The mesh to replace the default mesh of the gizmo
  55583. */
  55584. setCustomMesh(mesh: Mesh): void;
  55585. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  55586. /**
  55587. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  55588. */
  55589. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55590. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55591. /**
  55592. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  55593. */
  55594. updateGizmoPositionToMatchAttachedMesh: boolean;
  55595. /**
  55596. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  55597. */
  55598. updateScale: boolean;
  55599. protected _interactionsEnabled: boolean;
  55600. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55601. private _beforeRenderObserver;
  55602. private _tempQuaternion;
  55603. private _tempVector;
  55604. private _tempVector2;
  55605. private _tempMatrix1;
  55606. private _tempMatrix2;
  55607. private _rightHandtoLeftHandMatrix;
  55608. /**
  55609. * Creates a gizmo
  55610. * @param gizmoLayer The utility layer the gizmo will be added to
  55611. */
  55612. constructor(
  55613. /** The utility layer the gizmo will be added to */
  55614. gizmoLayer?: UtilityLayerRenderer);
  55615. /**
  55616. * Updates the gizmo to match the attached mesh's position/rotation
  55617. */
  55618. protected _update(): void;
  55619. /**
  55620. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  55621. * @param value Node, TransformNode or mesh
  55622. */
  55623. protected _matrixChanged(): void;
  55624. /**
  55625. * Disposes of the gizmo
  55626. */
  55627. dispose(): void;
  55628. }
  55629. }
  55630. declare module "babylonjs/Gizmos/planeDragGizmo" {
  55631. import { Observable } from "babylonjs/Misc/observable";
  55632. import { Nullable } from "babylonjs/types";
  55633. import { Vector3 } from "babylonjs/Maths/math.vector";
  55634. import { Color3 } from "babylonjs/Maths/math.color";
  55635. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55636. import { Node } from "babylonjs/node";
  55637. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55638. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55639. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55640. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55641. import { Scene } from "babylonjs/scene";
  55642. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55643. /**
  55644. * Single plane drag gizmo
  55645. */
  55646. export class PlaneDragGizmo extends Gizmo {
  55647. /**
  55648. * Drag behavior responsible for the gizmos dragging interactions
  55649. */
  55650. dragBehavior: PointerDragBehavior;
  55651. private _pointerObserver;
  55652. /**
  55653. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55654. */
  55655. snapDistance: number;
  55656. /**
  55657. * Event that fires each time the gizmo snaps to a new location.
  55658. * * snapDistance is the the change in distance
  55659. */
  55660. onSnapObservable: Observable<{
  55661. snapDistance: number;
  55662. }>;
  55663. private _plane;
  55664. private _coloredMaterial;
  55665. private _hoverMaterial;
  55666. private _isEnabled;
  55667. private _parent;
  55668. /** @hidden */
  55669. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  55670. /** @hidden */
  55671. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55672. /**
  55673. * Creates a PlaneDragGizmo
  55674. * @param gizmoLayer The utility layer the gizmo will be added to
  55675. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  55676. * @param color The color of the gizmo
  55677. */
  55678. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  55679. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55680. /**
  55681. * If the gizmo is enabled
  55682. */
  55683. set isEnabled(value: boolean);
  55684. get isEnabled(): boolean;
  55685. /**
  55686. * Disposes of the gizmo
  55687. */
  55688. dispose(): void;
  55689. }
  55690. }
  55691. declare module "babylonjs/Gizmos/positionGizmo" {
  55692. import { Observable } from "babylonjs/Misc/observable";
  55693. import { Nullable } from "babylonjs/types";
  55694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55695. import { Node } from "babylonjs/node";
  55696. import { Mesh } from "babylonjs/Meshes/mesh";
  55697. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55698. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  55699. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  55700. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55701. /**
  55702. * Gizmo that enables dragging a mesh along 3 axis
  55703. */
  55704. export class PositionGizmo extends Gizmo {
  55705. /**
  55706. * Internal gizmo used for interactions on the x axis
  55707. */
  55708. xGizmo: AxisDragGizmo;
  55709. /**
  55710. * Internal gizmo used for interactions on the y axis
  55711. */
  55712. yGizmo: AxisDragGizmo;
  55713. /**
  55714. * Internal gizmo used for interactions on the z axis
  55715. */
  55716. zGizmo: AxisDragGizmo;
  55717. /**
  55718. * Internal gizmo used for interactions on the yz plane
  55719. */
  55720. xPlaneGizmo: PlaneDragGizmo;
  55721. /**
  55722. * Internal gizmo used for interactions on the xz plane
  55723. */
  55724. yPlaneGizmo: PlaneDragGizmo;
  55725. /**
  55726. * Internal gizmo used for interactions on the xy plane
  55727. */
  55728. zPlaneGizmo: PlaneDragGizmo;
  55729. /**
  55730. * private variables
  55731. */
  55732. private _meshAttached;
  55733. private _nodeAttached;
  55734. private _snapDistance;
  55735. /** Fires an event when any of it's sub gizmos are dragged */
  55736. onDragStartObservable: Observable<unknown>;
  55737. /** Fires an event when any of it's sub gizmos are released from dragging */
  55738. onDragEndObservable: Observable<unknown>;
  55739. /**
  55740. * If set to true, planar drag is enabled
  55741. */
  55742. private _planarGizmoEnabled;
  55743. get attachedMesh(): Nullable<AbstractMesh>;
  55744. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55745. get attachedNode(): Nullable<Node>;
  55746. set attachedNode(node: Nullable<Node>);
  55747. /**
  55748. * True when the mouse pointer is hovering a gizmo mesh
  55749. */
  55750. get isHovered(): boolean;
  55751. /**
  55752. * Creates a PositionGizmo
  55753. * @param gizmoLayer The utility layer the gizmo will be added to
  55754. @param thickness display gizmo axis thickness
  55755. */
  55756. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55757. /**
  55758. * If the planar drag gizmo is enabled
  55759. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  55760. */
  55761. set planarGizmoEnabled(value: boolean);
  55762. get planarGizmoEnabled(): boolean;
  55763. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55764. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55765. /**
  55766. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55767. */
  55768. set snapDistance(value: number);
  55769. get snapDistance(): number;
  55770. /**
  55771. * Ratio for the scale of the gizmo (Default: 1)
  55772. */
  55773. set scaleRatio(value: number);
  55774. get scaleRatio(): number;
  55775. /**
  55776. * Disposes of the gizmo
  55777. */
  55778. dispose(): void;
  55779. /**
  55780. * CustomMeshes are not supported by this gizmo
  55781. * @param mesh The mesh to replace the default mesh of the gizmo
  55782. */
  55783. setCustomMesh(mesh: Mesh): void;
  55784. }
  55785. }
  55786. declare module "babylonjs/Gizmos/axisDragGizmo" {
  55787. import { Observable } from "babylonjs/Misc/observable";
  55788. import { Nullable } from "babylonjs/types";
  55789. import { Vector3 } from "babylonjs/Maths/math.vector";
  55790. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55791. import { Node } from "babylonjs/node";
  55792. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55793. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55794. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55795. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55796. import { Scene } from "babylonjs/scene";
  55797. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55798. import { Color3 } from "babylonjs/Maths/math.color";
  55799. /**
  55800. * Single axis drag gizmo
  55801. */
  55802. export class AxisDragGizmo extends Gizmo {
  55803. /**
  55804. * Drag behavior responsible for the gizmos dragging interactions
  55805. */
  55806. dragBehavior: PointerDragBehavior;
  55807. private _pointerObserver;
  55808. /**
  55809. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55810. */
  55811. snapDistance: number;
  55812. /**
  55813. * Event that fires each time the gizmo snaps to a new location.
  55814. * * snapDistance is the the change in distance
  55815. */
  55816. onSnapObservable: Observable<{
  55817. snapDistance: number;
  55818. }>;
  55819. private _isEnabled;
  55820. private _parent;
  55821. private _arrow;
  55822. private _coloredMaterial;
  55823. private _hoverMaterial;
  55824. /** @hidden */
  55825. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  55826. /** @hidden */
  55827. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55828. /**
  55829. * Creates an AxisDragGizmo
  55830. * @param gizmoLayer The utility layer the gizmo will be added to
  55831. * @param dragAxis The axis which the gizmo will be able to drag on
  55832. * @param color The color of the gizmo
  55833. * @param thickness display gizmo axis thickness
  55834. */
  55835. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55836. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55837. /**
  55838. * If the gizmo is enabled
  55839. */
  55840. set isEnabled(value: boolean);
  55841. get isEnabled(): boolean;
  55842. /**
  55843. * Disposes of the gizmo
  55844. */
  55845. dispose(): void;
  55846. }
  55847. }
  55848. declare module "babylonjs/Debug/axesViewer" {
  55849. import { Vector3 } from "babylonjs/Maths/math.vector";
  55850. import { Nullable } from "babylonjs/types";
  55851. import { Scene } from "babylonjs/scene";
  55852. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55853. /**
  55854. * The Axes viewer will show 3 axes in a specific point in space
  55855. */
  55856. export class AxesViewer {
  55857. private _xAxis;
  55858. private _yAxis;
  55859. private _zAxis;
  55860. private _scaleLinesFactor;
  55861. private _instanced;
  55862. /**
  55863. * Gets the hosting scene
  55864. */
  55865. scene: Nullable<Scene>;
  55866. /**
  55867. * Gets or sets a number used to scale line length
  55868. */
  55869. scaleLines: number;
  55870. /** Gets the node hierarchy used to render x-axis */
  55871. get xAxis(): TransformNode;
  55872. /** Gets the node hierarchy used to render y-axis */
  55873. get yAxis(): TransformNode;
  55874. /** Gets the node hierarchy used to render z-axis */
  55875. get zAxis(): TransformNode;
  55876. /**
  55877. * Creates a new AxesViewer
  55878. * @param scene defines the hosting scene
  55879. * @param scaleLines defines a number used to scale line length (1 by default)
  55880. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55881. * @param xAxis defines the node hierarchy used to render the x-axis
  55882. * @param yAxis defines the node hierarchy used to render the y-axis
  55883. * @param zAxis defines the node hierarchy used to render the z-axis
  55884. */
  55885. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55886. /**
  55887. * Force the viewer to update
  55888. * @param position defines the position of the viewer
  55889. * @param xaxis defines the x axis of the viewer
  55890. * @param yaxis defines the y axis of the viewer
  55891. * @param zaxis defines the z axis of the viewer
  55892. */
  55893. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55894. /**
  55895. * Creates an instance of this axes viewer.
  55896. * @returns a new axes viewer with instanced meshes
  55897. */
  55898. createInstance(): AxesViewer;
  55899. /** Releases resources */
  55900. dispose(): void;
  55901. private static _SetRenderingGroupId;
  55902. }
  55903. }
  55904. declare module "babylonjs/Debug/boneAxesViewer" {
  55905. import { Nullable } from "babylonjs/types";
  55906. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  55907. import { Vector3 } from "babylonjs/Maths/math.vector";
  55908. import { Mesh } from "babylonjs/Meshes/mesh";
  55909. import { Bone } from "babylonjs/Bones/bone";
  55910. import { Scene } from "babylonjs/scene";
  55911. /**
  55912. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55913. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55914. */
  55915. export class BoneAxesViewer extends AxesViewer {
  55916. /**
  55917. * Gets or sets the target mesh where to display the axes viewer
  55918. */
  55919. mesh: Nullable<Mesh>;
  55920. /**
  55921. * Gets or sets the target bone where to display the axes viewer
  55922. */
  55923. bone: Nullable<Bone>;
  55924. /** Gets current position */
  55925. pos: Vector3;
  55926. /** Gets direction of X axis */
  55927. xaxis: Vector3;
  55928. /** Gets direction of Y axis */
  55929. yaxis: Vector3;
  55930. /** Gets direction of Z axis */
  55931. zaxis: Vector3;
  55932. /**
  55933. * Creates a new BoneAxesViewer
  55934. * @param scene defines the hosting scene
  55935. * @param bone defines the target bone
  55936. * @param mesh defines the target mesh
  55937. * @param scaleLines defines a scaling factor for line length (1 by default)
  55938. */
  55939. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55940. /**
  55941. * Force the viewer to update
  55942. */
  55943. update(): void;
  55944. /** Releases resources */
  55945. dispose(): void;
  55946. }
  55947. }
  55948. declare module "babylonjs/Debug/debugLayer" {
  55949. import { Scene } from "babylonjs/scene";
  55950. /**
  55951. * Interface used to define scene explorer extensibility option
  55952. */
  55953. export interface IExplorerExtensibilityOption {
  55954. /**
  55955. * Define the option label
  55956. */
  55957. label: string;
  55958. /**
  55959. * Defines the action to execute on click
  55960. */
  55961. action: (entity: any) => void;
  55962. }
  55963. /**
  55964. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55965. */
  55966. export interface IExplorerExtensibilityGroup {
  55967. /**
  55968. * Defines a predicate to test if a given type mut be extended
  55969. */
  55970. predicate: (entity: any) => boolean;
  55971. /**
  55972. * Gets the list of options added to a type
  55973. */
  55974. entries: IExplorerExtensibilityOption[];
  55975. }
  55976. /**
  55977. * Interface used to define the options to use to create the Inspector
  55978. */
  55979. export interface IInspectorOptions {
  55980. /**
  55981. * Display in overlay mode (default: false)
  55982. */
  55983. overlay?: boolean;
  55984. /**
  55985. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55986. */
  55987. globalRoot?: HTMLElement;
  55988. /**
  55989. * Display the Scene explorer
  55990. */
  55991. showExplorer?: boolean;
  55992. /**
  55993. * Display the property inspector
  55994. */
  55995. showInspector?: boolean;
  55996. /**
  55997. * Display in embed mode (both panes on the right)
  55998. */
  55999. embedMode?: boolean;
  56000. /**
  56001. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  56002. */
  56003. handleResize?: boolean;
  56004. /**
  56005. * Allow the panes to popup (default: true)
  56006. */
  56007. enablePopup?: boolean;
  56008. /**
  56009. * Allow the panes to be closed by users (default: true)
  56010. */
  56011. enableClose?: boolean;
  56012. /**
  56013. * Optional list of extensibility entries
  56014. */
  56015. explorerExtensibility?: IExplorerExtensibilityGroup[];
  56016. /**
  56017. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  56018. */
  56019. inspectorURL?: string;
  56020. /**
  56021. * Optional initial tab (default to DebugLayerTab.Properties)
  56022. */
  56023. initialTab?: DebugLayerTab;
  56024. }
  56025. module "babylonjs/scene" {
  56026. interface Scene {
  56027. /**
  56028. * @hidden
  56029. * Backing field
  56030. */
  56031. _debugLayer: DebugLayer;
  56032. /**
  56033. * Gets the debug layer (aka Inspector) associated with the scene
  56034. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56035. */
  56036. debugLayer: DebugLayer;
  56037. }
  56038. }
  56039. /**
  56040. * Enum of inspector action tab
  56041. */
  56042. export enum DebugLayerTab {
  56043. /**
  56044. * Properties tag (default)
  56045. */
  56046. Properties = 0,
  56047. /**
  56048. * Debug tab
  56049. */
  56050. Debug = 1,
  56051. /**
  56052. * Statistics tab
  56053. */
  56054. Statistics = 2,
  56055. /**
  56056. * Tools tab
  56057. */
  56058. Tools = 3,
  56059. /**
  56060. * Settings tab
  56061. */
  56062. Settings = 4
  56063. }
  56064. /**
  56065. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56066. * what is happening in your scene
  56067. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56068. */
  56069. export class DebugLayer {
  56070. /**
  56071. * Define the url to get the inspector script from.
  56072. * By default it uses the babylonjs CDN.
  56073. * @ignoreNaming
  56074. */
  56075. static InspectorURL: string;
  56076. private _scene;
  56077. private BJSINSPECTOR;
  56078. private _onPropertyChangedObservable?;
  56079. /**
  56080. * Observable triggered when a property is changed through the inspector.
  56081. */
  56082. get onPropertyChangedObservable(): any;
  56083. /**
  56084. * Instantiates a new debug layer.
  56085. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56086. * what is happening in your scene
  56087. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56088. * @param scene Defines the scene to inspect
  56089. */
  56090. constructor(scene: Scene);
  56091. /** Creates the inspector window. */
  56092. private _createInspector;
  56093. /**
  56094. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56095. * @param entity defines the entity to select
  56096. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56097. */
  56098. select(entity: any, lineContainerTitles?: string | string[]): void;
  56099. /** Get the inspector from bundle or global */
  56100. private _getGlobalInspector;
  56101. /**
  56102. * Get if the inspector is visible or not.
  56103. * @returns true if visible otherwise, false
  56104. */
  56105. isVisible(): boolean;
  56106. /**
  56107. * Hide the inspector and close its window.
  56108. */
  56109. hide(): void;
  56110. /**
  56111. * Update the scene in the inspector
  56112. */
  56113. setAsActiveScene(): void;
  56114. /**
  56115. * Launch the debugLayer.
  56116. * @param config Define the configuration of the inspector
  56117. * @return a promise fulfilled when the debug layer is visible
  56118. */
  56119. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56120. }
  56121. }
  56122. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56123. import { Nullable } from "babylonjs/types";
  56124. import { Scene } from "babylonjs/scene";
  56125. import { Vector4 } from "babylonjs/Maths/math.vector";
  56126. import { Color4 } from "babylonjs/Maths/math.color";
  56127. import { Mesh } from "babylonjs/Meshes/mesh";
  56128. /**
  56129. * Class containing static functions to help procedurally build meshes
  56130. */
  56131. export class BoxBuilder {
  56132. /**
  56133. * Creates a box mesh
  56134. * * The parameter `size` sets the size (float) of each box side (default 1)
  56135. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56136. * * 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)
  56137. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56141. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56142. * @param name defines the name of the mesh
  56143. * @param options defines the options used to create the mesh
  56144. * @param scene defines the hosting scene
  56145. * @returns the box mesh
  56146. */
  56147. static CreateBox(name: string, options: {
  56148. size?: number;
  56149. width?: number;
  56150. height?: number;
  56151. depth?: number;
  56152. faceUV?: Vector4[];
  56153. faceColors?: Color4[];
  56154. sideOrientation?: number;
  56155. frontUVs?: Vector4;
  56156. backUVs?: Vector4;
  56157. wrap?: boolean;
  56158. topBaseAt?: number;
  56159. bottomBaseAt?: number;
  56160. updatable?: boolean;
  56161. }, scene?: Nullable<Scene>): Mesh;
  56162. }
  56163. }
  56164. declare module "babylonjs/Debug/physicsViewer" {
  56165. import { Nullable } from "babylonjs/types";
  56166. import { Scene } from "babylonjs/scene";
  56167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56168. import { Mesh } from "babylonjs/Meshes/mesh";
  56169. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56170. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56171. /**
  56172. * Used to show the physics impostor around the specific mesh
  56173. */
  56174. export class PhysicsViewer {
  56175. /** @hidden */
  56176. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56177. /** @hidden */
  56178. protected _meshes: Array<Nullable<AbstractMesh>>;
  56179. /** @hidden */
  56180. protected _scene: Nullable<Scene>;
  56181. /** @hidden */
  56182. protected _numMeshes: number;
  56183. /** @hidden */
  56184. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56185. private _renderFunction;
  56186. private _utilityLayer;
  56187. private _debugBoxMesh;
  56188. private _debugSphereMesh;
  56189. private _debugCylinderMesh;
  56190. private _debugMaterial;
  56191. private _debugMeshMeshes;
  56192. /**
  56193. * Creates a new PhysicsViewer
  56194. * @param scene defines the hosting scene
  56195. */
  56196. constructor(scene: Scene);
  56197. /** @hidden */
  56198. protected _updateDebugMeshes(): void;
  56199. /**
  56200. * Renders a specified physic impostor
  56201. * @param impostor defines the impostor to render
  56202. * @param targetMesh defines the mesh represented by the impostor
  56203. * @returns the new debug mesh used to render the impostor
  56204. */
  56205. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56206. /**
  56207. * Hides a specified physic impostor
  56208. * @param impostor defines the impostor to hide
  56209. */
  56210. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56211. private _getDebugMaterial;
  56212. private _getDebugBoxMesh;
  56213. private _getDebugSphereMesh;
  56214. private _getDebugCylinderMesh;
  56215. private _getDebugMeshMesh;
  56216. private _getDebugMesh;
  56217. /** Releases all resources */
  56218. dispose(): void;
  56219. }
  56220. }
  56221. declare module "babylonjs/Debug/rayHelper" {
  56222. import { Nullable } from "babylonjs/types";
  56223. import { Ray } from "babylonjs/Culling/ray";
  56224. import { Vector3 } from "babylonjs/Maths/math.vector";
  56225. import { Color3 } from "babylonjs/Maths/math.color";
  56226. import { Scene } from "babylonjs/scene";
  56227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56228. import "babylonjs/Meshes/Builders/linesBuilder";
  56229. /**
  56230. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56231. * in order to better appreciate the issue one might have.
  56232. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56233. */
  56234. export class RayHelper {
  56235. /**
  56236. * Defines the ray we are currently tryin to visualize.
  56237. */
  56238. ray: Nullable<Ray>;
  56239. private _renderPoints;
  56240. private _renderLine;
  56241. private _renderFunction;
  56242. private _scene;
  56243. private _onAfterRenderObserver;
  56244. private _onAfterStepObserver;
  56245. private _attachedToMesh;
  56246. private _meshSpaceDirection;
  56247. private _meshSpaceOrigin;
  56248. /**
  56249. * Helper function to create a colored helper in a scene in one line.
  56250. * @param ray Defines the ray we are currently tryin to visualize
  56251. * @param scene Defines the scene the ray is used in
  56252. * @param color Defines the color we want to see the ray in
  56253. * @returns The newly created ray helper.
  56254. */
  56255. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56256. /**
  56257. * Instantiate a new ray helper.
  56258. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56259. * in order to better appreciate the issue one might have.
  56260. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56261. * @param ray Defines the ray we are currently tryin to visualize
  56262. */
  56263. constructor(ray: Ray);
  56264. /**
  56265. * Shows the ray we are willing to debug.
  56266. * @param scene Defines the scene the ray needs to be rendered in
  56267. * @param color Defines the color the ray needs to be rendered in
  56268. */
  56269. show(scene: Scene, color?: Color3): void;
  56270. /**
  56271. * Hides the ray we are debugging.
  56272. */
  56273. hide(): void;
  56274. private _render;
  56275. /**
  56276. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56277. * @param mesh Defines the mesh we want the helper attached to
  56278. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56279. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56280. * @param length Defines the length of the ray
  56281. */
  56282. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56283. /**
  56284. * Detach the ray helper from the mesh it has previously been attached to.
  56285. */
  56286. detachFromMesh(): void;
  56287. private _updateToMesh;
  56288. /**
  56289. * Dispose the helper and release its associated resources.
  56290. */
  56291. dispose(): void;
  56292. }
  56293. }
  56294. declare module "babylonjs/Debug/ISkeletonViewer" {
  56295. import { Skeleton } from "babylonjs/Bones/skeleton";
  56296. import { Color3 } from "babylonjs/Maths/math.color";
  56297. /**
  56298. * Defines the options associated with the creation of a SkeletonViewer.
  56299. */
  56300. export interface ISkeletonViewerOptions {
  56301. /** Should the system pause animations before building the Viewer? */
  56302. pauseAnimations: boolean;
  56303. /** Should the system return the skeleton to rest before building? */
  56304. returnToRest: boolean;
  56305. /** public Display Mode of the Viewer */
  56306. displayMode: number;
  56307. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56308. displayOptions: ISkeletonViewerDisplayOptions;
  56309. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56310. computeBonesUsingShaders: boolean;
  56311. /** Flag ignore non weighted bones */
  56312. useAllBones: boolean;
  56313. }
  56314. /**
  56315. * Defines how to display the various bone meshes for the viewer.
  56316. */
  56317. export interface ISkeletonViewerDisplayOptions {
  56318. /** How far down to start tapering the bone spurs */
  56319. midStep?: number;
  56320. /** How big is the midStep? */
  56321. midStepFactor?: number;
  56322. /** Base for the Sphere Size */
  56323. sphereBaseSize?: number;
  56324. /** The ratio of the sphere to the longest bone in units */
  56325. sphereScaleUnit?: number;
  56326. /** Ratio for the Sphere Size */
  56327. sphereFactor?: number;
  56328. /** Whether a spur should attach its far end to the child bone position */
  56329. spurFollowsChild?: boolean;
  56330. /** Whether to show local axes or not */
  56331. showLocalAxes?: boolean;
  56332. /** Length of each local axis */
  56333. localAxesSize?: number;
  56334. }
  56335. /**
  56336. * Defines the constructor options for the BoneWeight Shader.
  56337. */
  56338. export interface IBoneWeightShaderOptions {
  56339. /** Skeleton to Map */
  56340. skeleton: Skeleton;
  56341. /** Colors for Uninfluenced bones */
  56342. colorBase?: Color3;
  56343. /** Colors for 0.0-0.25 Weight bones */
  56344. colorZero?: Color3;
  56345. /** Color for 0.25-0.5 Weight Influence */
  56346. colorQuarter?: Color3;
  56347. /** Color for 0.5-0.75 Weight Influence */
  56348. colorHalf?: Color3;
  56349. /** Color for 0.75-1 Weight Influence */
  56350. colorFull?: Color3;
  56351. /** Color for Zero Weight Influence */
  56352. targetBoneIndex?: number;
  56353. }
  56354. /**
  56355. * Simple structure of the gradient steps for the Color Map.
  56356. */
  56357. export interface ISkeletonMapShaderColorMapKnot {
  56358. /** Color of the Knot */
  56359. color: Color3;
  56360. /** Location of the Knot */
  56361. location: number;
  56362. }
  56363. /**
  56364. * Defines the constructor options for the SkeletonMap Shader.
  56365. */
  56366. export interface ISkeletonMapShaderOptions {
  56367. /** Skeleton to Map */
  56368. skeleton: Skeleton;
  56369. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56370. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56371. }
  56372. }
  56373. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56374. import { Nullable } from "babylonjs/types";
  56375. import { Scene } from "babylonjs/scene";
  56376. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56377. import { Color4 } from "babylonjs/Maths/math.color";
  56378. import { Mesh } from "babylonjs/Meshes/mesh";
  56379. /**
  56380. * Class containing static functions to help procedurally build meshes
  56381. */
  56382. export class RibbonBuilder {
  56383. /**
  56384. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56385. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56386. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56387. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56388. * * 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
  56389. * * 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
  56390. * * 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
  56391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56394. * * 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
  56395. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56396. * * 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
  56397. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56399. * @param name defines the name of the mesh
  56400. * @param options defines the options used to create the mesh
  56401. * @param scene defines the hosting scene
  56402. * @returns the ribbon mesh
  56403. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56404. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56405. */
  56406. static CreateRibbon(name: string, options: {
  56407. pathArray: Vector3[][];
  56408. closeArray?: boolean;
  56409. closePath?: boolean;
  56410. offset?: number;
  56411. updatable?: boolean;
  56412. sideOrientation?: number;
  56413. frontUVs?: Vector4;
  56414. backUVs?: Vector4;
  56415. instance?: Mesh;
  56416. invertUV?: boolean;
  56417. uvs?: Vector2[];
  56418. colors?: Color4[];
  56419. }, scene?: Nullable<Scene>): Mesh;
  56420. }
  56421. }
  56422. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56423. import { Nullable } from "babylonjs/types";
  56424. import { Scene } from "babylonjs/scene";
  56425. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56426. import { Mesh } from "babylonjs/Meshes/mesh";
  56427. /**
  56428. * Class containing static functions to help procedurally build meshes
  56429. */
  56430. export class ShapeBuilder {
  56431. /**
  56432. * 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.
  56433. * * 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.
  56434. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56435. * * 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.
  56436. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56437. * * 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
  56438. * * 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
  56439. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56444. * @param name defines the name of the mesh
  56445. * @param options defines the options used to create the mesh
  56446. * @param scene defines the hosting scene
  56447. * @returns the extruded shape mesh
  56448. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56450. */
  56451. static ExtrudeShape(name: string, options: {
  56452. shape: Vector3[];
  56453. path: Vector3[];
  56454. scale?: number;
  56455. rotation?: number;
  56456. cap?: number;
  56457. updatable?: boolean;
  56458. sideOrientation?: number;
  56459. frontUVs?: Vector4;
  56460. backUVs?: Vector4;
  56461. instance?: Mesh;
  56462. invertUV?: boolean;
  56463. }, scene?: Nullable<Scene>): Mesh;
  56464. /**
  56465. * Creates an custom extruded shape mesh.
  56466. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56467. * * 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.
  56468. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56469. * * 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
  56470. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56471. * * 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
  56472. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56473. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56474. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56475. * * 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
  56476. * * 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
  56477. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56480. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56482. * @param name defines the name of the mesh
  56483. * @param options defines the options used to create the mesh
  56484. * @param scene defines the hosting scene
  56485. * @returns the custom extruded shape mesh
  56486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56487. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56489. */
  56490. static ExtrudeShapeCustom(name: string, options: {
  56491. shape: Vector3[];
  56492. path: Vector3[];
  56493. scaleFunction?: any;
  56494. rotationFunction?: any;
  56495. ribbonCloseArray?: boolean;
  56496. ribbonClosePath?: boolean;
  56497. cap?: number;
  56498. updatable?: boolean;
  56499. sideOrientation?: number;
  56500. frontUVs?: Vector4;
  56501. backUVs?: Vector4;
  56502. instance?: Mesh;
  56503. invertUV?: boolean;
  56504. }, scene?: Nullable<Scene>): Mesh;
  56505. private static _ExtrudeShapeGeneric;
  56506. }
  56507. }
  56508. declare module "babylonjs/Debug/skeletonViewer" {
  56509. import { Color3 } from "babylonjs/Maths/math.color";
  56510. import { Scene } from "babylonjs/scene";
  56511. import { Nullable } from "babylonjs/types";
  56512. import { Skeleton } from "babylonjs/Bones/skeleton";
  56513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56514. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56515. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56516. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56517. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56518. /**
  56519. * Class used to render a debug view of a given skeleton
  56520. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56521. */
  56522. export class SkeletonViewer {
  56523. /** defines the skeleton to render */
  56524. skeleton: Skeleton;
  56525. /** defines the mesh attached to the skeleton */
  56526. mesh: AbstractMesh;
  56527. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56528. autoUpdateBonesMatrices: boolean;
  56529. /** defines the rendering group id to use with the viewer */
  56530. renderingGroupId: number;
  56531. /** is the options for the viewer */
  56532. options: Partial<ISkeletonViewerOptions>;
  56533. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56534. static readonly DISPLAY_LINES: number;
  56535. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56536. static readonly DISPLAY_SPHERES: number;
  56537. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56538. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56539. /** public static method to create a BoneWeight Shader
  56540. * @param options The constructor options
  56541. * @param scene The scene that the shader is scoped to
  56542. * @returns The created ShaderMaterial
  56543. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56544. */
  56545. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56546. /** public static method to create a BoneWeight Shader
  56547. * @param options The constructor options
  56548. * @param scene The scene that the shader is scoped to
  56549. * @returns The created ShaderMaterial
  56550. */
  56551. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56552. /** private static method to create a BoneWeight Shader
  56553. * @param size The size of the buffer to create (usually the bone count)
  56554. * @param colorMap The gradient data to generate
  56555. * @param scene The scene that the shader is scoped to
  56556. * @returns an Array of floats from the color gradient values
  56557. */
  56558. private static _CreateBoneMapColorBuffer;
  56559. /** If SkeletonViewer scene scope. */
  56560. private _scene;
  56561. /** Gets or sets the color used to render the skeleton */
  56562. color: Color3;
  56563. /** Array of the points of the skeleton fo the line view. */
  56564. private _debugLines;
  56565. /** The SkeletonViewers Mesh. */
  56566. private _debugMesh;
  56567. /** The local axes Meshes. */
  56568. private _localAxes;
  56569. /** If SkeletonViewer is enabled. */
  56570. private _isEnabled;
  56571. /** If SkeletonViewer is ready. */
  56572. private _ready;
  56573. /** SkeletonViewer render observable. */
  56574. private _obs;
  56575. /** The Utility Layer to render the gizmos in. */
  56576. private _utilityLayer;
  56577. private _boneIndices;
  56578. /** Gets the Scene. */
  56579. get scene(): Scene;
  56580. /** Gets the utilityLayer. */
  56581. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  56582. /** Checks Ready Status. */
  56583. get isReady(): Boolean;
  56584. /** Sets Ready Status. */
  56585. set ready(value: boolean);
  56586. /** Gets the debugMesh */
  56587. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  56588. /** Sets the debugMesh */
  56589. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  56590. /** Gets the displayMode */
  56591. get displayMode(): number;
  56592. /** Sets the displayMode */
  56593. set displayMode(value: number);
  56594. /**
  56595. * Creates a new SkeletonViewer
  56596. * @param skeleton defines the skeleton to render
  56597. * @param mesh defines the mesh attached to the skeleton
  56598. * @param scene defines the hosting scene
  56599. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  56600. * @param renderingGroupId defines the rendering group id to use with the viewer
  56601. * @param options All of the extra constructor options for the SkeletonViewer
  56602. */
  56603. constructor(
  56604. /** defines the skeleton to render */
  56605. skeleton: Skeleton,
  56606. /** defines the mesh attached to the skeleton */
  56607. mesh: AbstractMesh,
  56608. /** The Scene scope*/
  56609. scene: Scene,
  56610. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56611. autoUpdateBonesMatrices?: boolean,
  56612. /** defines the rendering group id to use with the viewer */
  56613. renderingGroupId?: number,
  56614. /** is the options for the viewer */
  56615. options?: Partial<ISkeletonViewerOptions>);
  56616. /** The Dynamic bindings for the update functions */
  56617. private _bindObs;
  56618. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  56619. update(): void;
  56620. /** Gets or sets a boolean indicating if the viewer is enabled */
  56621. set isEnabled(value: boolean);
  56622. get isEnabled(): boolean;
  56623. private _getBonePosition;
  56624. private _getLinesForBonesWithLength;
  56625. private _getLinesForBonesNoLength;
  56626. /** function to revert the mesh and scene back to the initial state. */
  56627. private _revert;
  56628. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  56629. private _getAbsoluteBindPoseToRef;
  56630. /** function to build and bind sphere joint points and spur bone representations. */
  56631. private _buildSpheresAndSpurs;
  56632. private _buildLocalAxes;
  56633. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  56634. private _displayLinesUpdate;
  56635. /** Changes the displayMode of the skeleton viewer
  56636. * @param mode The displayMode numerical value
  56637. */
  56638. changeDisplayMode(mode: number): void;
  56639. /** Sets a display option of the skeleton viewer
  56640. *
  56641. * | Option | Type | Default | Description |
  56642. * | ---------------- | ------- | ------- | ----------- |
  56643. * | 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`. |
  56644. * | 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`. |
  56645. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56646. * | 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`. |
  56647. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  56648. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  56649. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  56650. *
  56651. * @param option String of the option name
  56652. * @param value The numerical option value
  56653. */
  56654. changeDisplayOptions(option: string, value: number): void;
  56655. /** Release associated resources */
  56656. dispose(): void;
  56657. }
  56658. }
  56659. declare module "babylonjs/Debug/index" {
  56660. export * from "babylonjs/Debug/axesViewer";
  56661. export * from "babylonjs/Debug/boneAxesViewer";
  56662. export * from "babylonjs/Debug/debugLayer";
  56663. export * from "babylonjs/Debug/physicsViewer";
  56664. export * from "babylonjs/Debug/rayHelper";
  56665. export * from "babylonjs/Debug/skeletonViewer";
  56666. export * from "babylonjs/Debug/ISkeletonViewer";
  56667. }
  56668. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  56669. /**
  56670. * Enum for Device Types
  56671. */
  56672. export enum DeviceType {
  56673. /** Generic */
  56674. Generic = 0,
  56675. /** Keyboard */
  56676. Keyboard = 1,
  56677. /** Mouse */
  56678. Mouse = 2,
  56679. /** Touch Pointers */
  56680. Touch = 3,
  56681. /** PS4 Dual Shock */
  56682. DualShock = 4,
  56683. /** Xbox */
  56684. Xbox = 5,
  56685. /** Switch Controller */
  56686. Switch = 6
  56687. }
  56688. /**
  56689. * Enum for All Pointers (Touch/Mouse)
  56690. */
  56691. export enum PointerInput {
  56692. /** Horizontal Axis */
  56693. Horizontal = 0,
  56694. /** Vertical Axis */
  56695. Vertical = 1,
  56696. /** Left Click or Touch */
  56697. LeftClick = 2,
  56698. /** Middle Click */
  56699. MiddleClick = 3,
  56700. /** Right Click */
  56701. RightClick = 4,
  56702. /** Browser Back */
  56703. BrowserBack = 5,
  56704. /** Browser Forward */
  56705. BrowserForward = 6
  56706. }
  56707. /**
  56708. * Enum for Dual Shock Gamepad
  56709. */
  56710. export enum DualShockInput {
  56711. /** Cross */
  56712. Cross = 0,
  56713. /** Circle */
  56714. Circle = 1,
  56715. /** Square */
  56716. Square = 2,
  56717. /** Triangle */
  56718. Triangle = 3,
  56719. /** L1 */
  56720. L1 = 4,
  56721. /** R1 */
  56722. R1 = 5,
  56723. /** L2 */
  56724. L2 = 6,
  56725. /** R2 */
  56726. R2 = 7,
  56727. /** Share */
  56728. Share = 8,
  56729. /** Options */
  56730. Options = 9,
  56731. /** L3 */
  56732. L3 = 10,
  56733. /** R3 */
  56734. R3 = 11,
  56735. /** DPadUp */
  56736. DPadUp = 12,
  56737. /** DPadDown */
  56738. DPadDown = 13,
  56739. /** DPadLeft */
  56740. DPadLeft = 14,
  56741. /** DRight */
  56742. DPadRight = 15,
  56743. /** Home */
  56744. Home = 16,
  56745. /** TouchPad */
  56746. TouchPad = 17,
  56747. /** LStickXAxis */
  56748. LStickXAxis = 18,
  56749. /** LStickYAxis */
  56750. LStickYAxis = 19,
  56751. /** RStickXAxis */
  56752. RStickXAxis = 20,
  56753. /** RStickYAxis */
  56754. RStickYAxis = 21
  56755. }
  56756. /**
  56757. * Enum for Xbox Gamepad
  56758. */
  56759. export enum XboxInput {
  56760. /** A */
  56761. A = 0,
  56762. /** B */
  56763. B = 1,
  56764. /** X */
  56765. X = 2,
  56766. /** Y */
  56767. Y = 3,
  56768. /** LB */
  56769. LB = 4,
  56770. /** RB */
  56771. RB = 5,
  56772. /** LT */
  56773. LT = 6,
  56774. /** RT */
  56775. RT = 7,
  56776. /** Back */
  56777. Back = 8,
  56778. /** Start */
  56779. Start = 9,
  56780. /** LS */
  56781. LS = 10,
  56782. /** RS */
  56783. RS = 11,
  56784. /** DPadUp */
  56785. DPadUp = 12,
  56786. /** DPadDown */
  56787. DPadDown = 13,
  56788. /** DPadLeft */
  56789. DPadLeft = 14,
  56790. /** DRight */
  56791. DPadRight = 15,
  56792. /** Home */
  56793. Home = 16,
  56794. /** LStickXAxis */
  56795. LStickXAxis = 17,
  56796. /** LStickYAxis */
  56797. LStickYAxis = 18,
  56798. /** RStickXAxis */
  56799. RStickXAxis = 19,
  56800. /** RStickYAxis */
  56801. RStickYAxis = 20
  56802. }
  56803. /**
  56804. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  56805. */
  56806. export enum SwitchInput {
  56807. /** B */
  56808. B = 0,
  56809. /** A */
  56810. A = 1,
  56811. /** Y */
  56812. Y = 2,
  56813. /** X */
  56814. X = 3,
  56815. /** L */
  56816. L = 4,
  56817. /** R */
  56818. R = 5,
  56819. /** ZL */
  56820. ZL = 6,
  56821. /** ZR */
  56822. ZR = 7,
  56823. /** Minus */
  56824. Minus = 8,
  56825. /** Plus */
  56826. Plus = 9,
  56827. /** LS */
  56828. LS = 10,
  56829. /** RS */
  56830. RS = 11,
  56831. /** DPadUp */
  56832. DPadUp = 12,
  56833. /** DPadDown */
  56834. DPadDown = 13,
  56835. /** DPadLeft */
  56836. DPadLeft = 14,
  56837. /** DRight */
  56838. DPadRight = 15,
  56839. /** Home */
  56840. Home = 16,
  56841. /** Capture */
  56842. Capture = 17,
  56843. /** LStickXAxis */
  56844. LStickXAxis = 18,
  56845. /** LStickYAxis */
  56846. LStickYAxis = 19,
  56847. /** RStickXAxis */
  56848. RStickXAxis = 20,
  56849. /** RStickYAxis */
  56850. RStickYAxis = 21
  56851. }
  56852. }
  56853. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  56854. import { Engine } from "babylonjs/Engines/engine";
  56855. import { IDisposable } from "babylonjs/scene";
  56856. import { Nullable } from "babylonjs/types";
  56857. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56858. /**
  56859. * This class will take all inputs from Keyboard, Pointer, and
  56860. * any Gamepads and provide a polling system that all devices
  56861. * will use. This class assumes that there will only be one
  56862. * pointer device and one keyboard.
  56863. */
  56864. export class DeviceInputSystem implements IDisposable {
  56865. /**
  56866. * Callback to be triggered when a device is connected
  56867. */
  56868. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56869. /**
  56870. * Callback to be triggered when a device is disconnected
  56871. */
  56872. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56873. /**
  56874. * Callback to be triggered when event driven input is updated
  56875. */
  56876. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  56877. private _inputs;
  56878. private _gamepads;
  56879. private _keyboardActive;
  56880. private _pointerActive;
  56881. private _elementToAttachTo;
  56882. private _keyboardDownEvent;
  56883. private _keyboardUpEvent;
  56884. private _pointerMoveEvent;
  56885. private _pointerDownEvent;
  56886. private _pointerUpEvent;
  56887. private _gamepadConnectedEvent;
  56888. private _gamepadDisconnectedEvent;
  56889. private static _MAX_KEYCODES;
  56890. private static _MAX_POINTER_INPUTS;
  56891. private constructor();
  56892. /**
  56893. * Creates a new DeviceInputSystem instance
  56894. * @param engine Engine to pull input element from
  56895. * @returns The new instance
  56896. */
  56897. static Create(engine: Engine): DeviceInputSystem;
  56898. /**
  56899. * Checks for current device input value, given an id and input index
  56900. * @param deviceName Id of connected device
  56901. * @param inputIndex Index of device input
  56902. * @returns Current value of input
  56903. */
  56904. /**
  56905. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  56906. * @param deviceType Enum specifiying device type
  56907. * @param deviceSlot "Slot" or index that device is referenced in
  56908. * @param inputIndex Id of input to be checked
  56909. * @returns Current value of input
  56910. */
  56911. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  56912. /**
  56913. * Dispose of all the eventlisteners
  56914. */
  56915. dispose(): void;
  56916. /**
  56917. * Add device and inputs to device array
  56918. * @param deviceType Enum specifiying device type
  56919. * @param deviceSlot "Slot" or index that device is referenced in
  56920. * @param numberOfInputs Number of input entries to create for given device
  56921. */
  56922. private _registerDevice;
  56923. /**
  56924. * Given a specific device name, remove that device from the device map
  56925. * @param deviceType Enum specifiying device type
  56926. * @param deviceSlot "Slot" or index that device is referenced in
  56927. */
  56928. private _unregisterDevice;
  56929. /**
  56930. * Handle all actions that come from keyboard interaction
  56931. */
  56932. private _handleKeyActions;
  56933. /**
  56934. * Handle all actions that come from pointer interaction
  56935. */
  56936. private _handlePointerActions;
  56937. /**
  56938. * Handle all actions that come from gamepad interaction
  56939. */
  56940. private _handleGamepadActions;
  56941. /**
  56942. * Update all non-event based devices with each frame
  56943. * @param deviceType Enum specifiying device type
  56944. * @param deviceSlot "Slot" or index that device is referenced in
  56945. * @param inputIndex Id of input to be checked
  56946. */
  56947. private _updateDevice;
  56948. /**
  56949. * Gets DeviceType from the device name
  56950. * @param deviceName Name of Device from DeviceInputSystem
  56951. * @returns DeviceType enum value
  56952. */
  56953. private _getGamepadDeviceType;
  56954. }
  56955. }
  56956. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  56957. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56958. /**
  56959. * Type to handle enforcement of inputs
  56960. */
  56961. 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;
  56962. }
  56963. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  56964. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  56965. import { Engine } from "babylonjs/Engines/engine";
  56966. import { IDisposable } from "babylonjs/scene";
  56967. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56968. import { Nullable } from "babylonjs/types";
  56969. import { Observable } from "babylonjs/Misc/observable";
  56970. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  56971. /**
  56972. * Class that handles all input for a specific device
  56973. */
  56974. export class DeviceSource<T extends DeviceType> {
  56975. /** Type of device */
  56976. readonly deviceType: DeviceType;
  56977. /** "Slot" or index that device is referenced in */
  56978. readonly deviceSlot: number;
  56979. /**
  56980. * Observable to handle device input changes per device
  56981. */
  56982. readonly onInputChangedObservable: Observable<{
  56983. inputIndex: DeviceInput<T>;
  56984. previousState: Nullable<number>;
  56985. currentState: Nullable<number>;
  56986. }>;
  56987. private readonly _deviceInputSystem;
  56988. /**
  56989. * Default Constructor
  56990. * @param deviceInputSystem Reference to DeviceInputSystem
  56991. * @param deviceType Type of device
  56992. * @param deviceSlot "Slot" or index that device is referenced in
  56993. */
  56994. constructor(deviceInputSystem: DeviceInputSystem,
  56995. /** Type of device */
  56996. deviceType: DeviceType,
  56997. /** "Slot" or index that device is referenced in */
  56998. deviceSlot?: number);
  56999. /**
  57000. * Get input for specific input
  57001. * @param inputIndex index of specific input on device
  57002. * @returns Input value from DeviceInputSystem
  57003. */
  57004. getInput(inputIndex: DeviceInput<T>): number;
  57005. }
  57006. /**
  57007. * Class to keep track of devices
  57008. */
  57009. export class DeviceSourceManager implements IDisposable {
  57010. /**
  57011. * Observable to be triggered when before a device is connected
  57012. */
  57013. readonly onBeforeDeviceConnectedObservable: Observable<{
  57014. deviceType: DeviceType;
  57015. deviceSlot: number;
  57016. }>;
  57017. /**
  57018. * Observable to be triggered when before a device is disconnected
  57019. */
  57020. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  57021. deviceType: DeviceType;
  57022. deviceSlot: number;
  57023. }>;
  57024. /**
  57025. * Observable to be triggered when after a device is connected
  57026. */
  57027. readonly onAfterDeviceConnectedObservable: Observable<{
  57028. deviceType: DeviceType;
  57029. deviceSlot: number;
  57030. }>;
  57031. /**
  57032. * Observable to be triggered when after a device is disconnected
  57033. */
  57034. readonly onAfterDeviceDisconnectedObservable: Observable<{
  57035. deviceType: DeviceType;
  57036. deviceSlot: number;
  57037. }>;
  57038. private readonly _devices;
  57039. private readonly _firstDevice;
  57040. private readonly _deviceInputSystem;
  57041. /**
  57042. * Default Constructor
  57043. * @param engine engine to pull input element from
  57044. */
  57045. constructor(engine: Engine);
  57046. /**
  57047. * Gets a DeviceSource, given a type and slot
  57048. * @param deviceType Enum specifying device type
  57049. * @param deviceSlot "Slot" or index that device is referenced in
  57050. * @returns DeviceSource object
  57051. */
  57052. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  57053. /**
  57054. * Gets an array of DeviceSource objects for a given device type
  57055. * @param deviceType Enum specifying device type
  57056. * @returns Array of DeviceSource objects
  57057. */
  57058. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  57059. /**
  57060. * Dispose of DeviceInputSystem and other parts
  57061. */
  57062. dispose(): void;
  57063. /**
  57064. * Function to add device name to device list
  57065. * @param deviceType Enum specifying device type
  57066. * @param deviceSlot "Slot" or index that device is referenced in
  57067. */
  57068. private _addDevice;
  57069. /**
  57070. * Function to remove device name to device list
  57071. * @param deviceType Enum specifying device type
  57072. * @param deviceSlot "Slot" or index that device is referenced in
  57073. */
  57074. private _removeDevice;
  57075. /**
  57076. * Updates array storing first connected device of each type
  57077. * @param type Type of Device
  57078. */
  57079. private _updateFirstDevices;
  57080. }
  57081. }
  57082. declare module "babylonjs/DeviceInput/index" {
  57083. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57084. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57085. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57086. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57087. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57088. }
  57089. declare module "babylonjs/Engines/nullEngine" {
  57090. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57091. import { Engine } from "babylonjs/Engines/engine";
  57092. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57093. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57094. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57095. import { Effect } from "babylonjs/Materials/effect";
  57096. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57097. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57098. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57099. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57100. /**
  57101. * Options to create the null engine
  57102. */
  57103. export class NullEngineOptions {
  57104. /**
  57105. * Render width (Default: 512)
  57106. */
  57107. renderWidth: number;
  57108. /**
  57109. * Render height (Default: 256)
  57110. */
  57111. renderHeight: number;
  57112. /**
  57113. * Texture size (Default: 512)
  57114. */
  57115. textureSize: number;
  57116. /**
  57117. * If delta time between frames should be constant
  57118. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57119. */
  57120. deterministicLockstep: boolean;
  57121. /**
  57122. * Maximum about of steps between frames (Default: 4)
  57123. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57124. */
  57125. lockstepMaxSteps: number;
  57126. /**
  57127. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57128. */
  57129. useHighPrecisionMatrix?: boolean;
  57130. }
  57131. /**
  57132. * The null engine class provides support for headless version of babylon.js.
  57133. * This can be used in server side scenario or for testing purposes
  57134. */
  57135. export class NullEngine extends Engine {
  57136. private _options;
  57137. /**
  57138. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57139. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57140. * @returns true if engine is in deterministic lock step mode
  57141. */
  57142. isDeterministicLockStep(): boolean;
  57143. /**
  57144. * Gets the max steps when engine is running in deterministic lock step
  57145. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57146. * @returns the max steps
  57147. */
  57148. getLockstepMaxSteps(): number;
  57149. /**
  57150. * Gets the current hardware scaling level.
  57151. * By default the hardware scaling level is computed from the window device ratio.
  57152. * 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.
  57153. * @returns a number indicating the current hardware scaling level
  57154. */
  57155. getHardwareScalingLevel(): number;
  57156. constructor(options?: NullEngineOptions);
  57157. /**
  57158. * Creates a vertex buffer
  57159. * @param vertices the data for the vertex buffer
  57160. * @returns the new WebGL static buffer
  57161. */
  57162. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57163. /**
  57164. * Creates a new index buffer
  57165. * @param indices defines the content of the index buffer
  57166. * @param updatable defines if the index buffer must be updatable
  57167. * @returns a new webGL buffer
  57168. */
  57169. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57170. /**
  57171. * Clear the current render buffer or the current render target (if any is set up)
  57172. * @param color defines the color to use
  57173. * @param backBuffer defines if the back buffer must be cleared
  57174. * @param depth defines if the depth buffer must be cleared
  57175. * @param stencil defines if the stencil buffer must be cleared
  57176. */
  57177. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57178. /**
  57179. * Gets the current render width
  57180. * @param useScreen defines if screen size must be used (or the current render target if any)
  57181. * @returns a number defining the current render width
  57182. */
  57183. getRenderWidth(useScreen?: boolean): number;
  57184. /**
  57185. * Gets the current render height
  57186. * @param useScreen defines if screen size must be used (or the current render target if any)
  57187. * @returns a number defining the current render height
  57188. */
  57189. getRenderHeight(useScreen?: boolean): number;
  57190. /**
  57191. * Set the WebGL's viewport
  57192. * @param viewport defines the viewport element to be used
  57193. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57194. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57195. */
  57196. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57197. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57198. /**
  57199. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57200. * @param pipelineContext defines the pipeline context to use
  57201. * @param uniformsNames defines the list of uniform names
  57202. * @returns an array of webGL uniform locations
  57203. */
  57204. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57205. /**
  57206. * Gets the lsit of active attributes for a given webGL program
  57207. * @param pipelineContext defines the pipeline context to use
  57208. * @param attributesNames defines the list of attribute names to get
  57209. * @returns an array of indices indicating the offset of each attribute
  57210. */
  57211. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57212. /**
  57213. * Binds an effect to the webGL context
  57214. * @param effect defines the effect to bind
  57215. */
  57216. bindSamplers(effect: Effect): void;
  57217. /**
  57218. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57219. * @param effect defines the effect to activate
  57220. */
  57221. enableEffect(effect: Effect): void;
  57222. /**
  57223. * Set various states to the webGL context
  57224. * @param culling defines backface culling state
  57225. * @param zOffset defines the value to apply to zOffset (0 by default)
  57226. * @param force defines if states must be applied even if cache is up to date
  57227. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57228. */
  57229. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57230. /**
  57231. * Set the value of an uniform to an array of int32
  57232. * @param uniform defines the webGL uniform location where to store the value
  57233. * @param array defines the array of int32 to store
  57234. * @returns true if value was set
  57235. */
  57236. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57237. /**
  57238. * Set the value of an uniform to an array of int32 (stored as vec2)
  57239. * @param uniform defines the webGL uniform location where to store the value
  57240. * @param array defines the array of int32 to store
  57241. * @returns true if value was set
  57242. */
  57243. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57244. /**
  57245. * Set the value of an uniform to an array of int32 (stored as vec3)
  57246. * @param uniform defines the webGL uniform location where to store the value
  57247. * @param array defines the array of int32 to store
  57248. * @returns true if value was set
  57249. */
  57250. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57251. /**
  57252. * Set the value of an uniform to an array of int32 (stored as vec4)
  57253. * @param uniform defines the webGL uniform location where to store the value
  57254. * @param array defines the array of int32 to store
  57255. * @returns true if value was set
  57256. */
  57257. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57258. /**
  57259. * Set the value of an uniform to an array of float32
  57260. * @param uniform defines the webGL uniform location where to store the value
  57261. * @param array defines the array of float32 to store
  57262. * @returns true if value was set
  57263. */
  57264. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57265. /**
  57266. * Set the value of an uniform to an array of float32 (stored as vec2)
  57267. * @param uniform defines the webGL uniform location where to store the value
  57268. * @param array defines the array of float32 to store
  57269. * @returns true if value was set
  57270. */
  57271. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57272. /**
  57273. * Set the value of an uniform to an array of float32 (stored as vec3)
  57274. * @param uniform defines the webGL uniform location where to store the value
  57275. * @param array defines the array of float32 to store
  57276. * @returns true if value was set
  57277. */
  57278. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57279. /**
  57280. * Set the value of an uniform to an array of float32 (stored as vec4)
  57281. * @param uniform defines the webGL uniform location where to store the value
  57282. * @param array defines the array of float32 to store
  57283. * @returns true if value was set
  57284. */
  57285. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57286. /**
  57287. * Set the value of an uniform to an array of number
  57288. * @param uniform defines the webGL uniform location where to store the value
  57289. * @param array defines the array of number to store
  57290. * @returns true if value was set
  57291. */
  57292. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57293. /**
  57294. * Set the value of an uniform to an array of number (stored as vec2)
  57295. * @param uniform defines the webGL uniform location where to store the value
  57296. * @param array defines the array of number to store
  57297. * @returns true if value was set
  57298. */
  57299. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57300. /**
  57301. * Set the value of an uniform to an array of number (stored as vec3)
  57302. * @param uniform defines the webGL uniform location where to store the value
  57303. * @param array defines the array of number to store
  57304. * @returns true if value was set
  57305. */
  57306. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57307. /**
  57308. * Set the value of an uniform to an array of number (stored as vec4)
  57309. * @param uniform defines the webGL uniform location where to store the value
  57310. * @param array defines the array of number to store
  57311. * @returns true if value was set
  57312. */
  57313. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57314. /**
  57315. * Set the value of an uniform to an array of float32 (stored as matrices)
  57316. * @param uniform defines the webGL uniform location where to store the value
  57317. * @param matrices defines the array of float32 to store
  57318. * @returns true if value was set
  57319. */
  57320. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57321. /**
  57322. * Set the value of an uniform to a matrix (3x3)
  57323. * @param uniform defines the webGL uniform location where to store the value
  57324. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57325. * @returns true if value was set
  57326. */
  57327. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57328. /**
  57329. * Set the value of an uniform to a matrix (2x2)
  57330. * @param uniform defines the webGL uniform location where to store the value
  57331. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57332. * @returns true if value was set
  57333. */
  57334. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57335. /**
  57336. * Set the value of an uniform to a number (float)
  57337. * @param uniform defines the webGL uniform location where to store the value
  57338. * @param value defines the float number to store
  57339. * @returns true if value was set
  57340. */
  57341. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57342. /**
  57343. * Set the value of an uniform to a vec2
  57344. * @param uniform defines the webGL uniform location where to store the value
  57345. * @param x defines the 1st component of the value
  57346. * @param y defines the 2nd component of the value
  57347. * @returns true if value was set
  57348. */
  57349. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57350. /**
  57351. * Set the value of an uniform to a vec3
  57352. * @param uniform defines the webGL uniform location where to store the value
  57353. * @param x defines the 1st component of the value
  57354. * @param y defines the 2nd component of the value
  57355. * @param z defines the 3rd component of the value
  57356. * @returns true if value was set
  57357. */
  57358. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57359. /**
  57360. * Set the value of an uniform to a boolean
  57361. * @param uniform defines the webGL uniform location where to store the value
  57362. * @param bool defines the boolean to store
  57363. * @returns true if value was set
  57364. */
  57365. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57366. /**
  57367. * Set the value of an uniform to a vec4
  57368. * @param uniform defines the webGL uniform location where to store the value
  57369. * @param x defines the 1st component of the value
  57370. * @param y defines the 2nd component of the value
  57371. * @param z defines the 3rd component of the value
  57372. * @param w defines the 4th component of the value
  57373. * @returns true if value was set
  57374. */
  57375. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57376. /**
  57377. * Sets the current alpha mode
  57378. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57379. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57380. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57381. */
  57382. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57383. /**
  57384. * Bind webGl buffers directly to the webGL context
  57385. * @param vertexBuffers defines the vertex buffer to bind
  57386. * @param indexBuffer defines the index buffer to bind
  57387. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57388. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57389. * @param effect defines the effect associated with the vertex buffer
  57390. */
  57391. bindBuffers(vertexBuffers: {
  57392. [key: string]: VertexBuffer;
  57393. }, indexBuffer: DataBuffer, effect: Effect): void;
  57394. /**
  57395. * Force the entire cache to be cleared
  57396. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57397. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57398. */
  57399. wipeCaches(bruteForce?: boolean): void;
  57400. /**
  57401. * Send a draw order
  57402. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57403. * @param indexStart defines the starting index
  57404. * @param indexCount defines the number of index to draw
  57405. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57406. */
  57407. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57408. /**
  57409. * Draw a list of indexed primitives
  57410. * @param fillMode defines the primitive to use
  57411. * @param indexStart defines the starting index
  57412. * @param indexCount defines the number of index to draw
  57413. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57414. */
  57415. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57416. /**
  57417. * Draw a list of unindexed primitives
  57418. * @param fillMode defines the primitive to use
  57419. * @param verticesStart defines the index of first vertex to draw
  57420. * @param verticesCount defines the count of vertices to draw
  57421. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57422. */
  57423. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57424. /** @hidden */
  57425. _createTexture(): WebGLTexture;
  57426. /** @hidden */
  57427. _releaseTexture(texture: InternalTexture): void;
  57428. /**
  57429. * Usually called from Texture.ts.
  57430. * Passed information to create a WebGLTexture
  57431. * @param urlArg defines a value which contains one of the following:
  57432. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57433. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57434. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57435. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57436. * @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)
  57437. * @param scene needed for loading to the correct scene
  57438. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57439. * @param onLoad optional callback to be called upon successful completion
  57440. * @param onError optional callback to be called upon failure
  57441. * @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
  57442. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57443. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57444. * @param forcedExtension defines the extension to use to pick the right loader
  57445. * @param mimeType defines an optional mime type
  57446. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57447. */
  57448. 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;
  57449. /**
  57450. * Creates a new render target texture
  57451. * @param size defines the size of the texture
  57452. * @param options defines the options used to create the texture
  57453. * @returns a new render target texture stored in an InternalTexture
  57454. */
  57455. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57456. /**
  57457. * Update the sampling mode of a given texture
  57458. * @param samplingMode defines the required sampling mode
  57459. * @param texture defines the texture to update
  57460. */
  57461. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57462. /**
  57463. * Binds the frame buffer to the specified texture.
  57464. * @param texture The texture to render to or null for the default canvas
  57465. * @param faceIndex The face of the texture to render to in case of cube texture
  57466. * @param requiredWidth The width of the target to render to
  57467. * @param requiredHeight The height of the target to render to
  57468. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57469. * @param lodLevel defines le lod level to bind to the frame buffer
  57470. */
  57471. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57472. /**
  57473. * Unbind the current render target texture from the webGL context
  57474. * @param texture defines the render target texture to unbind
  57475. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57476. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57477. */
  57478. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57479. /**
  57480. * Creates a dynamic vertex buffer
  57481. * @param vertices the data for the dynamic vertex buffer
  57482. * @returns the new WebGL dynamic buffer
  57483. */
  57484. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57485. /**
  57486. * Update the content of a dynamic texture
  57487. * @param texture defines the texture to update
  57488. * @param canvas defines the canvas containing the source
  57489. * @param invertY defines if data must be stored with Y axis inverted
  57490. * @param premulAlpha defines if alpha is stored as premultiplied
  57491. * @param format defines the format of the data
  57492. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57493. */
  57494. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57495. /**
  57496. * Gets a boolean indicating if all created effects are ready
  57497. * @returns true if all effects are ready
  57498. */
  57499. areAllEffectsReady(): boolean;
  57500. /**
  57501. * @hidden
  57502. * Get the current error code of the webGL context
  57503. * @returns the error code
  57504. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57505. */
  57506. getError(): number;
  57507. /** @hidden */
  57508. _getUnpackAlignement(): number;
  57509. /** @hidden */
  57510. _unpackFlipY(value: boolean): void;
  57511. /**
  57512. * Update a dynamic index buffer
  57513. * @param indexBuffer defines the target index buffer
  57514. * @param indices defines the data to update
  57515. * @param offset defines the offset in the target index buffer where update should start
  57516. */
  57517. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57518. /**
  57519. * Updates a dynamic vertex buffer.
  57520. * @param vertexBuffer the vertex buffer to update
  57521. * @param vertices the data used to update the vertex buffer
  57522. * @param byteOffset the byte offset of the data (optional)
  57523. * @param byteLength the byte length of the data (optional)
  57524. */
  57525. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57526. /** @hidden */
  57527. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57528. /** @hidden */
  57529. _bindTexture(channel: number, texture: InternalTexture): void;
  57530. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57531. /**
  57532. * 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
  57533. */
  57534. releaseEffects(): void;
  57535. displayLoadingUI(): void;
  57536. hideLoadingUI(): void;
  57537. /** @hidden */
  57538. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57539. /** @hidden */
  57540. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57541. /** @hidden */
  57542. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57543. /** @hidden */
  57544. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57545. }
  57546. }
  57547. declare module "babylonjs/Instrumentation/timeToken" {
  57548. import { Nullable } from "babylonjs/types";
  57549. /**
  57550. * @hidden
  57551. **/
  57552. export class _TimeToken {
  57553. _startTimeQuery: Nullable<WebGLQuery>;
  57554. _endTimeQuery: Nullable<WebGLQuery>;
  57555. _timeElapsedQuery: Nullable<WebGLQuery>;
  57556. _timeElapsedQueryEnded: boolean;
  57557. }
  57558. }
  57559. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57560. import { Nullable, int } from "babylonjs/types";
  57561. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57562. /** @hidden */
  57563. export class _OcclusionDataStorage {
  57564. /** @hidden */
  57565. occlusionInternalRetryCounter: number;
  57566. /** @hidden */
  57567. isOcclusionQueryInProgress: boolean;
  57568. /** @hidden */
  57569. isOccluded: boolean;
  57570. /** @hidden */
  57571. occlusionRetryCount: number;
  57572. /** @hidden */
  57573. occlusionType: number;
  57574. /** @hidden */
  57575. occlusionQueryAlgorithmType: number;
  57576. }
  57577. module "babylonjs/Engines/engine" {
  57578. interface Engine {
  57579. /**
  57580. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  57581. * @return the new query
  57582. */
  57583. createQuery(): WebGLQuery;
  57584. /**
  57585. * Delete and release a webGL query
  57586. * @param query defines the query to delete
  57587. * @return the current engine
  57588. */
  57589. deleteQuery(query: WebGLQuery): Engine;
  57590. /**
  57591. * Check if a given query has resolved and got its value
  57592. * @param query defines the query to check
  57593. * @returns true if the query got its value
  57594. */
  57595. isQueryResultAvailable(query: WebGLQuery): boolean;
  57596. /**
  57597. * Gets the value of a given query
  57598. * @param query defines the query to check
  57599. * @returns the value of the query
  57600. */
  57601. getQueryResult(query: WebGLQuery): number;
  57602. /**
  57603. * Initiates an occlusion query
  57604. * @param algorithmType defines the algorithm to use
  57605. * @param query defines the query to use
  57606. * @returns the current engine
  57607. * @see https://doc.babylonjs.com/features/occlusionquery
  57608. */
  57609. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  57610. /**
  57611. * Ends an occlusion query
  57612. * @see https://doc.babylonjs.com/features/occlusionquery
  57613. * @param algorithmType defines the algorithm to use
  57614. * @returns the current engine
  57615. */
  57616. endOcclusionQuery(algorithmType: number): Engine;
  57617. /**
  57618. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  57619. * Please note that only one query can be issued at a time
  57620. * @returns a time token used to track the time span
  57621. */
  57622. startTimeQuery(): Nullable<_TimeToken>;
  57623. /**
  57624. * Ends a time query
  57625. * @param token defines the token used to measure the time span
  57626. * @returns the time spent (in ns)
  57627. */
  57628. endTimeQuery(token: _TimeToken): int;
  57629. /** @hidden */
  57630. _currentNonTimestampToken: Nullable<_TimeToken>;
  57631. /** @hidden */
  57632. _createTimeQuery(): WebGLQuery;
  57633. /** @hidden */
  57634. _deleteTimeQuery(query: WebGLQuery): void;
  57635. /** @hidden */
  57636. _getGlAlgorithmType(algorithmType: number): number;
  57637. /** @hidden */
  57638. _getTimeQueryResult(query: WebGLQuery): any;
  57639. /** @hidden */
  57640. _getTimeQueryAvailability(query: WebGLQuery): any;
  57641. }
  57642. }
  57643. module "babylonjs/Meshes/abstractMesh" {
  57644. interface AbstractMesh {
  57645. /**
  57646. * Backing filed
  57647. * @hidden
  57648. */
  57649. __occlusionDataStorage: _OcclusionDataStorage;
  57650. /**
  57651. * Access property
  57652. * @hidden
  57653. */
  57654. _occlusionDataStorage: _OcclusionDataStorage;
  57655. /**
  57656. * 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.
  57657. * The default value is -1 which means don't break the query and wait till the result
  57658. * @see https://doc.babylonjs.com/features/occlusionquery
  57659. */
  57660. occlusionRetryCount: number;
  57661. /**
  57662. * 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:
  57663. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  57664. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  57665. * * 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.
  57666. * @see https://doc.babylonjs.com/features/occlusionquery
  57667. */
  57668. occlusionType: number;
  57669. /**
  57670. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  57671. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  57672. * * 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.
  57673. * @see https://doc.babylonjs.com/features/occlusionquery
  57674. */
  57675. occlusionQueryAlgorithmType: number;
  57676. /**
  57677. * 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
  57678. * @see https://doc.babylonjs.com/features/occlusionquery
  57679. */
  57680. isOccluded: boolean;
  57681. /**
  57682. * Flag to check the progress status of the query
  57683. * @see https://doc.babylonjs.com/features/occlusionquery
  57684. */
  57685. isOcclusionQueryInProgress: boolean;
  57686. }
  57687. }
  57688. }
  57689. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  57690. import { Nullable } from "babylonjs/types";
  57691. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57692. /** @hidden */
  57693. export var _forceTransformFeedbackToBundle: boolean;
  57694. module "babylonjs/Engines/engine" {
  57695. interface Engine {
  57696. /**
  57697. * Creates a webGL transform feedback object
  57698. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  57699. * @returns the webGL transform feedback object
  57700. */
  57701. createTransformFeedback(): WebGLTransformFeedback;
  57702. /**
  57703. * Delete a webGL transform feedback object
  57704. * @param value defines the webGL transform feedback object to delete
  57705. */
  57706. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  57707. /**
  57708. * Bind a webGL transform feedback object to the webgl context
  57709. * @param value defines the webGL transform feedback object to bind
  57710. */
  57711. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  57712. /**
  57713. * Begins a transform feedback operation
  57714. * @param usePoints defines if points or triangles must be used
  57715. */
  57716. beginTransformFeedback(usePoints: boolean): void;
  57717. /**
  57718. * Ends a transform feedback operation
  57719. */
  57720. endTransformFeedback(): void;
  57721. /**
  57722. * Specify the varyings to use with transform feedback
  57723. * @param program defines the associated webGL program
  57724. * @param value defines the list of strings representing the varying names
  57725. */
  57726. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  57727. /**
  57728. * Bind a webGL buffer for a transform feedback operation
  57729. * @param value defines the webGL buffer to bind
  57730. */
  57731. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  57732. }
  57733. }
  57734. }
  57735. declare module "babylonjs/Engines/Extensions/engine.views" {
  57736. import { Camera } from "babylonjs/Cameras/camera";
  57737. import { Nullable } from "babylonjs/types";
  57738. /**
  57739. * Class used to define an additional view for the engine
  57740. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57741. */
  57742. export class EngineView {
  57743. /** Defines the canvas where to render the view */
  57744. target: HTMLCanvasElement;
  57745. /** Defines an optional camera used to render the view (will use active camera else) */
  57746. camera?: Camera;
  57747. }
  57748. module "babylonjs/Engines/engine" {
  57749. interface Engine {
  57750. /**
  57751. * Gets or sets the HTML element to use for attaching events
  57752. */
  57753. inputElement: Nullable<HTMLElement>;
  57754. /**
  57755. * Gets the current engine view
  57756. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57757. */
  57758. activeView: Nullable<EngineView>;
  57759. /** Gets or sets the list of views */
  57760. views: EngineView[];
  57761. /**
  57762. * Register a new child canvas
  57763. * @param canvas defines the canvas to register
  57764. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  57765. * @returns the associated view
  57766. */
  57767. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  57768. /**
  57769. * Remove a registered child canvas
  57770. * @param canvas defines the canvas to remove
  57771. * @returns the current engine
  57772. */
  57773. unRegisterView(canvas: HTMLCanvasElement): Engine;
  57774. }
  57775. }
  57776. }
  57777. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  57778. import { Nullable } from "babylonjs/types";
  57779. module "babylonjs/Engines/engine" {
  57780. interface Engine {
  57781. /** @hidden */
  57782. _excludedCompressedTextures: string[];
  57783. /** @hidden */
  57784. _textureFormatInUse: string;
  57785. /**
  57786. * Gets the list of texture formats supported
  57787. */
  57788. readonly texturesSupported: Array<string>;
  57789. /**
  57790. * Gets the texture format in use
  57791. */
  57792. readonly textureFormatInUse: Nullable<string>;
  57793. /**
  57794. * Set the compressed texture extensions or file names to skip.
  57795. *
  57796. * @param skippedFiles defines the list of those texture files you want to skip
  57797. * Example: [".dds", ".env", "myfile.png"]
  57798. */
  57799. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  57800. /**
  57801. * Set the compressed texture format to use, based on the formats you have, and the formats
  57802. * supported by the hardware / browser.
  57803. *
  57804. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  57805. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  57806. * to API arguments needed to compressed textures. This puts the burden on the container
  57807. * generator to house the arcane code for determining these for current & future formats.
  57808. *
  57809. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57810. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57811. *
  57812. * Note: The result of this call is not taken into account when a texture is base64.
  57813. *
  57814. * @param formatsAvailable defines the list of those format families you have created
  57815. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  57816. *
  57817. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  57818. * @returns The extension selected.
  57819. */
  57820. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  57821. }
  57822. }
  57823. }
  57824. declare module "babylonjs/Engines/Extensions/index" {
  57825. export * from "babylonjs/Engines/Extensions/engine.alpha";
  57826. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  57827. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  57828. export * from "babylonjs/Engines/Extensions/engine.multiview";
  57829. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  57830. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57831. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  57832. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  57833. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  57834. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  57835. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57836. export * from "babylonjs/Engines/Extensions/engine.webVR";
  57837. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  57838. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  57839. export * from "babylonjs/Engines/Extensions/engine.views";
  57840. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  57841. import "babylonjs/Engines/Extensions/engine.textureSelector";
  57842. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  57843. }
  57844. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  57845. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57846. /** @hidden */
  57847. export var rgbdEncodePixelShader: {
  57848. name: string;
  57849. shader: string;
  57850. };
  57851. }
  57852. declare module "babylonjs/Misc/environmentTextureTools" {
  57853. import { Nullable } from "babylonjs/types";
  57854. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57855. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57856. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57857. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57858. import "babylonjs/Engines/Extensions/engine.readTexture";
  57859. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57860. import "babylonjs/Shaders/rgbdEncode.fragment";
  57861. import "babylonjs/Shaders/rgbdDecode.fragment";
  57862. /**
  57863. * Raw texture data and descriptor sufficient for WebGL texture upload
  57864. */
  57865. export interface EnvironmentTextureInfo {
  57866. /**
  57867. * Version of the environment map
  57868. */
  57869. version: number;
  57870. /**
  57871. * Width of image
  57872. */
  57873. width: number;
  57874. /**
  57875. * Irradiance information stored in the file.
  57876. */
  57877. irradiance: any;
  57878. /**
  57879. * Specular information stored in the file.
  57880. */
  57881. specular: any;
  57882. }
  57883. /**
  57884. * Defines One Image in the file. It requires only the position in the file
  57885. * as well as the length.
  57886. */
  57887. interface BufferImageData {
  57888. /**
  57889. * Length of the image data.
  57890. */
  57891. length: number;
  57892. /**
  57893. * Position of the data from the null terminator delimiting the end of the JSON.
  57894. */
  57895. position: number;
  57896. }
  57897. /**
  57898. * Defines the specular data enclosed in the file.
  57899. * This corresponds to the version 1 of the data.
  57900. */
  57901. export interface EnvironmentTextureSpecularInfoV1 {
  57902. /**
  57903. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  57904. */
  57905. specularDataPosition?: number;
  57906. /**
  57907. * This contains all the images data needed to reconstruct the cubemap.
  57908. */
  57909. mipmaps: Array<BufferImageData>;
  57910. /**
  57911. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  57912. */
  57913. lodGenerationScale: number;
  57914. }
  57915. /**
  57916. * Sets of helpers addressing the serialization and deserialization of environment texture
  57917. * stored in a BabylonJS env file.
  57918. * Those files are usually stored as .env files.
  57919. */
  57920. export class EnvironmentTextureTools {
  57921. /**
  57922. * Magic number identifying the env file.
  57923. */
  57924. private static _MagicBytes;
  57925. /**
  57926. * Gets the environment info from an env file.
  57927. * @param data The array buffer containing the .env bytes.
  57928. * @returns the environment file info (the json header) if successfully parsed.
  57929. */
  57930. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  57931. /**
  57932. * Creates an environment texture from a loaded cube texture.
  57933. * @param texture defines the cube texture to convert in env file
  57934. * @return a promise containing the environment data if succesfull.
  57935. */
  57936. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  57937. /**
  57938. * Creates a JSON representation of the spherical data.
  57939. * @param texture defines the texture containing the polynomials
  57940. * @return the JSON representation of the spherical info
  57941. */
  57942. private static _CreateEnvTextureIrradiance;
  57943. /**
  57944. * Creates the ArrayBufferViews used for initializing environment texture image data.
  57945. * @param data the image data
  57946. * @param info parameters that determine what views will be created for accessing the underlying buffer
  57947. * @return the views described by info providing access to the underlying buffer
  57948. */
  57949. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  57950. /**
  57951. * Uploads the texture info contained in the env file to the GPU.
  57952. * @param texture defines the internal texture to upload to
  57953. * @param data defines the data to load
  57954. * @param info defines the texture info retrieved through the GetEnvInfo method
  57955. * @returns a promise
  57956. */
  57957. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  57958. private static _OnImageReadyAsync;
  57959. /**
  57960. * Uploads the levels of image data to the GPU.
  57961. * @param texture defines the internal texture to upload to
  57962. * @param imageData defines the array buffer views of image data [mipmap][face]
  57963. * @returns a promise
  57964. */
  57965. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  57966. /**
  57967. * Uploads spherical polynomials information to the texture.
  57968. * @param texture defines the texture we are trying to upload the information to
  57969. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  57970. */
  57971. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  57972. /** @hidden */
  57973. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57974. }
  57975. }
  57976. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  57977. /**
  57978. * Class used to inline functions in shader code
  57979. */
  57980. export class ShaderCodeInliner {
  57981. private static readonly _RegexpFindFunctionNameAndType;
  57982. private _sourceCode;
  57983. private _functionDescr;
  57984. private _numMaxIterations;
  57985. /** Gets or sets the token used to mark the functions to inline */
  57986. inlineToken: string;
  57987. /** Gets or sets the debug mode */
  57988. debug: boolean;
  57989. /** Gets the code after the inlining process */
  57990. get code(): string;
  57991. /**
  57992. * Initializes the inliner
  57993. * @param sourceCode shader code source to inline
  57994. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  57995. */
  57996. constructor(sourceCode: string, numMaxIterations?: number);
  57997. /**
  57998. * Start the processing of the shader code
  57999. */
  58000. processCode(): void;
  58001. private _collectFunctions;
  58002. private _processInlining;
  58003. private _extractBetweenMarkers;
  58004. private _skipWhitespaces;
  58005. private _removeComments;
  58006. private _replaceFunctionCallsByCode;
  58007. private _findBackward;
  58008. private _escapeRegExp;
  58009. private _replaceNames;
  58010. }
  58011. }
  58012. declare module "babylonjs/Engines/nativeEngine" {
  58013. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  58014. import { Engine } from "babylonjs/Engines/engine";
  58015. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58016. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58017. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58018. import { Effect } from "babylonjs/Materials/effect";
  58019. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58020. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  58021. import { IColor4Like } from "babylonjs/Maths/math.like";
  58022. import { Scene } from "babylonjs/scene";
  58023. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58024. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58025. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58026. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  58027. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  58028. /**
  58029. * Container for accessors for natively-stored mesh data buffers.
  58030. */
  58031. class NativeDataBuffer extends DataBuffer {
  58032. /**
  58033. * Accessor value used to identify/retrieve a natively-stored index buffer.
  58034. */
  58035. nativeIndexBuffer?: any;
  58036. /**
  58037. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  58038. */
  58039. nativeVertexBuffer?: any;
  58040. }
  58041. /** @hidden */
  58042. class NativeTexture extends InternalTexture {
  58043. getInternalTexture(): InternalTexture;
  58044. getViewCount(): number;
  58045. }
  58046. /** @hidden */
  58047. export class NativeEngine extends Engine {
  58048. private readonly _native;
  58049. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  58050. private readonly INVALID_HANDLE;
  58051. private _boundBuffersVertexArray;
  58052. private _currentDepthTest;
  58053. getHardwareScalingLevel(): number;
  58054. constructor();
  58055. dispose(): void;
  58056. /**
  58057. * Can be used to override the current requestAnimationFrame requester.
  58058. * @hidden
  58059. */
  58060. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  58061. /**
  58062. * Override default engine behavior.
  58063. * @param color
  58064. * @param backBuffer
  58065. * @param depth
  58066. * @param stencil
  58067. */
  58068. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  58069. /**
  58070. * Gets host document
  58071. * @returns the host document object
  58072. */
  58073. getHostDocument(): Nullable<Document>;
  58074. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58075. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58076. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58077. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58078. [key: string]: VertexBuffer;
  58079. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58080. bindBuffers(vertexBuffers: {
  58081. [key: string]: VertexBuffer;
  58082. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58083. recordVertexArrayObject(vertexBuffers: {
  58084. [key: string]: VertexBuffer;
  58085. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58086. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58087. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58088. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58089. /**
  58090. * Draw a list of indexed primitives
  58091. * @param fillMode defines the primitive to use
  58092. * @param indexStart defines the starting index
  58093. * @param indexCount defines the number of index to draw
  58094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58095. */
  58096. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58097. /**
  58098. * Draw a list of unindexed primitives
  58099. * @param fillMode defines the primitive to use
  58100. * @param verticesStart defines the index of first vertex to draw
  58101. * @param verticesCount defines the count of vertices to draw
  58102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58103. */
  58104. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58105. createPipelineContext(): IPipelineContext;
  58106. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58107. /** @hidden */
  58108. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58109. /** @hidden */
  58110. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58111. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58112. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58113. protected _setProgram(program: WebGLProgram): void;
  58114. _releaseEffect(effect: Effect): void;
  58115. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58116. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58117. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58118. bindSamplers(effect: Effect): void;
  58119. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58120. getRenderWidth(useScreen?: boolean): number;
  58121. getRenderHeight(useScreen?: boolean): number;
  58122. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58123. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58124. /**
  58125. * Set the z offset to apply to current rendering
  58126. * @param value defines the offset to apply
  58127. */
  58128. setZOffset(value: number): void;
  58129. /**
  58130. * Gets the current value of the zOffset
  58131. * @returns the current zOffset state
  58132. */
  58133. getZOffset(): number;
  58134. /**
  58135. * Enable or disable depth buffering
  58136. * @param enable defines the state to set
  58137. */
  58138. setDepthBuffer(enable: boolean): void;
  58139. /**
  58140. * Gets a boolean indicating if depth writing is enabled
  58141. * @returns the current depth writing state
  58142. */
  58143. getDepthWrite(): boolean;
  58144. setDepthFunctionToGreater(): void;
  58145. setDepthFunctionToGreaterOrEqual(): void;
  58146. setDepthFunctionToLess(): void;
  58147. setDepthFunctionToLessOrEqual(): void;
  58148. /**
  58149. * Enable or disable depth writing
  58150. * @param enable defines the state to set
  58151. */
  58152. setDepthWrite(enable: boolean): void;
  58153. /**
  58154. * Enable or disable color writing
  58155. * @param enable defines the state to set
  58156. */
  58157. setColorWrite(enable: boolean): void;
  58158. /**
  58159. * Gets a boolean indicating if color writing is enabled
  58160. * @returns the current color writing state
  58161. */
  58162. getColorWrite(): boolean;
  58163. /**
  58164. * Sets alpha constants used by some alpha blending modes
  58165. * @param r defines the red component
  58166. * @param g defines the green component
  58167. * @param b defines the blue component
  58168. * @param a defines the alpha component
  58169. */
  58170. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58171. /**
  58172. * Sets the current alpha mode
  58173. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58174. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58175. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58176. */
  58177. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58178. /**
  58179. * Gets the current alpha mode
  58180. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58181. * @returns the current alpha mode
  58182. */
  58183. getAlphaMode(): number;
  58184. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58185. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58186. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58187. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58188. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58189. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58190. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58191. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58192. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58193. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58194. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58195. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58196. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58197. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58198. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58199. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58200. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58201. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58202. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58203. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58204. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58205. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58206. wipeCaches(bruteForce?: boolean): void;
  58207. _createTexture(): WebGLTexture;
  58208. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58209. /**
  58210. * Update the content of a dynamic texture
  58211. * @param texture defines the texture to update
  58212. * @param canvas defines the canvas containing the source
  58213. * @param invertY defines if data must be stored with Y axis inverted
  58214. * @param premulAlpha defines if alpha is stored as premultiplied
  58215. * @param format defines the format of the data
  58216. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58217. */
  58218. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58219. /**
  58220. * Usually called from Texture.ts.
  58221. * Passed information to create a WebGLTexture
  58222. * @param url defines a value which contains one of the following:
  58223. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58224. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58225. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58226. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58227. * @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)
  58228. * @param scene needed for loading to the correct scene
  58229. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58230. * @param onLoad optional callback to be called upon successful completion
  58231. * @param onError optional callback to be called upon failure
  58232. * @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
  58233. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58234. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58235. * @param forcedExtension defines the extension to use to pick the right loader
  58236. * @param mimeType defines an optional mime type
  58237. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58238. */
  58239. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  58240. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58241. _releaseFramebufferObjects(texture: InternalTexture): void;
  58242. /**
  58243. * Creates a cube texture
  58244. * @param rootUrl defines the url where the files to load is located
  58245. * @param scene defines the current scene
  58246. * @param files defines the list of files to load (1 per face)
  58247. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58248. * @param onLoad defines an optional callback raised when the texture is loaded
  58249. * @param onError defines an optional callback raised if there is an issue to load the texture
  58250. * @param format defines the format of the data
  58251. * @param forcedExtension defines the extension to use to pick the right loader
  58252. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58253. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58254. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58255. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58256. * @returns the cube texture as an InternalTexture
  58257. */
  58258. 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;
  58259. createRenderTargetTexture(size: number | {
  58260. width: number;
  58261. height: number;
  58262. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58263. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58264. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58265. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58266. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58267. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58268. /**
  58269. * Updates a dynamic vertex buffer.
  58270. * @param vertexBuffer the vertex buffer to update
  58271. * @param data the data used to update the vertex buffer
  58272. * @param byteOffset the byte offset of the data (optional)
  58273. * @param byteLength the byte length of the data (optional)
  58274. */
  58275. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58276. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58277. private _updateAnisotropicLevel;
  58278. private _getAddressMode;
  58279. /** @hidden */
  58280. _bindTexture(channel: number, texture: InternalTexture): void;
  58281. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58282. releaseEffects(): void;
  58283. /** @hidden */
  58284. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58285. /** @hidden */
  58286. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58287. /** @hidden */
  58288. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58289. /** @hidden */
  58290. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58291. private _getNativeSamplingMode;
  58292. private _getNativeTextureFormat;
  58293. private _getNativeAlphaMode;
  58294. private _getNativeAttribType;
  58295. }
  58296. }
  58297. declare module "babylonjs/Engines/index" {
  58298. export * from "babylonjs/Engines/constants";
  58299. export * from "babylonjs/Engines/engineCapabilities";
  58300. export * from "babylonjs/Engines/instancingAttributeInfo";
  58301. export * from "babylonjs/Engines/thinEngine";
  58302. export * from "babylonjs/Engines/engine";
  58303. export * from "babylonjs/Engines/engineStore";
  58304. export * from "babylonjs/Engines/nullEngine";
  58305. export * from "babylonjs/Engines/Extensions/index";
  58306. export * from "babylonjs/Engines/IPipelineContext";
  58307. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58308. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58309. export * from "babylonjs/Engines/nativeEngine";
  58310. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58311. export * from "babylonjs/Engines/performanceConfigurator";
  58312. }
  58313. declare module "babylonjs/Events/clipboardEvents" {
  58314. /**
  58315. * Gather the list of clipboard event types as constants.
  58316. */
  58317. export class ClipboardEventTypes {
  58318. /**
  58319. * The clipboard event is fired when a copy command is active (pressed).
  58320. */
  58321. static readonly COPY: number;
  58322. /**
  58323. * The clipboard event is fired when a cut command is active (pressed).
  58324. */
  58325. static readonly CUT: number;
  58326. /**
  58327. * The clipboard event is fired when a paste command is active (pressed).
  58328. */
  58329. static readonly PASTE: number;
  58330. }
  58331. /**
  58332. * This class is used to store clipboard related info for the onClipboardObservable event.
  58333. */
  58334. export class ClipboardInfo {
  58335. /**
  58336. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58337. */
  58338. type: number;
  58339. /**
  58340. * Defines the related dom event
  58341. */
  58342. event: ClipboardEvent;
  58343. /**
  58344. *Creates an instance of ClipboardInfo.
  58345. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58346. * @param event Defines the related dom event
  58347. */
  58348. constructor(
  58349. /**
  58350. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58351. */
  58352. type: number,
  58353. /**
  58354. * Defines the related dom event
  58355. */
  58356. event: ClipboardEvent);
  58357. /**
  58358. * Get the clipboard event's type from the keycode.
  58359. * @param keyCode Defines the keyCode for the current keyboard event.
  58360. * @return {number}
  58361. */
  58362. static GetTypeFromCharacter(keyCode: number): number;
  58363. }
  58364. }
  58365. declare module "babylonjs/Events/index" {
  58366. export * from "babylonjs/Events/keyboardEvents";
  58367. export * from "babylonjs/Events/pointerEvents";
  58368. export * from "babylonjs/Events/clipboardEvents";
  58369. }
  58370. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58371. import { Scene } from "babylonjs/scene";
  58372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58373. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58374. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58375. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58376. /**
  58377. * Google Daydream controller
  58378. */
  58379. export class DaydreamController extends WebVRController {
  58380. /**
  58381. * Base Url for the controller model.
  58382. */
  58383. static MODEL_BASE_URL: string;
  58384. /**
  58385. * File name for the controller model.
  58386. */
  58387. static MODEL_FILENAME: string;
  58388. /**
  58389. * Gamepad Id prefix used to identify Daydream Controller.
  58390. */
  58391. static readonly GAMEPAD_ID_PREFIX: string;
  58392. /**
  58393. * Creates a new DaydreamController from a gamepad
  58394. * @param vrGamepad the gamepad that the controller should be created from
  58395. */
  58396. constructor(vrGamepad: any);
  58397. /**
  58398. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58399. * @param scene scene in which to add meshes
  58400. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58401. */
  58402. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58403. /**
  58404. * Called once for each button that changed state since the last frame
  58405. * @param buttonIdx Which button index changed
  58406. * @param state New state of the button
  58407. * @param changes Which properties on the state changed since last frame
  58408. */
  58409. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58410. }
  58411. }
  58412. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58413. import { Scene } from "babylonjs/scene";
  58414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58415. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58416. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58417. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58418. /**
  58419. * Gear VR Controller
  58420. */
  58421. export class GearVRController extends WebVRController {
  58422. /**
  58423. * Base Url for the controller model.
  58424. */
  58425. static MODEL_BASE_URL: string;
  58426. /**
  58427. * File name for the controller model.
  58428. */
  58429. static MODEL_FILENAME: string;
  58430. /**
  58431. * Gamepad Id prefix used to identify this controller.
  58432. */
  58433. static readonly GAMEPAD_ID_PREFIX: string;
  58434. private readonly _buttonIndexToObservableNameMap;
  58435. /**
  58436. * Creates a new GearVRController from a gamepad
  58437. * @param vrGamepad the gamepad that the controller should be created from
  58438. */
  58439. constructor(vrGamepad: any);
  58440. /**
  58441. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58442. * @param scene scene in which to add meshes
  58443. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58444. */
  58445. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58446. /**
  58447. * Called once for each button that changed state since the last frame
  58448. * @param buttonIdx Which button index changed
  58449. * @param state New state of the button
  58450. * @param changes Which properties on the state changed since last frame
  58451. */
  58452. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58453. }
  58454. }
  58455. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58456. import { Scene } from "babylonjs/scene";
  58457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58458. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58459. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58460. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58461. /**
  58462. * Generic Controller
  58463. */
  58464. export class GenericController extends WebVRController {
  58465. /**
  58466. * Base Url for the controller model.
  58467. */
  58468. static readonly MODEL_BASE_URL: string;
  58469. /**
  58470. * File name for the controller model.
  58471. */
  58472. static readonly MODEL_FILENAME: string;
  58473. /**
  58474. * Creates a new GenericController from a gamepad
  58475. * @param vrGamepad the gamepad that the controller should be created from
  58476. */
  58477. constructor(vrGamepad: any);
  58478. /**
  58479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58480. * @param scene scene in which to add meshes
  58481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58482. */
  58483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58484. /**
  58485. * Called once for each button that changed state since the last frame
  58486. * @param buttonIdx Which button index changed
  58487. * @param state New state of the button
  58488. * @param changes Which properties on the state changed since last frame
  58489. */
  58490. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58491. }
  58492. }
  58493. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58494. import { Observable } from "babylonjs/Misc/observable";
  58495. import { Scene } from "babylonjs/scene";
  58496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58497. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58498. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58499. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58500. /**
  58501. * Oculus Touch Controller
  58502. */
  58503. export class OculusTouchController extends WebVRController {
  58504. /**
  58505. * Base Url for the controller model.
  58506. */
  58507. static MODEL_BASE_URL: string;
  58508. /**
  58509. * File name for the left controller model.
  58510. */
  58511. static MODEL_LEFT_FILENAME: string;
  58512. /**
  58513. * File name for the right controller model.
  58514. */
  58515. static MODEL_RIGHT_FILENAME: string;
  58516. /**
  58517. * Base Url for the Quest controller model.
  58518. */
  58519. static QUEST_MODEL_BASE_URL: string;
  58520. /**
  58521. * @hidden
  58522. * If the controllers are running on a device that needs the updated Quest controller models
  58523. */
  58524. static _IsQuest: boolean;
  58525. /**
  58526. * Fired when the secondary trigger on this controller is modified
  58527. */
  58528. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58529. /**
  58530. * Fired when the thumb rest on this controller is modified
  58531. */
  58532. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58533. /**
  58534. * Creates a new OculusTouchController from a gamepad
  58535. * @param vrGamepad the gamepad that the controller should be created from
  58536. */
  58537. constructor(vrGamepad: any);
  58538. /**
  58539. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58540. * @param scene scene in which to add meshes
  58541. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58542. */
  58543. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58544. /**
  58545. * Fired when the A button on this controller is modified
  58546. */
  58547. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58548. /**
  58549. * Fired when the B button on this controller is modified
  58550. */
  58551. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58552. /**
  58553. * Fired when the X button on this controller is modified
  58554. */
  58555. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58556. /**
  58557. * Fired when the Y button on this controller is modified
  58558. */
  58559. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58560. /**
  58561. * Called once for each button that changed state since the last frame
  58562. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58563. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58564. * 2) secondary trigger (same)
  58565. * 3) A (right) X (left), touch, pressed = value
  58566. * 4) B / Y
  58567. * 5) thumb rest
  58568. * @param buttonIdx Which button index changed
  58569. * @param state New state of the button
  58570. * @param changes Which properties on the state changed since last frame
  58571. */
  58572. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58573. }
  58574. }
  58575. declare module "babylonjs/Gamepads/Controllers/viveController" {
  58576. import { Scene } from "babylonjs/scene";
  58577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58578. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58579. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58580. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58581. import { Observable } from "babylonjs/Misc/observable";
  58582. /**
  58583. * Vive Controller
  58584. */
  58585. export class ViveController extends WebVRController {
  58586. /**
  58587. * Base Url for the controller model.
  58588. */
  58589. static MODEL_BASE_URL: string;
  58590. /**
  58591. * File name for the controller model.
  58592. */
  58593. static MODEL_FILENAME: string;
  58594. /**
  58595. * Creates a new ViveController from a gamepad
  58596. * @param vrGamepad the gamepad that the controller should be created from
  58597. */
  58598. constructor(vrGamepad: any);
  58599. /**
  58600. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58601. * @param scene scene in which to add meshes
  58602. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58603. */
  58604. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58605. /**
  58606. * Fired when the left button on this controller is modified
  58607. */
  58608. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58609. /**
  58610. * Fired when the right button on this controller is modified
  58611. */
  58612. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58613. /**
  58614. * Fired when the menu button on this controller is modified
  58615. */
  58616. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58617. /**
  58618. * Called once for each button that changed state since the last frame
  58619. * Vive mapping:
  58620. * 0: touchpad
  58621. * 1: trigger
  58622. * 2: left AND right buttons
  58623. * 3: menu button
  58624. * @param buttonIdx Which button index changed
  58625. * @param state New state of the button
  58626. * @param changes Which properties on the state changed since last frame
  58627. */
  58628. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58629. }
  58630. }
  58631. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  58632. import { Observable } from "babylonjs/Misc/observable";
  58633. import { Scene } from "babylonjs/scene";
  58634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58635. import { Ray } from "babylonjs/Culling/ray";
  58636. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58637. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58638. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58639. /**
  58640. * Defines the WindowsMotionController object that the state of the windows motion controller
  58641. */
  58642. export class WindowsMotionController extends WebVRController {
  58643. /**
  58644. * The base url used to load the left and right controller models
  58645. */
  58646. static MODEL_BASE_URL: string;
  58647. /**
  58648. * The name of the left controller model file
  58649. */
  58650. static MODEL_LEFT_FILENAME: string;
  58651. /**
  58652. * The name of the right controller model file
  58653. */
  58654. static MODEL_RIGHT_FILENAME: string;
  58655. /**
  58656. * The controller name prefix for this controller type
  58657. */
  58658. static readonly GAMEPAD_ID_PREFIX: string;
  58659. /**
  58660. * The controller id pattern for this controller type
  58661. */
  58662. private static readonly GAMEPAD_ID_PATTERN;
  58663. private _loadedMeshInfo;
  58664. protected readonly _mapping: {
  58665. buttons: string[];
  58666. buttonMeshNames: {
  58667. trigger: string;
  58668. menu: string;
  58669. grip: string;
  58670. thumbstick: string;
  58671. trackpad: string;
  58672. };
  58673. buttonObservableNames: {
  58674. trigger: string;
  58675. menu: string;
  58676. grip: string;
  58677. thumbstick: string;
  58678. trackpad: string;
  58679. };
  58680. axisMeshNames: string[];
  58681. pointingPoseMeshName: string;
  58682. };
  58683. /**
  58684. * Fired when the trackpad on this controller is clicked
  58685. */
  58686. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58687. /**
  58688. * Fired when the trackpad on this controller is modified
  58689. */
  58690. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58691. /**
  58692. * The current x and y values of this controller's trackpad
  58693. */
  58694. trackpad: StickValues;
  58695. /**
  58696. * Creates a new WindowsMotionController from a gamepad
  58697. * @param vrGamepad the gamepad that the controller should be created from
  58698. */
  58699. constructor(vrGamepad: any);
  58700. /**
  58701. * Fired when the trigger on this controller is modified
  58702. */
  58703. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58704. /**
  58705. * Fired when the menu button on this controller is modified
  58706. */
  58707. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58708. /**
  58709. * Fired when the grip button on this controller is modified
  58710. */
  58711. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58712. /**
  58713. * Fired when the thumbstick button on this controller is modified
  58714. */
  58715. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58716. /**
  58717. * Fired when the touchpad button on this controller is modified
  58718. */
  58719. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58720. /**
  58721. * Fired when the touchpad values on this controller are modified
  58722. */
  58723. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  58724. protected _updateTrackpad(): void;
  58725. /**
  58726. * Called once per frame by the engine.
  58727. */
  58728. update(): void;
  58729. /**
  58730. * Called once for each button that changed state since the last frame
  58731. * @param buttonIdx Which button index changed
  58732. * @param state New state of the button
  58733. * @param changes Which properties on the state changed since last frame
  58734. */
  58735. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58736. /**
  58737. * Moves the buttons on the controller mesh based on their current state
  58738. * @param buttonName the name of the button to move
  58739. * @param buttonValue the value of the button which determines the buttons new position
  58740. */
  58741. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  58742. /**
  58743. * Moves the axis on the controller mesh based on its current state
  58744. * @param axis the index of the axis
  58745. * @param axisValue the value of the axis which determines the meshes new position
  58746. * @hidden
  58747. */
  58748. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  58749. /**
  58750. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58751. * @param scene scene in which to add meshes
  58752. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58753. */
  58754. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  58755. /**
  58756. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  58757. * can be transformed by button presses and axes values, based on this._mapping.
  58758. *
  58759. * @param scene scene in which the meshes exist
  58760. * @param meshes list of meshes that make up the controller model to process
  58761. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  58762. */
  58763. private processModel;
  58764. private createMeshInfo;
  58765. /**
  58766. * Gets the ray of the controller in the direction the controller is pointing
  58767. * @param length the length the resulting ray should be
  58768. * @returns a ray in the direction the controller is pointing
  58769. */
  58770. getForwardRay(length?: number): Ray;
  58771. /**
  58772. * Disposes of the controller
  58773. */
  58774. dispose(): void;
  58775. }
  58776. /**
  58777. * This class represents a new windows motion controller in XR.
  58778. */
  58779. export class XRWindowsMotionController extends WindowsMotionController {
  58780. /**
  58781. * Changing the original WIndowsMotionController mapping to fir the new mapping
  58782. */
  58783. protected readonly _mapping: {
  58784. buttons: string[];
  58785. buttonMeshNames: {
  58786. trigger: string;
  58787. menu: string;
  58788. grip: string;
  58789. thumbstick: string;
  58790. trackpad: string;
  58791. };
  58792. buttonObservableNames: {
  58793. trigger: string;
  58794. menu: string;
  58795. grip: string;
  58796. thumbstick: string;
  58797. trackpad: string;
  58798. };
  58799. axisMeshNames: string[];
  58800. pointingPoseMeshName: string;
  58801. };
  58802. /**
  58803. * Construct a new XR-Based windows motion controller
  58804. *
  58805. * @param gamepadInfo the gamepad object from the browser
  58806. */
  58807. constructor(gamepadInfo: any);
  58808. /**
  58809. * holds the thumbstick values (X,Y)
  58810. */
  58811. thumbstickValues: StickValues;
  58812. /**
  58813. * Fired when the thumbstick on this controller is clicked
  58814. */
  58815. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  58816. /**
  58817. * Fired when the thumbstick on this controller is modified
  58818. */
  58819. onThumbstickValuesChangedObservable: Observable<StickValues>;
  58820. /**
  58821. * Fired when the touchpad button on this controller is modified
  58822. */
  58823. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58824. /**
  58825. * Fired when the touchpad values on this controller are modified
  58826. */
  58827. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58828. /**
  58829. * Fired when the thumbstick button on this controller is modified
  58830. * here to prevent breaking changes
  58831. */
  58832. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58833. /**
  58834. * updating the thumbstick(!) and not the trackpad.
  58835. * This is named this way due to the difference between WebVR and XR and to avoid
  58836. * changing the parent class.
  58837. */
  58838. protected _updateTrackpad(): void;
  58839. /**
  58840. * Disposes the class with joy
  58841. */
  58842. dispose(): void;
  58843. }
  58844. }
  58845. declare module "babylonjs/Gamepads/Controllers/index" {
  58846. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  58847. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  58848. export * from "babylonjs/Gamepads/Controllers/genericController";
  58849. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  58850. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58851. export * from "babylonjs/Gamepads/Controllers/viveController";
  58852. export * from "babylonjs/Gamepads/Controllers/webVRController";
  58853. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  58854. }
  58855. declare module "babylonjs/Gamepads/index" {
  58856. export * from "babylonjs/Gamepads/Controllers/index";
  58857. export * from "babylonjs/Gamepads/gamepad";
  58858. export * from "babylonjs/Gamepads/gamepadManager";
  58859. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  58860. export * from "babylonjs/Gamepads/xboxGamepad";
  58861. export * from "babylonjs/Gamepads/dualShockGamepad";
  58862. }
  58863. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  58864. import { Scene } from "babylonjs/scene";
  58865. import { Vector4 } from "babylonjs/Maths/math.vector";
  58866. import { Color4 } from "babylonjs/Maths/math.color";
  58867. import { Mesh } from "babylonjs/Meshes/mesh";
  58868. import { Nullable } from "babylonjs/types";
  58869. /**
  58870. * Class containing static functions to help procedurally build meshes
  58871. */
  58872. export class PolyhedronBuilder {
  58873. /**
  58874. * Creates a polyhedron mesh
  58875. * * 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
  58876. * * The parameter `size` (positive float, default 1) sets the polygon size
  58877. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58878. * * 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`
  58879. * * 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
  58880. * * 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)`)
  58881. * * 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
  58882. * * 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
  58883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58886. * @param name defines the name of the mesh
  58887. * @param options defines the options used to create the mesh
  58888. * @param scene defines the hosting scene
  58889. * @returns the polyhedron mesh
  58890. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58891. */
  58892. static CreatePolyhedron(name: string, options: {
  58893. type?: number;
  58894. size?: number;
  58895. sizeX?: number;
  58896. sizeY?: number;
  58897. sizeZ?: number;
  58898. custom?: any;
  58899. faceUV?: Vector4[];
  58900. faceColors?: Color4[];
  58901. flat?: boolean;
  58902. updatable?: boolean;
  58903. sideOrientation?: number;
  58904. frontUVs?: Vector4;
  58905. backUVs?: Vector4;
  58906. }, scene?: Nullable<Scene>): Mesh;
  58907. }
  58908. }
  58909. declare module "babylonjs/Gizmos/scaleGizmo" {
  58910. import { Observable } from "babylonjs/Misc/observable";
  58911. import { Nullable } from "babylonjs/types";
  58912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58913. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58914. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  58915. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58916. import { Node } from "babylonjs/node";
  58917. /**
  58918. * Gizmo that enables scaling a mesh along 3 axis
  58919. */
  58920. export class ScaleGizmo extends Gizmo {
  58921. /**
  58922. * Internal gizmo used for interactions on the x axis
  58923. */
  58924. xGizmo: AxisScaleGizmo;
  58925. /**
  58926. * Internal gizmo used for interactions on the y axis
  58927. */
  58928. yGizmo: AxisScaleGizmo;
  58929. /**
  58930. * Internal gizmo used for interactions on the z axis
  58931. */
  58932. zGizmo: AxisScaleGizmo;
  58933. /**
  58934. * Internal gizmo used to scale all axis equally
  58935. */
  58936. uniformScaleGizmo: AxisScaleGizmo;
  58937. private _meshAttached;
  58938. private _nodeAttached;
  58939. private _snapDistance;
  58940. private _uniformScalingMesh;
  58941. private _octahedron;
  58942. private _sensitivity;
  58943. /** Fires an event when any of it's sub gizmos are dragged */
  58944. onDragStartObservable: Observable<unknown>;
  58945. /** Fires an event when any of it's sub gizmos are released from dragging */
  58946. onDragEndObservable: Observable<unknown>;
  58947. get attachedMesh(): Nullable<AbstractMesh>;
  58948. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58949. get attachedNode(): Nullable<Node>;
  58950. set attachedNode(node: Nullable<Node>);
  58951. /**
  58952. * True when the mouse pointer is hovering a gizmo mesh
  58953. */
  58954. get isHovered(): boolean;
  58955. /**
  58956. * Creates a ScaleGizmo
  58957. * @param gizmoLayer The utility layer the gizmo will be added to
  58958. * @param thickness display gizmo axis thickness
  58959. */
  58960. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  58961. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58962. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58963. /**
  58964. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58965. */
  58966. set snapDistance(value: number);
  58967. get snapDistance(): number;
  58968. /**
  58969. * Ratio for the scale of the gizmo (Default: 1)
  58970. */
  58971. set scaleRatio(value: number);
  58972. get scaleRatio(): number;
  58973. /**
  58974. * Sensitivity factor for dragging (Default: 1)
  58975. */
  58976. set sensitivity(value: number);
  58977. get sensitivity(): number;
  58978. /**
  58979. * Disposes of the gizmo
  58980. */
  58981. dispose(): void;
  58982. }
  58983. }
  58984. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  58985. import { Observable } from "babylonjs/Misc/observable";
  58986. import { Nullable } from "babylonjs/types";
  58987. import { Vector3 } from "babylonjs/Maths/math.vector";
  58988. import { Node } from "babylonjs/node";
  58989. import { Mesh } from "babylonjs/Meshes/mesh";
  58990. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  58991. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58992. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58993. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  58994. import { Color3 } from "babylonjs/Maths/math.color";
  58995. /**
  58996. * Single axis scale gizmo
  58997. */
  58998. export class AxisScaleGizmo extends Gizmo {
  58999. /**
  59000. * Drag behavior responsible for the gizmos dragging interactions
  59001. */
  59002. dragBehavior: PointerDragBehavior;
  59003. private _pointerObserver;
  59004. /**
  59005. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59006. */
  59007. snapDistance: number;
  59008. /**
  59009. * Event that fires each time the gizmo snaps to a new location.
  59010. * * snapDistance is the the change in distance
  59011. */
  59012. onSnapObservable: Observable<{
  59013. snapDistance: number;
  59014. }>;
  59015. /**
  59016. * If the scaling operation should be done on all axis (default: false)
  59017. */
  59018. uniformScaling: boolean;
  59019. /**
  59020. * Custom sensitivity value for the drag strength
  59021. */
  59022. sensitivity: number;
  59023. private _isEnabled;
  59024. private _parent;
  59025. private _arrow;
  59026. private _coloredMaterial;
  59027. private _hoverMaterial;
  59028. /**
  59029. * Creates an AxisScaleGizmo
  59030. * @param gizmoLayer The utility layer the gizmo will be added to
  59031. * @param dragAxis The axis which the gizmo will be able to scale on
  59032. * @param color The color of the gizmo
  59033. * @param thickness display gizmo axis thickness
  59034. */
  59035. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59036. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59037. /**
  59038. * If the gizmo is enabled
  59039. */
  59040. set isEnabled(value: boolean);
  59041. get isEnabled(): boolean;
  59042. /**
  59043. * Disposes of the gizmo
  59044. */
  59045. dispose(): void;
  59046. /**
  59047. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59048. * @param mesh The mesh to replace the default mesh of the gizmo
  59049. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59050. */
  59051. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59052. }
  59053. }
  59054. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59055. import { Observable } from "babylonjs/Misc/observable";
  59056. import { Nullable } from "babylonjs/types";
  59057. import { Vector3 } from "babylonjs/Maths/math.vector";
  59058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59059. import { Mesh } from "babylonjs/Meshes/mesh";
  59060. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59061. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59062. import { Color3 } from "babylonjs/Maths/math.color";
  59063. import "babylonjs/Meshes/Builders/boxBuilder";
  59064. /**
  59065. * Bounding box gizmo
  59066. */
  59067. export class BoundingBoxGizmo extends Gizmo {
  59068. private _lineBoundingBox;
  59069. private _rotateSpheresParent;
  59070. private _scaleBoxesParent;
  59071. private _boundingDimensions;
  59072. private _renderObserver;
  59073. private _pointerObserver;
  59074. private _scaleDragSpeed;
  59075. private _tmpQuaternion;
  59076. private _tmpVector;
  59077. private _tmpRotationMatrix;
  59078. /**
  59079. * 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)
  59080. */
  59081. ignoreChildren: boolean;
  59082. /**
  59083. * 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)
  59084. */
  59085. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59086. /**
  59087. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59088. */
  59089. rotationSphereSize: number;
  59090. /**
  59091. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59092. */
  59093. scaleBoxSize: number;
  59094. /**
  59095. * 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)
  59096. */
  59097. fixedDragMeshScreenSize: boolean;
  59098. /**
  59099. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59100. */
  59101. fixedDragMeshScreenSizeDistanceFactor: number;
  59102. /**
  59103. * Fired when a rotation sphere or scale box is dragged
  59104. */
  59105. onDragStartObservable: Observable<{}>;
  59106. /**
  59107. * Fired when a scale box is dragged
  59108. */
  59109. onScaleBoxDragObservable: Observable<{}>;
  59110. /**
  59111. * Fired when a scale box drag is ended
  59112. */
  59113. onScaleBoxDragEndObservable: Observable<{}>;
  59114. /**
  59115. * Fired when a rotation sphere is dragged
  59116. */
  59117. onRotationSphereDragObservable: Observable<{}>;
  59118. /**
  59119. * Fired when a rotation sphere drag is ended
  59120. */
  59121. onRotationSphereDragEndObservable: Observable<{}>;
  59122. /**
  59123. * 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)
  59124. */
  59125. scalePivot: Nullable<Vector3>;
  59126. /**
  59127. * Mesh used as a pivot to rotate the attached node
  59128. */
  59129. private _anchorMesh;
  59130. private _existingMeshScale;
  59131. private _dragMesh;
  59132. private pointerDragBehavior;
  59133. private coloredMaterial;
  59134. private hoverColoredMaterial;
  59135. /**
  59136. * Sets the color of the bounding box gizmo
  59137. * @param color the color to set
  59138. */
  59139. setColor(color: Color3): void;
  59140. /**
  59141. * Creates an BoundingBoxGizmo
  59142. * @param gizmoLayer The utility layer the gizmo will be added to
  59143. * @param color The color of the gizmo
  59144. */
  59145. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59146. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59147. private _selectNode;
  59148. /**
  59149. * Updates the bounding box information for the Gizmo
  59150. */
  59151. updateBoundingBox(): void;
  59152. private _updateRotationSpheres;
  59153. private _updateScaleBoxes;
  59154. /**
  59155. * Enables rotation on the specified axis and disables rotation on the others
  59156. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59157. */
  59158. setEnabledRotationAxis(axis: string): void;
  59159. /**
  59160. * Enables/disables scaling
  59161. * @param enable if scaling should be enabled
  59162. * @param homogeneousScaling defines if scaling should only be homogeneous
  59163. */
  59164. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59165. private _updateDummy;
  59166. /**
  59167. * Enables a pointer drag behavior on the bounding box of the gizmo
  59168. */
  59169. enableDragBehavior(): void;
  59170. /**
  59171. * Disposes of the gizmo
  59172. */
  59173. dispose(): void;
  59174. /**
  59175. * 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)
  59176. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59177. * @returns the bounding box mesh with the passed in mesh as a child
  59178. */
  59179. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59180. /**
  59181. * CustomMeshes are not supported by this gizmo
  59182. * @param mesh The mesh to replace the default mesh of the gizmo
  59183. */
  59184. setCustomMesh(mesh: Mesh): void;
  59185. }
  59186. }
  59187. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59188. import { Observable } from "babylonjs/Misc/observable";
  59189. import { Nullable } from "babylonjs/types";
  59190. import { Vector3 } from "babylonjs/Maths/math.vector";
  59191. import { Color3 } from "babylonjs/Maths/math.color";
  59192. import { Node } from "babylonjs/node";
  59193. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59194. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59195. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59196. import "babylonjs/Meshes/Builders/linesBuilder";
  59197. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59198. /**
  59199. * Single plane rotation gizmo
  59200. */
  59201. export class PlaneRotationGizmo extends Gizmo {
  59202. /**
  59203. * Drag behavior responsible for the gizmos dragging interactions
  59204. */
  59205. dragBehavior: PointerDragBehavior;
  59206. private _pointerObserver;
  59207. /**
  59208. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59209. */
  59210. snapDistance: number;
  59211. /**
  59212. * Event that fires each time the gizmo snaps to a new location.
  59213. * * snapDistance is the the change in distance
  59214. */
  59215. onSnapObservable: Observable<{
  59216. snapDistance: number;
  59217. }>;
  59218. private _isEnabled;
  59219. private _parent;
  59220. /**
  59221. * Creates a PlaneRotationGizmo
  59222. * @param gizmoLayer The utility layer the gizmo will be added to
  59223. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59224. * @param color The color of the gizmo
  59225. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59226. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59227. * @param thickness display gizmo axis thickness
  59228. */
  59229. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59230. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59231. /**
  59232. * If the gizmo is enabled
  59233. */
  59234. set isEnabled(value: boolean);
  59235. get isEnabled(): boolean;
  59236. /**
  59237. * Disposes of the gizmo
  59238. */
  59239. dispose(): void;
  59240. }
  59241. }
  59242. declare module "babylonjs/Gizmos/rotationGizmo" {
  59243. import { Observable } from "babylonjs/Misc/observable";
  59244. import { Nullable } from "babylonjs/types";
  59245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59246. import { Mesh } from "babylonjs/Meshes/mesh";
  59247. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59248. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59249. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59250. import { Node } from "babylonjs/node";
  59251. /**
  59252. * Gizmo that enables rotating a mesh along 3 axis
  59253. */
  59254. export class RotationGizmo extends Gizmo {
  59255. /**
  59256. * Internal gizmo used for interactions on the x axis
  59257. */
  59258. xGizmo: PlaneRotationGizmo;
  59259. /**
  59260. * Internal gizmo used for interactions on the y axis
  59261. */
  59262. yGizmo: PlaneRotationGizmo;
  59263. /**
  59264. * Internal gizmo used for interactions on the z axis
  59265. */
  59266. zGizmo: PlaneRotationGizmo;
  59267. /** Fires an event when any of it's sub gizmos are dragged */
  59268. onDragStartObservable: Observable<unknown>;
  59269. /** Fires an event when any of it's sub gizmos are released from dragging */
  59270. onDragEndObservable: Observable<unknown>;
  59271. private _meshAttached;
  59272. private _nodeAttached;
  59273. get attachedMesh(): Nullable<AbstractMesh>;
  59274. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59275. get attachedNode(): Nullable<Node>;
  59276. set attachedNode(node: Nullable<Node>);
  59277. protected _checkBillboardTransform(): void;
  59278. /**
  59279. * True when the mouse pointer is hovering a gizmo mesh
  59280. */
  59281. get isHovered(): boolean;
  59282. /**
  59283. * Creates a RotationGizmo
  59284. * @param gizmoLayer The utility layer the gizmo will be added to
  59285. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59286. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59287. * @param thickness display gizmo axis thickness
  59288. */
  59289. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59290. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59291. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59292. /**
  59293. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59294. */
  59295. set snapDistance(value: number);
  59296. get snapDistance(): number;
  59297. /**
  59298. * Ratio for the scale of the gizmo (Default: 1)
  59299. */
  59300. set scaleRatio(value: number);
  59301. get scaleRatio(): number;
  59302. /**
  59303. * Disposes of the gizmo
  59304. */
  59305. dispose(): void;
  59306. /**
  59307. * CustomMeshes are not supported by this gizmo
  59308. * @param mesh The mesh to replace the default mesh of the gizmo
  59309. */
  59310. setCustomMesh(mesh: Mesh): void;
  59311. }
  59312. }
  59313. declare module "babylonjs/Gizmos/gizmoManager" {
  59314. import { Observable } from "babylonjs/Misc/observable";
  59315. import { Nullable } from "babylonjs/types";
  59316. import { Scene, IDisposable } from "babylonjs/scene";
  59317. import { Node } from "babylonjs/node";
  59318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59319. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59320. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59321. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59322. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59323. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59324. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59325. /**
  59326. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59327. */
  59328. export class GizmoManager implements IDisposable {
  59329. private scene;
  59330. /**
  59331. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59332. */
  59333. gizmos: {
  59334. positionGizmo: Nullable<PositionGizmo>;
  59335. rotationGizmo: Nullable<RotationGizmo>;
  59336. scaleGizmo: Nullable<ScaleGizmo>;
  59337. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59338. };
  59339. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59340. clearGizmoOnEmptyPointerEvent: boolean;
  59341. /** Fires an event when the manager is attached to a mesh */
  59342. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59343. /** Fires an event when the manager is attached to a node */
  59344. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59345. private _gizmosEnabled;
  59346. private _pointerObserver;
  59347. private _attachedMesh;
  59348. private _attachedNode;
  59349. private _boundingBoxColor;
  59350. private _defaultUtilityLayer;
  59351. private _defaultKeepDepthUtilityLayer;
  59352. private _thickness;
  59353. /**
  59354. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59355. */
  59356. boundingBoxDragBehavior: SixDofDragBehavior;
  59357. /**
  59358. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59359. */
  59360. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59361. /**
  59362. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59363. */
  59364. attachableNodes: Nullable<Array<Node>>;
  59365. /**
  59366. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59367. */
  59368. usePointerToAttachGizmos: boolean;
  59369. /**
  59370. * Utility layer that the bounding box gizmo belongs to
  59371. */
  59372. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59373. /**
  59374. * Utility layer that all gizmos besides bounding box belong to
  59375. */
  59376. get utilityLayer(): UtilityLayerRenderer;
  59377. /**
  59378. * True when the mouse pointer is hovering a gizmo mesh
  59379. */
  59380. get isHovered(): boolean;
  59381. /**
  59382. * Instatiates a gizmo manager
  59383. * @param scene the scene to overlay the gizmos on top of
  59384. * @param thickness display gizmo axis thickness
  59385. */
  59386. constructor(scene: Scene, thickness?: number);
  59387. /**
  59388. * Attaches a set of gizmos to the specified mesh
  59389. * @param mesh The mesh the gizmo's should be attached to
  59390. */
  59391. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59392. /**
  59393. * Attaches a set of gizmos to the specified node
  59394. * @param node The node the gizmo's should be attached to
  59395. */
  59396. attachToNode(node: Nullable<Node>): void;
  59397. /**
  59398. * If the position gizmo is enabled
  59399. */
  59400. set positionGizmoEnabled(value: boolean);
  59401. get positionGizmoEnabled(): boolean;
  59402. /**
  59403. * If the rotation gizmo is enabled
  59404. */
  59405. set rotationGizmoEnabled(value: boolean);
  59406. get rotationGizmoEnabled(): boolean;
  59407. /**
  59408. * If the scale gizmo is enabled
  59409. */
  59410. set scaleGizmoEnabled(value: boolean);
  59411. get scaleGizmoEnabled(): boolean;
  59412. /**
  59413. * If the boundingBox gizmo is enabled
  59414. */
  59415. set boundingBoxGizmoEnabled(value: boolean);
  59416. get boundingBoxGizmoEnabled(): boolean;
  59417. /**
  59418. * Disposes of the gizmo manager
  59419. */
  59420. dispose(): void;
  59421. }
  59422. }
  59423. declare module "babylonjs/Lights/directionalLight" {
  59424. import { Camera } from "babylonjs/Cameras/camera";
  59425. import { Scene } from "babylonjs/scene";
  59426. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59428. import { Light } from "babylonjs/Lights/light";
  59429. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59430. import { Effect } from "babylonjs/Materials/effect";
  59431. /**
  59432. * A directional light is defined by a direction (what a surprise!).
  59433. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59434. * 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.
  59435. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59436. */
  59437. export class DirectionalLight extends ShadowLight {
  59438. private _shadowFrustumSize;
  59439. /**
  59440. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59441. */
  59442. get shadowFrustumSize(): number;
  59443. /**
  59444. * Specifies a fix frustum size for the shadow generation.
  59445. */
  59446. set shadowFrustumSize(value: number);
  59447. private _shadowOrthoScale;
  59448. /**
  59449. * Gets the shadow projection scale against the optimal computed one.
  59450. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59451. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59452. */
  59453. get shadowOrthoScale(): number;
  59454. /**
  59455. * Sets the shadow projection scale against the optimal computed one.
  59456. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59457. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59458. */
  59459. set shadowOrthoScale(value: number);
  59460. /**
  59461. * Automatically compute the projection matrix to best fit (including all the casters)
  59462. * on each frame.
  59463. */
  59464. autoUpdateExtends: boolean;
  59465. /**
  59466. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59467. * on each frame. autoUpdateExtends must be set to true for this to work
  59468. */
  59469. autoCalcShadowZBounds: boolean;
  59470. private _orthoLeft;
  59471. private _orthoRight;
  59472. private _orthoTop;
  59473. private _orthoBottom;
  59474. /**
  59475. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59476. * The directional light is emitted from everywhere in the given direction.
  59477. * It can cast shadows.
  59478. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59479. * @param name The friendly name of the light
  59480. * @param direction The direction of the light
  59481. * @param scene The scene the light belongs to
  59482. */
  59483. constructor(name: string, direction: Vector3, scene: Scene);
  59484. /**
  59485. * Returns the string "DirectionalLight".
  59486. * @return The class name
  59487. */
  59488. getClassName(): string;
  59489. /**
  59490. * Returns the integer 1.
  59491. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59492. */
  59493. getTypeID(): number;
  59494. /**
  59495. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59496. * Returns the DirectionalLight Shadow projection matrix.
  59497. */
  59498. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59499. /**
  59500. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59501. * Returns the DirectionalLight Shadow projection matrix.
  59502. */
  59503. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59504. /**
  59505. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59506. * Returns the DirectionalLight Shadow projection matrix.
  59507. */
  59508. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59509. protected _buildUniformLayout(): void;
  59510. /**
  59511. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59512. * @param effect The effect to update
  59513. * @param lightIndex The index of the light in the effect to update
  59514. * @returns The directional light
  59515. */
  59516. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59517. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59518. /**
  59519. * Gets the minZ used for shadow according to both the scene and the light.
  59520. *
  59521. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59522. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59523. * @param activeCamera The camera we are returning the min for
  59524. * @returns the depth min z
  59525. */
  59526. getDepthMinZ(activeCamera: Camera): number;
  59527. /**
  59528. * Gets the maxZ used for shadow according to both the scene and the light.
  59529. *
  59530. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59531. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59532. * @param activeCamera The camera we are returning the max for
  59533. * @returns the depth max z
  59534. */
  59535. getDepthMaxZ(activeCamera: Camera): number;
  59536. /**
  59537. * Prepares the list of defines specific to the light type.
  59538. * @param defines the list of defines
  59539. * @param lightIndex defines the index of the light for the effect
  59540. */
  59541. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59542. }
  59543. }
  59544. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59545. import { Mesh } from "babylonjs/Meshes/mesh";
  59546. /**
  59547. * Class containing static functions to help procedurally build meshes
  59548. */
  59549. export class HemisphereBuilder {
  59550. /**
  59551. * Creates a hemisphere mesh
  59552. * @param name defines the name of the mesh
  59553. * @param options defines the options used to create the mesh
  59554. * @param scene defines the hosting scene
  59555. * @returns the hemisphere mesh
  59556. */
  59557. static CreateHemisphere(name: string, options: {
  59558. segments?: number;
  59559. diameter?: number;
  59560. sideOrientation?: number;
  59561. }, scene: any): Mesh;
  59562. }
  59563. }
  59564. declare module "babylonjs/Lights/spotLight" {
  59565. import { Nullable } from "babylonjs/types";
  59566. import { Scene } from "babylonjs/scene";
  59567. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59569. import { Effect } from "babylonjs/Materials/effect";
  59570. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59571. import { Light } from "babylonjs/Lights/light";
  59572. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59573. /**
  59574. * A spot light is defined by a position, a direction, an angle, and an exponent.
  59575. * These values define a cone of light starting from the position, emitting toward the direction.
  59576. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  59577. * and the exponent defines the speed of the decay of the light with distance (reach).
  59578. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59579. */
  59580. export class SpotLight extends ShadowLight {
  59581. private _angle;
  59582. private _innerAngle;
  59583. private _cosHalfAngle;
  59584. private _lightAngleScale;
  59585. private _lightAngleOffset;
  59586. /**
  59587. * Gets the cone angle of the spot light in Radians.
  59588. */
  59589. get angle(): number;
  59590. /**
  59591. * Sets the cone angle of the spot light in Radians.
  59592. */
  59593. set angle(value: number);
  59594. /**
  59595. * Only used in gltf falloff mode, this defines the angle where
  59596. * the directional falloff will start before cutting at angle which could be seen
  59597. * as outer angle.
  59598. */
  59599. get innerAngle(): number;
  59600. /**
  59601. * Only used in gltf falloff mode, this defines the angle where
  59602. * the directional falloff will start before cutting at angle which could be seen
  59603. * as outer angle.
  59604. */
  59605. set innerAngle(value: number);
  59606. private _shadowAngleScale;
  59607. /**
  59608. * Allows scaling the angle of the light for shadow generation only.
  59609. */
  59610. get shadowAngleScale(): number;
  59611. /**
  59612. * Allows scaling the angle of the light for shadow generation only.
  59613. */
  59614. set shadowAngleScale(value: number);
  59615. /**
  59616. * The light decay speed with the distance from the emission spot.
  59617. */
  59618. exponent: number;
  59619. private _projectionTextureMatrix;
  59620. /**
  59621. * Allows reading the projecton texture
  59622. */
  59623. get projectionTextureMatrix(): Matrix;
  59624. protected _projectionTextureLightNear: number;
  59625. /**
  59626. * Gets the near clip of the Spotlight for texture projection.
  59627. */
  59628. get projectionTextureLightNear(): number;
  59629. /**
  59630. * Sets the near clip of the Spotlight for texture projection.
  59631. */
  59632. set projectionTextureLightNear(value: number);
  59633. protected _projectionTextureLightFar: number;
  59634. /**
  59635. * Gets the far clip of the Spotlight for texture projection.
  59636. */
  59637. get projectionTextureLightFar(): number;
  59638. /**
  59639. * Sets the far clip of the Spotlight for texture projection.
  59640. */
  59641. set projectionTextureLightFar(value: number);
  59642. protected _projectionTextureUpDirection: Vector3;
  59643. /**
  59644. * Gets the Up vector of the Spotlight for texture projection.
  59645. */
  59646. get projectionTextureUpDirection(): Vector3;
  59647. /**
  59648. * Sets the Up vector of the Spotlight for texture projection.
  59649. */
  59650. set projectionTextureUpDirection(value: Vector3);
  59651. private _projectionTexture;
  59652. /**
  59653. * Gets the projection texture of the light.
  59654. */
  59655. get projectionTexture(): Nullable<BaseTexture>;
  59656. /**
  59657. * Sets the projection texture of the light.
  59658. */
  59659. set projectionTexture(value: Nullable<BaseTexture>);
  59660. private _projectionTextureViewLightDirty;
  59661. private _projectionTextureProjectionLightDirty;
  59662. private _projectionTextureDirty;
  59663. private _projectionTextureViewTargetVector;
  59664. private _projectionTextureViewLightMatrix;
  59665. private _projectionTextureProjectionLightMatrix;
  59666. private _projectionTextureScalingMatrix;
  59667. /**
  59668. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  59669. * It can cast shadows.
  59670. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59671. * @param name The light friendly name
  59672. * @param position The position of the spot light in the scene
  59673. * @param direction The direction of the light in the scene
  59674. * @param angle The cone angle of the light in Radians
  59675. * @param exponent The light decay speed with the distance from the emission spot
  59676. * @param scene The scene the lights belongs to
  59677. */
  59678. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  59679. /**
  59680. * Returns the string "SpotLight".
  59681. * @returns the class name
  59682. */
  59683. getClassName(): string;
  59684. /**
  59685. * Returns the integer 2.
  59686. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59687. */
  59688. getTypeID(): number;
  59689. /**
  59690. * Overrides the direction setter to recompute the projection texture view light Matrix.
  59691. */
  59692. protected _setDirection(value: Vector3): void;
  59693. /**
  59694. * Overrides the position setter to recompute the projection texture view light Matrix.
  59695. */
  59696. protected _setPosition(value: Vector3): void;
  59697. /**
  59698. * 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.
  59699. * Returns the SpotLight.
  59700. */
  59701. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59702. protected _computeProjectionTextureViewLightMatrix(): void;
  59703. protected _computeProjectionTextureProjectionLightMatrix(): void;
  59704. /**
  59705. * Main function for light texture projection matrix computing.
  59706. */
  59707. protected _computeProjectionTextureMatrix(): void;
  59708. protected _buildUniformLayout(): void;
  59709. private _computeAngleValues;
  59710. /**
  59711. * Sets the passed Effect "effect" with the Light textures.
  59712. * @param effect The effect to update
  59713. * @param lightIndex The index of the light in the effect to update
  59714. * @returns The light
  59715. */
  59716. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  59717. /**
  59718. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  59719. * @param effect The effect to update
  59720. * @param lightIndex The index of the light in the effect to update
  59721. * @returns The spot light
  59722. */
  59723. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  59724. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59725. /**
  59726. * Disposes the light and the associated resources.
  59727. */
  59728. dispose(): void;
  59729. /**
  59730. * Prepares the list of defines specific to the light type.
  59731. * @param defines the list of defines
  59732. * @param lightIndex defines the index of the light for the effect
  59733. */
  59734. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59735. }
  59736. }
  59737. declare module "babylonjs/Gizmos/lightGizmo" {
  59738. import { Nullable } from "babylonjs/types";
  59739. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59740. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59741. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59742. import { Light } from "babylonjs/Lights/light";
  59743. import { Observable } from "babylonjs/Misc/observable";
  59744. /**
  59745. * Gizmo that enables viewing a light
  59746. */
  59747. export class LightGizmo extends Gizmo {
  59748. private _lightMesh;
  59749. private _material;
  59750. private _cachedPosition;
  59751. private _cachedForward;
  59752. private _attachedMeshParent;
  59753. private _pointerObserver;
  59754. /**
  59755. * Event that fires each time the gizmo is clicked
  59756. */
  59757. onClickedObservable: Observable<Light>;
  59758. /**
  59759. * Creates a LightGizmo
  59760. * @param gizmoLayer The utility layer the gizmo will be added to
  59761. */
  59762. constructor(gizmoLayer?: UtilityLayerRenderer);
  59763. private _light;
  59764. /**
  59765. * The light that the gizmo is attached to
  59766. */
  59767. set light(light: Nullable<Light>);
  59768. get light(): Nullable<Light>;
  59769. /**
  59770. * Gets the material used to render the light gizmo
  59771. */
  59772. get material(): StandardMaterial;
  59773. /**
  59774. * @hidden
  59775. * Updates the gizmo to match the attached mesh's position/rotation
  59776. */
  59777. protected _update(): void;
  59778. private static _Scale;
  59779. /**
  59780. * Creates the lines for a light mesh
  59781. */
  59782. private static _CreateLightLines;
  59783. /**
  59784. * Disposes of the light gizmo
  59785. */
  59786. dispose(): void;
  59787. private static _CreateHemisphericLightMesh;
  59788. private static _CreatePointLightMesh;
  59789. private static _CreateSpotLightMesh;
  59790. private static _CreateDirectionalLightMesh;
  59791. }
  59792. }
  59793. declare module "babylonjs/Gizmos/cameraGizmo" {
  59794. import { Nullable } from "babylonjs/types";
  59795. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59796. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59797. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59798. import { Camera } from "babylonjs/Cameras/camera";
  59799. import { Observable } from "babylonjs/Misc/observable";
  59800. /**
  59801. * Gizmo that enables viewing a camera
  59802. */
  59803. export class CameraGizmo extends Gizmo {
  59804. private _cameraMesh;
  59805. private _cameraLinesMesh;
  59806. private _material;
  59807. private _pointerObserver;
  59808. /**
  59809. * Event that fires each time the gizmo is clicked
  59810. */
  59811. onClickedObservable: Observable<Camera>;
  59812. /**
  59813. * Creates a CameraGizmo
  59814. * @param gizmoLayer The utility layer the gizmo will be added to
  59815. */
  59816. constructor(gizmoLayer?: UtilityLayerRenderer);
  59817. private _camera;
  59818. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  59819. get displayFrustum(): boolean;
  59820. set displayFrustum(value: boolean);
  59821. /**
  59822. * The camera that the gizmo is attached to
  59823. */
  59824. set camera(camera: Nullable<Camera>);
  59825. get camera(): Nullable<Camera>;
  59826. /**
  59827. * Gets the material used to render the camera gizmo
  59828. */
  59829. get material(): StandardMaterial;
  59830. /**
  59831. * @hidden
  59832. * Updates the gizmo to match the attached mesh's position/rotation
  59833. */
  59834. protected _update(): void;
  59835. private static _Scale;
  59836. private _invProjection;
  59837. /**
  59838. * Disposes of the camera gizmo
  59839. */
  59840. dispose(): void;
  59841. private static _CreateCameraMesh;
  59842. private static _CreateCameraFrustum;
  59843. }
  59844. }
  59845. declare module "babylonjs/Gizmos/index" {
  59846. export * from "babylonjs/Gizmos/axisDragGizmo";
  59847. export * from "babylonjs/Gizmos/axisScaleGizmo";
  59848. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  59849. export * from "babylonjs/Gizmos/gizmo";
  59850. export * from "babylonjs/Gizmos/gizmoManager";
  59851. export * from "babylonjs/Gizmos/planeRotationGizmo";
  59852. export * from "babylonjs/Gizmos/positionGizmo";
  59853. export * from "babylonjs/Gizmos/rotationGizmo";
  59854. export * from "babylonjs/Gizmos/scaleGizmo";
  59855. export * from "babylonjs/Gizmos/lightGizmo";
  59856. export * from "babylonjs/Gizmos/cameraGizmo";
  59857. export * from "babylonjs/Gizmos/planeDragGizmo";
  59858. }
  59859. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  59860. /** @hidden */
  59861. export var backgroundFragmentDeclaration: {
  59862. name: string;
  59863. shader: string;
  59864. };
  59865. }
  59866. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  59867. /** @hidden */
  59868. export var backgroundUboDeclaration: {
  59869. name: string;
  59870. shader: string;
  59871. };
  59872. }
  59873. declare module "babylonjs/Shaders/background.fragment" {
  59874. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  59875. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59876. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59877. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59878. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59879. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59880. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59881. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59882. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59883. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59884. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  59885. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59886. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59887. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59888. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  59889. /** @hidden */
  59890. export var backgroundPixelShader: {
  59891. name: string;
  59892. shader: string;
  59893. };
  59894. }
  59895. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  59896. /** @hidden */
  59897. export var backgroundVertexDeclaration: {
  59898. name: string;
  59899. shader: string;
  59900. };
  59901. }
  59902. declare module "babylonjs/Shaders/background.vertex" {
  59903. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  59904. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59905. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59906. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59907. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59908. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59909. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59910. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59911. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59912. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59913. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59914. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59915. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59916. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59917. /** @hidden */
  59918. export var backgroundVertexShader: {
  59919. name: string;
  59920. shader: string;
  59921. };
  59922. }
  59923. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  59924. import { Nullable, int, float } from "babylonjs/types";
  59925. import { Scene } from "babylonjs/scene";
  59926. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59927. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59929. import { Mesh } from "babylonjs/Meshes/mesh";
  59930. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59931. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59932. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59934. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  59935. import { Color3 } from "babylonjs/Maths/math.color";
  59936. import "babylonjs/Shaders/background.fragment";
  59937. import "babylonjs/Shaders/background.vertex";
  59938. /**
  59939. * Background material used to create an efficient environement around your scene.
  59940. */
  59941. export class BackgroundMaterial extends PushMaterial {
  59942. /**
  59943. * Standard reflectance value at parallel view angle.
  59944. */
  59945. static StandardReflectance0: number;
  59946. /**
  59947. * Standard reflectance value at grazing angle.
  59948. */
  59949. static StandardReflectance90: number;
  59950. protected _primaryColor: Color3;
  59951. /**
  59952. * Key light Color (multiply against the environement texture)
  59953. */
  59954. primaryColor: Color3;
  59955. protected __perceptualColor: Nullable<Color3>;
  59956. /**
  59957. * Experimental Internal Use Only.
  59958. *
  59959. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  59960. * This acts as a helper to set the primary color to a more "human friendly" value.
  59961. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  59962. * output color as close as possible from the chosen value.
  59963. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  59964. * part of lighting setup.)
  59965. */
  59966. get _perceptualColor(): Nullable<Color3>;
  59967. set _perceptualColor(value: Nullable<Color3>);
  59968. protected _primaryColorShadowLevel: float;
  59969. /**
  59970. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  59971. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  59972. */
  59973. get primaryColorShadowLevel(): float;
  59974. set primaryColorShadowLevel(value: float);
  59975. protected _primaryColorHighlightLevel: float;
  59976. /**
  59977. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  59978. * The primary color is used at the level chosen to define what the white area would look.
  59979. */
  59980. get primaryColorHighlightLevel(): float;
  59981. set primaryColorHighlightLevel(value: float);
  59982. protected _reflectionTexture: Nullable<BaseTexture>;
  59983. /**
  59984. * Reflection Texture used in the material.
  59985. * Should be author in a specific way for the best result (refer to the documentation).
  59986. */
  59987. reflectionTexture: Nullable<BaseTexture>;
  59988. protected _reflectionBlur: float;
  59989. /**
  59990. * Reflection Texture level of blur.
  59991. *
  59992. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  59993. * texture twice.
  59994. */
  59995. reflectionBlur: float;
  59996. protected _diffuseTexture: Nullable<BaseTexture>;
  59997. /**
  59998. * Diffuse Texture used in the material.
  59999. * Should be author in a specific way for the best result (refer to the documentation).
  60000. */
  60001. diffuseTexture: Nullable<BaseTexture>;
  60002. protected _shadowLights: Nullable<IShadowLight[]>;
  60003. /**
  60004. * Specify the list of lights casting shadow on the material.
  60005. * All scene shadow lights will be included if null.
  60006. */
  60007. shadowLights: Nullable<IShadowLight[]>;
  60008. protected _shadowLevel: float;
  60009. /**
  60010. * Helps adjusting the shadow to a softer level if required.
  60011. * 0 means black shadows and 1 means no shadows.
  60012. */
  60013. shadowLevel: float;
  60014. protected _sceneCenter: Vector3;
  60015. /**
  60016. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60017. * It is usually zero but might be interesting to modify according to your setup.
  60018. */
  60019. sceneCenter: Vector3;
  60020. protected _opacityFresnel: boolean;
  60021. /**
  60022. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60023. * This helps ensuring a nice transition when the camera goes under the ground.
  60024. */
  60025. opacityFresnel: boolean;
  60026. protected _reflectionFresnel: boolean;
  60027. /**
  60028. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60029. * This helps adding a mirror texture on the ground.
  60030. */
  60031. reflectionFresnel: boolean;
  60032. protected _reflectionFalloffDistance: number;
  60033. /**
  60034. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60035. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60036. */
  60037. reflectionFalloffDistance: number;
  60038. protected _reflectionAmount: number;
  60039. /**
  60040. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60041. */
  60042. reflectionAmount: number;
  60043. protected _reflectionReflectance0: number;
  60044. /**
  60045. * This specifies the weight of the reflection at grazing angle.
  60046. */
  60047. reflectionReflectance0: number;
  60048. protected _reflectionReflectance90: number;
  60049. /**
  60050. * This specifies the weight of the reflection at a perpendicular point of view.
  60051. */
  60052. reflectionReflectance90: number;
  60053. /**
  60054. * Sets the reflection reflectance fresnel values according to the default standard
  60055. * empirically know to work well :-)
  60056. */
  60057. set reflectionStandardFresnelWeight(value: number);
  60058. protected _useRGBColor: boolean;
  60059. /**
  60060. * Helps to directly use the maps channels instead of their level.
  60061. */
  60062. useRGBColor: boolean;
  60063. protected _enableNoise: boolean;
  60064. /**
  60065. * This helps reducing the banding effect that could occur on the background.
  60066. */
  60067. enableNoise: boolean;
  60068. /**
  60069. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60070. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60071. * Recommended to be keep at 1.0 except for special cases.
  60072. */
  60073. get fovMultiplier(): number;
  60074. set fovMultiplier(value: number);
  60075. private _fovMultiplier;
  60076. /**
  60077. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60078. */
  60079. useEquirectangularFOV: boolean;
  60080. private _maxSimultaneousLights;
  60081. /**
  60082. * Number of Simultaneous lights allowed on the material.
  60083. */
  60084. maxSimultaneousLights: int;
  60085. private _shadowOnly;
  60086. /**
  60087. * Make the material only render shadows
  60088. */
  60089. shadowOnly: boolean;
  60090. /**
  60091. * Default configuration related to image processing available in the Background Material.
  60092. */
  60093. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60094. /**
  60095. * Keep track of the image processing observer to allow dispose and replace.
  60096. */
  60097. private _imageProcessingObserver;
  60098. /**
  60099. * Attaches a new image processing configuration to the PBR Material.
  60100. * @param configuration (if null the scene configuration will be use)
  60101. */
  60102. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60103. /**
  60104. * Gets the image processing configuration used either in this material.
  60105. */
  60106. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60107. /**
  60108. * Sets the Default image processing configuration used either in the this material.
  60109. *
  60110. * If sets to null, the scene one is in use.
  60111. */
  60112. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60113. /**
  60114. * Gets wether the color curves effect is enabled.
  60115. */
  60116. get cameraColorCurvesEnabled(): boolean;
  60117. /**
  60118. * Sets wether the color curves effect is enabled.
  60119. */
  60120. set cameraColorCurvesEnabled(value: boolean);
  60121. /**
  60122. * Gets wether the color grading effect is enabled.
  60123. */
  60124. get cameraColorGradingEnabled(): boolean;
  60125. /**
  60126. * Gets wether the color grading effect is enabled.
  60127. */
  60128. set cameraColorGradingEnabled(value: boolean);
  60129. /**
  60130. * Gets wether tonemapping is enabled or not.
  60131. */
  60132. get cameraToneMappingEnabled(): boolean;
  60133. /**
  60134. * Sets wether tonemapping is enabled or not
  60135. */
  60136. set cameraToneMappingEnabled(value: boolean);
  60137. /**
  60138. * The camera exposure used on this material.
  60139. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60140. * This corresponds to a photographic exposure.
  60141. */
  60142. get cameraExposure(): float;
  60143. /**
  60144. * The camera exposure used on this material.
  60145. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60146. * This corresponds to a photographic exposure.
  60147. */
  60148. set cameraExposure(value: float);
  60149. /**
  60150. * Gets The camera contrast used on this material.
  60151. */
  60152. get cameraContrast(): float;
  60153. /**
  60154. * Sets The camera contrast used on this material.
  60155. */
  60156. set cameraContrast(value: float);
  60157. /**
  60158. * Gets the Color Grading 2D Lookup Texture.
  60159. */
  60160. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60161. /**
  60162. * Sets the Color Grading 2D Lookup Texture.
  60163. */
  60164. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60165. /**
  60166. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60167. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60168. * 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;
  60169. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60170. */
  60171. get cameraColorCurves(): Nullable<ColorCurves>;
  60172. /**
  60173. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60174. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60175. * 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;
  60176. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60177. */
  60178. set cameraColorCurves(value: Nullable<ColorCurves>);
  60179. /**
  60180. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60181. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60182. */
  60183. switchToBGR: boolean;
  60184. private _renderTargets;
  60185. private _reflectionControls;
  60186. private _white;
  60187. private _primaryShadowColor;
  60188. private _primaryHighlightColor;
  60189. /**
  60190. * Instantiates a Background Material in the given scene
  60191. * @param name The friendly name of the material
  60192. * @param scene The scene to add the material to
  60193. */
  60194. constructor(name: string, scene: Scene);
  60195. /**
  60196. * Gets a boolean indicating that current material needs to register RTT
  60197. */
  60198. get hasRenderTargetTextures(): boolean;
  60199. /**
  60200. * The entire material has been created in order to prevent overdraw.
  60201. * @returns false
  60202. */
  60203. needAlphaTesting(): boolean;
  60204. /**
  60205. * The entire material has been created in order to prevent overdraw.
  60206. * @returns true if blending is enable
  60207. */
  60208. needAlphaBlending(): boolean;
  60209. /**
  60210. * Checks wether the material is ready to be rendered for a given mesh.
  60211. * @param mesh The mesh to render
  60212. * @param subMesh The submesh to check against
  60213. * @param useInstances Specify wether or not the material is used with instances
  60214. * @returns true if all the dependencies are ready (Textures, Effects...)
  60215. */
  60216. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60217. /**
  60218. * Compute the primary color according to the chosen perceptual color.
  60219. */
  60220. private _computePrimaryColorFromPerceptualColor;
  60221. /**
  60222. * Compute the highlights and shadow colors according to their chosen levels.
  60223. */
  60224. private _computePrimaryColors;
  60225. /**
  60226. * Build the uniform buffer used in the material.
  60227. */
  60228. buildUniformLayout(): void;
  60229. /**
  60230. * Unbind the material.
  60231. */
  60232. unbind(): void;
  60233. /**
  60234. * Bind only the world matrix to the material.
  60235. * @param world The world matrix to bind.
  60236. */
  60237. bindOnlyWorldMatrix(world: Matrix): void;
  60238. /**
  60239. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60240. * @param world The world matrix to bind.
  60241. * @param subMesh The submesh to bind for.
  60242. */
  60243. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60244. /**
  60245. * Checks to see if a texture is used in the material.
  60246. * @param texture - Base texture to use.
  60247. * @returns - Boolean specifying if a texture is used in the material.
  60248. */
  60249. hasTexture(texture: BaseTexture): boolean;
  60250. /**
  60251. * Dispose the material.
  60252. * @param forceDisposeEffect Force disposal of the associated effect.
  60253. * @param forceDisposeTextures Force disposal of the associated textures.
  60254. */
  60255. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60256. /**
  60257. * Clones the material.
  60258. * @param name The cloned name.
  60259. * @returns The cloned material.
  60260. */
  60261. clone(name: string): BackgroundMaterial;
  60262. /**
  60263. * Serializes the current material to its JSON representation.
  60264. * @returns The JSON representation.
  60265. */
  60266. serialize(): any;
  60267. /**
  60268. * Gets the class name of the material
  60269. * @returns "BackgroundMaterial"
  60270. */
  60271. getClassName(): string;
  60272. /**
  60273. * Parse a JSON input to create back a background material.
  60274. * @param source The JSON data to parse
  60275. * @param scene The scene to create the parsed material in
  60276. * @param rootUrl The root url of the assets the material depends upon
  60277. * @returns the instantiated BackgroundMaterial.
  60278. */
  60279. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60280. }
  60281. }
  60282. declare module "babylonjs/Helpers/environmentHelper" {
  60283. import { Observable } from "babylonjs/Misc/observable";
  60284. import { Nullable } from "babylonjs/types";
  60285. import { Scene } from "babylonjs/scene";
  60286. import { Vector3 } from "babylonjs/Maths/math.vector";
  60287. import { Color3 } from "babylonjs/Maths/math.color";
  60288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60289. import { Mesh } from "babylonjs/Meshes/mesh";
  60290. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60291. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60292. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60293. import "babylonjs/Meshes/Builders/planeBuilder";
  60294. import "babylonjs/Meshes/Builders/boxBuilder";
  60295. /**
  60296. * Represents the different options available during the creation of
  60297. * a Environment helper.
  60298. *
  60299. * This can control the default ground, skybox and image processing setup of your scene.
  60300. */
  60301. export interface IEnvironmentHelperOptions {
  60302. /**
  60303. * Specifies whether or not to create a ground.
  60304. * True by default.
  60305. */
  60306. createGround: boolean;
  60307. /**
  60308. * Specifies the ground size.
  60309. * 15 by default.
  60310. */
  60311. groundSize: number;
  60312. /**
  60313. * The texture used on the ground for the main color.
  60314. * Comes from the BabylonJS CDN by default.
  60315. *
  60316. * Remarks: Can be either a texture or a url.
  60317. */
  60318. groundTexture: string | BaseTexture;
  60319. /**
  60320. * The color mixed in the ground texture by default.
  60321. * BabylonJS clearColor by default.
  60322. */
  60323. groundColor: Color3;
  60324. /**
  60325. * Specifies the ground opacity.
  60326. * 1 by default.
  60327. */
  60328. groundOpacity: number;
  60329. /**
  60330. * Enables the ground to receive shadows.
  60331. * True by default.
  60332. */
  60333. enableGroundShadow: boolean;
  60334. /**
  60335. * Helps preventing the shadow to be fully black on the ground.
  60336. * 0.5 by default.
  60337. */
  60338. groundShadowLevel: number;
  60339. /**
  60340. * Creates a mirror texture attach to the ground.
  60341. * false by default.
  60342. */
  60343. enableGroundMirror: boolean;
  60344. /**
  60345. * Specifies the ground mirror size ratio.
  60346. * 0.3 by default as the default kernel is 64.
  60347. */
  60348. groundMirrorSizeRatio: number;
  60349. /**
  60350. * Specifies the ground mirror blur kernel size.
  60351. * 64 by default.
  60352. */
  60353. groundMirrorBlurKernel: number;
  60354. /**
  60355. * Specifies the ground mirror visibility amount.
  60356. * 1 by default
  60357. */
  60358. groundMirrorAmount: number;
  60359. /**
  60360. * Specifies the ground mirror reflectance weight.
  60361. * This uses the standard weight of the background material to setup the fresnel effect
  60362. * of the mirror.
  60363. * 1 by default.
  60364. */
  60365. groundMirrorFresnelWeight: number;
  60366. /**
  60367. * Specifies the ground mirror Falloff distance.
  60368. * This can helps reducing the size of the reflection.
  60369. * 0 by Default.
  60370. */
  60371. groundMirrorFallOffDistance: number;
  60372. /**
  60373. * Specifies the ground mirror texture type.
  60374. * Unsigned Int by Default.
  60375. */
  60376. groundMirrorTextureType: number;
  60377. /**
  60378. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60379. * the shown objects.
  60380. */
  60381. groundYBias: number;
  60382. /**
  60383. * Specifies whether or not to create a skybox.
  60384. * True by default.
  60385. */
  60386. createSkybox: boolean;
  60387. /**
  60388. * Specifies the skybox size.
  60389. * 20 by default.
  60390. */
  60391. skyboxSize: number;
  60392. /**
  60393. * The texture used on the skybox for the main color.
  60394. * Comes from the BabylonJS CDN by default.
  60395. *
  60396. * Remarks: Can be either a texture or a url.
  60397. */
  60398. skyboxTexture: string | BaseTexture;
  60399. /**
  60400. * The color mixed in the skybox texture by default.
  60401. * BabylonJS clearColor by default.
  60402. */
  60403. skyboxColor: Color3;
  60404. /**
  60405. * The background rotation around the Y axis of the scene.
  60406. * This helps aligning the key lights of your scene with the background.
  60407. * 0 by default.
  60408. */
  60409. backgroundYRotation: number;
  60410. /**
  60411. * Compute automatically the size of the elements to best fit with the scene.
  60412. */
  60413. sizeAuto: boolean;
  60414. /**
  60415. * Default position of the rootMesh if autoSize is not true.
  60416. */
  60417. rootPosition: Vector3;
  60418. /**
  60419. * Sets up the image processing in the scene.
  60420. * true by default.
  60421. */
  60422. setupImageProcessing: boolean;
  60423. /**
  60424. * The texture used as your environment texture in the scene.
  60425. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60426. *
  60427. * Remarks: Can be either a texture or a url.
  60428. */
  60429. environmentTexture: string | BaseTexture;
  60430. /**
  60431. * The value of the exposure to apply to the scene.
  60432. * 0.6 by default if setupImageProcessing is true.
  60433. */
  60434. cameraExposure: number;
  60435. /**
  60436. * The value of the contrast to apply to the scene.
  60437. * 1.6 by default if setupImageProcessing is true.
  60438. */
  60439. cameraContrast: number;
  60440. /**
  60441. * Specifies whether or not tonemapping should be enabled in the scene.
  60442. * true by default if setupImageProcessing is true.
  60443. */
  60444. toneMappingEnabled: boolean;
  60445. }
  60446. /**
  60447. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60448. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60449. * It also helps with the default setup of your imageProcessing configuration.
  60450. */
  60451. export class EnvironmentHelper {
  60452. /**
  60453. * Default ground texture URL.
  60454. */
  60455. private static _groundTextureCDNUrl;
  60456. /**
  60457. * Default skybox texture URL.
  60458. */
  60459. private static _skyboxTextureCDNUrl;
  60460. /**
  60461. * Default environment texture URL.
  60462. */
  60463. private static _environmentTextureCDNUrl;
  60464. /**
  60465. * Creates the default options for the helper.
  60466. */
  60467. private static _getDefaultOptions;
  60468. private _rootMesh;
  60469. /**
  60470. * Gets the root mesh created by the helper.
  60471. */
  60472. get rootMesh(): Mesh;
  60473. private _skybox;
  60474. /**
  60475. * Gets the skybox created by the helper.
  60476. */
  60477. get skybox(): Nullable<Mesh>;
  60478. private _skyboxTexture;
  60479. /**
  60480. * Gets the skybox texture created by the helper.
  60481. */
  60482. get skyboxTexture(): Nullable<BaseTexture>;
  60483. private _skyboxMaterial;
  60484. /**
  60485. * Gets the skybox material created by the helper.
  60486. */
  60487. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60488. private _ground;
  60489. /**
  60490. * Gets the ground mesh created by the helper.
  60491. */
  60492. get ground(): Nullable<Mesh>;
  60493. private _groundTexture;
  60494. /**
  60495. * Gets the ground texture created by the helper.
  60496. */
  60497. get groundTexture(): Nullable<BaseTexture>;
  60498. private _groundMirror;
  60499. /**
  60500. * Gets the ground mirror created by the helper.
  60501. */
  60502. get groundMirror(): Nullable<MirrorTexture>;
  60503. /**
  60504. * Gets the ground mirror render list to helps pushing the meshes
  60505. * you wish in the ground reflection.
  60506. */
  60507. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60508. private _groundMaterial;
  60509. /**
  60510. * Gets the ground material created by the helper.
  60511. */
  60512. get groundMaterial(): Nullable<BackgroundMaterial>;
  60513. /**
  60514. * Stores the creation options.
  60515. */
  60516. private readonly _scene;
  60517. private _options;
  60518. /**
  60519. * This observable will be notified with any error during the creation of the environment,
  60520. * mainly texture creation errors.
  60521. */
  60522. onErrorObservable: Observable<{
  60523. message?: string;
  60524. exception?: any;
  60525. }>;
  60526. /**
  60527. * constructor
  60528. * @param options Defines the options we want to customize the helper
  60529. * @param scene The scene to add the material to
  60530. */
  60531. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60532. /**
  60533. * Updates the background according to the new options
  60534. * @param options
  60535. */
  60536. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60537. /**
  60538. * Sets the primary color of all the available elements.
  60539. * @param color the main color to affect to the ground and the background
  60540. */
  60541. setMainColor(color: Color3): void;
  60542. /**
  60543. * Setup the image processing according to the specified options.
  60544. */
  60545. private _setupImageProcessing;
  60546. /**
  60547. * Setup the environment texture according to the specified options.
  60548. */
  60549. private _setupEnvironmentTexture;
  60550. /**
  60551. * Setup the background according to the specified options.
  60552. */
  60553. private _setupBackground;
  60554. /**
  60555. * Get the scene sizes according to the setup.
  60556. */
  60557. private _getSceneSize;
  60558. /**
  60559. * Setup the ground according to the specified options.
  60560. */
  60561. private _setupGround;
  60562. /**
  60563. * Setup the ground material according to the specified options.
  60564. */
  60565. private _setupGroundMaterial;
  60566. /**
  60567. * Setup the ground diffuse texture according to the specified options.
  60568. */
  60569. private _setupGroundDiffuseTexture;
  60570. /**
  60571. * Setup the ground mirror texture according to the specified options.
  60572. */
  60573. private _setupGroundMirrorTexture;
  60574. /**
  60575. * Setup the ground to receive the mirror texture.
  60576. */
  60577. private _setupMirrorInGroundMaterial;
  60578. /**
  60579. * Setup the skybox according to the specified options.
  60580. */
  60581. private _setupSkybox;
  60582. /**
  60583. * Setup the skybox material according to the specified options.
  60584. */
  60585. private _setupSkyboxMaterial;
  60586. /**
  60587. * Setup the skybox reflection texture according to the specified options.
  60588. */
  60589. private _setupSkyboxReflectionTexture;
  60590. private _errorHandler;
  60591. /**
  60592. * Dispose all the elements created by the Helper.
  60593. */
  60594. dispose(): void;
  60595. }
  60596. }
  60597. declare module "babylonjs/Helpers/textureDome" {
  60598. import { Scene } from "babylonjs/scene";
  60599. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60600. import { Mesh } from "babylonjs/Meshes/mesh";
  60601. import { Texture } from "babylonjs/Materials/Textures/texture";
  60602. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60603. import "babylonjs/Meshes/Builders/sphereBuilder";
  60604. import { Nullable } from "babylonjs/types";
  60605. import { Observable } from "babylonjs/Misc/observable";
  60606. /**
  60607. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  60608. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  60609. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60610. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60611. */
  60612. export abstract class TextureDome<T extends Texture> extends TransformNode {
  60613. protected onError: Nullable<(message?: string, exception?: any) => void>;
  60614. /**
  60615. * Define the source as a Monoscopic panoramic 360/180.
  60616. */
  60617. static readonly MODE_MONOSCOPIC: number;
  60618. /**
  60619. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  60620. */
  60621. static readonly MODE_TOPBOTTOM: number;
  60622. /**
  60623. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  60624. */
  60625. static readonly MODE_SIDEBYSIDE: number;
  60626. private _halfDome;
  60627. private _crossEye;
  60628. protected _useDirectMapping: boolean;
  60629. /**
  60630. * The texture being displayed on the sphere
  60631. */
  60632. protected _texture: T;
  60633. /**
  60634. * Gets the texture being displayed on the sphere
  60635. */
  60636. get texture(): T;
  60637. /**
  60638. * Sets the texture being displayed on the sphere
  60639. */
  60640. set texture(newTexture: T);
  60641. /**
  60642. * The skybox material
  60643. */
  60644. protected _material: BackgroundMaterial;
  60645. /**
  60646. * The surface used for the dome
  60647. */
  60648. protected _mesh: Mesh;
  60649. /**
  60650. * Gets the mesh used for the dome.
  60651. */
  60652. get mesh(): Mesh;
  60653. /**
  60654. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  60655. */
  60656. private _halfDomeMask;
  60657. /**
  60658. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60659. * Also see the options.resolution property.
  60660. */
  60661. get fovMultiplier(): number;
  60662. set fovMultiplier(value: number);
  60663. protected _textureMode: number;
  60664. /**
  60665. * Gets or set the current texture mode for the texture. It can be:
  60666. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60667. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60668. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60669. */
  60670. get textureMode(): number;
  60671. /**
  60672. * Sets the current texture mode for the texture. It can be:
  60673. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60674. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60675. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60676. */
  60677. set textureMode(value: number);
  60678. /**
  60679. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  60680. */
  60681. get halfDome(): boolean;
  60682. /**
  60683. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60684. */
  60685. set halfDome(enabled: boolean);
  60686. /**
  60687. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  60688. */
  60689. set crossEye(enabled: boolean);
  60690. /**
  60691. * Is it a cross-eye texture?
  60692. */
  60693. get crossEye(): boolean;
  60694. /**
  60695. * Oberserver used in Stereoscopic VR Mode.
  60696. */
  60697. private _onBeforeCameraRenderObserver;
  60698. /**
  60699. * Observable raised when an error occured while loading the 360 image
  60700. */
  60701. onLoadErrorObservable: Observable<string>;
  60702. /**
  60703. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  60704. * @param name Element's name, child elements will append suffixes for their own names.
  60705. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  60706. * @param options An object containing optional or exposed sub element properties
  60707. */
  60708. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  60709. resolution?: number;
  60710. clickToPlay?: boolean;
  60711. autoPlay?: boolean;
  60712. loop?: boolean;
  60713. size?: number;
  60714. poster?: string;
  60715. faceForward?: boolean;
  60716. useDirectMapping?: boolean;
  60717. halfDomeMode?: boolean;
  60718. crossEyeMode?: boolean;
  60719. generateMipMaps?: boolean;
  60720. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  60721. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  60722. protected _changeTextureMode(value: number): void;
  60723. /**
  60724. * Releases resources associated with this node.
  60725. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60726. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60727. */
  60728. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60729. }
  60730. }
  60731. declare module "babylonjs/Helpers/photoDome" {
  60732. import { Scene } from "babylonjs/scene";
  60733. import { Texture } from "babylonjs/Materials/Textures/texture";
  60734. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60735. /**
  60736. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  60737. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  60738. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60739. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60740. */
  60741. export class PhotoDome extends TextureDome<Texture> {
  60742. /**
  60743. * Define the image as a Monoscopic panoramic 360 image.
  60744. */
  60745. static readonly MODE_MONOSCOPIC: number;
  60746. /**
  60747. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  60748. */
  60749. static readonly MODE_TOPBOTTOM: number;
  60750. /**
  60751. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  60752. */
  60753. static readonly MODE_SIDEBYSIDE: number;
  60754. /**
  60755. * Gets or sets the texture being displayed on the sphere
  60756. */
  60757. get photoTexture(): Texture;
  60758. /**
  60759. * sets the texture being displayed on the sphere
  60760. */
  60761. set photoTexture(value: Texture);
  60762. /**
  60763. * Gets the current video mode for the video. It can be:
  60764. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60765. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60766. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60767. */
  60768. get imageMode(): number;
  60769. /**
  60770. * Sets the current video mode for the video. It can be:
  60771. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60772. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60773. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60774. */
  60775. set imageMode(value: number);
  60776. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  60777. }
  60778. }
  60779. declare module "babylonjs/Misc/dds" {
  60780. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60781. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60782. import { Nullable } from "babylonjs/types";
  60783. import { Scene } from "babylonjs/scene";
  60784. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60785. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60786. /**
  60787. * Direct draw surface info
  60788. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60789. */
  60790. export interface DDSInfo {
  60791. /**
  60792. * Width of the texture
  60793. */
  60794. width: number;
  60795. /**
  60796. * Width of the texture
  60797. */
  60798. height: number;
  60799. /**
  60800. * Number of Mipmaps for the texture
  60801. * @see https://en.wikipedia.org/wiki/Mipmap
  60802. */
  60803. mipmapCount: number;
  60804. /**
  60805. * If the textures format is a known fourCC format
  60806. * @see https://www.fourcc.org/
  60807. */
  60808. isFourCC: boolean;
  60809. /**
  60810. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60811. */
  60812. isRGB: boolean;
  60813. /**
  60814. * If the texture is a lumincance format
  60815. */
  60816. isLuminance: boolean;
  60817. /**
  60818. * If this is a cube texture
  60819. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60820. */
  60821. isCube: boolean;
  60822. /**
  60823. * If the texture is a compressed format eg. FOURCC_DXT1
  60824. */
  60825. isCompressed: boolean;
  60826. /**
  60827. * The dxgiFormat of the texture
  60828. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60829. */
  60830. dxgiFormat: number;
  60831. /**
  60832. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60833. */
  60834. textureType: number;
  60835. /**
  60836. * Sphericle polynomial created for the dds texture
  60837. */
  60838. sphericalPolynomial?: SphericalPolynomial;
  60839. }
  60840. /**
  60841. * Class used to provide DDS decompression tools
  60842. */
  60843. export class DDSTools {
  60844. /**
  60845. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60846. */
  60847. static StoreLODInAlphaChannel: boolean;
  60848. /**
  60849. * Gets DDS information from an array buffer
  60850. * @param data defines the array buffer view to read data from
  60851. * @returns the DDS information
  60852. */
  60853. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60854. private static _FloatView;
  60855. private static _Int32View;
  60856. private static _ToHalfFloat;
  60857. private static _FromHalfFloat;
  60858. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60859. private static _GetHalfFloatRGBAArrayBuffer;
  60860. private static _GetFloatRGBAArrayBuffer;
  60861. private static _GetFloatAsUIntRGBAArrayBuffer;
  60862. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60863. private static _GetRGBAArrayBuffer;
  60864. private static _ExtractLongWordOrder;
  60865. private static _GetRGBArrayBuffer;
  60866. private static _GetLuminanceArrayBuffer;
  60867. /**
  60868. * Uploads DDS Levels to a Babylon Texture
  60869. * @hidden
  60870. */
  60871. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60872. }
  60873. module "babylonjs/Engines/thinEngine" {
  60874. interface ThinEngine {
  60875. /**
  60876. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60877. * @param rootUrl defines the url where the file to load is located
  60878. * @param scene defines the current scene
  60879. * @param lodScale defines scale to apply to the mip map selection
  60880. * @param lodOffset defines offset to apply to the mip map selection
  60881. * @param onLoad defines an optional callback raised when the texture is loaded
  60882. * @param onError defines an optional callback raised if there is an issue to load the texture
  60883. * @param format defines the format of the data
  60884. * @param forcedExtension defines the extension to use to pick the right loader
  60885. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60886. * @returns the cube texture as an InternalTexture
  60887. */
  60888. 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;
  60889. }
  60890. }
  60891. }
  60892. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60893. import { Nullable } from "babylonjs/types";
  60894. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60895. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60896. /**
  60897. * Implementation of the DDS Texture Loader.
  60898. * @hidden
  60899. */
  60900. export class _DDSTextureLoader implements IInternalTextureLoader {
  60901. /**
  60902. * Defines wether the loader supports cascade loading the different faces.
  60903. */
  60904. readonly supportCascades: boolean;
  60905. /**
  60906. * This returns if the loader support the current file information.
  60907. * @param extension defines the file extension of the file being loaded
  60908. * @returns true if the loader can load the specified file
  60909. */
  60910. canLoad(extension: string): boolean;
  60911. /**
  60912. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60913. * @param data contains the texture data
  60914. * @param texture defines the BabylonJS internal texture
  60915. * @param createPolynomials will be true if polynomials have been requested
  60916. * @param onLoad defines the callback to trigger once the texture is ready
  60917. * @param onError defines the callback to trigger in case of error
  60918. */
  60919. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60920. /**
  60921. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60922. * @param data contains the texture data
  60923. * @param texture defines the BabylonJS internal texture
  60924. * @param callback defines the method to call once ready to upload
  60925. */
  60926. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60927. }
  60928. }
  60929. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60930. import { Nullable } from "babylonjs/types";
  60931. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60932. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60933. /**
  60934. * Implementation of the ENV Texture Loader.
  60935. * @hidden
  60936. */
  60937. export class _ENVTextureLoader implements IInternalTextureLoader {
  60938. /**
  60939. * Defines wether the loader supports cascade loading the different faces.
  60940. */
  60941. readonly supportCascades: boolean;
  60942. /**
  60943. * This returns if the loader support the current file information.
  60944. * @param extension defines the file extension of the file being loaded
  60945. * @returns true if the loader can load the specified file
  60946. */
  60947. canLoad(extension: string): boolean;
  60948. /**
  60949. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60950. * @param data contains the texture data
  60951. * @param texture defines the BabylonJS internal texture
  60952. * @param createPolynomials will be true if polynomials have been requested
  60953. * @param onLoad defines the callback to trigger once the texture is ready
  60954. * @param onError defines the callback to trigger in case of error
  60955. */
  60956. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60957. /**
  60958. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60959. * @param data contains the texture data
  60960. * @param texture defines the BabylonJS internal texture
  60961. * @param callback defines the method to call once ready to upload
  60962. */
  60963. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60964. }
  60965. }
  60966. declare module "babylonjs/Misc/khronosTextureContainer" {
  60967. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60968. /**
  60969. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60970. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60971. */
  60972. export class KhronosTextureContainer {
  60973. /** contents of the KTX container file */
  60974. data: ArrayBufferView;
  60975. private static HEADER_LEN;
  60976. private static COMPRESSED_2D;
  60977. private static COMPRESSED_3D;
  60978. private static TEX_2D;
  60979. private static TEX_3D;
  60980. /**
  60981. * Gets the openGL type
  60982. */
  60983. glType: number;
  60984. /**
  60985. * Gets the openGL type size
  60986. */
  60987. glTypeSize: number;
  60988. /**
  60989. * Gets the openGL format
  60990. */
  60991. glFormat: number;
  60992. /**
  60993. * Gets the openGL internal format
  60994. */
  60995. glInternalFormat: number;
  60996. /**
  60997. * Gets the base internal format
  60998. */
  60999. glBaseInternalFormat: number;
  61000. /**
  61001. * Gets image width in pixel
  61002. */
  61003. pixelWidth: number;
  61004. /**
  61005. * Gets image height in pixel
  61006. */
  61007. pixelHeight: number;
  61008. /**
  61009. * Gets image depth in pixels
  61010. */
  61011. pixelDepth: number;
  61012. /**
  61013. * Gets the number of array elements
  61014. */
  61015. numberOfArrayElements: number;
  61016. /**
  61017. * Gets the number of faces
  61018. */
  61019. numberOfFaces: number;
  61020. /**
  61021. * Gets the number of mipmap levels
  61022. */
  61023. numberOfMipmapLevels: number;
  61024. /**
  61025. * Gets the bytes of key value data
  61026. */
  61027. bytesOfKeyValueData: number;
  61028. /**
  61029. * Gets the load type
  61030. */
  61031. loadType: number;
  61032. /**
  61033. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61034. */
  61035. isInvalid: boolean;
  61036. /**
  61037. * Creates a new KhronosTextureContainer
  61038. * @param data contents of the KTX container file
  61039. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61040. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61041. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61042. */
  61043. constructor(
  61044. /** contents of the KTX container file */
  61045. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61046. /**
  61047. * Uploads KTX content to a Babylon Texture.
  61048. * It is assumed that the texture has already been created & is currently bound
  61049. * @hidden
  61050. */
  61051. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61052. private _upload2DCompressedLevels;
  61053. /**
  61054. * Checks if the given data starts with a KTX file identifier.
  61055. * @param data the data to check
  61056. * @returns true if the data is a KTX file or false otherwise
  61057. */
  61058. static IsValid(data: ArrayBufferView): boolean;
  61059. }
  61060. }
  61061. declare module "babylonjs/Misc/workerPool" {
  61062. import { IDisposable } from "babylonjs/scene";
  61063. /**
  61064. * Helper class to push actions to a pool of workers.
  61065. */
  61066. export class WorkerPool implements IDisposable {
  61067. private _workerInfos;
  61068. private _pendingActions;
  61069. /**
  61070. * Constructor
  61071. * @param workers Array of workers to use for actions
  61072. */
  61073. constructor(workers: Array<Worker>);
  61074. /**
  61075. * Terminates all workers and clears any pending actions.
  61076. */
  61077. dispose(): void;
  61078. /**
  61079. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61080. * pended until a worker has completed its action.
  61081. * @param action The action to perform. Call onComplete when the action is complete.
  61082. */
  61083. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61084. private _execute;
  61085. }
  61086. }
  61087. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61088. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61089. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61090. /**
  61091. * Class for loading KTX2 files
  61092. */
  61093. export class KhronosTextureContainer2 {
  61094. private static _WorkerPoolPromise?;
  61095. private static _Initialized;
  61096. private static _Ktx2Decoder;
  61097. /**
  61098. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61099. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61100. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61101. * Urls you can change:
  61102. * URLConfig.jsDecoderModule
  61103. * URLConfig.wasmUASTCToASTC
  61104. * URLConfig.wasmUASTCToBC7
  61105. * URLConfig.jsMSCTranscoder
  61106. * URLConfig.wasmMSCTranscoder
  61107. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61108. */
  61109. static URLConfig: {
  61110. jsDecoderModule: string;
  61111. wasmUASTCToASTC: null;
  61112. wasmUASTCToBC7: null;
  61113. jsMSCTranscoder: null;
  61114. wasmMSCTranscoder: null;
  61115. };
  61116. /**
  61117. * Default number of workers used to handle data decoding
  61118. */
  61119. static DefaultNumWorkers: number;
  61120. private static GetDefaultNumWorkers;
  61121. private _engine;
  61122. private static _CreateWorkerPool;
  61123. /**
  61124. * Constructor
  61125. * @param engine The engine to use
  61126. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61127. */
  61128. constructor(engine: ThinEngine, numWorkers?: number);
  61129. /** @hidden */
  61130. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  61131. /**
  61132. * Stop all async operations and release resources.
  61133. */
  61134. dispose(): void;
  61135. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  61136. /**
  61137. * Checks if the given data starts with a KTX2 file identifier.
  61138. * @param data the data to check
  61139. * @returns true if the data is a KTX2 file or false otherwise
  61140. */
  61141. static IsValid(data: ArrayBufferView): boolean;
  61142. }
  61143. }
  61144. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61145. import { Nullable } from "babylonjs/types";
  61146. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61147. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61148. /**
  61149. * Implementation of the KTX Texture Loader.
  61150. * @hidden
  61151. */
  61152. export class _KTXTextureLoader implements IInternalTextureLoader {
  61153. /**
  61154. * Defines wether the loader supports cascade loading the different faces.
  61155. */
  61156. readonly supportCascades: boolean;
  61157. /**
  61158. * This returns if the loader support the current file information.
  61159. * @param extension defines the file extension of the file being loaded
  61160. * @param mimeType defines the optional mime type of the file being loaded
  61161. * @returns true if the loader can load the specified file
  61162. */
  61163. canLoad(extension: string, mimeType?: string): boolean;
  61164. /**
  61165. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61166. * @param data contains the texture data
  61167. * @param texture defines the BabylonJS internal texture
  61168. * @param createPolynomials will be true if polynomials have been requested
  61169. * @param onLoad defines the callback to trigger once the texture is ready
  61170. * @param onError defines the callback to trigger in case of error
  61171. */
  61172. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61173. /**
  61174. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61175. * @param data contains the texture data
  61176. * @param texture defines the BabylonJS internal texture
  61177. * @param callback defines the method to call once ready to upload
  61178. */
  61179. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  61180. }
  61181. }
  61182. declare module "babylonjs/Helpers/sceneHelpers" {
  61183. import { Nullable } from "babylonjs/types";
  61184. import { Mesh } from "babylonjs/Meshes/mesh";
  61185. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61186. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61187. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61188. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61189. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61190. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61191. import "babylonjs/Meshes/Builders/boxBuilder";
  61192. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61193. /** @hidden */
  61194. export var _forceSceneHelpersToBundle: boolean;
  61195. module "babylonjs/scene" {
  61196. interface Scene {
  61197. /**
  61198. * Creates a default light for the scene.
  61199. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61200. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61201. */
  61202. createDefaultLight(replace?: boolean): void;
  61203. /**
  61204. * Creates a default camera for the scene.
  61205. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61206. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61207. * @param replace has default false, when true replaces the active camera in the scene
  61208. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61209. */
  61210. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61211. /**
  61212. * Creates a default camera and a default light.
  61213. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61214. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61215. * @param replace has the default false, when true replaces the active camera/light in the scene
  61216. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61217. */
  61218. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61219. /**
  61220. * Creates a new sky box
  61221. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61222. * @param environmentTexture defines the texture to use as environment texture
  61223. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61224. * @param scale defines the overall scale of the skybox
  61225. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61226. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61227. * @returns a new mesh holding the sky box
  61228. */
  61229. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61230. /**
  61231. * Creates a new environment
  61232. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61233. * @param options defines the options you can use to configure the environment
  61234. * @returns the new EnvironmentHelper
  61235. */
  61236. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61237. /**
  61238. * Creates a new VREXperienceHelper
  61239. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61240. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61241. * @returns a new VREXperienceHelper
  61242. */
  61243. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61244. /**
  61245. * Creates a new WebXRDefaultExperience
  61246. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61247. * @param options experience options
  61248. * @returns a promise for a new WebXRDefaultExperience
  61249. */
  61250. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61251. }
  61252. }
  61253. }
  61254. declare module "babylonjs/Helpers/videoDome" {
  61255. import { Scene } from "babylonjs/scene";
  61256. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61257. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61258. /**
  61259. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61260. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61261. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61262. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61263. */
  61264. export class VideoDome extends TextureDome<VideoTexture> {
  61265. /**
  61266. * Define the video source as a Monoscopic panoramic 360 video.
  61267. */
  61268. static readonly MODE_MONOSCOPIC: number;
  61269. /**
  61270. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61271. */
  61272. static readonly MODE_TOPBOTTOM: number;
  61273. /**
  61274. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61275. */
  61276. static readonly MODE_SIDEBYSIDE: number;
  61277. /**
  61278. * Get the video texture associated with this video dome
  61279. */
  61280. get videoTexture(): VideoTexture;
  61281. /**
  61282. * Get the video mode of this dome
  61283. */
  61284. get videoMode(): number;
  61285. /**
  61286. * Set the video mode of this dome.
  61287. * @see textureMode
  61288. */
  61289. set videoMode(value: number);
  61290. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61291. }
  61292. }
  61293. declare module "babylonjs/Helpers/index" {
  61294. export * from "babylonjs/Helpers/environmentHelper";
  61295. export * from "babylonjs/Helpers/photoDome";
  61296. export * from "babylonjs/Helpers/sceneHelpers";
  61297. export * from "babylonjs/Helpers/videoDome";
  61298. }
  61299. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61300. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61301. import { IDisposable } from "babylonjs/scene";
  61302. import { Engine } from "babylonjs/Engines/engine";
  61303. /**
  61304. * This class can be used to get instrumentation data from a Babylon engine
  61305. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61306. */
  61307. export class EngineInstrumentation implements IDisposable {
  61308. /**
  61309. * Define the instrumented engine.
  61310. */
  61311. engine: Engine;
  61312. private _captureGPUFrameTime;
  61313. private _gpuFrameTimeToken;
  61314. private _gpuFrameTime;
  61315. private _captureShaderCompilationTime;
  61316. private _shaderCompilationTime;
  61317. private _onBeginFrameObserver;
  61318. private _onEndFrameObserver;
  61319. private _onBeforeShaderCompilationObserver;
  61320. private _onAfterShaderCompilationObserver;
  61321. /**
  61322. * Gets the perf counter used for GPU frame time
  61323. */
  61324. get gpuFrameTimeCounter(): PerfCounter;
  61325. /**
  61326. * Gets the GPU frame time capture status
  61327. */
  61328. get captureGPUFrameTime(): boolean;
  61329. /**
  61330. * Enable or disable the GPU frame time capture
  61331. */
  61332. set captureGPUFrameTime(value: boolean);
  61333. /**
  61334. * Gets the perf counter used for shader compilation time
  61335. */
  61336. get shaderCompilationTimeCounter(): PerfCounter;
  61337. /**
  61338. * Gets the shader compilation time capture status
  61339. */
  61340. get captureShaderCompilationTime(): boolean;
  61341. /**
  61342. * Enable or disable the shader compilation time capture
  61343. */
  61344. set captureShaderCompilationTime(value: boolean);
  61345. /**
  61346. * Instantiates a new engine instrumentation.
  61347. * This class can be used to get instrumentation data from a Babylon engine
  61348. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61349. * @param engine Defines the engine to instrument
  61350. */
  61351. constructor(
  61352. /**
  61353. * Define the instrumented engine.
  61354. */
  61355. engine: Engine);
  61356. /**
  61357. * Dispose and release associated resources.
  61358. */
  61359. dispose(): void;
  61360. }
  61361. }
  61362. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61363. import { Scene, IDisposable } from "babylonjs/scene";
  61364. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61365. /**
  61366. * This class can be used to get instrumentation data from a Babylon engine
  61367. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61368. */
  61369. export class SceneInstrumentation implements IDisposable {
  61370. /**
  61371. * Defines the scene to instrument
  61372. */
  61373. scene: Scene;
  61374. private _captureActiveMeshesEvaluationTime;
  61375. private _activeMeshesEvaluationTime;
  61376. private _captureRenderTargetsRenderTime;
  61377. private _renderTargetsRenderTime;
  61378. private _captureFrameTime;
  61379. private _frameTime;
  61380. private _captureRenderTime;
  61381. private _renderTime;
  61382. private _captureInterFrameTime;
  61383. private _interFrameTime;
  61384. private _captureParticlesRenderTime;
  61385. private _particlesRenderTime;
  61386. private _captureSpritesRenderTime;
  61387. private _spritesRenderTime;
  61388. private _capturePhysicsTime;
  61389. private _physicsTime;
  61390. private _captureAnimationsTime;
  61391. private _animationsTime;
  61392. private _captureCameraRenderTime;
  61393. private _cameraRenderTime;
  61394. private _onBeforeActiveMeshesEvaluationObserver;
  61395. private _onAfterActiveMeshesEvaluationObserver;
  61396. private _onBeforeRenderTargetsRenderObserver;
  61397. private _onAfterRenderTargetsRenderObserver;
  61398. private _onAfterRenderObserver;
  61399. private _onBeforeDrawPhaseObserver;
  61400. private _onAfterDrawPhaseObserver;
  61401. private _onBeforeAnimationsObserver;
  61402. private _onBeforeParticlesRenderingObserver;
  61403. private _onAfterParticlesRenderingObserver;
  61404. private _onBeforeSpritesRenderingObserver;
  61405. private _onAfterSpritesRenderingObserver;
  61406. private _onBeforePhysicsObserver;
  61407. private _onAfterPhysicsObserver;
  61408. private _onAfterAnimationsObserver;
  61409. private _onBeforeCameraRenderObserver;
  61410. private _onAfterCameraRenderObserver;
  61411. /**
  61412. * Gets the perf counter used for active meshes evaluation time
  61413. */
  61414. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61415. /**
  61416. * Gets the active meshes evaluation time capture status
  61417. */
  61418. get captureActiveMeshesEvaluationTime(): boolean;
  61419. /**
  61420. * Enable or disable the active meshes evaluation time capture
  61421. */
  61422. set captureActiveMeshesEvaluationTime(value: boolean);
  61423. /**
  61424. * Gets the perf counter used for render targets render time
  61425. */
  61426. get renderTargetsRenderTimeCounter(): PerfCounter;
  61427. /**
  61428. * Gets the render targets render time capture status
  61429. */
  61430. get captureRenderTargetsRenderTime(): boolean;
  61431. /**
  61432. * Enable or disable the render targets render time capture
  61433. */
  61434. set captureRenderTargetsRenderTime(value: boolean);
  61435. /**
  61436. * Gets the perf counter used for particles render time
  61437. */
  61438. get particlesRenderTimeCounter(): PerfCounter;
  61439. /**
  61440. * Gets the particles render time capture status
  61441. */
  61442. get captureParticlesRenderTime(): boolean;
  61443. /**
  61444. * Enable or disable the particles render time capture
  61445. */
  61446. set captureParticlesRenderTime(value: boolean);
  61447. /**
  61448. * Gets the perf counter used for sprites render time
  61449. */
  61450. get spritesRenderTimeCounter(): PerfCounter;
  61451. /**
  61452. * Gets the sprites render time capture status
  61453. */
  61454. get captureSpritesRenderTime(): boolean;
  61455. /**
  61456. * Enable or disable the sprites render time capture
  61457. */
  61458. set captureSpritesRenderTime(value: boolean);
  61459. /**
  61460. * Gets the perf counter used for physics time
  61461. */
  61462. get physicsTimeCounter(): PerfCounter;
  61463. /**
  61464. * Gets the physics time capture status
  61465. */
  61466. get capturePhysicsTime(): boolean;
  61467. /**
  61468. * Enable or disable the physics time capture
  61469. */
  61470. set capturePhysicsTime(value: boolean);
  61471. /**
  61472. * Gets the perf counter used for animations time
  61473. */
  61474. get animationsTimeCounter(): PerfCounter;
  61475. /**
  61476. * Gets the animations time capture status
  61477. */
  61478. get captureAnimationsTime(): boolean;
  61479. /**
  61480. * Enable or disable the animations time capture
  61481. */
  61482. set captureAnimationsTime(value: boolean);
  61483. /**
  61484. * Gets the perf counter used for frame time capture
  61485. */
  61486. get frameTimeCounter(): PerfCounter;
  61487. /**
  61488. * Gets the frame time capture status
  61489. */
  61490. get captureFrameTime(): boolean;
  61491. /**
  61492. * Enable or disable the frame time capture
  61493. */
  61494. set captureFrameTime(value: boolean);
  61495. /**
  61496. * Gets the perf counter used for inter-frames time capture
  61497. */
  61498. get interFrameTimeCounter(): PerfCounter;
  61499. /**
  61500. * Gets the inter-frames time capture status
  61501. */
  61502. get captureInterFrameTime(): boolean;
  61503. /**
  61504. * Enable or disable the inter-frames time capture
  61505. */
  61506. set captureInterFrameTime(value: boolean);
  61507. /**
  61508. * Gets the perf counter used for render time capture
  61509. */
  61510. get renderTimeCounter(): PerfCounter;
  61511. /**
  61512. * Gets the render time capture status
  61513. */
  61514. get captureRenderTime(): boolean;
  61515. /**
  61516. * Enable or disable the render time capture
  61517. */
  61518. set captureRenderTime(value: boolean);
  61519. /**
  61520. * Gets the perf counter used for camera render time capture
  61521. */
  61522. get cameraRenderTimeCounter(): PerfCounter;
  61523. /**
  61524. * Gets the camera render time capture status
  61525. */
  61526. get captureCameraRenderTime(): boolean;
  61527. /**
  61528. * Enable or disable the camera render time capture
  61529. */
  61530. set captureCameraRenderTime(value: boolean);
  61531. /**
  61532. * Gets the perf counter used for draw calls
  61533. */
  61534. get drawCallsCounter(): PerfCounter;
  61535. /**
  61536. * Instantiates a new scene instrumentation.
  61537. * This class can be used to get instrumentation data from a Babylon engine
  61538. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61539. * @param scene Defines the scene to instrument
  61540. */
  61541. constructor(
  61542. /**
  61543. * Defines the scene to instrument
  61544. */
  61545. scene: Scene);
  61546. /**
  61547. * Dispose and release associated resources.
  61548. */
  61549. dispose(): void;
  61550. }
  61551. }
  61552. declare module "babylonjs/Instrumentation/index" {
  61553. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61554. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61555. export * from "babylonjs/Instrumentation/timeToken";
  61556. }
  61557. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61558. /** @hidden */
  61559. export var glowMapGenerationPixelShader: {
  61560. name: string;
  61561. shader: string;
  61562. };
  61563. }
  61564. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61565. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61566. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61567. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61568. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61569. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61570. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61571. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61572. /** @hidden */
  61573. export var glowMapGenerationVertexShader: {
  61574. name: string;
  61575. shader: string;
  61576. };
  61577. }
  61578. declare module "babylonjs/Layers/effectLayer" {
  61579. import { Observable } from "babylonjs/Misc/observable";
  61580. import { Nullable } from "babylonjs/types";
  61581. import { Camera } from "babylonjs/Cameras/camera";
  61582. import { Scene } from "babylonjs/scene";
  61583. import { ISize } from "babylonjs/Maths/math.size";
  61584. import { Color4 } from "babylonjs/Maths/math.color";
  61585. import { Engine } from "babylonjs/Engines/engine";
  61586. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61588. import { Mesh } from "babylonjs/Meshes/mesh";
  61589. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61590. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61591. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61592. import { Effect } from "babylonjs/Materials/effect";
  61593. import { Material } from "babylonjs/Materials/material";
  61594. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61595. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61596. /**
  61597. * Effect layer options. This helps customizing the behaviour
  61598. * of the effect layer.
  61599. */
  61600. export interface IEffectLayerOptions {
  61601. /**
  61602. * Multiplication factor apply to the canvas size to compute the render target size
  61603. * used to generated the objects (the smaller the faster).
  61604. */
  61605. mainTextureRatio: number;
  61606. /**
  61607. * Enforces a fixed size texture to ensure effect stability across devices.
  61608. */
  61609. mainTextureFixedSize?: number;
  61610. /**
  61611. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61612. */
  61613. alphaBlendingMode: number;
  61614. /**
  61615. * The camera attached to the layer.
  61616. */
  61617. camera: Nullable<Camera>;
  61618. /**
  61619. * The rendering group to draw the layer in.
  61620. */
  61621. renderingGroupId: number;
  61622. }
  61623. /**
  61624. * The effect layer Helps adding post process effect blended with the main pass.
  61625. *
  61626. * This can be for instance use to generate glow or higlight effects on the scene.
  61627. *
  61628. * The effect layer class can not be used directly and is intented to inherited from to be
  61629. * customized per effects.
  61630. */
  61631. export abstract class EffectLayer {
  61632. private _vertexBuffers;
  61633. private _indexBuffer;
  61634. private _cachedDefines;
  61635. private _effectLayerMapGenerationEffect;
  61636. private _effectLayerOptions;
  61637. private _mergeEffect;
  61638. protected _scene: Scene;
  61639. protected _engine: Engine;
  61640. protected _maxSize: number;
  61641. protected _mainTextureDesiredSize: ISize;
  61642. protected _mainTexture: RenderTargetTexture;
  61643. protected _shouldRender: boolean;
  61644. protected _postProcesses: PostProcess[];
  61645. protected _textures: BaseTexture[];
  61646. protected _emissiveTextureAndColor: {
  61647. texture: Nullable<BaseTexture>;
  61648. color: Color4;
  61649. };
  61650. /**
  61651. * The name of the layer
  61652. */
  61653. name: string;
  61654. /**
  61655. * The clear color of the texture used to generate the glow map.
  61656. */
  61657. neutralColor: Color4;
  61658. /**
  61659. * Specifies whether the highlight layer is enabled or not.
  61660. */
  61661. isEnabled: boolean;
  61662. /**
  61663. * Gets the camera attached to the layer.
  61664. */
  61665. get camera(): Nullable<Camera>;
  61666. /**
  61667. * Gets the rendering group id the layer should render in.
  61668. */
  61669. get renderingGroupId(): number;
  61670. set renderingGroupId(renderingGroupId: number);
  61671. /**
  61672. * An event triggered when the effect layer has been disposed.
  61673. */
  61674. onDisposeObservable: Observable<EffectLayer>;
  61675. /**
  61676. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61677. */
  61678. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61679. /**
  61680. * An event triggered when the generated texture is being merged in the scene.
  61681. */
  61682. onBeforeComposeObservable: Observable<EffectLayer>;
  61683. /**
  61684. * An event triggered when the mesh is rendered into the effect render target.
  61685. */
  61686. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61687. /**
  61688. * An event triggered after the mesh has been rendered into the effect render target.
  61689. */
  61690. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61691. /**
  61692. * An event triggered when the generated texture has been merged in the scene.
  61693. */
  61694. onAfterComposeObservable: Observable<EffectLayer>;
  61695. /**
  61696. * An event triggered when the efffect layer changes its size.
  61697. */
  61698. onSizeChangedObservable: Observable<EffectLayer>;
  61699. /** @hidden */
  61700. static _SceneComponentInitialization: (scene: Scene) => void;
  61701. /**
  61702. * Instantiates a new effect Layer and references it in the scene.
  61703. * @param name The name of the layer
  61704. * @param scene The scene to use the layer in
  61705. */
  61706. constructor(
  61707. /** The Friendly of the effect in the scene */
  61708. name: string, scene: Scene);
  61709. /**
  61710. * Get the effect name of the layer.
  61711. * @return The effect name
  61712. */
  61713. abstract getEffectName(): string;
  61714. /**
  61715. * Checks for the readiness of the element composing the layer.
  61716. * @param subMesh the mesh to check for
  61717. * @param useInstances specify whether or not to use instances to render the mesh
  61718. * @return true if ready otherwise, false
  61719. */
  61720. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61721. /**
  61722. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61723. * @returns true if the effect requires stencil during the main canvas render pass.
  61724. */
  61725. abstract needStencil(): boolean;
  61726. /**
  61727. * Create the merge effect. This is the shader use to blit the information back
  61728. * to the main canvas at the end of the scene rendering.
  61729. * @returns The effect containing the shader used to merge the effect on the main canvas
  61730. */
  61731. protected abstract _createMergeEffect(): Effect;
  61732. /**
  61733. * Creates the render target textures and post processes used in the effect layer.
  61734. */
  61735. protected abstract _createTextureAndPostProcesses(): void;
  61736. /**
  61737. * Implementation specific of rendering the generating effect on the main canvas.
  61738. * @param effect The effect used to render through
  61739. */
  61740. protected abstract _internalRender(effect: Effect): void;
  61741. /**
  61742. * Sets the required values for both the emissive texture and and the main color.
  61743. */
  61744. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61745. /**
  61746. * Free any resources and references associated to a mesh.
  61747. * Internal use
  61748. * @param mesh The mesh to free.
  61749. */
  61750. abstract _disposeMesh(mesh: Mesh): void;
  61751. /**
  61752. * Serializes this layer (Glow or Highlight for example)
  61753. * @returns a serialized layer object
  61754. */
  61755. abstract serialize?(): any;
  61756. /**
  61757. * Initializes the effect layer with the required options.
  61758. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61759. */
  61760. protected _init(options: Partial<IEffectLayerOptions>): void;
  61761. /**
  61762. * Generates the index buffer of the full screen quad blending to the main canvas.
  61763. */
  61764. private _generateIndexBuffer;
  61765. /**
  61766. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61767. */
  61768. private _generateVertexBuffer;
  61769. /**
  61770. * Sets the main texture desired size which is the closest power of two
  61771. * of the engine canvas size.
  61772. */
  61773. private _setMainTextureSize;
  61774. /**
  61775. * Creates the main texture for the effect layer.
  61776. */
  61777. protected _createMainTexture(): void;
  61778. /**
  61779. * Adds specific effects defines.
  61780. * @param defines The defines to add specifics to.
  61781. */
  61782. protected _addCustomEffectDefines(defines: string[]): void;
  61783. /**
  61784. * Checks for the readiness of the element composing the layer.
  61785. * @param subMesh the mesh to check for
  61786. * @param useInstances specify whether or not to use instances to render the mesh
  61787. * @param emissiveTexture the associated emissive texture used to generate the glow
  61788. * @return true if ready otherwise, false
  61789. */
  61790. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61791. /**
  61792. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61793. */
  61794. render(): void;
  61795. /**
  61796. * Determine if a given mesh will be used in the current effect.
  61797. * @param mesh mesh to test
  61798. * @returns true if the mesh will be used
  61799. */
  61800. hasMesh(mesh: AbstractMesh): boolean;
  61801. /**
  61802. * Returns true if the layer contains information to display, otherwise false.
  61803. * @returns true if the glow layer should be rendered
  61804. */
  61805. shouldRender(): boolean;
  61806. /**
  61807. * Returns true if the mesh should render, otherwise false.
  61808. * @param mesh The mesh to render
  61809. * @returns true if it should render otherwise false
  61810. */
  61811. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61812. /**
  61813. * Returns true if the mesh can be rendered, otherwise false.
  61814. * @param mesh The mesh to render
  61815. * @param material The material used on the mesh
  61816. * @returns true if it can be rendered otherwise false
  61817. */
  61818. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61819. /**
  61820. * Returns true if the mesh should render, otherwise false.
  61821. * @param mesh The mesh to render
  61822. * @returns true if it should render otherwise false
  61823. */
  61824. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61825. /**
  61826. * Renders the submesh passed in parameter to the generation map.
  61827. */
  61828. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61829. /**
  61830. * Defines whether the current material of the mesh should be use to render the effect.
  61831. * @param mesh defines the current mesh to render
  61832. */
  61833. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61834. /**
  61835. * Rebuild the required buffers.
  61836. * @hidden Internal use only.
  61837. */
  61838. _rebuild(): void;
  61839. /**
  61840. * Dispose only the render target textures and post process.
  61841. */
  61842. private _disposeTextureAndPostProcesses;
  61843. /**
  61844. * Dispose the highlight layer and free resources.
  61845. */
  61846. dispose(): void;
  61847. /**
  61848. * Gets the class name of the effect layer
  61849. * @returns the string with the class name of the effect layer
  61850. */
  61851. getClassName(): string;
  61852. /**
  61853. * Creates an effect layer from parsed effect layer data
  61854. * @param parsedEffectLayer defines effect layer data
  61855. * @param scene defines the current scene
  61856. * @param rootUrl defines the root URL containing the effect layer information
  61857. * @returns a parsed effect Layer
  61858. */
  61859. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61860. }
  61861. }
  61862. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61863. import { Scene } from "babylonjs/scene";
  61864. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61865. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61866. import { AbstractScene } from "babylonjs/abstractScene";
  61867. module "babylonjs/abstractScene" {
  61868. interface AbstractScene {
  61869. /**
  61870. * The list of effect layers (highlights/glow) added to the scene
  61871. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61872. * @see https://doc.babylonjs.com/how_to/glow_layer
  61873. */
  61874. effectLayers: Array<EffectLayer>;
  61875. /**
  61876. * Removes the given effect layer from this scene.
  61877. * @param toRemove defines the effect layer to remove
  61878. * @returns the index of the removed effect layer
  61879. */
  61880. removeEffectLayer(toRemove: EffectLayer): number;
  61881. /**
  61882. * Adds the given effect layer to this scene
  61883. * @param newEffectLayer defines the effect layer to add
  61884. */
  61885. addEffectLayer(newEffectLayer: EffectLayer): void;
  61886. }
  61887. }
  61888. /**
  61889. * Defines the layer scene component responsible to manage any effect layers
  61890. * in a given scene.
  61891. */
  61892. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61893. /**
  61894. * The component name helpfull to identify the component in the list of scene components.
  61895. */
  61896. readonly name: string;
  61897. /**
  61898. * The scene the component belongs to.
  61899. */
  61900. scene: Scene;
  61901. private _engine;
  61902. private _renderEffects;
  61903. private _needStencil;
  61904. private _previousStencilState;
  61905. /**
  61906. * Creates a new instance of the component for the given scene
  61907. * @param scene Defines the scene to register the component in
  61908. */
  61909. constructor(scene: Scene);
  61910. /**
  61911. * Registers the component in a given scene
  61912. */
  61913. register(): void;
  61914. /**
  61915. * Rebuilds the elements related to this component in case of
  61916. * context lost for instance.
  61917. */
  61918. rebuild(): void;
  61919. /**
  61920. * Serializes the component data to the specified json object
  61921. * @param serializationObject The object to serialize to
  61922. */
  61923. serialize(serializationObject: any): void;
  61924. /**
  61925. * Adds all the elements from the container to the scene
  61926. * @param container the container holding the elements
  61927. */
  61928. addFromContainer(container: AbstractScene): void;
  61929. /**
  61930. * Removes all the elements in the container from the scene
  61931. * @param container contains the elements to remove
  61932. * @param dispose if the removed element should be disposed (default: false)
  61933. */
  61934. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61935. /**
  61936. * Disposes the component and the associated ressources.
  61937. */
  61938. dispose(): void;
  61939. private _isReadyForMesh;
  61940. private _renderMainTexture;
  61941. private _setStencil;
  61942. private _setStencilBack;
  61943. private _draw;
  61944. private _drawCamera;
  61945. private _drawRenderingGroup;
  61946. }
  61947. }
  61948. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61949. /** @hidden */
  61950. export var glowMapMergePixelShader: {
  61951. name: string;
  61952. shader: string;
  61953. };
  61954. }
  61955. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61956. /** @hidden */
  61957. export var glowMapMergeVertexShader: {
  61958. name: string;
  61959. shader: string;
  61960. };
  61961. }
  61962. declare module "babylonjs/Layers/glowLayer" {
  61963. import { Nullable } from "babylonjs/types";
  61964. import { Camera } from "babylonjs/Cameras/camera";
  61965. import { Scene } from "babylonjs/scene";
  61966. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61968. import { Mesh } from "babylonjs/Meshes/mesh";
  61969. import { Texture } from "babylonjs/Materials/Textures/texture";
  61970. import { Effect } from "babylonjs/Materials/effect";
  61971. import { Material } from "babylonjs/Materials/material";
  61972. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61973. import { Color4 } from "babylonjs/Maths/math.color";
  61974. import "babylonjs/Shaders/glowMapMerge.fragment";
  61975. import "babylonjs/Shaders/glowMapMerge.vertex";
  61976. import "babylonjs/Layers/effectLayerSceneComponent";
  61977. module "babylonjs/abstractScene" {
  61978. interface AbstractScene {
  61979. /**
  61980. * Return a the first highlight layer of the scene with a given name.
  61981. * @param name The name of the highlight layer to look for.
  61982. * @return The highlight layer if found otherwise null.
  61983. */
  61984. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61985. }
  61986. }
  61987. /**
  61988. * Glow layer options. This helps customizing the behaviour
  61989. * of the glow layer.
  61990. */
  61991. export interface IGlowLayerOptions {
  61992. /**
  61993. * Multiplication factor apply to the canvas size to compute the render target size
  61994. * used to generated the glowing objects (the smaller the faster).
  61995. */
  61996. mainTextureRatio: number;
  61997. /**
  61998. * Enforces a fixed size texture to ensure resize independant blur.
  61999. */
  62000. mainTextureFixedSize?: number;
  62001. /**
  62002. * How big is the kernel of the blur texture.
  62003. */
  62004. blurKernelSize: number;
  62005. /**
  62006. * The camera attached to the layer.
  62007. */
  62008. camera: Nullable<Camera>;
  62009. /**
  62010. * Enable MSAA by chosing the number of samples.
  62011. */
  62012. mainTextureSamples?: number;
  62013. /**
  62014. * The rendering group to draw the layer in.
  62015. */
  62016. renderingGroupId: number;
  62017. }
  62018. /**
  62019. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62020. *
  62021. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62022. *
  62023. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62024. */
  62025. export class GlowLayer extends EffectLayer {
  62026. /**
  62027. * Effect Name of the layer.
  62028. */
  62029. static readonly EffectName: string;
  62030. /**
  62031. * The default blur kernel size used for the glow.
  62032. */
  62033. static DefaultBlurKernelSize: number;
  62034. /**
  62035. * The default texture size ratio used for the glow.
  62036. */
  62037. static DefaultTextureRatio: number;
  62038. /**
  62039. * Sets the kernel size of the blur.
  62040. */
  62041. set blurKernelSize(value: number);
  62042. /**
  62043. * Gets the kernel size of the blur.
  62044. */
  62045. get blurKernelSize(): number;
  62046. /**
  62047. * Sets the glow intensity.
  62048. */
  62049. set intensity(value: number);
  62050. /**
  62051. * Gets the glow intensity.
  62052. */
  62053. get intensity(): number;
  62054. private _options;
  62055. private _intensity;
  62056. private _horizontalBlurPostprocess1;
  62057. private _verticalBlurPostprocess1;
  62058. private _horizontalBlurPostprocess2;
  62059. private _verticalBlurPostprocess2;
  62060. private _blurTexture1;
  62061. private _blurTexture2;
  62062. private _postProcesses1;
  62063. private _postProcesses2;
  62064. private _includedOnlyMeshes;
  62065. private _excludedMeshes;
  62066. private _meshesUsingTheirOwnMaterials;
  62067. /**
  62068. * Callback used to let the user override the color selection on a per mesh basis
  62069. */
  62070. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62071. /**
  62072. * Callback used to let the user override the texture selection on a per mesh basis
  62073. */
  62074. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62075. /**
  62076. * Instantiates a new glow Layer and references it to the scene.
  62077. * @param name The name of the layer
  62078. * @param scene The scene to use the layer in
  62079. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62080. */
  62081. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62082. /**
  62083. * Get the effect name of the layer.
  62084. * @return The effect name
  62085. */
  62086. getEffectName(): string;
  62087. /**
  62088. * Create the merge effect. This is the shader use to blit the information back
  62089. * to the main canvas at the end of the scene rendering.
  62090. */
  62091. protected _createMergeEffect(): Effect;
  62092. /**
  62093. * Creates the render target textures and post processes used in the glow layer.
  62094. */
  62095. protected _createTextureAndPostProcesses(): void;
  62096. /**
  62097. * Checks for the readiness of the element composing the layer.
  62098. * @param subMesh the mesh to check for
  62099. * @param useInstances specify wether or not to use instances to render the mesh
  62100. * @param emissiveTexture the associated emissive texture used to generate the glow
  62101. * @return true if ready otherwise, false
  62102. */
  62103. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62104. /**
  62105. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62106. */
  62107. needStencil(): boolean;
  62108. /**
  62109. * Returns true if the mesh can be rendered, otherwise false.
  62110. * @param mesh The mesh to render
  62111. * @param material The material used on the mesh
  62112. * @returns true if it can be rendered otherwise false
  62113. */
  62114. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62115. /**
  62116. * Implementation specific of rendering the generating effect on the main canvas.
  62117. * @param effect The effect used to render through
  62118. */
  62119. protected _internalRender(effect: Effect): void;
  62120. /**
  62121. * Sets the required values for both the emissive texture and and the main color.
  62122. */
  62123. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62124. /**
  62125. * Returns true if the mesh should render, otherwise false.
  62126. * @param mesh The mesh to render
  62127. * @returns true if it should render otherwise false
  62128. */
  62129. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62130. /**
  62131. * Adds specific effects defines.
  62132. * @param defines The defines to add specifics to.
  62133. */
  62134. protected _addCustomEffectDefines(defines: string[]): void;
  62135. /**
  62136. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62137. * @param mesh The mesh to exclude from the glow layer
  62138. */
  62139. addExcludedMesh(mesh: Mesh): void;
  62140. /**
  62141. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62142. * @param mesh The mesh to remove
  62143. */
  62144. removeExcludedMesh(mesh: Mesh): void;
  62145. /**
  62146. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62147. * @param mesh The mesh to include in the glow layer
  62148. */
  62149. addIncludedOnlyMesh(mesh: Mesh): void;
  62150. /**
  62151. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62152. * @param mesh The mesh to remove
  62153. */
  62154. removeIncludedOnlyMesh(mesh: Mesh): void;
  62155. /**
  62156. * Determine if a given mesh will be used in the glow layer
  62157. * @param mesh The mesh to test
  62158. * @returns true if the mesh will be highlighted by the current glow layer
  62159. */
  62160. hasMesh(mesh: AbstractMesh): boolean;
  62161. /**
  62162. * Defines whether the current material of the mesh should be use to render the effect.
  62163. * @param mesh defines the current mesh to render
  62164. */
  62165. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62166. /**
  62167. * Add a mesh to be rendered through its own material and not with emissive only.
  62168. * @param mesh The mesh for which we need to use its material
  62169. */
  62170. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62171. /**
  62172. * Remove a mesh from being rendered through its own material and not with emissive only.
  62173. * @param mesh The mesh for which we need to not use its material
  62174. */
  62175. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62176. /**
  62177. * Free any resources and references associated to a mesh.
  62178. * Internal use
  62179. * @param mesh The mesh to free.
  62180. * @hidden
  62181. */
  62182. _disposeMesh(mesh: Mesh): void;
  62183. /**
  62184. * Gets the class name of the effect layer
  62185. * @returns the string with the class name of the effect layer
  62186. */
  62187. getClassName(): string;
  62188. /**
  62189. * Serializes this glow layer
  62190. * @returns a serialized glow layer object
  62191. */
  62192. serialize(): any;
  62193. /**
  62194. * Creates a Glow Layer from parsed glow layer data
  62195. * @param parsedGlowLayer defines glow layer data
  62196. * @param scene defines the current scene
  62197. * @param rootUrl defines the root URL containing the glow layer information
  62198. * @returns a parsed Glow Layer
  62199. */
  62200. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62201. }
  62202. }
  62203. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62204. /** @hidden */
  62205. export var glowBlurPostProcessPixelShader: {
  62206. name: string;
  62207. shader: string;
  62208. };
  62209. }
  62210. declare module "babylonjs/Layers/highlightLayer" {
  62211. import { Observable } from "babylonjs/Misc/observable";
  62212. import { Nullable } from "babylonjs/types";
  62213. import { Camera } from "babylonjs/Cameras/camera";
  62214. import { Scene } from "babylonjs/scene";
  62215. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62217. import { Mesh } from "babylonjs/Meshes/mesh";
  62218. import { Effect } from "babylonjs/Materials/effect";
  62219. import { Material } from "babylonjs/Materials/material";
  62220. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62221. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62222. import "babylonjs/Shaders/glowMapMerge.fragment";
  62223. import "babylonjs/Shaders/glowMapMerge.vertex";
  62224. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62225. module "babylonjs/abstractScene" {
  62226. interface AbstractScene {
  62227. /**
  62228. * Return a the first highlight layer of the scene with a given name.
  62229. * @param name The name of the highlight layer to look for.
  62230. * @return The highlight layer if found otherwise null.
  62231. */
  62232. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62233. }
  62234. }
  62235. /**
  62236. * Highlight layer options. This helps customizing the behaviour
  62237. * of the highlight layer.
  62238. */
  62239. export interface IHighlightLayerOptions {
  62240. /**
  62241. * Multiplication factor apply to the canvas size to compute the render target size
  62242. * used to generated the glowing objects (the smaller the faster).
  62243. */
  62244. mainTextureRatio: number;
  62245. /**
  62246. * Enforces a fixed size texture to ensure resize independant blur.
  62247. */
  62248. mainTextureFixedSize?: number;
  62249. /**
  62250. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62251. * of the picture to blur (the smaller the faster).
  62252. */
  62253. blurTextureSizeRatio: number;
  62254. /**
  62255. * How big in texel of the blur texture is the vertical blur.
  62256. */
  62257. blurVerticalSize: number;
  62258. /**
  62259. * How big in texel of the blur texture is the horizontal blur.
  62260. */
  62261. blurHorizontalSize: number;
  62262. /**
  62263. * Alpha blending mode used to apply the blur. Default is combine.
  62264. */
  62265. alphaBlendingMode: number;
  62266. /**
  62267. * The camera attached to the layer.
  62268. */
  62269. camera: Nullable<Camera>;
  62270. /**
  62271. * Should we display highlight as a solid stroke?
  62272. */
  62273. isStroke?: boolean;
  62274. /**
  62275. * The rendering group to draw the layer in.
  62276. */
  62277. renderingGroupId: number;
  62278. }
  62279. /**
  62280. * The highlight layer Helps adding a glow effect around a mesh.
  62281. *
  62282. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62283. * glowy meshes to your scene.
  62284. *
  62285. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62286. */
  62287. export class HighlightLayer extends EffectLayer {
  62288. name: string;
  62289. /**
  62290. * Effect Name of the highlight layer.
  62291. */
  62292. static readonly EffectName: string;
  62293. /**
  62294. * The neutral color used during the preparation of the glow effect.
  62295. * This is black by default as the blend operation is a blend operation.
  62296. */
  62297. static NeutralColor: Color4;
  62298. /**
  62299. * Stencil value used for glowing meshes.
  62300. */
  62301. static GlowingMeshStencilReference: number;
  62302. /**
  62303. * Stencil value used for the other meshes in the scene.
  62304. */
  62305. static NormalMeshStencilReference: number;
  62306. /**
  62307. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62308. */
  62309. innerGlow: boolean;
  62310. /**
  62311. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62312. */
  62313. outerGlow: boolean;
  62314. /**
  62315. * Specifies the horizontal size of the blur.
  62316. */
  62317. set blurHorizontalSize(value: number);
  62318. /**
  62319. * Specifies the vertical size of the blur.
  62320. */
  62321. set blurVerticalSize(value: number);
  62322. /**
  62323. * Gets the horizontal size of the blur.
  62324. */
  62325. get blurHorizontalSize(): number;
  62326. /**
  62327. * Gets the vertical size of the blur.
  62328. */
  62329. get blurVerticalSize(): number;
  62330. /**
  62331. * An event triggered when the highlight layer is being blurred.
  62332. */
  62333. onBeforeBlurObservable: Observable<HighlightLayer>;
  62334. /**
  62335. * An event triggered when the highlight layer has been blurred.
  62336. */
  62337. onAfterBlurObservable: Observable<HighlightLayer>;
  62338. private _instanceGlowingMeshStencilReference;
  62339. private _options;
  62340. private _downSamplePostprocess;
  62341. private _horizontalBlurPostprocess;
  62342. private _verticalBlurPostprocess;
  62343. private _blurTexture;
  62344. private _meshes;
  62345. private _excludedMeshes;
  62346. /**
  62347. * Instantiates a new highlight Layer and references it to the scene..
  62348. * @param name The name of the layer
  62349. * @param scene The scene to use the layer in
  62350. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62351. */
  62352. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62353. /**
  62354. * Get the effect name of the layer.
  62355. * @return The effect name
  62356. */
  62357. getEffectName(): string;
  62358. /**
  62359. * Create the merge effect. This is the shader use to blit the information back
  62360. * to the main canvas at the end of the scene rendering.
  62361. */
  62362. protected _createMergeEffect(): Effect;
  62363. /**
  62364. * Creates the render target textures and post processes used in the highlight layer.
  62365. */
  62366. protected _createTextureAndPostProcesses(): void;
  62367. /**
  62368. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62369. */
  62370. needStencil(): boolean;
  62371. /**
  62372. * Checks for the readiness of the element composing the layer.
  62373. * @param subMesh the mesh to check for
  62374. * @param useInstances specify wether or not to use instances to render the mesh
  62375. * @param emissiveTexture the associated emissive texture used to generate the glow
  62376. * @return true if ready otherwise, false
  62377. */
  62378. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62379. /**
  62380. * Implementation specific of rendering the generating effect on the main canvas.
  62381. * @param effect The effect used to render through
  62382. */
  62383. protected _internalRender(effect: Effect): void;
  62384. /**
  62385. * Returns true if the layer contains information to display, otherwise false.
  62386. */
  62387. shouldRender(): boolean;
  62388. /**
  62389. * Returns true if the mesh should render, otherwise false.
  62390. * @param mesh The mesh to render
  62391. * @returns true if it should render otherwise false
  62392. */
  62393. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62394. /**
  62395. * Returns true if the mesh can be rendered, otherwise false.
  62396. * @param mesh The mesh to render
  62397. * @param material The material used on the mesh
  62398. * @returns true if it can be rendered otherwise false
  62399. */
  62400. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62401. /**
  62402. * Adds specific effects defines.
  62403. * @param defines The defines to add specifics to.
  62404. */
  62405. protected _addCustomEffectDefines(defines: string[]): void;
  62406. /**
  62407. * Sets the required values for both the emissive texture and and the main color.
  62408. */
  62409. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62410. /**
  62411. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62412. * @param mesh The mesh to exclude from the highlight layer
  62413. */
  62414. addExcludedMesh(mesh: Mesh): void;
  62415. /**
  62416. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62417. * @param mesh The mesh to highlight
  62418. */
  62419. removeExcludedMesh(mesh: Mesh): void;
  62420. /**
  62421. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62422. * @param mesh mesh to test
  62423. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62424. */
  62425. hasMesh(mesh: AbstractMesh): boolean;
  62426. /**
  62427. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62428. * @param mesh The mesh to highlight
  62429. * @param color The color of the highlight
  62430. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62431. */
  62432. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62433. /**
  62434. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62435. * @param mesh The mesh to highlight
  62436. */
  62437. removeMesh(mesh: Mesh): void;
  62438. /**
  62439. * Remove all the meshes currently referenced in the highlight layer
  62440. */
  62441. removeAllMeshes(): void;
  62442. /**
  62443. * Force the stencil to the normal expected value for none glowing parts
  62444. */
  62445. private _defaultStencilReference;
  62446. /**
  62447. * Free any resources and references associated to a mesh.
  62448. * Internal use
  62449. * @param mesh The mesh to free.
  62450. * @hidden
  62451. */
  62452. _disposeMesh(mesh: Mesh): void;
  62453. /**
  62454. * Dispose the highlight layer and free resources.
  62455. */
  62456. dispose(): void;
  62457. /**
  62458. * Gets the class name of the effect layer
  62459. * @returns the string with the class name of the effect layer
  62460. */
  62461. getClassName(): string;
  62462. /**
  62463. * Serializes this Highlight layer
  62464. * @returns a serialized Highlight layer object
  62465. */
  62466. serialize(): any;
  62467. /**
  62468. * Creates a Highlight layer from parsed Highlight layer data
  62469. * @param parsedHightlightLayer defines the Highlight layer data
  62470. * @param scene defines the current scene
  62471. * @param rootUrl defines the root URL containing the Highlight layer information
  62472. * @returns a parsed Highlight layer
  62473. */
  62474. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62475. }
  62476. }
  62477. declare module "babylonjs/Layers/layerSceneComponent" {
  62478. import { Scene } from "babylonjs/scene";
  62479. import { ISceneComponent } from "babylonjs/sceneComponent";
  62480. import { Layer } from "babylonjs/Layers/layer";
  62481. import { AbstractScene } from "babylonjs/abstractScene";
  62482. module "babylonjs/abstractScene" {
  62483. interface AbstractScene {
  62484. /**
  62485. * The list of layers (background and foreground) of the scene
  62486. */
  62487. layers: Array<Layer>;
  62488. }
  62489. }
  62490. /**
  62491. * Defines the layer scene component responsible to manage any layers
  62492. * in a given scene.
  62493. */
  62494. export class LayerSceneComponent implements ISceneComponent {
  62495. /**
  62496. * The component name helpfull to identify the component in the list of scene components.
  62497. */
  62498. readonly name: string;
  62499. /**
  62500. * The scene the component belongs to.
  62501. */
  62502. scene: Scene;
  62503. private _engine;
  62504. /**
  62505. * Creates a new instance of the component for the given scene
  62506. * @param scene Defines the scene to register the component in
  62507. */
  62508. constructor(scene: Scene);
  62509. /**
  62510. * Registers the component in a given scene
  62511. */
  62512. register(): void;
  62513. /**
  62514. * Rebuilds the elements related to this component in case of
  62515. * context lost for instance.
  62516. */
  62517. rebuild(): void;
  62518. /**
  62519. * Disposes the component and the associated ressources.
  62520. */
  62521. dispose(): void;
  62522. private _draw;
  62523. private _drawCameraPredicate;
  62524. private _drawCameraBackground;
  62525. private _drawCameraForeground;
  62526. private _drawRenderTargetPredicate;
  62527. private _drawRenderTargetBackground;
  62528. private _drawRenderTargetForeground;
  62529. /**
  62530. * Adds all the elements from the container to the scene
  62531. * @param container the container holding the elements
  62532. */
  62533. addFromContainer(container: AbstractScene): void;
  62534. /**
  62535. * Removes all the elements in the container from the scene
  62536. * @param container contains the elements to remove
  62537. * @param dispose if the removed element should be disposed (default: false)
  62538. */
  62539. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62540. }
  62541. }
  62542. declare module "babylonjs/Shaders/layer.fragment" {
  62543. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62544. /** @hidden */
  62545. export var layerPixelShader: {
  62546. name: string;
  62547. shader: string;
  62548. };
  62549. }
  62550. declare module "babylonjs/Shaders/layer.vertex" {
  62551. /** @hidden */
  62552. export var layerVertexShader: {
  62553. name: string;
  62554. shader: string;
  62555. };
  62556. }
  62557. declare module "babylonjs/Layers/layer" {
  62558. import { Observable } from "babylonjs/Misc/observable";
  62559. import { Nullable } from "babylonjs/types";
  62560. import { Scene } from "babylonjs/scene";
  62561. import { Vector2 } from "babylonjs/Maths/math.vector";
  62562. import { Color4 } from "babylonjs/Maths/math.color";
  62563. import { Texture } from "babylonjs/Materials/Textures/texture";
  62564. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62565. import "babylonjs/Shaders/layer.fragment";
  62566. import "babylonjs/Shaders/layer.vertex";
  62567. /**
  62568. * This represents a full screen 2d layer.
  62569. * This can be useful to display a picture in the background of your scene for instance.
  62570. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62571. */
  62572. export class Layer {
  62573. /**
  62574. * Define the name of the layer.
  62575. */
  62576. name: string;
  62577. /**
  62578. * Define the texture the layer should display.
  62579. */
  62580. texture: Nullable<Texture>;
  62581. /**
  62582. * Is the layer in background or foreground.
  62583. */
  62584. isBackground: boolean;
  62585. /**
  62586. * Define the color of the layer (instead of texture).
  62587. */
  62588. color: Color4;
  62589. /**
  62590. * Define the scale of the layer in order to zoom in out of the texture.
  62591. */
  62592. scale: Vector2;
  62593. /**
  62594. * Define an offset for the layer in order to shift the texture.
  62595. */
  62596. offset: Vector2;
  62597. /**
  62598. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62599. */
  62600. alphaBlendingMode: number;
  62601. /**
  62602. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62603. * Alpha test will not mix with the background color in case of transparency.
  62604. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62605. */
  62606. alphaTest: boolean;
  62607. /**
  62608. * Define a mask to restrict the layer to only some of the scene cameras.
  62609. */
  62610. layerMask: number;
  62611. /**
  62612. * Define the list of render target the layer is visible into.
  62613. */
  62614. renderTargetTextures: RenderTargetTexture[];
  62615. /**
  62616. * Define if the layer is only used in renderTarget or if it also
  62617. * renders in the main frame buffer of the canvas.
  62618. */
  62619. renderOnlyInRenderTargetTextures: boolean;
  62620. private _scene;
  62621. private _vertexBuffers;
  62622. private _indexBuffer;
  62623. private _effect;
  62624. private _previousDefines;
  62625. /**
  62626. * An event triggered when the layer is disposed.
  62627. */
  62628. onDisposeObservable: Observable<Layer>;
  62629. private _onDisposeObserver;
  62630. /**
  62631. * Back compatibility with callback before the onDisposeObservable existed.
  62632. * The set callback will be triggered when the layer has been disposed.
  62633. */
  62634. set onDispose(callback: () => void);
  62635. /**
  62636. * An event triggered before rendering the scene
  62637. */
  62638. onBeforeRenderObservable: Observable<Layer>;
  62639. private _onBeforeRenderObserver;
  62640. /**
  62641. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62642. * The set callback will be triggered just before rendering the layer.
  62643. */
  62644. set onBeforeRender(callback: () => void);
  62645. /**
  62646. * An event triggered after rendering the scene
  62647. */
  62648. onAfterRenderObservable: Observable<Layer>;
  62649. private _onAfterRenderObserver;
  62650. /**
  62651. * Back compatibility with callback before the onAfterRenderObservable existed.
  62652. * The set callback will be triggered just after rendering the layer.
  62653. */
  62654. set onAfterRender(callback: () => void);
  62655. /**
  62656. * Instantiates a new layer.
  62657. * This represents a full screen 2d layer.
  62658. * This can be useful to display a picture in the background of your scene for instance.
  62659. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62660. * @param name Define the name of the layer in the scene
  62661. * @param imgUrl Define the url of the texture to display in the layer
  62662. * @param scene Define the scene the layer belongs to
  62663. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62664. * @param color Defines a color for the layer
  62665. */
  62666. constructor(
  62667. /**
  62668. * Define the name of the layer.
  62669. */
  62670. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62671. private _createIndexBuffer;
  62672. /** @hidden */
  62673. _rebuild(): void;
  62674. /**
  62675. * Renders the layer in the scene.
  62676. */
  62677. render(): void;
  62678. /**
  62679. * Disposes and releases the associated ressources.
  62680. */
  62681. dispose(): void;
  62682. }
  62683. }
  62684. declare module "babylonjs/Layers/index" {
  62685. export * from "babylonjs/Layers/effectLayer";
  62686. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62687. export * from "babylonjs/Layers/glowLayer";
  62688. export * from "babylonjs/Layers/highlightLayer";
  62689. export * from "babylonjs/Layers/layer";
  62690. export * from "babylonjs/Layers/layerSceneComponent";
  62691. }
  62692. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62693. /** @hidden */
  62694. export var lensFlarePixelShader: {
  62695. name: string;
  62696. shader: string;
  62697. };
  62698. }
  62699. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62700. /** @hidden */
  62701. export var lensFlareVertexShader: {
  62702. name: string;
  62703. shader: string;
  62704. };
  62705. }
  62706. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62707. import { Scene } from "babylonjs/scene";
  62708. import { Vector3 } from "babylonjs/Maths/math.vector";
  62709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62710. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62711. import "babylonjs/Shaders/lensFlare.fragment";
  62712. import "babylonjs/Shaders/lensFlare.vertex";
  62713. import { Viewport } from "babylonjs/Maths/math.viewport";
  62714. /**
  62715. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62716. * It is usually composed of several `lensFlare`.
  62717. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62718. */
  62719. export class LensFlareSystem {
  62720. /**
  62721. * Define the name of the lens flare system
  62722. */
  62723. name: string;
  62724. /**
  62725. * List of lens flares used in this system.
  62726. */
  62727. lensFlares: LensFlare[];
  62728. /**
  62729. * Define a limit from the border the lens flare can be visible.
  62730. */
  62731. borderLimit: number;
  62732. /**
  62733. * Define a viewport border we do not want to see the lens flare in.
  62734. */
  62735. viewportBorder: number;
  62736. /**
  62737. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62738. */
  62739. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62740. /**
  62741. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62742. */
  62743. layerMask: number;
  62744. /**
  62745. * Define the id of the lens flare system in the scene.
  62746. * (equal to name by default)
  62747. */
  62748. id: string;
  62749. private _scene;
  62750. private _emitter;
  62751. private _vertexBuffers;
  62752. private _indexBuffer;
  62753. private _effect;
  62754. private _positionX;
  62755. private _positionY;
  62756. private _isEnabled;
  62757. /** @hidden */
  62758. static _SceneComponentInitialization: (scene: Scene) => void;
  62759. /**
  62760. * Instantiates a lens flare system.
  62761. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62762. * It is usually composed of several `lensFlare`.
  62763. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62764. * @param name Define the name of the lens flare system in the scene
  62765. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62766. * @param scene Define the scene the lens flare system belongs to
  62767. */
  62768. constructor(
  62769. /**
  62770. * Define the name of the lens flare system
  62771. */
  62772. name: string, emitter: any, scene: Scene);
  62773. /**
  62774. * Define if the lens flare system is enabled.
  62775. */
  62776. get isEnabled(): boolean;
  62777. set isEnabled(value: boolean);
  62778. /**
  62779. * Get the scene the effects belongs to.
  62780. * @returns the scene holding the lens flare system
  62781. */
  62782. getScene(): Scene;
  62783. /**
  62784. * Get the emitter of the lens flare system.
  62785. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62786. * @returns the emitter of the lens flare system
  62787. */
  62788. getEmitter(): any;
  62789. /**
  62790. * Set the emitter of the lens flare system.
  62791. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62792. * @param newEmitter Define the new emitter of the system
  62793. */
  62794. setEmitter(newEmitter: any): void;
  62795. /**
  62796. * Get the lens flare system emitter position.
  62797. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62798. * @returns the position
  62799. */
  62800. getEmitterPosition(): Vector3;
  62801. /**
  62802. * @hidden
  62803. */
  62804. computeEffectivePosition(globalViewport: Viewport): boolean;
  62805. /** @hidden */
  62806. _isVisible(): boolean;
  62807. /**
  62808. * @hidden
  62809. */
  62810. render(): boolean;
  62811. /**
  62812. * Dispose and release the lens flare with its associated resources.
  62813. */
  62814. dispose(): void;
  62815. /**
  62816. * Parse a lens flare system from a JSON repressentation
  62817. * @param parsedLensFlareSystem Define the JSON to parse
  62818. * @param scene Define the scene the parsed system should be instantiated in
  62819. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62820. * @returns the parsed system
  62821. */
  62822. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62823. /**
  62824. * Serialize the current Lens Flare System into a JSON representation.
  62825. * @returns the serialized JSON
  62826. */
  62827. serialize(): any;
  62828. }
  62829. }
  62830. declare module "babylonjs/LensFlares/lensFlare" {
  62831. import { Nullable } from "babylonjs/types";
  62832. import { Color3 } from "babylonjs/Maths/math.color";
  62833. import { Texture } from "babylonjs/Materials/Textures/texture";
  62834. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62835. /**
  62836. * This represents one of the lens effect in a `lensFlareSystem`.
  62837. * It controls one of the indiviual texture used in the effect.
  62838. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62839. */
  62840. export class LensFlare {
  62841. /**
  62842. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62843. */
  62844. size: number;
  62845. /**
  62846. * 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.
  62847. */
  62848. position: number;
  62849. /**
  62850. * Define the lens color.
  62851. */
  62852. color: Color3;
  62853. /**
  62854. * Define the lens texture.
  62855. */
  62856. texture: Nullable<Texture>;
  62857. /**
  62858. * Define the alpha mode to render this particular lens.
  62859. */
  62860. alphaMode: number;
  62861. private _system;
  62862. /**
  62863. * Creates a new Lens Flare.
  62864. * This represents one of the lens effect in a `lensFlareSystem`.
  62865. * It controls one of the indiviual texture used in the effect.
  62866. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62867. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62868. * @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.
  62869. * @param color Define the lens color
  62870. * @param imgUrl Define the lens texture url
  62871. * @param system Define the `lensFlareSystem` this flare is part of
  62872. * @returns The newly created Lens Flare
  62873. */
  62874. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62875. /**
  62876. * Instantiates a new Lens Flare.
  62877. * This represents one of the lens effect in a `lensFlareSystem`.
  62878. * It controls one of the indiviual texture used in the effect.
  62879. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62880. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62881. * @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.
  62882. * @param color Define the lens color
  62883. * @param imgUrl Define the lens texture url
  62884. * @param system Define the `lensFlareSystem` this flare is part of
  62885. */
  62886. constructor(
  62887. /**
  62888. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62889. */
  62890. size: number,
  62891. /**
  62892. * 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.
  62893. */
  62894. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62895. /**
  62896. * Dispose and release the lens flare with its associated resources.
  62897. */
  62898. dispose(): void;
  62899. }
  62900. }
  62901. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62902. import { Nullable } from "babylonjs/types";
  62903. import { Scene } from "babylonjs/scene";
  62904. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62905. import { AbstractScene } from "babylonjs/abstractScene";
  62906. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62907. module "babylonjs/abstractScene" {
  62908. interface AbstractScene {
  62909. /**
  62910. * The list of lens flare system added to the scene
  62911. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62912. */
  62913. lensFlareSystems: Array<LensFlareSystem>;
  62914. /**
  62915. * Removes the given lens flare system from this scene.
  62916. * @param toRemove The lens flare system to remove
  62917. * @returns The index of the removed lens flare system
  62918. */
  62919. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62920. /**
  62921. * Adds the given lens flare system to this scene
  62922. * @param newLensFlareSystem The lens flare system to add
  62923. */
  62924. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62925. /**
  62926. * Gets a lens flare system using its name
  62927. * @param name defines the name to look for
  62928. * @returns the lens flare system or null if not found
  62929. */
  62930. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62931. /**
  62932. * Gets a lens flare system using its id
  62933. * @param id defines the id to look for
  62934. * @returns the lens flare system or null if not found
  62935. */
  62936. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62937. }
  62938. }
  62939. /**
  62940. * Defines the lens flare scene component responsible to manage any lens flares
  62941. * in a given scene.
  62942. */
  62943. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62944. /**
  62945. * The component name helpfull to identify the component in the list of scene components.
  62946. */
  62947. readonly name: string;
  62948. /**
  62949. * The scene the component belongs to.
  62950. */
  62951. scene: Scene;
  62952. /**
  62953. * Creates a new instance of the component for the given scene
  62954. * @param scene Defines the scene to register the component in
  62955. */
  62956. constructor(scene: Scene);
  62957. /**
  62958. * Registers the component in a given scene
  62959. */
  62960. register(): void;
  62961. /**
  62962. * Rebuilds the elements related to this component in case of
  62963. * context lost for instance.
  62964. */
  62965. rebuild(): void;
  62966. /**
  62967. * Adds all the elements from the container to the scene
  62968. * @param container the container holding the elements
  62969. */
  62970. addFromContainer(container: AbstractScene): void;
  62971. /**
  62972. * Removes all the elements in the container from the scene
  62973. * @param container contains the elements to remove
  62974. * @param dispose if the removed element should be disposed (default: false)
  62975. */
  62976. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62977. /**
  62978. * Serializes the component data to the specified json object
  62979. * @param serializationObject The object to serialize to
  62980. */
  62981. serialize(serializationObject: any): void;
  62982. /**
  62983. * Disposes the component and the associated ressources.
  62984. */
  62985. dispose(): void;
  62986. private _draw;
  62987. }
  62988. }
  62989. declare module "babylonjs/LensFlares/index" {
  62990. export * from "babylonjs/LensFlares/lensFlare";
  62991. export * from "babylonjs/LensFlares/lensFlareSystem";
  62992. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62993. }
  62994. declare module "babylonjs/Shaders/depth.fragment" {
  62995. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62996. /** @hidden */
  62997. export var depthPixelShader: {
  62998. name: string;
  62999. shader: string;
  63000. };
  63001. }
  63002. declare module "babylonjs/Shaders/depth.vertex" {
  63003. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63004. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63005. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63006. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63007. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63008. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63009. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63010. /** @hidden */
  63011. export var depthVertexShader: {
  63012. name: string;
  63013. shader: string;
  63014. };
  63015. }
  63016. declare module "babylonjs/Rendering/depthRenderer" {
  63017. import { Nullable } from "babylonjs/types";
  63018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63019. import { Scene } from "babylonjs/scene";
  63020. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63021. import { Camera } from "babylonjs/Cameras/camera";
  63022. import "babylonjs/Shaders/depth.fragment";
  63023. import "babylonjs/Shaders/depth.vertex";
  63024. /**
  63025. * This represents a depth renderer in Babylon.
  63026. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63027. */
  63028. export class DepthRenderer {
  63029. private _scene;
  63030. private _depthMap;
  63031. private _effect;
  63032. private readonly _storeNonLinearDepth;
  63033. private readonly _clearColor;
  63034. /** Get if the depth renderer is using packed depth or not */
  63035. readonly isPacked: boolean;
  63036. private _cachedDefines;
  63037. private _camera;
  63038. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63039. enabled: boolean;
  63040. /**
  63041. * Specifiess that the depth renderer will only be used within
  63042. * the camera it is created for.
  63043. * This can help forcing its rendering during the camera processing.
  63044. */
  63045. useOnlyInActiveCamera: boolean;
  63046. /** @hidden */
  63047. static _SceneComponentInitialization: (scene: Scene) => void;
  63048. /**
  63049. * Instantiates a depth renderer
  63050. * @param scene The scene the renderer belongs to
  63051. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63052. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63053. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63054. */
  63055. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63056. /**
  63057. * Creates the depth rendering effect and checks if the effect is ready.
  63058. * @param subMesh The submesh to be used to render the depth map of
  63059. * @param useInstances If multiple world instances should be used
  63060. * @returns if the depth renderer is ready to render the depth map
  63061. */
  63062. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63063. /**
  63064. * Gets the texture which the depth map will be written to.
  63065. * @returns The depth map texture
  63066. */
  63067. getDepthMap(): RenderTargetTexture;
  63068. /**
  63069. * Disposes of the depth renderer.
  63070. */
  63071. dispose(): void;
  63072. }
  63073. }
  63074. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63075. /** @hidden */
  63076. export var minmaxReduxPixelShader: {
  63077. name: string;
  63078. shader: string;
  63079. };
  63080. }
  63081. declare module "babylonjs/Misc/minMaxReducer" {
  63082. import { Nullable } from "babylonjs/types";
  63083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63084. import { Camera } from "babylonjs/Cameras/camera";
  63085. import { Observer } from "babylonjs/Misc/observable";
  63086. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63087. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63088. import { Observable } from "babylonjs/Misc/observable";
  63089. import "babylonjs/Shaders/minmaxRedux.fragment";
  63090. /**
  63091. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63092. * and maximum values from all values of the texture.
  63093. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63094. * The source values are read from the red channel of the texture.
  63095. */
  63096. export class MinMaxReducer {
  63097. /**
  63098. * Observable triggered when the computation has been performed
  63099. */
  63100. onAfterReductionPerformed: Observable<{
  63101. min: number;
  63102. max: number;
  63103. }>;
  63104. protected _camera: Camera;
  63105. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63106. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63107. protected _postProcessManager: PostProcessManager;
  63108. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63109. protected _forceFullscreenViewport: boolean;
  63110. /**
  63111. * Creates a min/max reducer
  63112. * @param camera The camera to use for the post processes
  63113. */
  63114. constructor(camera: Camera);
  63115. /**
  63116. * Gets the texture used to read the values from.
  63117. */
  63118. get sourceTexture(): Nullable<RenderTargetTexture>;
  63119. /**
  63120. * Sets the source texture to read the values from.
  63121. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63122. * because in such textures '1' value must not be taken into account to compute the maximum
  63123. * as this value is used to clear the texture.
  63124. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63125. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63126. * @param depthRedux Indicates if the texture is a depth texture or not
  63127. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63128. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63129. */
  63130. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63131. /**
  63132. * Defines the refresh rate of the computation.
  63133. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63134. */
  63135. get refreshRate(): number;
  63136. set refreshRate(value: number);
  63137. protected _activated: boolean;
  63138. /**
  63139. * Gets the activation status of the reducer
  63140. */
  63141. get activated(): boolean;
  63142. /**
  63143. * Activates the reduction computation.
  63144. * When activated, the observers registered in onAfterReductionPerformed are
  63145. * called after the compuation is performed
  63146. */
  63147. activate(): void;
  63148. /**
  63149. * Deactivates the reduction computation.
  63150. */
  63151. deactivate(): void;
  63152. /**
  63153. * Disposes the min/max reducer
  63154. * @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.
  63155. */
  63156. dispose(disposeAll?: boolean): void;
  63157. }
  63158. }
  63159. declare module "babylonjs/Misc/depthReducer" {
  63160. import { Nullable } from "babylonjs/types";
  63161. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63162. import { Camera } from "babylonjs/Cameras/camera";
  63163. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63164. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63165. /**
  63166. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63167. */
  63168. export class DepthReducer extends MinMaxReducer {
  63169. private _depthRenderer;
  63170. private _depthRendererId;
  63171. /**
  63172. * Gets the depth renderer used for the computation.
  63173. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63174. */
  63175. get depthRenderer(): Nullable<DepthRenderer>;
  63176. /**
  63177. * Creates a depth reducer
  63178. * @param camera The camera used to render the depth texture
  63179. */
  63180. constructor(camera: Camera);
  63181. /**
  63182. * Sets the depth renderer to use to generate the depth map
  63183. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63184. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63185. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63186. */
  63187. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63188. /** @hidden */
  63189. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63190. /**
  63191. * Activates the reduction computation.
  63192. * When activated, the observers registered in onAfterReductionPerformed are
  63193. * called after the compuation is performed
  63194. */
  63195. activate(): void;
  63196. /**
  63197. * Deactivates the reduction computation.
  63198. */
  63199. deactivate(): void;
  63200. /**
  63201. * Disposes the depth reducer
  63202. * @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.
  63203. */
  63204. dispose(disposeAll?: boolean): void;
  63205. }
  63206. }
  63207. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63208. import { Nullable } from "babylonjs/types";
  63209. import { Scene } from "babylonjs/scene";
  63210. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63213. import { Effect } from "babylonjs/Materials/effect";
  63214. import "babylonjs/Shaders/shadowMap.fragment";
  63215. import "babylonjs/Shaders/shadowMap.vertex";
  63216. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63217. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63218. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63219. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63220. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63221. /**
  63222. * A CSM implementation allowing casting shadows on large scenes.
  63223. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63224. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63225. */
  63226. export class CascadedShadowGenerator extends ShadowGenerator {
  63227. private static readonly frustumCornersNDCSpace;
  63228. /**
  63229. * Name of the CSM class
  63230. */
  63231. static CLASSNAME: string;
  63232. /**
  63233. * Defines the default number of cascades used by the CSM.
  63234. */
  63235. static readonly DEFAULT_CASCADES_COUNT: number;
  63236. /**
  63237. * Defines the minimum number of cascades used by the CSM.
  63238. */
  63239. static readonly MIN_CASCADES_COUNT: number;
  63240. /**
  63241. * Defines the maximum number of cascades used by the CSM.
  63242. */
  63243. static readonly MAX_CASCADES_COUNT: number;
  63244. protected _validateFilter(filter: number): number;
  63245. /**
  63246. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63247. */
  63248. penumbraDarkness: number;
  63249. private _numCascades;
  63250. /**
  63251. * Gets or set the number of cascades used by the CSM.
  63252. */
  63253. get numCascades(): number;
  63254. set numCascades(value: number);
  63255. /**
  63256. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63257. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63258. */
  63259. stabilizeCascades: boolean;
  63260. private _freezeShadowCastersBoundingInfo;
  63261. private _freezeShadowCastersBoundingInfoObservable;
  63262. /**
  63263. * Enables or disables the shadow casters bounding info computation.
  63264. * If your shadow casters don't move, you can disable this feature.
  63265. * If it is enabled, the bounding box computation is done every frame.
  63266. */
  63267. get freezeShadowCastersBoundingInfo(): boolean;
  63268. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63269. private _scbiMin;
  63270. private _scbiMax;
  63271. protected _computeShadowCastersBoundingInfo(): void;
  63272. protected _shadowCastersBoundingInfo: BoundingInfo;
  63273. /**
  63274. * Gets or sets the shadow casters bounding info.
  63275. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63276. * so that the system won't overwrite the bounds you provide
  63277. */
  63278. get shadowCastersBoundingInfo(): BoundingInfo;
  63279. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63280. protected _breaksAreDirty: boolean;
  63281. protected _minDistance: number;
  63282. protected _maxDistance: number;
  63283. /**
  63284. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63285. *
  63286. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63287. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63288. * @param min minimal distance for the breaks (default to 0.)
  63289. * @param max maximal distance for the breaks (default to 1.)
  63290. */
  63291. setMinMaxDistance(min: number, max: number): void;
  63292. /** Gets the minimal distance used in the cascade break computation */
  63293. get minDistance(): number;
  63294. /** Gets the maximal distance used in the cascade break computation */
  63295. get maxDistance(): number;
  63296. /**
  63297. * Gets the class name of that object
  63298. * @returns "CascadedShadowGenerator"
  63299. */
  63300. getClassName(): string;
  63301. private _cascadeMinExtents;
  63302. private _cascadeMaxExtents;
  63303. /**
  63304. * Gets a cascade minimum extents
  63305. * @param cascadeIndex index of the cascade
  63306. * @returns the minimum cascade extents
  63307. */
  63308. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63309. /**
  63310. * Gets a cascade maximum extents
  63311. * @param cascadeIndex index of the cascade
  63312. * @returns the maximum cascade extents
  63313. */
  63314. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63315. private _cascades;
  63316. private _currentLayer;
  63317. private _viewSpaceFrustumsZ;
  63318. private _viewMatrices;
  63319. private _projectionMatrices;
  63320. private _transformMatrices;
  63321. private _transformMatricesAsArray;
  63322. private _frustumLengths;
  63323. private _lightSizeUVCorrection;
  63324. private _depthCorrection;
  63325. private _frustumCornersWorldSpace;
  63326. private _frustumCenter;
  63327. private _shadowCameraPos;
  63328. private _shadowMaxZ;
  63329. /**
  63330. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63331. * It defaults to camera.maxZ
  63332. */
  63333. get shadowMaxZ(): number;
  63334. /**
  63335. * Sets the shadow max z distance.
  63336. */
  63337. set shadowMaxZ(value: number);
  63338. protected _debug: boolean;
  63339. /**
  63340. * Gets or sets the debug flag.
  63341. * When enabled, the cascades are materialized by different colors on the screen.
  63342. */
  63343. get debug(): boolean;
  63344. set debug(dbg: boolean);
  63345. private _depthClamp;
  63346. /**
  63347. * Gets or sets the depth clamping value.
  63348. *
  63349. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63350. * to account for the shadow casters far away.
  63351. *
  63352. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63353. */
  63354. get depthClamp(): boolean;
  63355. set depthClamp(value: boolean);
  63356. private _cascadeBlendPercentage;
  63357. /**
  63358. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63359. * It defaults to 0.1 (10% blending).
  63360. */
  63361. get cascadeBlendPercentage(): number;
  63362. set cascadeBlendPercentage(value: number);
  63363. private _lambda;
  63364. /**
  63365. * Gets or set the lambda parameter.
  63366. * This parameter is used to split the camera frustum and create the cascades.
  63367. * 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.
  63368. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63369. */
  63370. get lambda(): number;
  63371. set lambda(value: number);
  63372. /**
  63373. * Gets the view matrix corresponding to a given cascade
  63374. * @param cascadeNum cascade to retrieve the view matrix from
  63375. * @returns the cascade view matrix
  63376. */
  63377. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63378. /**
  63379. * Gets the projection matrix corresponding to a given cascade
  63380. * @param cascadeNum cascade to retrieve the projection matrix from
  63381. * @returns the cascade projection matrix
  63382. */
  63383. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63384. /**
  63385. * Gets the transformation matrix corresponding to a given cascade
  63386. * @param cascadeNum cascade to retrieve the transformation matrix from
  63387. * @returns the cascade transformation matrix
  63388. */
  63389. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63390. private _depthRenderer;
  63391. /**
  63392. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63393. *
  63394. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63395. *
  63396. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63397. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63398. * @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
  63399. */
  63400. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63401. private _depthReducer;
  63402. private _autoCalcDepthBounds;
  63403. /**
  63404. * Gets or sets the autoCalcDepthBounds property.
  63405. *
  63406. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63407. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63408. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63409. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63410. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63411. */
  63412. get autoCalcDepthBounds(): boolean;
  63413. set autoCalcDepthBounds(value: boolean);
  63414. /**
  63415. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63416. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63417. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63418. * for setting the refresh rate on the renderer yourself!
  63419. */
  63420. get autoCalcDepthBoundsRefreshRate(): number;
  63421. set autoCalcDepthBoundsRefreshRate(value: number);
  63422. /**
  63423. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63424. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63425. * you change the camera near/far planes!
  63426. */
  63427. splitFrustum(): void;
  63428. private _splitFrustum;
  63429. private _computeMatrices;
  63430. private _computeFrustumInWorldSpace;
  63431. private _computeCascadeFrustum;
  63432. /**
  63433. * Support test.
  63434. */
  63435. static get IsSupported(): boolean;
  63436. /** @hidden */
  63437. static _SceneComponentInitialization: (scene: Scene) => void;
  63438. /**
  63439. * Creates a Cascaded Shadow Generator object.
  63440. * A ShadowGenerator is the required tool to use the shadows.
  63441. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63442. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63443. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63444. * @param light The directional light object generating the shadows.
  63445. * @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.
  63446. */
  63447. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63448. protected _initializeGenerator(): void;
  63449. protected _createTargetRenderTexture(): void;
  63450. protected _initializeShadowMap(): void;
  63451. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63452. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63453. /**
  63454. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63455. * @param defines Defines of the material we want to update
  63456. * @param lightIndex Index of the light in the enabled light list of the material
  63457. */
  63458. prepareDefines(defines: any, lightIndex: number): void;
  63459. /**
  63460. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63461. * defined in the generator but impacting the effect).
  63462. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63463. * @param effect The effect we are binfing the information for
  63464. */
  63465. bindShadowLight(lightIndex: string, effect: Effect): void;
  63466. /**
  63467. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63468. * (eq to view projection * shadow projection matrices)
  63469. * @returns The transform matrix used to create the shadow map
  63470. */
  63471. getTransformMatrix(): Matrix;
  63472. /**
  63473. * Disposes the ShadowGenerator.
  63474. * Returns nothing.
  63475. */
  63476. dispose(): void;
  63477. /**
  63478. * Serializes the shadow generator setup to a json object.
  63479. * @returns The serialized JSON object
  63480. */
  63481. serialize(): any;
  63482. /**
  63483. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63484. * @param parsedShadowGenerator The JSON object to parse
  63485. * @param scene The scene to create the shadow map for
  63486. * @returns The parsed shadow generator
  63487. */
  63488. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63489. }
  63490. }
  63491. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63492. import { Scene } from "babylonjs/scene";
  63493. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63494. import { AbstractScene } from "babylonjs/abstractScene";
  63495. /**
  63496. * Defines the shadow generator component responsible to manage any shadow generators
  63497. * in a given scene.
  63498. */
  63499. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63500. /**
  63501. * The component name helpfull to identify the component in the list of scene components.
  63502. */
  63503. readonly name: string;
  63504. /**
  63505. * The scene the component belongs to.
  63506. */
  63507. scene: Scene;
  63508. /**
  63509. * Creates a new instance of the component for the given scene
  63510. * @param scene Defines the scene to register the component in
  63511. */
  63512. constructor(scene: Scene);
  63513. /**
  63514. * Registers the component in a given scene
  63515. */
  63516. register(): void;
  63517. /**
  63518. * Rebuilds the elements related to this component in case of
  63519. * context lost for instance.
  63520. */
  63521. rebuild(): void;
  63522. /**
  63523. * Serializes the component data to the specified json object
  63524. * @param serializationObject The object to serialize to
  63525. */
  63526. serialize(serializationObject: any): void;
  63527. /**
  63528. * Adds all the elements from the container to the scene
  63529. * @param container the container holding the elements
  63530. */
  63531. addFromContainer(container: AbstractScene): void;
  63532. /**
  63533. * Removes all the elements in the container from the scene
  63534. * @param container contains the elements to remove
  63535. * @param dispose if the removed element should be disposed (default: false)
  63536. */
  63537. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63538. /**
  63539. * Rebuilds the elements related to this component in case of
  63540. * context lost for instance.
  63541. */
  63542. dispose(): void;
  63543. private _gatherRenderTargets;
  63544. }
  63545. }
  63546. declare module "babylonjs/Lights/Shadows/index" {
  63547. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63548. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63549. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63550. }
  63551. declare module "babylonjs/Lights/pointLight" {
  63552. import { Scene } from "babylonjs/scene";
  63553. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63555. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63556. import { Effect } from "babylonjs/Materials/effect";
  63557. /**
  63558. * A point light is a light defined by an unique point in world space.
  63559. * The light is emitted in every direction from this point.
  63560. * A good example of a point light is a standard light bulb.
  63561. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63562. */
  63563. export class PointLight extends ShadowLight {
  63564. private _shadowAngle;
  63565. /**
  63566. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63567. * This specifies what angle the shadow will use to be created.
  63568. *
  63569. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63570. */
  63571. get shadowAngle(): number;
  63572. /**
  63573. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63574. * This specifies what angle the shadow will use to be created.
  63575. *
  63576. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63577. */
  63578. set shadowAngle(value: number);
  63579. /**
  63580. * Gets the direction if it has been set.
  63581. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63582. */
  63583. get direction(): Vector3;
  63584. /**
  63585. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63586. */
  63587. set direction(value: Vector3);
  63588. /**
  63589. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63590. * A PointLight emits the light in every direction.
  63591. * It can cast shadows.
  63592. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63593. * ```javascript
  63594. * var pointLight = new PointLight("pl", camera.position, scene);
  63595. * ```
  63596. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63597. * @param name The light friendly name
  63598. * @param position The position of the point light in the scene
  63599. * @param scene The scene the lights belongs to
  63600. */
  63601. constructor(name: string, position: Vector3, scene: Scene);
  63602. /**
  63603. * Returns the string "PointLight"
  63604. * @returns the class name
  63605. */
  63606. getClassName(): string;
  63607. /**
  63608. * Returns the integer 0.
  63609. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63610. */
  63611. getTypeID(): number;
  63612. /**
  63613. * Specifies wether or not the shadowmap should be a cube texture.
  63614. * @returns true if the shadowmap needs to be a cube texture.
  63615. */
  63616. needCube(): boolean;
  63617. /**
  63618. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63619. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63620. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63621. */
  63622. getShadowDirection(faceIndex?: number): Vector3;
  63623. /**
  63624. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63625. * - fov = PI / 2
  63626. * - aspect ratio : 1.0
  63627. * - z-near and far equal to the active camera minZ and maxZ.
  63628. * Returns the PointLight.
  63629. */
  63630. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63631. protected _buildUniformLayout(): void;
  63632. /**
  63633. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63634. * @param effect The effect to update
  63635. * @param lightIndex The index of the light in the effect to update
  63636. * @returns The point light
  63637. */
  63638. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63639. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63640. /**
  63641. * Prepares the list of defines specific to the light type.
  63642. * @param defines the list of defines
  63643. * @param lightIndex defines the index of the light for the effect
  63644. */
  63645. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63646. }
  63647. }
  63648. declare module "babylonjs/Lights/index" {
  63649. export * from "babylonjs/Lights/light";
  63650. export * from "babylonjs/Lights/shadowLight";
  63651. export * from "babylonjs/Lights/Shadows/index";
  63652. export * from "babylonjs/Lights/directionalLight";
  63653. export * from "babylonjs/Lights/hemisphericLight";
  63654. export * from "babylonjs/Lights/pointLight";
  63655. export * from "babylonjs/Lights/spotLight";
  63656. }
  63657. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63658. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63659. /**
  63660. * Header information of HDR texture files.
  63661. */
  63662. export interface HDRInfo {
  63663. /**
  63664. * The height of the texture in pixels.
  63665. */
  63666. height: number;
  63667. /**
  63668. * The width of the texture in pixels.
  63669. */
  63670. width: number;
  63671. /**
  63672. * The index of the beginning of the data in the binary file.
  63673. */
  63674. dataPosition: number;
  63675. }
  63676. /**
  63677. * This groups tools to convert HDR texture to native colors array.
  63678. */
  63679. export class HDRTools {
  63680. private static Ldexp;
  63681. private static Rgbe2float;
  63682. private static readStringLine;
  63683. /**
  63684. * Reads header information from an RGBE texture stored in a native array.
  63685. * More information on this format are available here:
  63686. * https://en.wikipedia.org/wiki/RGBE_image_format
  63687. *
  63688. * @param uint8array The binary file stored in native array.
  63689. * @return The header information.
  63690. */
  63691. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63692. /**
  63693. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63694. * This RGBE texture needs to store the information as a panorama.
  63695. *
  63696. * More information on this format are available here:
  63697. * https://en.wikipedia.org/wiki/RGBE_image_format
  63698. *
  63699. * @param buffer The binary file stored in an array buffer.
  63700. * @param size The expected size of the extracted cubemap.
  63701. * @return The Cube Map information.
  63702. */
  63703. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63704. /**
  63705. * Returns the pixels data extracted from an RGBE texture.
  63706. * This pixels will be stored left to right up to down in the R G B order in one array.
  63707. *
  63708. * More information on this format are available here:
  63709. * https://en.wikipedia.org/wiki/RGBE_image_format
  63710. *
  63711. * @param uint8array The binary file stored in an array buffer.
  63712. * @param hdrInfo The header information of the file.
  63713. * @return The pixels data in RGB right to left up to down order.
  63714. */
  63715. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63716. private static RGBE_ReadPixels_RLE;
  63717. private static RGBE_ReadPixels_NOT_RLE;
  63718. }
  63719. }
  63720. declare module "babylonjs/Materials/effectRenderer" {
  63721. import { Nullable } from "babylonjs/types";
  63722. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63723. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63724. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63725. import { Viewport } from "babylonjs/Maths/math.viewport";
  63726. import { Observable } from "babylonjs/Misc/observable";
  63727. import { Effect } from "babylonjs/Materials/effect";
  63728. import "babylonjs/Shaders/postprocess.vertex";
  63729. /**
  63730. * Effect Render Options
  63731. */
  63732. export interface IEffectRendererOptions {
  63733. /**
  63734. * Defines the vertices positions.
  63735. */
  63736. positions?: number[];
  63737. /**
  63738. * Defines the indices.
  63739. */
  63740. indices?: number[];
  63741. }
  63742. /**
  63743. * Helper class to render one or more effects.
  63744. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63745. */
  63746. export class EffectRenderer {
  63747. private engine;
  63748. private static _DefaultOptions;
  63749. private _vertexBuffers;
  63750. private _indexBuffer;
  63751. private _fullscreenViewport;
  63752. /**
  63753. * Creates an effect renderer
  63754. * @param engine the engine to use for rendering
  63755. * @param options defines the options of the effect renderer
  63756. */
  63757. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63758. /**
  63759. * Sets the current viewport in normalized coordinates 0-1
  63760. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63761. */
  63762. setViewport(viewport?: Viewport): void;
  63763. /**
  63764. * Binds the embedded attributes buffer to the effect.
  63765. * @param effect Defines the effect to bind the attributes for
  63766. */
  63767. bindBuffers(effect: Effect): void;
  63768. /**
  63769. * Sets the current effect wrapper to use during draw.
  63770. * The effect needs to be ready before calling this api.
  63771. * This also sets the default full screen position attribute.
  63772. * @param effectWrapper Defines the effect to draw with
  63773. */
  63774. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63775. /**
  63776. * Restores engine states
  63777. */
  63778. restoreStates(): void;
  63779. /**
  63780. * Draws a full screen quad.
  63781. */
  63782. draw(): void;
  63783. private isRenderTargetTexture;
  63784. /**
  63785. * renders one or more effects to a specified texture
  63786. * @param effectWrapper the effect to renderer
  63787. * @param outputTexture texture to draw to, if null it will render to the screen.
  63788. */
  63789. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63790. /**
  63791. * Disposes of the effect renderer
  63792. */
  63793. dispose(): void;
  63794. }
  63795. /**
  63796. * Options to create an EffectWrapper
  63797. */
  63798. interface EffectWrapperCreationOptions {
  63799. /**
  63800. * Engine to use to create the effect
  63801. */
  63802. engine: ThinEngine;
  63803. /**
  63804. * Fragment shader for the effect
  63805. */
  63806. fragmentShader: string;
  63807. /**
  63808. * Use the shader store instead of direct source code
  63809. */
  63810. useShaderStore?: boolean;
  63811. /**
  63812. * Vertex shader for the effect
  63813. */
  63814. vertexShader?: string;
  63815. /**
  63816. * Attributes to use in the shader
  63817. */
  63818. attributeNames?: Array<string>;
  63819. /**
  63820. * Uniforms to use in the shader
  63821. */
  63822. uniformNames?: Array<string>;
  63823. /**
  63824. * Texture sampler names to use in the shader
  63825. */
  63826. samplerNames?: Array<string>;
  63827. /**
  63828. * Defines to use in the shader
  63829. */
  63830. defines?: Array<string>;
  63831. /**
  63832. * Callback when effect is compiled
  63833. */
  63834. onCompiled?: Nullable<(effect: Effect) => void>;
  63835. /**
  63836. * The friendly name of the effect displayed in Spector.
  63837. */
  63838. name?: string;
  63839. }
  63840. /**
  63841. * Wraps an effect to be used for rendering
  63842. */
  63843. export class EffectWrapper {
  63844. /**
  63845. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63846. */
  63847. onApplyObservable: Observable<{}>;
  63848. /**
  63849. * The underlying effect
  63850. */
  63851. effect: Effect;
  63852. /**
  63853. * Creates an effect to be renderer
  63854. * @param creationOptions options to create the effect
  63855. */
  63856. constructor(creationOptions: EffectWrapperCreationOptions);
  63857. /**
  63858. * Disposes of the effect wrapper
  63859. */
  63860. dispose(): void;
  63861. }
  63862. }
  63863. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63864. /** @hidden */
  63865. export var hdrFilteringVertexShader: {
  63866. name: string;
  63867. shader: string;
  63868. };
  63869. }
  63870. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63871. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63872. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63873. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63874. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63875. /** @hidden */
  63876. export var hdrFilteringPixelShader: {
  63877. name: string;
  63878. shader: string;
  63879. };
  63880. }
  63881. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63882. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63883. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63884. import { Nullable } from "babylonjs/types";
  63885. import "babylonjs/Shaders/hdrFiltering.vertex";
  63886. import "babylonjs/Shaders/hdrFiltering.fragment";
  63887. /**
  63888. * Options for texture filtering
  63889. */
  63890. interface IHDRFilteringOptions {
  63891. /**
  63892. * Scales pixel intensity for the input HDR map.
  63893. */
  63894. hdrScale?: number;
  63895. /**
  63896. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63897. */
  63898. quality?: number;
  63899. }
  63900. /**
  63901. * Filters HDR maps to get correct renderings of PBR reflections
  63902. */
  63903. export class HDRFiltering {
  63904. private _engine;
  63905. private _effectRenderer;
  63906. private _effectWrapper;
  63907. private _lodGenerationOffset;
  63908. private _lodGenerationScale;
  63909. /**
  63910. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63911. * you care about baking speed.
  63912. */
  63913. quality: number;
  63914. /**
  63915. * Scales pixel intensity for the input HDR map.
  63916. */
  63917. hdrScale: number;
  63918. /**
  63919. * Instantiates HDR filter for reflection maps
  63920. *
  63921. * @param engine Thin engine
  63922. * @param options Options
  63923. */
  63924. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63925. private _createRenderTarget;
  63926. private _prefilterInternal;
  63927. private _createEffect;
  63928. /**
  63929. * Get a value indicating if the filter is ready to be used
  63930. * @param texture Texture to filter
  63931. * @returns true if the filter is ready
  63932. */
  63933. isReady(texture: BaseTexture): boolean;
  63934. /**
  63935. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63936. * Prefiltering will be invoked at the end of next rendering pass.
  63937. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63938. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63939. * @param texture Texture to filter
  63940. * @param onFinished Callback when filtering is done
  63941. * @return Promise called when prefiltering is done
  63942. */
  63943. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63944. }
  63945. }
  63946. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63947. import { Nullable } from "babylonjs/types";
  63948. import { Scene } from "babylonjs/scene";
  63949. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63950. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63951. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63952. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63953. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63954. /**
  63955. * This represents a texture coming from an HDR input.
  63956. *
  63957. * The only supported format is currently panorama picture stored in RGBE format.
  63958. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63959. */
  63960. export class HDRCubeTexture extends BaseTexture {
  63961. private static _facesMapping;
  63962. private _generateHarmonics;
  63963. private _noMipmap;
  63964. private _prefilterOnLoad;
  63965. private _textureMatrix;
  63966. private _size;
  63967. private _onLoad;
  63968. private _onError;
  63969. /**
  63970. * The texture URL.
  63971. */
  63972. url: string;
  63973. protected _isBlocking: boolean;
  63974. /**
  63975. * Sets wether or not the texture is blocking during loading.
  63976. */
  63977. set isBlocking(value: boolean);
  63978. /**
  63979. * Gets wether or not the texture is blocking during loading.
  63980. */
  63981. get isBlocking(): boolean;
  63982. protected _rotationY: number;
  63983. /**
  63984. * Sets texture matrix rotation angle around Y axis in radians.
  63985. */
  63986. set rotationY(value: number);
  63987. /**
  63988. * Gets texture matrix rotation angle around Y axis radians.
  63989. */
  63990. get rotationY(): number;
  63991. /**
  63992. * Gets or sets the center of the bounding box associated with the cube texture
  63993. * It must define where the camera used to render the texture was set
  63994. */
  63995. boundingBoxPosition: Vector3;
  63996. private _boundingBoxSize;
  63997. /**
  63998. * Gets or sets the size of the bounding box associated with the cube texture
  63999. * When defined, the cubemap will switch to local mode
  64000. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64001. * @example https://www.babylonjs-playground.com/#RNASML
  64002. */
  64003. set boundingBoxSize(value: Vector3);
  64004. get boundingBoxSize(): Vector3;
  64005. /**
  64006. * Instantiates an HDRTexture from the following parameters.
  64007. *
  64008. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64009. * @param sceneOrEngine The scene or engine the texture will be used in
  64010. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64011. * @param noMipmap Forces to not generate the mipmap if true
  64012. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64013. * @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)
  64014. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64015. */
  64016. 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>);
  64017. /**
  64018. * Get the current class name of the texture useful for serialization or dynamic coding.
  64019. * @returns "HDRCubeTexture"
  64020. */
  64021. getClassName(): string;
  64022. /**
  64023. * Occurs when the file is raw .hdr file.
  64024. */
  64025. private loadTexture;
  64026. clone(): HDRCubeTexture;
  64027. delayLoad(): void;
  64028. /**
  64029. * Get the texture reflection matrix used to rotate/transform the reflection.
  64030. * @returns the reflection matrix
  64031. */
  64032. getReflectionTextureMatrix(): Matrix;
  64033. /**
  64034. * Set the texture reflection matrix used to rotate/transform the reflection.
  64035. * @param value Define the reflection matrix to set
  64036. */
  64037. setReflectionTextureMatrix(value: Matrix): void;
  64038. /**
  64039. * Parses a JSON representation of an HDR Texture in order to create the texture
  64040. * @param parsedTexture Define the JSON representation
  64041. * @param scene Define the scene the texture should be created in
  64042. * @param rootUrl Define the root url in case we need to load relative dependencies
  64043. * @returns the newly created texture after parsing
  64044. */
  64045. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64046. serialize(): any;
  64047. }
  64048. }
  64049. declare module "babylonjs/Physics/physicsEngine" {
  64050. import { Nullable } from "babylonjs/types";
  64051. import { Vector3 } from "babylonjs/Maths/math.vector";
  64052. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64053. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64054. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64055. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64056. /**
  64057. * Class used to control physics engine
  64058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64059. */
  64060. export class PhysicsEngine implements IPhysicsEngine {
  64061. private _physicsPlugin;
  64062. /**
  64063. * Global value used to control the smallest number supported by the simulation
  64064. */
  64065. static Epsilon: number;
  64066. private _impostors;
  64067. private _joints;
  64068. private _subTimeStep;
  64069. /**
  64070. * Gets the gravity vector used by the simulation
  64071. */
  64072. gravity: Vector3;
  64073. /**
  64074. * Factory used to create the default physics plugin.
  64075. * @returns The default physics plugin
  64076. */
  64077. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64078. /**
  64079. * Creates a new Physics Engine
  64080. * @param gravity defines the gravity vector used by the simulation
  64081. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64082. */
  64083. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64084. /**
  64085. * Sets the gravity vector used by the simulation
  64086. * @param gravity defines the gravity vector to use
  64087. */
  64088. setGravity(gravity: Vector3): void;
  64089. /**
  64090. * Set the time step of the physics engine.
  64091. * Default is 1/60.
  64092. * To slow it down, enter 1/600 for example.
  64093. * To speed it up, 1/30
  64094. * @param newTimeStep defines the new timestep to apply to this world.
  64095. */
  64096. setTimeStep(newTimeStep?: number): void;
  64097. /**
  64098. * Get the time step of the physics engine.
  64099. * @returns the current time step
  64100. */
  64101. getTimeStep(): number;
  64102. /**
  64103. * Set the sub time step of the physics engine.
  64104. * Default is 0 meaning there is no sub steps
  64105. * To increase physics resolution precision, set a small value (like 1 ms)
  64106. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64107. */
  64108. setSubTimeStep(subTimeStep?: number): void;
  64109. /**
  64110. * Get the sub time step of the physics engine.
  64111. * @returns the current sub time step
  64112. */
  64113. getSubTimeStep(): number;
  64114. /**
  64115. * Release all resources
  64116. */
  64117. dispose(): void;
  64118. /**
  64119. * Gets the name of the current physics plugin
  64120. * @returns the name of the plugin
  64121. */
  64122. getPhysicsPluginName(): string;
  64123. /**
  64124. * Adding a new impostor for the impostor tracking.
  64125. * This will be done by the impostor itself.
  64126. * @param impostor the impostor to add
  64127. */
  64128. addImpostor(impostor: PhysicsImpostor): void;
  64129. /**
  64130. * Remove an impostor from the engine.
  64131. * This impostor and its mesh will not longer be updated by the physics engine.
  64132. * @param impostor the impostor to remove
  64133. */
  64134. removeImpostor(impostor: PhysicsImpostor): void;
  64135. /**
  64136. * Add a joint to the physics engine
  64137. * @param mainImpostor defines the main impostor to which the joint is added.
  64138. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64139. * @param joint defines the joint that will connect both impostors.
  64140. */
  64141. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64142. /**
  64143. * Removes a joint from the simulation
  64144. * @param mainImpostor defines the impostor used with the joint
  64145. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64146. * @param joint defines the joint to remove
  64147. */
  64148. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64149. /**
  64150. * Called by the scene. No need to call it.
  64151. * @param delta defines the timespam between frames
  64152. */
  64153. _step(delta: number): void;
  64154. /**
  64155. * Gets the current plugin used to run the simulation
  64156. * @returns current plugin
  64157. */
  64158. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64159. /**
  64160. * Gets the list of physic impostors
  64161. * @returns an array of PhysicsImpostor
  64162. */
  64163. getImpostors(): Array<PhysicsImpostor>;
  64164. /**
  64165. * Gets the impostor for a physics enabled object
  64166. * @param object defines the object impersonated by the impostor
  64167. * @returns the PhysicsImpostor or null if not found
  64168. */
  64169. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64170. /**
  64171. * Gets the impostor for a physics body object
  64172. * @param body defines physics body used by the impostor
  64173. * @returns the PhysicsImpostor or null if not found
  64174. */
  64175. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64176. /**
  64177. * Does a raycast in the physics world
  64178. * @param from when should the ray start?
  64179. * @param to when should the ray end?
  64180. * @returns PhysicsRaycastResult
  64181. */
  64182. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64183. }
  64184. }
  64185. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64186. import { Nullable } from "babylonjs/types";
  64187. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64189. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64190. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64191. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64192. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64193. /** @hidden */
  64194. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64195. private _useDeltaForWorldStep;
  64196. world: any;
  64197. name: string;
  64198. private _physicsMaterials;
  64199. private _fixedTimeStep;
  64200. private _cannonRaycastResult;
  64201. private _raycastResult;
  64202. private _physicsBodysToRemoveAfterStep;
  64203. private _firstFrame;
  64204. BJSCANNON: any;
  64205. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64206. setGravity(gravity: Vector3): void;
  64207. setTimeStep(timeStep: number): void;
  64208. getTimeStep(): number;
  64209. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64210. private _removeMarkedPhysicsBodiesFromWorld;
  64211. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64212. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64213. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64214. private _processChildMeshes;
  64215. removePhysicsBody(impostor: PhysicsImpostor): void;
  64216. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64217. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64218. private _addMaterial;
  64219. private _checkWithEpsilon;
  64220. private _createShape;
  64221. private _createHeightmap;
  64222. private _minus90X;
  64223. private _plus90X;
  64224. private _tmpPosition;
  64225. private _tmpDeltaPosition;
  64226. private _tmpUnityRotation;
  64227. private _updatePhysicsBodyTransformation;
  64228. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64229. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64230. isSupported(): boolean;
  64231. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64232. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64233. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64234. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64235. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64236. getBodyMass(impostor: PhysicsImpostor): number;
  64237. getBodyFriction(impostor: PhysicsImpostor): number;
  64238. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64239. getBodyRestitution(impostor: PhysicsImpostor): number;
  64240. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64241. sleepBody(impostor: PhysicsImpostor): void;
  64242. wakeUpBody(impostor: PhysicsImpostor): void;
  64243. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64244. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64245. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64246. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64247. getRadius(impostor: PhysicsImpostor): number;
  64248. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64249. dispose(): void;
  64250. private _extendNamespace;
  64251. /**
  64252. * Does a raycast in the physics world
  64253. * @param from when should the ray start?
  64254. * @param to when should the ray end?
  64255. * @returns PhysicsRaycastResult
  64256. */
  64257. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64258. }
  64259. }
  64260. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64261. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64262. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64263. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64265. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64266. import { Nullable } from "babylonjs/types";
  64267. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64268. /** @hidden */
  64269. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64270. private _useDeltaForWorldStep;
  64271. world: any;
  64272. name: string;
  64273. BJSOIMO: any;
  64274. private _raycastResult;
  64275. private _fixedTimeStep;
  64276. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64277. setGravity(gravity: Vector3): void;
  64278. setTimeStep(timeStep: number): void;
  64279. getTimeStep(): number;
  64280. private _tmpImpostorsArray;
  64281. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64282. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64283. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64284. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64285. private _tmpPositionVector;
  64286. removePhysicsBody(impostor: PhysicsImpostor): void;
  64287. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64288. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64289. isSupported(): boolean;
  64290. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64291. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64292. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64293. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64294. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64295. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64296. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64297. getBodyMass(impostor: PhysicsImpostor): number;
  64298. getBodyFriction(impostor: PhysicsImpostor): number;
  64299. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64300. getBodyRestitution(impostor: PhysicsImpostor): number;
  64301. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64302. sleepBody(impostor: PhysicsImpostor): void;
  64303. wakeUpBody(impostor: PhysicsImpostor): void;
  64304. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64305. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64306. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64307. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64308. getRadius(impostor: PhysicsImpostor): number;
  64309. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64310. dispose(): void;
  64311. /**
  64312. * Does a raycast in the physics world
  64313. * @param from when should the ray start?
  64314. * @param to when should the ray end?
  64315. * @returns PhysicsRaycastResult
  64316. */
  64317. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64318. }
  64319. }
  64320. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64321. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64322. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64323. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64324. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64325. import { Nullable } from "babylonjs/types";
  64326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64327. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64328. /**
  64329. * AmmoJS Physics plugin
  64330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64331. * @see https://github.com/kripken/ammo.js/
  64332. */
  64333. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64334. private _useDeltaForWorldStep;
  64335. /**
  64336. * Reference to the Ammo library
  64337. */
  64338. bjsAMMO: any;
  64339. /**
  64340. * Created ammoJS world which physics bodies are added to
  64341. */
  64342. world: any;
  64343. /**
  64344. * Name of the plugin
  64345. */
  64346. name: string;
  64347. private _timeStep;
  64348. private _fixedTimeStep;
  64349. private _maxSteps;
  64350. private _tmpQuaternion;
  64351. private _tmpAmmoTransform;
  64352. private _tmpAmmoQuaternion;
  64353. private _tmpAmmoConcreteContactResultCallback;
  64354. private _collisionConfiguration;
  64355. private _dispatcher;
  64356. private _overlappingPairCache;
  64357. private _solver;
  64358. private _softBodySolver;
  64359. private _tmpAmmoVectorA;
  64360. private _tmpAmmoVectorB;
  64361. private _tmpAmmoVectorC;
  64362. private _tmpAmmoVectorD;
  64363. private _tmpContactCallbackResult;
  64364. private _tmpAmmoVectorRCA;
  64365. private _tmpAmmoVectorRCB;
  64366. private _raycastResult;
  64367. private static readonly DISABLE_COLLISION_FLAG;
  64368. private static readonly KINEMATIC_FLAG;
  64369. private static readonly DISABLE_DEACTIVATION_FLAG;
  64370. /**
  64371. * Initializes the ammoJS plugin
  64372. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64373. * @param ammoInjection can be used to inject your own ammo reference
  64374. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64375. */
  64376. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64377. /**
  64378. * Sets the gravity of the physics world (m/(s^2))
  64379. * @param gravity Gravity to set
  64380. */
  64381. setGravity(gravity: Vector3): void;
  64382. /**
  64383. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64384. * @param timeStep timestep to use in seconds
  64385. */
  64386. setTimeStep(timeStep: number): void;
  64387. /**
  64388. * 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)
  64389. * @param fixedTimeStep fixedTimeStep to use in seconds
  64390. */
  64391. setFixedTimeStep(fixedTimeStep: number): void;
  64392. /**
  64393. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64394. * @param maxSteps the maximum number of steps by the physics engine per frame
  64395. */
  64396. setMaxSteps(maxSteps: number): void;
  64397. /**
  64398. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64399. * @returns the current timestep in seconds
  64400. */
  64401. getTimeStep(): number;
  64402. /**
  64403. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64404. */
  64405. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64406. private _isImpostorInContact;
  64407. private _isImpostorPairInContact;
  64408. private _stepSimulation;
  64409. /**
  64410. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64411. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64412. * After the step the babylon meshes are set to the position of the physics imposters
  64413. * @param delta amount of time to step forward
  64414. * @param impostors array of imposters to update before/after the step
  64415. */
  64416. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64417. /**
  64418. * Update babylon mesh to match physics world object
  64419. * @param impostor imposter to match
  64420. */
  64421. private _afterSoftStep;
  64422. /**
  64423. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64424. * @param impostor imposter to match
  64425. */
  64426. private _ropeStep;
  64427. /**
  64428. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64429. * @param impostor imposter to match
  64430. */
  64431. private _softbodyOrClothStep;
  64432. private _tmpMatrix;
  64433. /**
  64434. * Applies an impulse on the imposter
  64435. * @param impostor imposter to apply impulse to
  64436. * @param force amount of force to be applied to the imposter
  64437. * @param contactPoint the location to apply the impulse on the imposter
  64438. */
  64439. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64440. /**
  64441. * Applies a force on the imposter
  64442. * @param impostor imposter to apply force
  64443. * @param force amount of force to be applied to the imposter
  64444. * @param contactPoint the location to apply the force on the imposter
  64445. */
  64446. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64447. /**
  64448. * Creates a physics body using the plugin
  64449. * @param impostor the imposter to create the physics body on
  64450. */
  64451. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64452. /**
  64453. * Removes the physics body from the imposter and disposes of the body's memory
  64454. * @param impostor imposter to remove the physics body from
  64455. */
  64456. removePhysicsBody(impostor: PhysicsImpostor): void;
  64457. /**
  64458. * Generates a joint
  64459. * @param impostorJoint the imposter joint to create the joint with
  64460. */
  64461. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64462. /**
  64463. * Removes a joint
  64464. * @param impostorJoint the imposter joint to remove the joint from
  64465. */
  64466. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64467. private _addMeshVerts;
  64468. /**
  64469. * Initialise the soft body vertices to match its object's (mesh) vertices
  64470. * Softbody vertices (nodes) are in world space and to match this
  64471. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64472. * @param impostor to create the softbody for
  64473. */
  64474. private _softVertexData;
  64475. /**
  64476. * Create an impostor's soft body
  64477. * @param impostor to create the softbody for
  64478. */
  64479. private _createSoftbody;
  64480. /**
  64481. * Create cloth for an impostor
  64482. * @param impostor to create the softbody for
  64483. */
  64484. private _createCloth;
  64485. /**
  64486. * Create rope for an impostor
  64487. * @param impostor to create the softbody for
  64488. */
  64489. private _createRope;
  64490. /**
  64491. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64492. * @param impostor to create the custom physics shape for
  64493. */
  64494. private _createCustom;
  64495. private _addHullVerts;
  64496. private _createShape;
  64497. /**
  64498. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64499. * @param impostor imposter containing the physics body and babylon object
  64500. */
  64501. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64502. /**
  64503. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64504. * @param impostor imposter containing the physics body and babylon object
  64505. * @param newPosition new position
  64506. * @param newRotation new rotation
  64507. */
  64508. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64509. /**
  64510. * If this plugin is supported
  64511. * @returns true if its supported
  64512. */
  64513. isSupported(): boolean;
  64514. /**
  64515. * Sets the linear velocity of the physics body
  64516. * @param impostor imposter to set the velocity on
  64517. * @param velocity velocity to set
  64518. */
  64519. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64520. /**
  64521. * Sets the angular velocity of the physics body
  64522. * @param impostor imposter to set the velocity on
  64523. * @param velocity velocity to set
  64524. */
  64525. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64526. /**
  64527. * gets the linear velocity
  64528. * @param impostor imposter to get linear velocity from
  64529. * @returns linear velocity
  64530. */
  64531. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64532. /**
  64533. * gets the angular velocity
  64534. * @param impostor imposter to get angular velocity from
  64535. * @returns angular velocity
  64536. */
  64537. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64538. /**
  64539. * Sets the mass of physics body
  64540. * @param impostor imposter to set the mass on
  64541. * @param mass mass to set
  64542. */
  64543. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64544. /**
  64545. * Gets the mass of the physics body
  64546. * @param impostor imposter to get the mass from
  64547. * @returns mass
  64548. */
  64549. getBodyMass(impostor: PhysicsImpostor): number;
  64550. /**
  64551. * Gets friction of the impostor
  64552. * @param impostor impostor to get friction from
  64553. * @returns friction value
  64554. */
  64555. getBodyFriction(impostor: PhysicsImpostor): number;
  64556. /**
  64557. * Sets friction of the impostor
  64558. * @param impostor impostor to set friction on
  64559. * @param friction friction value
  64560. */
  64561. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64562. /**
  64563. * Gets restitution of the impostor
  64564. * @param impostor impostor to get restitution from
  64565. * @returns restitution value
  64566. */
  64567. getBodyRestitution(impostor: PhysicsImpostor): number;
  64568. /**
  64569. * Sets resitution of the impostor
  64570. * @param impostor impostor to set resitution on
  64571. * @param restitution resitution value
  64572. */
  64573. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64574. /**
  64575. * Gets pressure inside the impostor
  64576. * @param impostor impostor to get pressure from
  64577. * @returns pressure value
  64578. */
  64579. getBodyPressure(impostor: PhysicsImpostor): number;
  64580. /**
  64581. * Sets pressure inside a soft body impostor
  64582. * Cloth and rope must remain 0 pressure
  64583. * @param impostor impostor to set pressure on
  64584. * @param pressure pressure value
  64585. */
  64586. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64587. /**
  64588. * Gets stiffness of the impostor
  64589. * @param impostor impostor to get stiffness from
  64590. * @returns pressure value
  64591. */
  64592. getBodyStiffness(impostor: PhysicsImpostor): number;
  64593. /**
  64594. * Sets stiffness of the impostor
  64595. * @param impostor impostor to set stiffness on
  64596. * @param stiffness stiffness value from 0 to 1
  64597. */
  64598. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64599. /**
  64600. * Gets velocityIterations of the impostor
  64601. * @param impostor impostor to get velocity iterations from
  64602. * @returns velocityIterations value
  64603. */
  64604. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64605. /**
  64606. * Sets velocityIterations of the impostor
  64607. * @param impostor impostor to set velocity iterations on
  64608. * @param velocityIterations velocityIterations value
  64609. */
  64610. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64611. /**
  64612. * Gets positionIterations of the impostor
  64613. * @param impostor impostor to get position iterations from
  64614. * @returns positionIterations value
  64615. */
  64616. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64617. /**
  64618. * Sets positionIterations of the impostor
  64619. * @param impostor impostor to set position on
  64620. * @param positionIterations positionIterations value
  64621. */
  64622. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64623. /**
  64624. * Append an anchor to a cloth object
  64625. * @param impostor is the cloth impostor to add anchor to
  64626. * @param otherImpostor is the rigid impostor to anchor to
  64627. * @param width ratio across width from 0 to 1
  64628. * @param height ratio up height from 0 to 1
  64629. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64630. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64631. */
  64632. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64633. /**
  64634. * Append an hook to a rope object
  64635. * @param impostor is the rope impostor to add hook to
  64636. * @param otherImpostor is the rigid impostor to hook to
  64637. * @param length ratio along the rope from 0 to 1
  64638. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64639. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64640. */
  64641. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64642. /**
  64643. * Sleeps the physics body and stops it from being active
  64644. * @param impostor impostor to sleep
  64645. */
  64646. sleepBody(impostor: PhysicsImpostor): void;
  64647. /**
  64648. * Activates the physics body
  64649. * @param impostor impostor to activate
  64650. */
  64651. wakeUpBody(impostor: PhysicsImpostor): void;
  64652. /**
  64653. * Updates the distance parameters of the joint
  64654. * @param joint joint to update
  64655. * @param maxDistance maximum distance of the joint
  64656. * @param minDistance minimum distance of the joint
  64657. */
  64658. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64659. /**
  64660. * Sets a motor on the joint
  64661. * @param joint joint to set motor on
  64662. * @param speed speed of the motor
  64663. * @param maxForce maximum force of the motor
  64664. * @param motorIndex index of the motor
  64665. */
  64666. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64667. /**
  64668. * Sets the motors limit
  64669. * @param joint joint to set limit on
  64670. * @param upperLimit upper limit
  64671. * @param lowerLimit lower limit
  64672. */
  64673. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64674. /**
  64675. * Syncs the position and rotation of a mesh with the impostor
  64676. * @param mesh mesh to sync
  64677. * @param impostor impostor to update the mesh with
  64678. */
  64679. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64680. /**
  64681. * Gets the radius of the impostor
  64682. * @param impostor impostor to get radius from
  64683. * @returns the radius
  64684. */
  64685. getRadius(impostor: PhysicsImpostor): number;
  64686. /**
  64687. * Gets the box size of the impostor
  64688. * @param impostor impostor to get box size from
  64689. * @param result the resulting box size
  64690. */
  64691. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64692. /**
  64693. * Disposes of the impostor
  64694. */
  64695. dispose(): void;
  64696. /**
  64697. * Does a raycast in the physics world
  64698. * @param from when should the ray start?
  64699. * @param to when should the ray end?
  64700. * @returns PhysicsRaycastResult
  64701. */
  64702. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64703. }
  64704. }
  64705. declare module "babylonjs/Probes/reflectionProbe" {
  64706. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64707. import { Vector3 } from "babylonjs/Maths/math.vector";
  64708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64709. import { Nullable } from "babylonjs/types";
  64710. import { Scene } from "babylonjs/scene";
  64711. module "babylonjs/abstractScene" {
  64712. interface AbstractScene {
  64713. /**
  64714. * The list of reflection probes added to the scene
  64715. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64716. */
  64717. reflectionProbes: Array<ReflectionProbe>;
  64718. /**
  64719. * Removes the given reflection probe from this scene.
  64720. * @param toRemove The reflection probe to remove
  64721. * @returns The index of the removed reflection probe
  64722. */
  64723. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64724. /**
  64725. * Adds the given reflection probe to this scene.
  64726. * @param newReflectionProbe The reflection probe to add
  64727. */
  64728. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64729. }
  64730. }
  64731. /**
  64732. * Class used to generate realtime reflection / refraction cube textures
  64733. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64734. */
  64735. export class ReflectionProbe {
  64736. /** defines the name of the probe */
  64737. name: string;
  64738. private _scene;
  64739. private _renderTargetTexture;
  64740. private _projectionMatrix;
  64741. private _viewMatrix;
  64742. private _target;
  64743. private _add;
  64744. private _attachedMesh;
  64745. private _invertYAxis;
  64746. /** Gets or sets probe position (center of the cube map) */
  64747. position: Vector3;
  64748. /**
  64749. * Creates a new reflection probe
  64750. * @param name defines the name of the probe
  64751. * @param size defines the texture resolution (for each face)
  64752. * @param scene defines the hosting scene
  64753. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64754. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64755. */
  64756. constructor(
  64757. /** defines the name of the probe */
  64758. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64759. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64760. get samples(): number;
  64761. set samples(value: number);
  64762. /** Gets or sets the refresh rate to use (on every frame by default) */
  64763. get refreshRate(): number;
  64764. set refreshRate(value: number);
  64765. /**
  64766. * Gets the hosting scene
  64767. * @returns a Scene
  64768. */
  64769. getScene(): Scene;
  64770. /** Gets the internal CubeTexture used to render to */
  64771. get cubeTexture(): RenderTargetTexture;
  64772. /** Gets the list of meshes to render */
  64773. get renderList(): Nullable<AbstractMesh[]>;
  64774. /**
  64775. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64776. * @param mesh defines the mesh to attach to
  64777. */
  64778. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64779. /**
  64780. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64781. * @param renderingGroupId The rendering group id corresponding to its index
  64782. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64783. */
  64784. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64785. /**
  64786. * Clean all associated resources
  64787. */
  64788. dispose(): void;
  64789. /**
  64790. * Converts the reflection probe information to a readable string for debug purpose.
  64791. * @param fullDetails Supports for multiple levels of logging within scene loading
  64792. * @returns the human readable reflection probe info
  64793. */
  64794. toString(fullDetails?: boolean): string;
  64795. /**
  64796. * Get the class name of the relfection probe.
  64797. * @returns "ReflectionProbe"
  64798. */
  64799. getClassName(): string;
  64800. /**
  64801. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64802. * @returns The JSON representation of the texture
  64803. */
  64804. serialize(): any;
  64805. /**
  64806. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64807. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64808. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64809. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64810. * @returns The parsed reflection probe if successful
  64811. */
  64812. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64813. }
  64814. }
  64815. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64816. /** @hidden */
  64817. export var _BabylonLoaderRegistered: boolean;
  64818. /**
  64819. * Helps setting up some configuration for the babylon file loader.
  64820. */
  64821. export class BabylonFileLoaderConfiguration {
  64822. /**
  64823. * The loader does not allow injecting custom physix engine into the plugins.
  64824. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64825. * So you could set this variable to your engine import to make it work.
  64826. */
  64827. static LoaderInjectedPhysicsEngine: any;
  64828. }
  64829. }
  64830. declare module "babylonjs/Loading/Plugins/index" {
  64831. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64832. }
  64833. declare module "babylonjs/Loading/index" {
  64834. export * from "babylonjs/Loading/loadingScreen";
  64835. export * from "babylonjs/Loading/Plugins/index";
  64836. export * from "babylonjs/Loading/sceneLoader";
  64837. export * from "babylonjs/Loading/sceneLoaderFlags";
  64838. }
  64839. declare module "babylonjs/Materials/Background/index" {
  64840. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64841. }
  64842. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64843. import { Scene } from "babylonjs/scene";
  64844. import { Color3 } from "babylonjs/Maths/math.color";
  64845. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64846. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64847. /**
  64848. * The Physically based simple base material of BJS.
  64849. *
  64850. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64851. * It is used as the base class for both the specGloss and metalRough conventions.
  64852. */
  64853. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64854. /**
  64855. * Number of Simultaneous lights allowed on the material.
  64856. */
  64857. maxSimultaneousLights: number;
  64858. /**
  64859. * If sets to true, disables all the lights affecting the material.
  64860. */
  64861. disableLighting: boolean;
  64862. /**
  64863. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64864. */
  64865. environmentTexture: BaseTexture;
  64866. /**
  64867. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64868. */
  64869. invertNormalMapX: boolean;
  64870. /**
  64871. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64872. */
  64873. invertNormalMapY: boolean;
  64874. /**
  64875. * Normal map used in the model.
  64876. */
  64877. normalTexture: BaseTexture;
  64878. /**
  64879. * Emissivie color used to self-illuminate the model.
  64880. */
  64881. emissiveColor: Color3;
  64882. /**
  64883. * Emissivie texture used to self-illuminate the model.
  64884. */
  64885. emissiveTexture: BaseTexture;
  64886. /**
  64887. * Occlusion Channel Strenght.
  64888. */
  64889. occlusionStrength: number;
  64890. /**
  64891. * Occlusion Texture of the material (adding extra occlusion effects).
  64892. */
  64893. occlusionTexture: BaseTexture;
  64894. /**
  64895. * Defines the alpha limits in alpha test mode.
  64896. */
  64897. alphaCutOff: number;
  64898. /**
  64899. * Gets the current double sided mode.
  64900. */
  64901. get doubleSided(): boolean;
  64902. /**
  64903. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64904. */
  64905. set doubleSided(value: boolean);
  64906. /**
  64907. * Stores the pre-calculated light information of a mesh in a texture.
  64908. */
  64909. lightmapTexture: BaseTexture;
  64910. /**
  64911. * If true, the light map contains occlusion information instead of lighting info.
  64912. */
  64913. useLightmapAsShadowmap: boolean;
  64914. /**
  64915. * Instantiates a new PBRMaterial instance.
  64916. *
  64917. * @param name The material name
  64918. * @param scene The scene the material will be use in.
  64919. */
  64920. constructor(name: string, scene: Scene);
  64921. getClassName(): string;
  64922. }
  64923. }
  64924. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64925. import { Scene } from "babylonjs/scene";
  64926. import { Color3 } from "babylonjs/Maths/math.color";
  64927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64928. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64929. /**
  64930. * The PBR material of BJS following the metal roughness convention.
  64931. *
  64932. * This fits to the PBR convention in the GLTF definition:
  64933. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64934. */
  64935. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64936. /**
  64937. * The base color has two different interpretations depending on the value of metalness.
  64938. * When the material is a metal, the base color is the specific measured reflectance value
  64939. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64940. * of the material.
  64941. */
  64942. baseColor: Color3;
  64943. /**
  64944. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64945. * well as opacity information in the alpha channel.
  64946. */
  64947. baseTexture: BaseTexture;
  64948. /**
  64949. * Specifies the metallic scalar value of the material.
  64950. * Can also be used to scale the metalness values of the metallic texture.
  64951. */
  64952. metallic: number;
  64953. /**
  64954. * Specifies the roughness scalar value of the material.
  64955. * Can also be used to scale the roughness values of the metallic texture.
  64956. */
  64957. roughness: number;
  64958. /**
  64959. * Texture containing both the metallic value in the B channel and the
  64960. * roughness value in the G channel to keep better precision.
  64961. */
  64962. metallicRoughnessTexture: BaseTexture;
  64963. /**
  64964. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64965. *
  64966. * @param name The material name
  64967. * @param scene The scene the material will be use in.
  64968. */
  64969. constructor(name: string, scene: Scene);
  64970. /**
  64971. * Return the currrent class name of the material.
  64972. */
  64973. getClassName(): string;
  64974. /**
  64975. * Makes a duplicate of the current material.
  64976. * @param name - name to use for the new material.
  64977. */
  64978. clone(name: string): PBRMetallicRoughnessMaterial;
  64979. /**
  64980. * Serialize the material to a parsable JSON object.
  64981. */
  64982. serialize(): any;
  64983. /**
  64984. * Parses a JSON object correponding to the serialize function.
  64985. */
  64986. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64987. }
  64988. }
  64989. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64990. import { Scene } from "babylonjs/scene";
  64991. import { Color3 } from "babylonjs/Maths/math.color";
  64992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64993. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64994. /**
  64995. * The PBR material of BJS following the specular glossiness convention.
  64996. *
  64997. * This fits to the PBR convention in the GLTF definition:
  64998. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64999. */
  65000. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65001. /**
  65002. * Specifies the diffuse color of the material.
  65003. */
  65004. diffuseColor: Color3;
  65005. /**
  65006. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65007. * channel.
  65008. */
  65009. diffuseTexture: BaseTexture;
  65010. /**
  65011. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65012. */
  65013. specularColor: Color3;
  65014. /**
  65015. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65016. */
  65017. glossiness: number;
  65018. /**
  65019. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65020. */
  65021. specularGlossinessTexture: BaseTexture;
  65022. /**
  65023. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65024. *
  65025. * @param name The material name
  65026. * @param scene The scene the material will be use in.
  65027. */
  65028. constructor(name: string, scene: Scene);
  65029. /**
  65030. * Return the currrent class name of the material.
  65031. */
  65032. getClassName(): string;
  65033. /**
  65034. * Makes a duplicate of the current material.
  65035. * @param name - name to use for the new material.
  65036. */
  65037. clone(name: string): PBRSpecularGlossinessMaterial;
  65038. /**
  65039. * Serialize the material to a parsable JSON object.
  65040. */
  65041. serialize(): any;
  65042. /**
  65043. * Parses a JSON object correponding to the serialize function.
  65044. */
  65045. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65046. }
  65047. }
  65048. declare module "babylonjs/Materials/PBR/index" {
  65049. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65050. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65051. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65052. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65053. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65054. }
  65055. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65056. import { Nullable } from "babylonjs/types";
  65057. import { Scene } from "babylonjs/scene";
  65058. import { Matrix } from "babylonjs/Maths/math.vector";
  65059. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65060. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65061. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65062. /**
  65063. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65064. * It can help converting any input color in a desired output one. This can then be used to create effects
  65065. * from sepia, black and white to sixties or futuristic rendering...
  65066. *
  65067. * The only supported format is currently 3dl.
  65068. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65069. */
  65070. export class ColorGradingTexture extends BaseTexture {
  65071. /**
  65072. * The texture URL.
  65073. */
  65074. url: string;
  65075. /**
  65076. * Empty line regex stored for GC.
  65077. */
  65078. private static _noneEmptyLineRegex;
  65079. private _textureMatrix;
  65080. private _onLoad;
  65081. /**
  65082. * Instantiates a ColorGradingTexture from the following parameters.
  65083. *
  65084. * @param url The location of the color gradind data (currently only supporting 3dl)
  65085. * @param sceneOrEngine The scene or engine the texture will be used in
  65086. * @param onLoad defines a callback triggered when the texture has been loaded
  65087. */
  65088. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65089. /**
  65090. * Fires the onload event from the constructor if requested.
  65091. */
  65092. private _triggerOnLoad;
  65093. /**
  65094. * Returns the texture matrix used in most of the material.
  65095. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65096. */
  65097. getTextureMatrix(): Matrix;
  65098. /**
  65099. * Occurs when the file being loaded is a .3dl LUT file.
  65100. */
  65101. private load3dlTexture;
  65102. /**
  65103. * Starts the loading process of the texture.
  65104. */
  65105. private loadTexture;
  65106. /**
  65107. * Clones the color gradind texture.
  65108. */
  65109. clone(): ColorGradingTexture;
  65110. /**
  65111. * Called during delayed load for textures.
  65112. */
  65113. delayLoad(): void;
  65114. /**
  65115. * Parses a color grading texture serialized by Babylon.
  65116. * @param parsedTexture The texture information being parsedTexture
  65117. * @param scene The scene to load the texture in
  65118. * @param rootUrl The root url of the data assets to load
  65119. * @return A color gradind texture
  65120. */
  65121. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65122. /**
  65123. * Serializes the LUT texture to json format.
  65124. */
  65125. serialize(): any;
  65126. }
  65127. }
  65128. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65130. import { Scene } from "babylonjs/scene";
  65131. import { Nullable } from "babylonjs/types";
  65132. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65133. /**
  65134. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65135. */
  65136. export class EquiRectangularCubeTexture extends BaseTexture {
  65137. /** The six faces of the cube. */
  65138. private static _FacesMapping;
  65139. private _noMipmap;
  65140. private _onLoad;
  65141. private _onError;
  65142. /** The size of the cubemap. */
  65143. private _size;
  65144. /** The buffer of the image. */
  65145. private _buffer;
  65146. /** The width of the input image. */
  65147. private _width;
  65148. /** The height of the input image. */
  65149. private _height;
  65150. /** The URL to the image. */
  65151. url: string;
  65152. /**
  65153. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65154. * @param url The location of the image
  65155. * @param scene The scene the texture will be used in
  65156. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65157. * @param noMipmap Forces to not generate the mipmap if true
  65158. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65159. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65160. * @param onLoad — defines a callback called when texture is loaded
  65161. * @param onError — defines a callback called if there is an error
  65162. */
  65163. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65164. /**
  65165. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65166. */
  65167. private loadImage;
  65168. /**
  65169. * Convert the image buffer into a cubemap and create a CubeTexture.
  65170. */
  65171. private loadTexture;
  65172. /**
  65173. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65174. * @param buffer The ArrayBuffer that should be converted.
  65175. * @returns The buffer as Float32Array.
  65176. */
  65177. private getFloat32ArrayFromArrayBuffer;
  65178. /**
  65179. * Get the current class name of the texture useful for serialization or dynamic coding.
  65180. * @returns "EquiRectangularCubeTexture"
  65181. */
  65182. getClassName(): string;
  65183. /**
  65184. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65185. * @returns A clone of the current EquiRectangularCubeTexture.
  65186. */
  65187. clone(): EquiRectangularCubeTexture;
  65188. }
  65189. }
  65190. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65191. import { Nullable } from "babylonjs/types";
  65192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65193. import { Matrix } from "babylonjs/Maths/math.vector";
  65194. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65195. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65196. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65197. import { Scene } from "babylonjs/scene";
  65198. /**
  65199. * Defines the options related to the creation of an HtmlElementTexture
  65200. */
  65201. export interface IHtmlElementTextureOptions {
  65202. /**
  65203. * Defines wether mip maps should be created or not.
  65204. */
  65205. generateMipMaps?: boolean;
  65206. /**
  65207. * Defines the sampling mode of the texture.
  65208. */
  65209. samplingMode?: number;
  65210. /**
  65211. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65212. */
  65213. engine: Nullable<ThinEngine>;
  65214. /**
  65215. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65216. */
  65217. scene: Nullable<Scene>;
  65218. }
  65219. /**
  65220. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65221. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65222. * is automatically managed.
  65223. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65224. * in your application.
  65225. *
  65226. * As the update is not automatic, you need to call them manually.
  65227. */
  65228. export class HtmlElementTexture extends BaseTexture {
  65229. /**
  65230. * The texture URL.
  65231. */
  65232. element: HTMLVideoElement | HTMLCanvasElement;
  65233. private static readonly DefaultOptions;
  65234. private _textureMatrix;
  65235. private _isVideo;
  65236. private _generateMipMaps;
  65237. private _samplingMode;
  65238. /**
  65239. * Instantiates a HtmlElementTexture from the following parameters.
  65240. *
  65241. * @param name Defines the name of the texture
  65242. * @param element Defines the video or canvas the texture is filled with
  65243. * @param options Defines the other none mandatory texture creation options
  65244. */
  65245. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65246. private _createInternalTexture;
  65247. /**
  65248. * Returns the texture matrix used in most of the material.
  65249. */
  65250. getTextureMatrix(): Matrix;
  65251. /**
  65252. * Updates the content of the texture.
  65253. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65254. */
  65255. update(invertY?: Nullable<boolean>): void;
  65256. }
  65257. }
  65258. declare module "babylonjs/Misc/tga" {
  65259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65260. /**
  65261. * Based on jsTGALoader - Javascript loader for TGA file
  65262. * By Vincent Thibault
  65263. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65264. */
  65265. export class TGATools {
  65266. private static _TYPE_INDEXED;
  65267. private static _TYPE_RGB;
  65268. private static _TYPE_GREY;
  65269. private static _TYPE_RLE_INDEXED;
  65270. private static _TYPE_RLE_RGB;
  65271. private static _TYPE_RLE_GREY;
  65272. private static _ORIGIN_MASK;
  65273. private static _ORIGIN_SHIFT;
  65274. private static _ORIGIN_BL;
  65275. private static _ORIGIN_BR;
  65276. private static _ORIGIN_UL;
  65277. private static _ORIGIN_UR;
  65278. /**
  65279. * Gets the header of a TGA file
  65280. * @param data defines the TGA data
  65281. * @returns the header
  65282. */
  65283. static GetTGAHeader(data: Uint8Array): any;
  65284. /**
  65285. * Uploads TGA content to a Babylon Texture
  65286. * @hidden
  65287. */
  65288. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65289. /** @hidden */
  65290. 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;
  65291. /** @hidden */
  65292. 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;
  65293. /** @hidden */
  65294. 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;
  65295. /** @hidden */
  65296. 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;
  65297. /** @hidden */
  65298. 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;
  65299. /** @hidden */
  65300. 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;
  65301. }
  65302. }
  65303. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65304. import { Nullable } from "babylonjs/types";
  65305. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65306. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65307. /**
  65308. * Implementation of the TGA Texture Loader.
  65309. * @hidden
  65310. */
  65311. export class _TGATextureLoader implements IInternalTextureLoader {
  65312. /**
  65313. * Defines wether the loader supports cascade loading the different faces.
  65314. */
  65315. readonly supportCascades: boolean;
  65316. /**
  65317. * This returns if the loader support the current file information.
  65318. * @param extension defines the file extension of the file being loaded
  65319. * @returns true if the loader can load the specified file
  65320. */
  65321. canLoad(extension: string): boolean;
  65322. /**
  65323. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65324. * @param data contains the texture data
  65325. * @param texture defines the BabylonJS internal texture
  65326. * @param createPolynomials will be true if polynomials have been requested
  65327. * @param onLoad defines the callback to trigger once the texture is ready
  65328. * @param onError defines the callback to trigger in case of error
  65329. */
  65330. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65331. /**
  65332. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65333. * @param data contains the texture data
  65334. * @param texture defines the BabylonJS internal texture
  65335. * @param callback defines the method to call once ready to upload
  65336. */
  65337. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65338. }
  65339. }
  65340. declare module "babylonjs/Misc/basis" {
  65341. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65342. /**
  65343. * Info about the .basis files
  65344. */
  65345. class BasisFileInfo {
  65346. /**
  65347. * If the file has alpha
  65348. */
  65349. hasAlpha: boolean;
  65350. /**
  65351. * Info about each image of the basis file
  65352. */
  65353. images: Array<{
  65354. levels: Array<{
  65355. width: number;
  65356. height: number;
  65357. transcodedPixels: ArrayBufferView;
  65358. }>;
  65359. }>;
  65360. }
  65361. /**
  65362. * Result of transcoding a basis file
  65363. */
  65364. class TranscodeResult {
  65365. /**
  65366. * Info about the .basis file
  65367. */
  65368. fileInfo: BasisFileInfo;
  65369. /**
  65370. * Format to use when loading the file
  65371. */
  65372. format: number;
  65373. }
  65374. /**
  65375. * Configuration options for the Basis transcoder
  65376. */
  65377. export class BasisTranscodeConfiguration {
  65378. /**
  65379. * Supported compression formats used to determine the supported output format of the transcoder
  65380. */
  65381. supportedCompressionFormats?: {
  65382. /**
  65383. * etc1 compression format
  65384. */
  65385. etc1?: boolean;
  65386. /**
  65387. * s3tc compression format
  65388. */
  65389. s3tc?: boolean;
  65390. /**
  65391. * pvrtc compression format
  65392. */
  65393. pvrtc?: boolean;
  65394. /**
  65395. * etc2 compression format
  65396. */
  65397. etc2?: boolean;
  65398. };
  65399. /**
  65400. * If mipmap levels should be loaded for transcoded images (Default: true)
  65401. */
  65402. loadMipmapLevels?: boolean;
  65403. /**
  65404. * Index of a single image to load (Default: all images)
  65405. */
  65406. loadSingleImage?: number;
  65407. }
  65408. /**
  65409. * Used to load .Basis files
  65410. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65411. */
  65412. export class BasisTools {
  65413. private static _IgnoreSupportedFormats;
  65414. /**
  65415. * URL to use when loading the basis transcoder
  65416. */
  65417. static JSModuleURL: string;
  65418. /**
  65419. * URL to use when loading the wasm module for the transcoder
  65420. */
  65421. static WasmModuleURL: string;
  65422. /**
  65423. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65424. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65425. * @returns internal format corresponding to the Basis format
  65426. */
  65427. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65428. private static _WorkerPromise;
  65429. private static _Worker;
  65430. private static _actionId;
  65431. private static _CreateWorkerAsync;
  65432. /**
  65433. * Transcodes a loaded image file to compressed pixel data
  65434. * @param data image data to transcode
  65435. * @param config configuration options for the transcoding
  65436. * @returns a promise resulting in the transcoded image
  65437. */
  65438. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65439. /**
  65440. * Loads a texture from the transcode result
  65441. * @param texture texture load to
  65442. * @param transcodeResult the result of transcoding the basis file to load from
  65443. */
  65444. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65445. }
  65446. }
  65447. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65448. import { Nullable } from "babylonjs/types";
  65449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65450. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65451. /**
  65452. * Loader for .basis file format
  65453. */
  65454. export class _BasisTextureLoader implements IInternalTextureLoader {
  65455. /**
  65456. * Defines whether the loader supports cascade loading the different faces.
  65457. */
  65458. readonly supportCascades: boolean;
  65459. /**
  65460. * This returns if the loader support the current file information.
  65461. * @param extension defines the file extension of the file being loaded
  65462. * @returns true if the loader can load the specified file
  65463. */
  65464. canLoad(extension: string): boolean;
  65465. /**
  65466. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65467. * @param data contains the texture data
  65468. * @param texture defines the BabylonJS internal texture
  65469. * @param createPolynomials will be true if polynomials have been requested
  65470. * @param onLoad defines the callback to trigger once the texture is ready
  65471. * @param onError defines the callback to trigger in case of error
  65472. */
  65473. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65474. /**
  65475. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65476. * @param data contains the texture data
  65477. * @param texture defines the BabylonJS internal texture
  65478. * @param callback defines the method to call once ready to upload
  65479. */
  65480. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65481. }
  65482. }
  65483. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65484. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65485. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65486. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65487. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65488. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65489. }
  65490. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65491. import { Vector2 } from "babylonjs/Maths/math.vector";
  65492. /**
  65493. * Defines the basic options interface of a TexturePacker Frame
  65494. */
  65495. export interface ITexturePackerFrame {
  65496. /**
  65497. * The frame ID
  65498. */
  65499. id: number;
  65500. /**
  65501. * The frames Scale
  65502. */
  65503. scale: Vector2;
  65504. /**
  65505. * The Frames offset
  65506. */
  65507. offset: Vector2;
  65508. }
  65509. /**
  65510. * This is a support class for frame Data on texture packer sets.
  65511. */
  65512. export class TexturePackerFrame implements ITexturePackerFrame {
  65513. /**
  65514. * The frame ID
  65515. */
  65516. id: number;
  65517. /**
  65518. * The frames Scale
  65519. */
  65520. scale: Vector2;
  65521. /**
  65522. * The Frames offset
  65523. */
  65524. offset: Vector2;
  65525. /**
  65526. * Initializes a texture package frame.
  65527. * @param id The numerical frame identifier
  65528. * @param scale Scalar Vector2 for UV frame
  65529. * @param offset Vector2 for the frame position in UV units.
  65530. * @returns TexturePackerFrame
  65531. */
  65532. constructor(id: number, scale: Vector2, offset: Vector2);
  65533. }
  65534. }
  65535. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65537. import { Scene } from "babylonjs/scene";
  65538. import { Nullable } from "babylonjs/types";
  65539. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65540. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65541. /**
  65542. * Defines the basic options interface of a TexturePacker
  65543. */
  65544. export interface ITexturePackerOptions {
  65545. /**
  65546. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65547. */
  65548. map?: string[];
  65549. /**
  65550. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65551. */
  65552. uvsIn?: string;
  65553. /**
  65554. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65555. */
  65556. uvsOut?: string;
  65557. /**
  65558. * number representing the layout style. Defaults to LAYOUT_STRIP
  65559. */
  65560. layout?: number;
  65561. /**
  65562. * number of columns if using custom column count layout(2). This defaults to 4.
  65563. */
  65564. colnum?: number;
  65565. /**
  65566. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65567. */
  65568. updateInputMeshes?: boolean;
  65569. /**
  65570. * boolean flag to dispose all the source textures. Defaults to true.
  65571. */
  65572. disposeSources?: boolean;
  65573. /**
  65574. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65575. */
  65576. fillBlanks?: boolean;
  65577. /**
  65578. * string value representing the context fill style color. Defaults to 'black'.
  65579. */
  65580. customFillColor?: string;
  65581. /**
  65582. * Width and Height Value of each Frame in the TexturePacker Sets
  65583. */
  65584. frameSize?: number;
  65585. /**
  65586. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65587. */
  65588. paddingRatio?: number;
  65589. /**
  65590. * Number that declares the fill method for the padding gutter.
  65591. */
  65592. paddingMode?: number;
  65593. /**
  65594. * If in SUBUV_COLOR padding mode what color to use.
  65595. */
  65596. paddingColor?: Color3 | Color4;
  65597. }
  65598. /**
  65599. * Defines the basic interface of a TexturePacker JSON File
  65600. */
  65601. export interface ITexturePackerJSON {
  65602. /**
  65603. * The frame ID
  65604. */
  65605. name: string;
  65606. /**
  65607. * The base64 channel data
  65608. */
  65609. sets: any;
  65610. /**
  65611. * The options of the Packer
  65612. */
  65613. options: ITexturePackerOptions;
  65614. /**
  65615. * The frame data of the Packer
  65616. */
  65617. frames: Array<number>;
  65618. }
  65619. /**
  65620. * This is a support class that generates a series of packed texture sets.
  65621. * @see https://doc.babylonjs.com/babylon101/materials
  65622. */
  65623. export class TexturePacker {
  65624. /** Packer Layout Constant 0 */
  65625. static readonly LAYOUT_STRIP: number;
  65626. /** Packer Layout Constant 1 */
  65627. static readonly LAYOUT_POWER2: number;
  65628. /** Packer Layout Constant 2 */
  65629. static readonly LAYOUT_COLNUM: number;
  65630. /** Packer Layout Constant 0 */
  65631. static readonly SUBUV_WRAP: number;
  65632. /** Packer Layout Constant 1 */
  65633. static readonly SUBUV_EXTEND: number;
  65634. /** Packer Layout Constant 2 */
  65635. static readonly SUBUV_COLOR: number;
  65636. /** The Name of the Texture Package */
  65637. name: string;
  65638. /** The scene scope of the TexturePacker */
  65639. scene: Scene;
  65640. /** The Meshes to target */
  65641. meshes: AbstractMesh[];
  65642. /** Arguments passed with the Constructor */
  65643. options: ITexturePackerOptions;
  65644. /** The promise that is started upon initialization */
  65645. promise: Nullable<Promise<TexturePacker | string>>;
  65646. /** The Container object for the channel sets that are generated */
  65647. sets: object;
  65648. /** The Container array for the frames that are generated */
  65649. frames: TexturePackerFrame[];
  65650. /** The expected number of textures the system is parsing. */
  65651. private _expecting;
  65652. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65653. private _paddingValue;
  65654. /**
  65655. * Initializes a texture package series from an array of meshes or a single mesh.
  65656. * @param name The name of the package
  65657. * @param meshes The target meshes to compose the package from
  65658. * @param options The arguments that texture packer should follow while building.
  65659. * @param scene The scene which the textures are scoped to.
  65660. * @returns TexturePacker
  65661. */
  65662. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65663. /**
  65664. * Starts the package process
  65665. * @param resolve The promises resolution function
  65666. * @returns TexturePacker
  65667. */
  65668. private _createFrames;
  65669. /**
  65670. * Calculates the Size of the Channel Sets
  65671. * @returns Vector2
  65672. */
  65673. private _calculateSize;
  65674. /**
  65675. * Calculates the UV data for the frames.
  65676. * @param baseSize the base frameSize
  65677. * @param padding the base frame padding
  65678. * @param dtSize size of the Dynamic Texture for that channel
  65679. * @param dtUnits is 1/dtSize
  65680. * @param update flag to update the input meshes
  65681. */
  65682. private _calculateMeshUVFrames;
  65683. /**
  65684. * Calculates the frames Offset.
  65685. * @param index of the frame
  65686. * @returns Vector2
  65687. */
  65688. private _getFrameOffset;
  65689. /**
  65690. * Updates a Mesh to the frame data
  65691. * @param mesh that is the target
  65692. * @param frameID or the frame index
  65693. */
  65694. private _updateMeshUV;
  65695. /**
  65696. * Updates a Meshes materials to use the texture packer channels
  65697. * @param m is the mesh to target
  65698. * @param force all channels on the packer to be set.
  65699. */
  65700. private _updateTextureReferences;
  65701. /**
  65702. * Public method to set a Mesh to a frame
  65703. * @param m that is the target
  65704. * @param frameID or the frame index
  65705. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65706. */
  65707. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65708. /**
  65709. * Starts the async promise to compile the texture packer.
  65710. * @returns Promise<void>
  65711. */
  65712. processAsync(): Promise<void>;
  65713. /**
  65714. * Disposes all textures associated with this packer
  65715. */
  65716. dispose(): void;
  65717. /**
  65718. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65719. * @param imageType is the image type to use.
  65720. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65721. */
  65722. download(imageType?: string, quality?: number): void;
  65723. /**
  65724. * Public method to load a texturePacker JSON file.
  65725. * @param data of the JSON file in string format.
  65726. */
  65727. updateFromJSON(data: string): void;
  65728. }
  65729. }
  65730. declare module "babylonjs/Materials/Textures/Packer/index" {
  65731. export * from "babylonjs/Materials/Textures/Packer/packer";
  65732. export * from "babylonjs/Materials/Textures/Packer/frame";
  65733. }
  65734. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65735. import { Scene } from "babylonjs/scene";
  65736. import { Texture } from "babylonjs/Materials/Textures/texture";
  65737. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65738. /**
  65739. * 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.
  65740. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65741. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65742. */
  65743. export class CustomProceduralTexture extends ProceduralTexture {
  65744. private _animate;
  65745. private _time;
  65746. private _config;
  65747. private _texturePath;
  65748. /**
  65749. * Instantiates a new Custom Procedural Texture.
  65750. * 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.
  65751. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65752. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65753. * @param name Define the name of the texture
  65754. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65755. * @param size Define the size of the texture to create
  65756. * @param scene Define the scene the texture belongs to
  65757. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65758. * @param generateMipMaps Define if the texture should creates mip maps or not
  65759. */
  65760. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65761. private _loadJson;
  65762. /**
  65763. * Is the texture ready to be used ? (rendered at least once)
  65764. * @returns true if ready, otherwise, false.
  65765. */
  65766. isReady(): boolean;
  65767. /**
  65768. * Render the texture to its associated render target.
  65769. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65770. */
  65771. render(useCameraPostProcess?: boolean): void;
  65772. /**
  65773. * Update the list of dependant textures samplers in the shader.
  65774. */
  65775. updateTextures(): void;
  65776. /**
  65777. * Update the uniform values of the procedural texture in the shader.
  65778. */
  65779. updateShaderUniforms(): void;
  65780. /**
  65781. * Define if the texture animates or not.
  65782. */
  65783. get animate(): boolean;
  65784. set animate(value: boolean);
  65785. }
  65786. }
  65787. declare module "babylonjs/Shaders/noise.fragment" {
  65788. /** @hidden */
  65789. export var noisePixelShader: {
  65790. name: string;
  65791. shader: string;
  65792. };
  65793. }
  65794. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65795. import { Nullable } from "babylonjs/types";
  65796. import { Scene } from "babylonjs/scene";
  65797. import { Texture } from "babylonjs/Materials/Textures/texture";
  65798. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65799. import "babylonjs/Shaders/noise.fragment";
  65800. /**
  65801. * Class used to generate noise procedural textures
  65802. */
  65803. export class NoiseProceduralTexture extends ProceduralTexture {
  65804. /** Gets or sets the start time (default is 0) */
  65805. time: number;
  65806. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65807. brightness: number;
  65808. /** Defines the number of octaves to process */
  65809. octaves: number;
  65810. /** Defines the level of persistence (0.8 by default) */
  65811. persistence: number;
  65812. /** Gets or sets animation speed factor (default is 1) */
  65813. animationSpeedFactor: number;
  65814. /**
  65815. * Creates a new NoiseProceduralTexture
  65816. * @param name defines the name fo the texture
  65817. * @param size defines the size of the texture (default is 256)
  65818. * @param scene defines the hosting scene
  65819. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65820. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65821. */
  65822. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65823. private _updateShaderUniforms;
  65824. protected _getDefines(): string;
  65825. /** Generate the current state of the procedural texture */
  65826. render(useCameraPostProcess?: boolean): void;
  65827. /**
  65828. * Serializes this noise procedural texture
  65829. * @returns a serialized noise procedural texture object
  65830. */
  65831. serialize(): any;
  65832. /**
  65833. * Clone the texture.
  65834. * @returns the cloned texture
  65835. */
  65836. clone(): NoiseProceduralTexture;
  65837. /**
  65838. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65839. * @param parsedTexture defines parsed texture data
  65840. * @param scene defines the current scene
  65841. * @param rootUrl defines the root URL containing noise procedural texture information
  65842. * @returns a parsed NoiseProceduralTexture
  65843. */
  65844. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65845. }
  65846. }
  65847. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65848. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65849. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65850. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65851. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65852. }
  65853. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65854. import { Nullable } from "babylonjs/types";
  65855. import { Scene } from "babylonjs/scene";
  65856. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65857. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65858. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65859. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65860. /**
  65861. * Raw cube texture where the raw buffers are passed in
  65862. */
  65863. export class RawCubeTexture extends CubeTexture {
  65864. /**
  65865. * Creates a cube texture where the raw buffers are passed in.
  65866. * @param scene defines the scene the texture is attached to
  65867. * @param data defines the array of data to use to create each face
  65868. * @param size defines the size of the textures
  65869. * @param format defines the format of the data
  65870. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65871. * @param generateMipMaps defines if the engine should generate the mip levels
  65872. * @param invertY defines if data must be stored with Y axis inverted
  65873. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65874. * @param compression defines the compression used (null by default)
  65875. */
  65876. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65877. /**
  65878. * Updates the raw cube texture.
  65879. * @param data defines the data to store
  65880. * @param format defines the data format
  65881. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65882. * @param invertY defines if data must be stored with Y axis inverted
  65883. * @param compression defines the compression used (null by default)
  65884. * @param level defines which level of the texture to update
  65885. */
  65886. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65887. /**
  65888. * Updates a raw cube texture with RGBD encoded data.
  65889. * @param data defines the array of data [mipmap][face] to use to create each face
  65890. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65891. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65892. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65893. * @returns a promsie that resolves when the operation is complete
  65894. */
  65895. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65896. /**
  65897. * Clones the raw cube texture.
  65898. * @return a new cube texture
  65899. */
  65900. clone(): CubeTexture;
  65901. /** @hidden */
  65902. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65903. }
  65904. }
  65905. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65906. import { Scene } from "babylonjs/scene";
  65907. import { Texture } from "babylonjs/Materials/Textures/texture";
  65908. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65909. /**
  65910. * Class used to store 2D array textures containing user data
  65911. */
  65912. export class RawTexture2DArray extends Texture {
  65913. /** Gets or sets the texture format to use */
  65914. format: number;
  65915. /**
  65916. * Create a new RawTexture2DArray
  65917. * @param data defines the data of the texture
  65918. * @param width defines the width of the texture
  65919. * @param height defines the height of the texture
  65920. * @param depth defines the number of layers of the texture
  65921. * @param format defines the texture format to use
  65922. * @param scene defines the hosting scene
  65923. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65924. * @param invertY defines if texture must be stored with Y axis inverted
  65925. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65926. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65927. */
  65928. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65929. /** Gets or sets the texture format to use */
  65930. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65931. /**
  65932. * Update the texture with new data
  65933. * @param data defines the data to store in the texture
  65934. */
  65935. update(data: ArrayBufferView): void;
  65936. }
  65937. }
  65938. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65939. import { Scene } from "babylonjs/scene";
  65940. import { Texture } from "babylonjs/Materials/Textures/texture";
  65941. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65942. /**
  65943. * Class used to store 3D textures containing user data
  65944. */
  65945. export class RawTexture3D extends Texture {
  65946. /** Gets or sets the texture format to use */
  65947. format: number;
  65948. /**
  65949. * Create a new RawTexture3D
  65950. * @param data defines the data of the texture
  65951. * @param width defines the width of the texture
  65952. * @param height defines the height of the texture
  65953. * @param depth defines the depth of the texture
  65954. * @param format defines the texture format to use
  65955. * @param scene defines the hosting scene
  65956. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65957. * @param invertY defines if texture must be stored with Y axis inverted
  65958. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65959. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65960. */
  65961. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65962. /** Gets or sets the texture format to use */
  65963. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65964. /**
  65965. * Update the texture with new data
  65966. * @param data defines the data to store in the texture
  65967. */
  65968. update(data: ArrayBufferView): void;
  65969. }
  65970. }
  65971. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65972. import { Scene } from "babylonjs/scene";
  65973. import { Plane } from "babylonjs/Maths/math.plane";
  65974. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65975. /**
  65976. * Creates a refraction texture used by refraction channel of the standard material.
  65977. * It is like a mirror but to see through a material.
  65978. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65979. */
  65980. export class RefractionTexture extends RenderTargetTexture {
  65981. /**
  65982. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65983. * 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.
  65984. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65985. */
  65986. refractionPlane: Plane;
  65987. /**
  65988. * Define how deep under the surface we should see.
  65989. */
  65990. depth: number;
  65991. /**
  65992. * Creates a refraction texture used by refraction channel of the standard material.
  65993. * It is like a mirror but to see through a material.
  65994. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65995. * @param name Define the texture name
  65996. * @param size Define the size of the underlying texture
  65997. * @param scene Define the scene the refraction belongs to
  65998. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65999. */
  66000. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66001. /**
  66002. * Clone the refraction texture.
  66003. * @returns the cloned texture
  66004. */
  66005. clone(): RefractionTexture;
  66006. /**
  66007. * Serialize the texture to a JSON representation you could use in Parse later on
  66008. * @returns the serialized JSON representation
  66009. */
  66010. serialize(): any;
  66011. }
  66012. }
  66013. declare module "babylonjs/Materials/Textures/index" {
  66014. export * from "babylonjs/Materials/Textures/baseTexture";
  66015. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66016. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66017. export * from "babylonjs/Materials/Textures/cubeTexture";
  66018. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66019. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66020. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66021. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66022. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66023. export * from "babylonjs/Materials/Textures/internalTexture";
  66024. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66025. export * from "babylonjs/Materials/Textures/Loaders/index";
  66026. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66027. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66028. export * from "babylonjs/Materials/Textures/Packer/index";
  66029. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66030. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66031. export * from "babylonjs/Materials/Textures/rawTexture";
  66032. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66033. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66034. export * from "babylonjs/Materials/Textures/refractionTexture";
  66035. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66036. export * from "babylonjs/Materials/Textures/texture";
  66037. export * from "babylonjs/Materials/Textures/videoTexture";
  66038. }
  66039. declare module "babylonjs/Materials/Node/Enums/index" {
  66040. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66041. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66042. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66043. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66044. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66045. }
  66046. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66050. import { Mesh } from "babylonjs/Meshes/mesh";
  66051. import { Effect } from "babylonjs/Materials/effect";
  66052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66053. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66054. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66055. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66056. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66057. /**
  66058. * Block used to add support for vertex skinning (bones)
  66059. */
  66060. export class BonesBlock extends NodeMaterialBlock {
  66061. /**
  66062. * Creates a new BonesBlock
  66063. * @param name defines the block name
  66064. */
  66065. constructor(name: string);
  66066. /**
  66067. * Initialize the block and prepare the context for build
  66068. * @param state defines the state that will be used for the build
  66069. */
  66070. initialize(state: NodeMaterialBuildState): void;
  66071. /**
  66072. * Gets the current class name
  66073. * @returns the class name
  66074. */
  66075. getClassName(): string;
  66076. /**
  66077. * Gets the matrix indices input component
  66078. */
  66079. get matricesIndices(): NodeMaterialConnectionPoint;
  66080. /**
  66081. * Gets the matrix weights input component
  66082. */
  66083. get matricesWeights(): NodeMaterialConnectionPoint;
  66084. /**
  66085. * Gets the extra matrix indices input component
  66086. */
  66087. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66088. /**
  66089. * Gets the extra matrix weights input component
  66090. */
  66091. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66092. /**
  66093. * Gets the world input component
  66094. */
  66095. get world(): NodeMaterialConnectionPoint;
  66096. /**
  66097. * Gets the output component
  66098. */
  66099. get output(): NodeMaterialConnectionPoint;
  66100. autoConfigure(material: NodeMaterial): void;
  66101. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66102. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66103. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66104. protected _buildBlock(state: NodeMaterialBuildState): this;
  66105. }
  66106. }
  66107. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66109. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66110. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66112. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66113. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66114. /**
  66115. * Block used to add support for instances
  66116. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66117. */
  66118. export class InstancesBlock extends NodeMaterialBlock {
  66119. /**
  66120. * Creates a new InstancesBlock
  66121. * @param name defines the block name
  66122. */
  66123. constructor(name: string);
  66124. /**
  66125. * Gets the current class name
  66126. * @returns the class name
  66127. */
  66128. getClassName(): string;
  66129. /**
  66130. * Gets the first world row input component
  66131. */
  66132. get world0(): NodeMaterialConnectionPoint;
  66133. /**
  66134. * Gets the second world row input component
  66135. */
  66136. get world1(): NodeMaterialConnectionPoint;
  66137. /**
  66138. * Gets the third world row input component
  66139. */
  66140. get world2(): NodeMaterialConnectionPoint;
  66141. /**
  66142. * Gets the forth world row input component
  66143. */
  66144. get world3(): NodeMaterialConnectionPoint;
  66145. /**
  66146. * Gets the world input component
  66147. */
  66148. get world(): NodeMaterialConnectionPoint;
  66149. /**
  66150. * Gets the output component
  66151. */
  66152. get output(): NodeMaterialConnectionPoint;
  66153. /**
  66154. * Gets the isntanceID component
  66155. */
  66156. get instanceID(): NodeMaterialConnectionPoint;
  66157. autoConfigure(material: NodeMaterial): void;
  66158. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66159. protected _buildBlock(state: NodeMaterialBuildState): this;
  66160. }
  66161. }
  66162. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66163. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66164. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66165. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66167. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66168. import { Effect } from "babylonjs/Materials/effect";
  66169. import { Mesh } from "babylonjs/Meshes/mesh";
  66170. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66171. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66172. /**
  66173. * Block used to add morph targets support to vertex shader
  66174. */
  66175. export class MorphTargetsBlock extends NodeMaterialBlock {
  66176. private _repeatableContentAnchor;
  66177. /**
  66178. * Create a new MorphTargetsBlock
  66179. * @param name defines the block name
  66180. */
  66181. constructor(name: string);
  66182. /**
  66183. * Gets the current class name
  66184. * @returns the class name
  66185. */
  66186. getClassName(): string;
  66187. /**
  66188. * Gets the position input component
  66189. */
  66190. get position(): NodeMaterialConnectionPoint;
  66191. /**
  66192. * Gets the normal input component
  66193. */
  66194. get normal(): NodeMaterialConnectionPoint;
  66195. /**
  66196. * Gets the tangent input component
  66197. */
  66198. get tangent(): NodeMaterialConnectionPoint;
  66199. /**
  66200. * Gets the tangent input component
  66201. */
  66202. get uv(): NodeMaterialConnectionPoint;
  66203. /**
  66204. * Gets the position output component
  66205. */
  66206. get positionOutput(): NodeMaterialConnectionPoint;
  66207. /**
  66208. * Gets the normal output component
  66209. */
  66210. get normalOutput(): NodeMaterialConnectionPoint;
  66211. /**
  66212. * Gets the tangent output component
  66213. */
  66214. get tangentOutput(): NodeMaterialConnectionPoint;
  66215. /**
  66216. * Gets the tangent output component
  66217. */
  66218. get uvOutput(): NodeMaterialConnectionPoint;
  66219. initialize(state: NodeMaterialBuildState): void;
  66220. autoConfigure(material: NodeMaterial): void;
  66221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66222. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66223. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66224. protected _buildBlock(state: NodeMaterialBuildState): this;
  66225. }
  66226. }
  66227. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  66228. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66229. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66230. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66231. import { Nullable } from "babylonjs/types";
  66232. import { Scene } from "babylonjs/scene";
  66233. import { Effect } from "babylonjs/Materials/effect";
  66234. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66235. import { Mesh } from "babylonjs/Meshes/mesh";
  66236. import { Light } from "babylonjs/Lights/light";
  66237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66238. /**
  66239. * Block used to get data information from a light
  66240. */
  66241. export class LightInformationBlock extends NodeMaterialBlock {
  66242. private _lightDataUniformName;
  66243. private _lightColorUniformName;
  66244. private _lightTypeDefineName;
  66245. /**
  66246. * Gets or sets the light associated with this block
  66247. */
  66248. light: Nullable<Light>;
  66249. /**
  66250. * Creates a new LightInformationBlock
  66251. * @param name defines the block name
  66252. */
  66253. constructor(name: string);
  66254. /**
  66255. * Gets the current class name
  66256. * @returns the class name
  66257. */
  66258. getClassName(): string;
  66259. /**
  66260. * Gets the world position input component
  66261. */
  66262. get worldPosition(): NodeMaterialConnectionPoint;
  66263. /**
  66264. * Gets the direction output component
  66265. */
  66266. get direction(): NodeMaterialConnectionPoint;
  66267. /**
  66268. * Gets the direction output component
  66269. */
  66270. get color(): NodeMaterialConnectionPoint;
  66271. /**
  66272. * Gets the direction output component
  66273. */
  66274. get intensity(): NodeMaterialConnectionPoint;
  66275. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66276. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66277. protected _buildBlock(state: NodeMaterialBuildState): this;
  66278. serialize(): any;
  66279. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66280. }
  66281. }
  66282. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66283. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66284. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66285. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66286. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66287. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66288. }
  66289. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  66290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66294. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66295. import { Effect } from "babylonjs/Materials/effect";
  66296. import { Mesh } from "babylonjs/Meshes/mesh";
  66297. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66298. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66299. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66300. /**
  66301. * Block used to add image processing support to fragment shader
  66302. */
  66303. export class ImageProcessingBlock extends NodeMaterialBlock {
  66304. /**
  66305. * Create a new ImageProcessingBlock
  66306. * @param name defines the block name
  66307. */
  66308. constructor(name: string);
  66309. /**
  66310. * Gets the current class name
  66311. * @returns the class name
  66312. */
  66313. getClassName(): string;
  66314. /**
  66315. * Gets the color input component
  66316. */
  66317. get color(): NodeMaterialConnectionPoint;
  66318. /**
  66319. * Gets the output component
  66320. */
  66321. get output(): NodeMaterialConnectionPoint;
  66322. /**
  66323. * Initialize the block and prepare the context for build
  66324. * @param state defines the state that will be used for the build
  66325. */
  66326. initialize(state: NodeMaterialBuildState): void;
  66327. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66328. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66329. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66330. protected _buildBlock(state: NodeMaterialBuildState): this;
  66331. }
  66332. }
  66333. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66337. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66339. import { Effect } from "babylonjs/Materials/effect";
  66340. import { Mesh } from "babylonjs/Meshes/mesh";
  66341. import { Scene } from "babylonjs/scene";
  66342. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66343. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66344. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66345. /**
  66346. * Block used to pertub normals based on a normal map
  66347. */
  66348. export class PerturbNormalBlock extends NodeMaterialBlock {
  66349. private _tangentSpaceParameterName;
  66350. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66351. invertX: boolean;
  66352. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66353. invertY: boolean;
  66354. /**
  66355. * Create a new PerturbNormalBlock
  66356. * @param name defines the block name
  66357. */
  66358. constructor(name: string);
  66359. /**
  66360. * Gets the current class name
  66361. * @returns the class name
  66362. */
  66363. getClassName(): string;
  66364. /**
  66365. * Gets the world position input component
  66366. */
  66367. get worldPosition(): NodeMaterialConnectionPoint;
  66368. /**
  66369. * Gets the world normal input component
  66370. */
  66371. get worldNormal(): NodeMaterialConnectionPoint;
  66372. /**
  66373. * Gets the world tangent input component
  66374. */
  66375. get worldTangent(): NodeMaterialConnectionPoint;
  66376. /**
  66377. * Gets the uv input component
  66378. */
  66379. get uv(): NodeMaterialConnectionPoint;
  66380. /**
  66381. * Gets the normal map color input component
  66382. */
  66383. get normalMapColor(): NodeMaterialConnectionPoint;
  66384. /**
  66385. * Gets the strength input component
  66386. */
  66387. get strength(): NodeMaterialConnectionPoint;
  66388. /**
  66389. * Gets the output component
  66390. */
  66391. get output(): NodeMaterialConnectionPoint;
  66392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66393. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66394. autoConfigure(material: NodeMaterial): void;
  66395. protected _buildBlock(state: NodeMaterialBuildState): this;
  66396. protected _dumpPropertiesCode(): string;
  66397. serialize(): any;
  66398. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66399. }
  66400. }
  66401. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66405. /**
  66406. * Block used to discard a pixel if a value is smaller than a cutoff
  66407. */
  66408. export class DiscardBlock extends NodeMaterialBlock {
  66409. /**
  66410. * Create a new DiscardBlock
  66411. * @param name defines the block name
  66412. */
  66413. constructor(name: string);
  66414. /**
  66415. * Gets the current class name
  66416. * @returns the class name
  66417. */
  66418. getClassName(): string;
  66419. /**
  66420. * Gets the color input component
  66421. */
  66422. get value(): NodeMaterialConnectionPoint;
  66423. /**
  66424. * Gets the cutoff input component
  66425. */
  66426. get cutoff(): NodeMaterialConnectionPoint;
  66427. protected _buildBlock(state: NodeMaterialBuildState): this;
  66428. }
  66429. }
  66430. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66431. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66432. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66433. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66434. /**
  66435. * Block used to test if the fragment shader is front facing
  66436. */
  66437. export class FrontFacingBlock extends NodeMaterialBlock {
  66438. /**
  66439. * Creates a new FrontFacingBlock
  66440. * @param name defines the block name
  66441. */
  66442. constructor(name: string);
  66443. /**
  66444. * Gets the current class name
  66445. * @returns the class name
  66446. */
  66447. getClassName(): string;
  66448. /**
  66449. * Gets the output component
  66450. */
  66451. get output(): NodeMaterialConnectionPoint;
  66452. protected _buildBlock(state: NodeMaterialBuildState): this;
  66453. }
  66454. }
  66455. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66456. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66457. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66458. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66459. /**
  66460. * Block used to get the derivative value on x and y of a given input
  66461. */
  66462. export class DerivativeBlock extends NodeMaterialBlock {
  66463. /**
  66464. * Create a new DerivativeBlock
  66465. * @param name defines the block name
  66466. */
  66467. constructor(name: string);
  66468. /**
  66469. * Gets the current class name
  66470. * @returns the class name
  66471. */
  66472. getClassName(): string;
  66473. /**
  66474. * Gets the input component
  66475. */
  66476. get input(): NodeMaterialConnectionPoint;
  66477. /**
  66478. * Gets the derivative output on x
  66479. */
  66480. get dx(): NodeMaterialConnectionPoint;
  66481. /**
  66482. * Gets the derivative output on y
  66483. */
  66484. get dy(): NodeMaterialConnectionPoint;
  66485. protected _buildBlock(state: NodeMaterialBuildState): this;
  66486. }
  66487. }
  66488. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66489. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66490. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66491. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66492. /**
  66493. * Block used to make gl_FragCoord available
  66494. */
  66495. export class FragCoordBlock extends NodeMaterialBlock {
  66496. /**
  66497. * Creates a new FragCoordBlock
  66498. * @param name defines the block name
  66499. */
  66500. constructor(name: string);
  66501. /**
  66502. * Gets the current class name
  66503. * @returns the class name
  66504. */
  66505. getClassName(): string;
  66506. /**
  66507. * Gets the xy component
  66508. */
  66509. get xy(): NodeMaterialConnectionPoint;
  66510. /**
  66511. * Gets the xyz component
  66512. */
  66513. get xyz(): NodeMaterialConnectionPoint;
  66514. /**
  66515. * Gets the xyzw component
  66516. */
  66517. get xyzw(): NodeMaterialConnectionPoint;
  66518. /**
  66519. * Gets the x component
  66520. */
  66521. get x(): NodeMaterialConnectionPoint;
  66522. /**
  66523. * Gets the y component
  66524. */
  66525. get y(): NodeMaterialConnectionPoint;
  66526. /**
  66527. * Gets the z component
  66528. */
  66529. get z(): NodeMaterialConnectionPoint;
  66530. /**
  66531. * Gets the w component
  66532. */
  66533. get output(): NodeMaterialConnectionPoint;
  66534. protected writeOutputs(state: NodeMaterialBuildState): string;
  66535. protected _buildBlock(state: NodeMaterialBuildState): this;
  66536. }
  66537. }
  66538. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66542. import { Effect } from "babylonjs/Materials/effect";
  66543. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66544. import { Mesh } from "babylonjs/Meshes/mesh";
  66545. /**
  66546. * Block used to get the screen sizes
  66547. */
  66548. export class ScreenSizeBlock extends NodeMaterialBlock {
  66549. private _varName;
  66550. private _scene;
  66551. /**
  66552. * Creates a new ScreenSizeBlock
  66553. * @param name defines the block name
  66554. */
  66555. constructor(name: string);
  66556. /**
  66557. * Gets the current class name
  66558. * @returns the class name
  66559. */
  66560. getClassName(): string;
  66561. /**
  66562. * Gets the xy component
  66563. */
  66564. get xy(): NodeMaterialConnectionPoint;
  66565. /**
  66566. * Gets the x component
  66567. */
  66568. get x(): NodeMaterialConnectionPoint;
  66569. /**
  66570. * Gets the y component
  66571. */
  66572. get y(): NodeMaterialConnectionPoint;
  66573. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66574. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66575. protected _buildBlock(state: NodeMaterialBuildState): this;
  66576. }
  66577. }
  66578. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66579. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66580. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66581. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66582. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66583. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66584. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66585. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66586. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66587. }
  66588. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66591. import { Mesh } from "babylonjs/Meshes/mesh";
  66592. import { Effect } from "babylonjs/Materials/effect";
  66593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66595. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66596. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66597. /**
  66598. * Block used to add support for scene fog
  66599. */
  66600. export class FogBlock extends NodeMaterialBlock {
  66601. private _fogDistanceName;
  66602. private _fogParameters;
  66603. /**
  66604. * Create a new FogBlock
  66605. * @param name defines the block name
  66606. */
  66607. constructor(name: string);
  66608. /**
  66609. * Gets the current class name
  66610. * @returns the class name
  66611. */
  66612. getClassName(): string;
  66613. /**
  66614. * Gets the world position input component
  66615. */
  66616. get worldPosition(): NodeMaterialConnectionPoint;
  66617. /**
  66618. * Gets the view input component
  66619. */
  66620. get view(): NodeMaterialConnectionPoint;
  66621. /**
  66622. * Gets the color input component
  66623. */
  66624. get input(): NodeMaterialConnectionPoint;
  66625. /**
  66626. * Gets the fog color input component
  66627. */
  66628. get fogColor(): NodeMaterialConnectionPoint;
  66629. /**
  66630. * Gets the output component
  66631. */
  66632. get output(): NodeMaterialConnectionPoint;
  66633. autoConfigure(material: NodeMaterial): void;
  66634. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66635. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66636. protected _buildBlock(state: NodeMaterialBuildState): this;
  66637. }
  66638. }
  66639. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66642. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66644. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66645. import { Effect } from "babylonjs/Materials/effect";
  66646. import { Mesh } from "babylonjs/Meshes/mesh";
  66647. import { Light } from "babylonjs/Lights/light";
  66648. import { Nullable } from "babylonjs/types";
  66649. import { Scene } from "babylonjs/scene";
  66650. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66651. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66652. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66653. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66654. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66655. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66656. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66657. /**
  66658. * Block used to add light in the fragment shader
  66659. */
  66660. export class LightBlock extends NodeMaterialBlock {
  66661. private _lightId;
  66662. /**
  66663. * Gets or sets the light associated with this block
  66664. */
  66665. light: Nullable<Light>;
  66666. /**
  66667. * Create a new LightBlock
  66668. * @param name defines the block name
  66669. */
  66670. constructor(name: string);
  66671. /**
  66672. * Gets the current class name
  66673. * @returns the class name
  66674. */
  66675. getClassName(): string;
  66676. /**
  66677. * Gets the world position input component
  66678. */
  66679. get worldPosition(): NodeMaterialConnectionPoint;
  66680. /**
  66681. * Gets the world normal input component
  66682. */
  66683. get worldNormal(): NodeMaterialConnectionPoint;
  66684. /**
  66685. * Gets the camera (or eye) position component
  66686. */
  66687. get cameraPosition(): NodeMaterialConnectionPoint;
  66688. /**
  66689. * Gets the glossiness component
  66690. */
  66691. get glossiness(): NodeMaterialConnectionPoint;
  66692. /**
  66693. * Gets the glossinness power component
  66694. */
  66695. get glossPower(): NodeMaterialConnectionPoint;
  66696. /**
  66697. * Gets the diffuse color component
  66698. */
  66699. get diffuseColor(): NodeMaterialConnectionPoint;
  66700. /**
  66701. * Gets the specular color component
  66702. */
  66703. get specularColor(): NodeMaterialConnectionPoint;
  66704. /**
  66705. * Gets the diffuse output component
  66706. */
  66707. get diffuseOutput(): NodeMaterialConnectionPoint;
  66708. /**
  66709. * Gets the specular output component
  66710. */
  66711. get specularOutput(): NodeMaterialConnectionPoint;
  66712. /**
  66713. * Gets the shadow output component
  66714. */
  66715. get shadow(): NodeMaterialConnectionPoint;
  66716. autoConfigure(material: NodeMaterial): void;
  66717. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66718. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66720. private _injectVertexCode;
  66721. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66722. serialize(): any;
  66723. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66724. }
  66725. }
  66726. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66727. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66728. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66729. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66730. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66731. /**
  66732. * Block used to read a reflection texture from a sampler
  66733. */
  66734. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66735. /**
  66736. * Create a new ReflectionTextureBlock
  66737. * @param name defines the block name
  66738. */
  66739. constructor(name: string);
  66740. /**
  66741. * Gets the current class name
  66742. * @returns the class name
  66743. */
  66744. getClassName(): string;
  66745. /**
  66746. * Gets the world position input component
  66747. */
  66748. get position(): NodeMaterialConnectionPoint;
  66749. /**
  66750. * Gets the world position input component
  66751. */
  66752. get worldPosition(): NodeMaterialConnectionPoint;
  66753. /**
  66754. * Gets the world normal input component
  66755. */
  66756. get worldNormal(): NodeMaterialConnectionPoint;
  66757. /**
  66758. * Gets the world input component
  66759. */
  66760. get world(): NodeMaterialConnectionPoint;
  66761. /**
  66762. * Gets the camera (or eye) position component
  66763. */
  66764. get cameraPosition(): NodeMaterialConnectionPoint;
  66765. /**
  66766. * Gets the view input component
  66767. */
  66768. get view(): NodeMaterialConnectionPoint;
  66769. /**
  66770. * Gets the rgb output component
  66771. */
  66772. get rgb(): NodeMaterialConnectionPoint;
  66773. /**
  66774. * Gets the rgba output component
  66775. */
  66776. get rgba(): NodeMaterialConnectionPoint;
  66777. /**
  66778. * Gets the r output component
  66779. */
  66780. get r(): NodeMaterialConnectionPoint;
  66781. /**
  66782. * Gets the g output component
  66783. */
  66784. get g(): NodeMaterialConnectionPoint;
  66785. /**
  66786. * Gets the b output component
  66787. */
  66788. get b(): NodeMaterialConnectionPoint;
  66789. /**
  66790. * Gets the a output component
  66791. */
  66792. get a(): NodeMaterialConnectionPoint;
  66793. autoConfigure(material: NodeMaterial): void;
  66794. protected _buildBlock(state: NodeMaterialBuildState): this;
  66795. }
  66796. }
  66797. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66798. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66799. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66800. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66801. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66802. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66803. }
  66804. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66805. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66806. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66807. }
  66808. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66812. /**
  66813. * Block used to add 2 vectors
  66814. */
  66815. export class AddBlock extends NodeMaterialBlock {
  66816. /**
  66817. * Creates a new AddBlock
  66818. * @param name defines the block name
  66819. */
  66820. constructor(name: string);
  66821. /**
  66822. * Gets the current class name
  66823. * @returns the class name
  66824. */
  66825. getClassName(): string;
  66826. /**
  66827. * Gets the left operand input component
  66828. */
  66829. get left(): NodeMaterialConnectionPoint;
  66830. /**
  66831. * Gets the right operand input component
  66832. */
  66833. get right(): NodeMaterialConnectionPoint;
  66834. /**
  66835. * Gets the output component
  66836. */
  66837. get output(): NodeMaterialConnectionPoint;
  66838. protected _buildBlock(state: NodeMaterialBuildState): this;
  66839. }
  66840. }
  66841. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66842. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66843. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66844. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66845. /**
  66846. * Block used to scale a vector by a float
  66847. */
  66848. export class ScaleBlock extends NodeMaterialBlock {
  66849. /**
  66850. * Creates a new ScaleBlock
  66851. * @param name defines the block name
  66852. */
  66853. constructor(name: string);
  66854. /**
  66855. * Gets the current class name
  66856. * @returns the class name
  66857. */
  66858. getClassName(): string;
  66859. /**
  66860. * Gets the input component
  66861. */
  66862. get input(): NodeMaterialConnectionPoint;
  66863. /**
  66864. * Gets the factor input component
  66865. */
  66866. get factor(): NodeMaterialConnectionPoint;
  66867. /**
  66868. * Gets the output component
  66869. */
  66870. get output(): NodeMaterialConnectionPoint;
  66871. protected _buildBlock(state: NodeMaterialBuildState): this;
  66872. }
  66873. }
  66874. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66878. import { Scene } from "babylonjs/scene";
  66879. /**
  66880. * Block used to clamp a float
  66881. */
  66882. export class ClampBlock extends NodeMaterialBlock {
  66883. /** Gets or sets the minimum range */
  66884. minimum: number;
  66885. /** Gets or sets the maximum range */
  66886. maximum: number;
  66887. /**
  66888. * Creates a new ClampBlock
  66889. * @param name defines the block name
  66890. */
  66891. constructor(name: string);
  66892. /**
  66893. * Gets the current class name
  66894. * @returns the class name
  66895. */
  66896. getClassName(): string;
  66897. /**
  66898. * Gets the value input component
  66899. */
  66900. get value(): NodeMaterialConnectionPoint;
  66901. /**
  66902. * Gets the output component
  66903. */
  66904. get output(): NodeMaterialConnectionPoint;
  66905. protected _buildBlock(state: NodeMaterialBuildState): this;
  66906. protected _dumpPropertiesCode(): string;
  66907. serialize(): any;
  66908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66909. }
  66910. }
  66911. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66915. /**
  66916. * Block used to apply a cross product between 2 vectors
  66917. */
  66918. export class CrossBlock extends NodeMaterialBlock {
  66919. /**
  66920. * Creates a new CrossBlock
  66921. * @param name defines the block name
  66922. */
  66923. constructor(name: string);
  66924. /**
  66925. * Gets the current class name
  66926. * @returns the class name
  66927. */
  66928. getClassName(): string;
  66929. /**
  66930. * Gets the left operand input component
  66931. */
  66932. get left(): NodeMaterialConnectionPoint;
  66933. /**
  66934. * Gets the right operand input component
  66935. */
  66936. get right(): NodeMaterialConnectionPoint;
  66937. /**
  66938. * Gets the output component
  66939. */
  66940. get output(): NodeMaterialConnectionPoint;
  66941. protected _buildBlock(state: NodeMaterialBuildState): this;
  66942. }
  66943. }
  66944. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66945. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66946. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66948. /**
  66949. * Block used to apply a dot product between 2 vectors
  66950. */
  66951. export class DotBlock extends NodeMaterialBlock {
  66952. /**
  66953. * Creates a new DotBlock
  66954. * @param name defines the block name
  66955. */
  66956. constructor(name: string);
  66957. /**
  66958. * Gets the current class name
  66959. * @returns the class name
  66960. */
  66961. getClassName(): string;
  66962. /**
  66963. * Gets the left operand input component
  66964. */
  66965. get left(): NodeMaterialConnectionPoint;
  66966. /**
  66967. * Gets the right operand input component
  66968. */
  66969. get right(): NodeMaterialConnectionPoint;
  66970. /**
  66971. * Gets the output component
  66972. */
  66973. get output(): NodeMaterialConnectionPoint;
  66974. protected _buildBlock(state: NodeMaterialBuildState): this;
  66975. }
  66976. }
  66977. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66981. /**
  66982. * Block used to normalize a vector
  66983. */
  66984. export class NormalizeBlock extends NodeMaterialBlock {
  66985. /**
  66986. * Creates a new NormalizeBlock
  66987. * @param name defines the block name
  66988. */
  66989. constructor(name: string);
  66990. /**
  66991. * Gets the current class name
  66992. * @returns the class name
  66993. */
  66994. getClassName(): string;
  66995. /**
  66996. * Gets the input component
  66997. */
  66998. get input(): NodeMaterialConnectionPoint;
  66999. /**
  67000. * Gets the output component
  67001. */
  67002. get output(): NodeMaterialConnectionPoint;
  67003. protected _buildBlock(state: NodeMaterialBuildState): this;
  67004. }
  67005. }
  67006. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67008. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67009. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67010. /**
  67011. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67012. */
  67013. export class ColorMergerBlock extends NodeMaterialBlock {
  67014. /**
  67015. * Create a new ColorMergerBlock
  67016. * @param name defines the block name
  67017. */
  67018. constructor(name: string);
  67019. /**
  67020. * Gets the current class name
  67021. * @returns the class name
  67022. */
  67023. getClassName(): string;
  67024. /**
  67025. * Gets the rgb component (input)
  67026. */
  67027. get rgbIn(): NodeMaterialConnectionPoint;
  67028. /**
  67029. * Gets the r component (input)
  67030. */
  67031. get r(): NodeMaterialConnectionPoint;
  67032. /**
  67033. * Gets the g component (input)
  67034. */
  67035. get g(): NodeMaterialConnectionPoint;
  67036. /**
  67037. * Gets the b component (input)
  67038. */
  67039. get b(): NodeMaterialConnectionPoint;
  67040. /**
  67041. * Gets the a component (input)
  67042. */
  67043. get a(): NodeMaterialConnectionPoint;
  67044. /**
  67045. * Gets the rgba component (output)
  67046. */
  67047. get rgba(): NodeMaterialConnectionPoint;
  67048. /**
  67049. * Gets the rgb component (output)
  67050. */
  67051. get rgbOut(): NodeMaterialConnectionPoint;
  67052. /**
  67053. * Gets the rgb component (output)
  67054. * @deprecated Please use rgbOut instead.
  67055. */
  67056. get rgb(): NodeMaterialConnectionPoint;
  67057. protected _buildBlock(state: NodeMaterialBuildState): this;
  67058. }
  67059. }
  67060. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67064. /**
  67065. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67066. */
  67067. export class VectorSplitterBlock extends NodeMaterialBlock {
  67068. /**
  67069. * Create a new VectorSplitterBlock
  67070. * @param name defines the block name
  67071. */
  67072. constructor(name: string);
  67073. /**
  67074. * Gets the current class name
  67075. * @returns the class name
  67076. */
  67077. getClassName(): string;
  67078. /**
  67079. * Gets the xyzw component (input)
  67080. */
  67081. get xyzw(): NodeMaterialConnectionPoint;
  67082. /**
  67083. * Gets the xyz component (input)
  67084. */
  67085. get xyzIn(): NodeMaterialConnectionPoint;
  67086. /**
  67087. * Gets the xy component (input)
  67088. */
  67089. get xyIn(): NodeMaterialConnectionPoint;
  67090. /**
  67091. * Gets the xyz component (output)
  67092. */
  67093. get xyzOut(): NodeMaterialConnectionPoint;
  67094. /**
  67095. * Gets the xy component (output)
  67096. */
  67097. get xyOut(): NodeMaterialConnectionPoint;
  67098. /**
  67099. * Gets the x component (output)
  67100. */
  67101. get x(): NodeMaterialConnectionPoint;
  67102. /**
  67103. * Gets the y component (output)
  67104. */
  67105. get y(): NodeMaterialConnectionPoint;
  67106. /**
  67107. * Gets the z component (output)
  67108. */
  67109. get z(): NodeMaterialConnectionPoint;
  67110. /**
  67111. * Gets the w component (output)
  67112. */
  67113. get w(): NodeMaterialConnectionPoint;
  67114. protected _inputRename(name: string): string;
  67115. protected _outputRename(name: string): string;
  67116. protected _buildBlock(state: NodeMaterialBuildState): this;
  67117. }
  67118. }
  67119. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67121. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67123. /**
  67124. * Block used to lerp between 2 values
  67125. */
  67126. export class LerpBlock extends NodeMaterialBlock {
  67127. /**
  67128. * Creates a new LerpBlock
  67129. * @param name defines the block name
  67130. */
  67131. constructor(name: string);
  67132. /**
  67133. * Gets the current class name
  67134. * @returns the class name
  67135. */
  67136. getClassName(): string;
  67137. /**
  67138. * Gets the left operand input component
  67139. */
  67140. get left(): NodeMaterialConnectionPoint;
  67141. /**
  67142. * Gets the right operand input component
  67143. */
  67144. get right(): NodeMaterialConnectionPoint;
  67145. /**
  67146. * Gets the gradient operand input component
  67147. */
  67148. get gradient(): NodeMaterialConnectionPoint;
  67149. /**
  67150. * Gets the output component
  67151. */
  67152. get output(): NodeMaterialConnectionPoint;
  67153. protected _buildBlock(state: NodeMaterialBuildState): this;
  67154. }
  67155. }
  67156. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67160. /**
  67161. * Block used to divide 2 vectors
  67162. */
  67163. export class DivideBlock extends NodeMaterialBlock {
  67164. /**
  67165. * Creates a new DivideBlock
  67166. * @param name defines the block name
  67167. */
  67168. constructor(name: string);
  67169. /**
  67170. * Gets the current class name
  67171. * @returns the class name
  67172. */
  67173. getClassName(): string;
  67174. /**
  67175. * Gets the left operand input component
  67176. */
  67177. get left(): NodeMaterialConnectionPoint;
  67178. /**
  67179. * Gets the right operand input component
  67180. */
  67181. get right(): NodeMaterialConnectionPoint;
  67182. /**
  67183. * Gets the output component
  67184. */
  67185. get output(): NodeMaterialConnectionPoint;
  67186. protected _buildBlock(state: NodeMaterialBuildState): this;
  67187. }
  67188. }
  67189. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67191. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67192. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67193. /**
  67194. * Block used to subtract 2 vectors
  67195. */
  67196. export class SubtractBlock extends NodeMaterialBlock {
  67197. /**
  67198. * Creates a new SubtractBlock
  67199. * @param name defines the block name
  67200. */
  67201. constructor(name: string);
  67202. /**
  67203. * Gets the current class name
  67204. * @returns the class name
  67205. */
  67206. getClassName(): string;
  67207. /**
  67208. * Gets the left operand input component
  67209. */
  67210. get left(): NodeMaterialConnectionPoint;
  67211. /**
  67212. * Gets the right operand input component
  67213. */
  67214. get right(): NodeMaterialConnectionPoint;
  67215. /**
  67216. * Gets the output component
  67217. */
  67218. get output(): NodeMaterialConnectionPoint;
  67219. protected _buildBlock(state: NodeMaterialBuildState): this;
  67220. }
  67221. }
  67222. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  67223. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67224. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67225. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67226. /**
  67227. * Block used to step a value
  67228. */
  67229. export class StepBlock extends NodeMaterialBlock {
  67230. /**
  67231. * Creates a new StepBlock
  67232. * @param name defines the block name
  67233. */
  67234. constructor(name: string);
  67235. /**
  67236. * Gets the current class name
  67237. * @returns the class name
  67238. */
  67239. getClassName(): string;
  67240. /**
  67241. * Gets the value operand input component
  67242. */
  67243. get value(): NodeMaterialConnectionPoint;
  67244. /**
  67245. * Gets the edge operand input component
  67246. */
  67247. get edge(): NodeMaterialConnectionPoint;
  67248. /**
  67249. * Gets the output component
  67250. */
  67251. get output(): NodeMaterialConnectionPoint;
  67252. protected _buildBlock(state: NodeMaterialBuildState): this;
  67253. }
  67254. }
  67255. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67256. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67257. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67258. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67259. /**
  67260. * Block used to get the opposite (1 - x) of a value
  67261. */
  67262. export class OneMinusBlock extends NodeMaterialBlock {
  67263. /**
  67264. * Creates a new OneMinusBlock
  67265. * @param name defines the block name
  67266. */
  67267. constructor(name: string);
  67268. /**
  67269. * Gets the current class name
  67270. * @returns the class name
  67271. */
  67272. getClassName(): string;
  67273. /**
  67274. * Gets the input component
  67275. */
  67276. get input(): NodeMaterialConnectionPoint;
  67277. /**
  67278. * Gets the output component
  67279. */
  67280. get output(): NodeMaterialConnectionPoint;
  67281. protected _buildBlock(state: NodeMaterialBuildState): this;
  67282. }
  67283. }
  67284. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67285. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67286. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67287. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67288. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67289. /**
  67290. * Block used to get the view direction
  67291. */
  67292. export class ViewDirectionBlock extends NodeMaterialBlock {
  67293. /**
  67294. * Creates a new ViewDirectionBlock
  67295. * @param name defines the block name
  67296. */
  67297. constructor(name: string);
  67298. /**
  67299. * Gets the current class name
  67300. * @returns the class name
  67301. */
  67302. getClassName(): string;
  67303. /**
  67304. * Gets the world position component
  67305. */
  67306. get worldPosition(): NodeMaterialConnectionPoint;
  67307. /**
  67308. * Gets the camera position component
  67309. */
  67310. get cameraPosition(): NodeMaterialConnectionPoint;
  67311. /**
  67312. * Gets the output component
  67313. */
  67314. get output(): NodeMaterialConnectionPoint;
  67315. autoConfigure(material: NodeMaterial): void;
  67316. protected _buildBlock(state: NodeMaterialBuildState): this;
  67317. }
  67318. }
  67319. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67323. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67324. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67325. /**
  67326. * Block used to compute fresnel value
  67327. */
  67328. export class FresnelBlock extends NodeMaterialBlock {
  67329. /**
  67330. * Create a new FresnelBlock
  67331. * @param name defines the block name
  67332. */
  67333. constructor(name: string);
  67334. /**
  67335. * Gets the current class name
  67336. * @returns the class name
  67337. */
  67338. getClassName(): string;
  67339. /**
  67340. * Gets the world normal input component
  67341. */
  67342. get worldNormal(): NodeMaterialConnectionPoint;
  67343. /**
  67344. * Gets the view direction input component
  67345. */
  67346. get viewDirection(): NodeMaterialConnectionPoint;
  67347. /**
  67348. * Gets the bias input component
  67349. */
  67350. get bias(): NodeMaterialConnectionPoint;
  67351. /**
  67352. * Gets the camera (or eye) position component
  67353. */
  67354. get power(): NodeMaterialConnectionPoint;
  67355. /**
  67356. * Gets the fresnel output component
  67357. */
  67358. get fresnel(): NodeMaterialConnectionPoint;
  67359. autoConfigure(material: NodeMaterial): void;
  67360. protected _buildBlock(state: NodeMaterialBuildState): this;
  67361. }
  67362. }
  67363. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67367. /**
  67368. * Block used to get the max of 2 values
  67369. */
  67370. export class MaxBlock extends NodeMaterialBlock {
  67371. /**
  67372. * Creates a new MaxBlock
  67373. * @param name defines the block name
  67374. */
  67375. constructor(name: string);
  67376. /**
  67377. * Gets the current class name
  67378. * @returns the class name
  67379. */
  67380. getClassName(): string;
  67381. /**
  67382. * Gets the left operand input component
  67383. */
  67384. get left(): NodeMaterialConnectionPoint;
  67385. /**
  67386. * Gets the right operand input component
  67387. */
  67388. get right(): NodeMaterialConnectionPoint;
  67389. /**
  67390. * Gets the output component
  67391. */
  67392. get output(): NodeMaterialConnectionPoint;
  67393. protected _buildBlock(state: NodeMaterialBuildState): this;
  67394. }
  67395. }
  67396. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67397. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67398. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67399. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67400. /**
  67401. * Block used to get the min of 2 values
  67402. */
  67403. export class MinBlock extends NodeMaterialBlock {
  67404. /**
  67405. * Creates a new MinBlock
  67406. * @param name defines the block name
  67407. */
  67408. constructor(name: string);
  67409. /**
  67410. * Gets the current class name
  67411. * @returns the class name
  67412. */
  67413. getClassName(): string;
  67414. /**
  67415. * Gets the left operand input component
  67416. */
  67417. get left(): NodeMaterialConnectionPoint;
  67418. /**
  67419. * Gets the right operand input component
  67420. */
  67421. get right(): NodeMaterialConnectionPoint;
  67422. /**
  67423. * Gets the output component
  67424. */
  67425. get output(): NodeMaterialConnectionPoint;
  67426. protected _buildBlock(state: NodeMaterialBuildState): this;
  67427. }
  67428. }
  67429. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67430. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67431. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67432. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67433. /**
  67434. * Block used to get the distance between 2 values
  67435. */
  67436. export class DistanceBlock extends NodeMaterialBlock {
  67437. /**
  67438. * Creates a new DistanceBlock
  67439. * @param name defines the block name
  67440. */
  67441. constructor(name: string);
  67442. /**
  67443. * Gets the current class name
  67444. * @returns the class name
  67445. */
  67446. getClassName(): string;
  67447. /**
  67448. * Gets the left operand input component
  67449. */
  67450. get left(): NodeMaterialConnectionPoint;
  67451. /**
  67452. * Gets the right operand input component
  67453. */
  67454. get right(): NodeMaterialConnectionPoint;
  67455. /**
  67456. * Gets the output component
  67457. */
  67458. get output(): NodeMaterialConnectionPoint;
  67459. protected _buildBlock(state: NodeMaterialBuildState): this;
  67460. }
  67461. }
  67462. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67464. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67465. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67466. /**
  67467. * Block used to get the length of a vector
  67468. */
  67469. export class LengthBlock extends NodeMaterialBlock {
  67470. /**
  67471. * Creates a new LengthBlock
  67472. * @param name defines the block name
  67473. */
  67474. constructor(name: string);
  67475. /**
  67476. * Gets the current class name
  67477. * @returns the class name
  67478. */
  67479. getClassName(): string;
  67480. /**
  67481. * Gets the value input component
  67482. */
  67483. get value(): NodeMaterialConnectionPoint;
  67484. /**
  67485. * Gets the output component
  67486. */
  67487. get output(): NodeMaterialConnectionPoint;
  67488. protected _buildBlock(state: NodeMaterialBuildState): this;
  67489. }
  67490. }
  67491. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67492. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67493. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67494. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67495. /**
  67496. * Block used to get negative version of a value (i.e. x * -1)
  67497. */
  67498. export class NegateBlock extends NodeMaterialBlock {
  67499. /**
  67500. * Creates a new NegateBlock
  67501. * @param name defines the block name
  67502. */
  67503. constructor(name: string);
  67504. /**
  67505. * Gets the current class name
  67506. * @returns the class name
  67507. */
  67508. getClassName(): string;
  67509. /**
  67510. * Gets the value input component
  67511. */
  67512. get value(): NodeMaterialConnectionPoint;
  67513. /**
  67514. * Gets the output component
  67515. */
  67516. get output(): NodeMaterialConnectionPoint;
  67517. protected _buildBlock(state: NodeMaterialBuildState): this;
  67518. }
  67519. }
  67520. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67521. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67522. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67524. /**
  67525. * Block used to get the value of the first parameter raised to the power of the second
  67526. */
  67527. export class PowBlock extends NodeMaterialBlock {
  67528. /**
  67529. * Creates a new PowBlock
  67530. * @param name defines the block name
  67531. */
  67532. constructor(name: string);
  67533. /**
  67534. * Gets the current class name
  67535. * @returns the class name
  67536. */
  67537. getClassName(): string;
  67538. /**
  67539. * Gets the value operand input component
  67540. */
  67541. get value(): NodeMaterialConnectionPoint;
  67542. /**
  67543. * Gets the power operand input component
  67544. */
  67545. get power(): NodeMaterialConnectionPoint;
  67546. /**
  67547. * Gets the output component
  67548. */
  67549. get output(): NodeMaterialConnectionPoint;
  67550. protected _buildBlock(state: NodeMaterialBuildState): this;
  67551. }
  67552. }
  67553. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67557. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67558. /**
  67559. * Block used to get a random number
  67560. */
  67561. export class RandomNumberBlock extends NodeMaterialBlock {
  67562. /**
  67563. * Creates a new RandomNumberBlock
  67564. * @param name defines the block name
  67565. */
  67566. constructor(name: string);
  67567. /**
  67568. * Gets the current class name
  67569. * @returns the class name
  67570. */
  67571. getClassName(): string;
  67572. /**
  67573. * Gets the seed input component
  67574. */
  67575. get seed(): NodeMaterialConnectionPoint;
  67576. /**
  67577. * Gets the output component
  67578. */
  67579. get output(): NodeMaterialConnectionPoint;
  67580. protected _buildBlock(state: NodeMaterialBuildState): this;
  67581. }
  67582. }
  67583. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67587. /**
  67588. * Block used to compute arc tangent of 2 values
  67589. */
  67590. export class ArcTan2Block extends NodeMaterialBlock {
  67591. /**
  67592. * Creates a new ArcTan2Block
  67593. * @param name defines the block name
  67594. */
  67595. constructor(name: string);
  67596. /**
  67597. * Gets the current class name
  67598. * @returns the class name
  67599. */
  67600. getClassName(): string;
  67601. /**
  67602. * Gets the x operand input component
  67603. */
  67604. get x(): NodeMaterialConnectionPoint;
  67605. /**
  67606. * Gets the y operand input component
  67607. */
  67608. get y(): NodeMaterialConnectionPoint;
  67609. /**
  67610. * Gets the output component
  67611. */
  67612. get output(): NodeMaterialConnectionPoint;
  67613. protected _buildBlock(state: NodeMaterialBuildState): this;
  67614. }
  67615. }
  67616. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67617. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67618. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67619. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67620. /**
  67621. * Block used to smooth step a value
  67622. */
  67623. export class SmoothStepBlock extends NodeMaterialBlock {
  67624. /**
  67625. * Creates a new SmoothStepBlock
  67626. * @param name defines the block name
  67627. */
  67628. constructor(name: string);
  67629. /**
  67630. * Gets the current class name
  67631. * @returns the class name
  67632. */
  67633. getClassName(): string;
  67634. /**
  67635. * Gets the value operand input component
  67636. */
  67637. get value(): NodeMaterialConnectionPoint;
  67638. /**
  67639. * Gets the first edge operand input component
  67640. */
  67641. get edge0(): NodeMaterialConnectionPoint;
  67642. /**
  67643. * Gets the second edge operand input component
  67644. */
  67645. get edge1(): NodeMaterialConnectionPoint;
  67646. /**
  67647. * Gets the output component
  67648. */
  67649. get output(): NodeMaterialConnectionPoint;
  67650. protected _buildBlock(state: NodeMaterialBuildState): this;
  67651. }
  67652. }
  67653. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67657. /**
  67658. * Block used to get the reciprocal (1 / x) of a value
  67659. */
  67660. export class ReciprocalBlock extends NodeMaterialBlock {
  67661. /**
  67662. * Creates a new ReciprocalBlock
  67663. * @param name defines the block name
  67664. */
  67665. constructor(name: string);
  67666. /**
  67667. * Gets the current class name
  67668. * @returns the class name
  67669. */
  67670. getClassName(): string;
  67671. /**
  67672. * Gets the input component
  67673. */
  67674. get input(): NodeMaterialConnectionPoint;
  67675. /**
  67676. * Gets the output component
  67677. */
  67678. get output(): NodeMaterialConnectionPoint;
  67679. protected _buildBlock(state: NodeMaterialBuildState): this;
  67680. }
  67681. }
  67682. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67684. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67685. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67686. /**
  67687. * Block used to replace a color by another one
  67688. */
  67689. export class ReplaceColorBlock extends NodeMaterialBlock {
  67690. /**
  67691. * Creates a new ReplaceColorBlock
  67692. * @param name defines the block name
  67693. */
  67694. constructor(name: string);
  67695. /**
  67696. * Gets the current class name
  67697. * @returns the class name
  67698. */
  67699. getClassName(): string;
  67700. /**
  67701. * Gets the value input component
  67702. */
  67703. get value(): NodeMaterialConnectionPoint;
  67704. /**
  67705. * Gets the reference input component
  67706. */
  67707. get reference(): NodeMaterialConnectionPoint;
  67708. /**
  67709. * Gets the distance input component
  67710. */
  67711. get distance(): NodeMaterialConnectionPoint;
  67712. /**
  67713. * Gets the replacement input component
  67714. */
  67715. get replacement(): NodeMaterialConnectionPoint;
  67716. /**
  67717. * Gets the output component
  67718. */
  67719. get output(): NodeMaterialConnectionPoint;
  67720. protected _buildBlock(state: NodeMaterialBuildState): this;
  67721. }
  67722. }
  67723. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  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 posterize a value
  67729. * @see https://en.wikipedia.org/wiki/Posterization
  67730. */
  67731. export class PosterizeBlock extends NodeMaterialBlock {
  67732. /**
  67733. * Creates a new PosterizeBlock
  67734. * @param name defines the block name
  67735. */
  67736. constructor(name: string);
  67737. /**
  67738. * Gets the current class name
  67739. * @returns the class name
  67740. */
  67741. getClassName(): string;
  67742. /**
  67743. * Gets the value input component
  67744. */
  67745. get value(): NodeMaterialConnectionPoint;
  67746. /**
  67747. * Gets the steps input component
  67748. */
  67749. get steps(): NodeMaterialConnectionPoint;
  67750. /**
  67751. * Gets the output component
  67752. */
  67753. get output(): NodeMaterialConnectionPoint;
  67754. protected _buildBlock(state: NodeMaterialBuildState): this;
  67755. }
  67756. }
  67757. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67759. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67761. import { Scene } from "babylonjs/scene";
  67762. /**
  67763. * Operations supported by the Wave block
  67764. */
  67765. export enum WaveBlockKind {
  67766. /** SawTooth */
  67767. SawTooth = 0,
  67768. /** Square */
  67769. Square = 1,
  67770. /** Triangle */
  67771. Triangle = 2
  67772. }
  67773. /**
  67774. * Block used to apply wave operation to floats
  67775. */
  67776. export class WaveBlock extends NodeMaterialBlock {
  67777. /**
  67778. * Gets or sets the kibnd of wave to be applied by the block
  67779. */
  67780. kind: WaveBlockKind;
  67781. /**
  67782. * Creates a new WaveBlock
  67783. * @param name defines the block name
  67784. */
  67785. constructor(name: string);
  67786. /**
  67787. * Gets the current class name
  67788. * @returns the class name
  67789. */
  67790. getClassName(): string;
  67791. /**
  67792. * Gets the input component
  67793. */
  67794. get input(): NodeMaterialConnectionPoint;
  67795. /**
  67796. * Gets the output component
  67797. */
  67798. get output(): NodeMaterialConnectionPoint;
  67799. protected _buildBlock(state: NodeMaterialBuildState): this;
  67800. serialize(): any;
  67801. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67802. }
  67803. }
  67804. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67808. import { Color3 } from "babylonjs/Maths/math.color";
  67809. import { Scene } from "babylonjs/scene";
  67810. import { Observable } from "babylonjs/Misc/observable";
  67811. /**
  67812. * Class used to store a color step for the GradientBlock
  67813. */
  67814. export class GradientBlockColorStep {
  67815. private _step;
  67816. /**
  67817. * Gets value indicating which step this color is associated with (between 0 and 1)
  67818. */
  67819. get step(): number;
  67820. /**
  67821. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67822. */
  67823. set step(val: number);
  67824. private _color;
  67825. /**
  67826. * Gets the color associated with this step
  67827. */
  67828. get color(): Color3;
  67829. /**
  67830. * Sets the color associated with this step
  67831. */
  67832. set color(val: Color3);
  67833. /**
  67834. * Creates a new GradientBlockColorStep
  67835. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67836. * @param color defines the color associated with this step
  67837. */
  67838. constructor(step: number, color: Color3);
  67839. }
  67840. /**
  67841. * Block used to return a color from a gradient based on an input value between 0 and 1
  67842. */
  67843. export class GradientBlock extends NodeMaterialBlock {
  67844. /**
  67845. * Gets or sets the list of color steps
  67846. */
  67847. colorSteps: GradientBlockColorStep[];
  67848. /** Gets an observable raised when the value is changed */
  67849. onValueChangedObservable: Observable<GradientBlock>;
  67850. /** calls observable when the value is changed*/
  67851. colorStepsUpdated(): void;
  67852. /**
  67853. * Creates a new GradientBlock
  67854. * @param name defines the block name
  67855. */
  67856. constructor(name: string);
  67857. /**
  67858. * Gets the current class name
  67859. * @returns the class name
  67860. */
  67861. getClassName(): string;
  67862. /**
  67863. * Gets the gradient input component
  67864. */
  67865. get gradient(): NodeMaterialConnectionPoint;
  67866. /**
  67867. * Gets the output component
  67868. */
  67869. get output(): NodeMaterialConnectionPoint;
  67870. private _writeColorConstant;
  67871. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67872. serialize(): any;
  67873. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67874. protected _dumpPropertiesCode(): string;
  67875. }
  67876. }
  67877. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67881. /**
  67882. * Block used to normalize lerp between 2 values
  67883. */
  67884. export class NLerpBlock extends NodeMaterialBlock {
  67885. /**
  67886. * Creates a new NLerpBlock
  67887. * @param name defines the block name
  67888. */
  67889. constructor(name: string);
  67890. /**
  67891. * Gets the current class name
  67892. * @returns the class name
  67893. */
  67894. getClassName(): string;
  67895. /**
  67896. * Gets the left operand input component
  67897. */
  67898. get left(): NodeMaterialConnectionPoint;
  67899. /**
  67900. * Gets the right operand input component
  67901. */
  67902. get right(): NodeMaterialConnectionPoint;
  67903. /**
  67904. * Gets the gradient operand input component
  67905. */
  67906. get gradient(): NodeMaterialConnectionPoint;
  67907. /**
  67908. * Gets the output component
  67909. */
  67910. get output(): NodeMaterialConnectionPoint;
  67911. protected _buildBlock(state: NodeMaterialBuildState): this;
  67912. }
  67913. }
  67914. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67918. import { Scene } from "babylonjs/scene";
  67919. /**
  67920. * block used to Generate a Worley Noise 3D Noise Pattern
  67921. */
  67922. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67923. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67924. manhattanDistance: boolean;
  67925. /**
  67926. * Creates a new WorleyNoise3DBlock
  67927. * @param name defines the block name
  67928. */
  67929. constructor(name: string);
  67930. /**
  67931. * Gets the current class name
  67932. * @returns the class name
  67933. */
  67934. getClassName(): string;
  67935. /**
  67936. * Gets the seed input component
  67937. */
  67938. get seed(): NodeMaterialConnectionPoint;
  67939. /**
  67940. * Gets the jitter input component
  67941. */
  67942. get jitter(): NodeMaterialConnectionPoint;
  67943. /**
  67944. * Gets the output component
  67945. */
  67946. get output(): NodeMaterialConnectionPoint;
  67947. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67948. /**
  67949. * Exposes the properties to the UI?
  67950. */
  67951. protected _dumpPropertiesCode(): string;
  67952. /**
  67953. * Exposes the properties to the Seralize?
  67954. */
  67955. serialize(): any;
  67956. /**
  67957. * Exposes the properties to the deseralize?
  67958. */
  67959. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67960. }
  67961. }
  67962. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67963. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67964. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67965. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67966. /**
  67967. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67968. */
  67969. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67970. /**
  67971. * Creates a new SimplexPerlin3DBlock
  67972. * @param name defines the block name
  67973. */
  67974. constructor(name: string);
  67975. /**
  67976. * Gets the current class name
  67977. * @returns the class name
  67978. */
  67979. getClassName(): string;
  67980. /**
  67981. * Gets the seed operand input component
  67982. */
  67983. get seed(): NodeMaterialConnectionPoint;
  67984. /**
  67985. * Gets the output component
  67986. */
  67987. get output(): NodeMaterialConnectionPoint;
  67988. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67989. }
  67990. }
  67991. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67995. /**
  67996. * Block used to blend normals
  67997. */
  67998. export class NormalBlendBlock extends NodeMaterialBlock {
  67999. /**
  68000. * Creates a new NormalBlendBlock
  68001. * @param name defines the block name
  68002. */
  68003. constructor(name: string);
  68004. /**
  68005. * Gets the current class name
  68006. * @returns the class name
  68007. */
  68008. getClassName(): string;
  68009. /**
  68010. * Gets the first input component
  68011. */
  68012. get normalMap0(): NodeMaterialConnectionPoint;
  68013. /**
  68014. * Gets the second input component
  68015. */
  68016. get normalMap1(): NodeMaterialConnectionPoint;
  68017. /**
  68018. * Gets the output component
  68019. */
  68020. get output(): NodeMaterialConnectionPoint;
  68021. protected _buildBlock(state: NodeMaterialBuildState): this;
  68022. }
  68023. }
  68024. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68027. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68028. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68029. /**
  68030. * Block used to rotate a 2d vector by a given angle
  68031. */
  68032. export class Rotate2dBlock extends NodeMaterialBlock {
  68033. /**
  68034. * Creates a new Rotate2dBlock
  68035. * @param name defines the block name
  68036. */
  68037. constructor(name: string);
  68038. /**
  68039. * Gets the current class name
  68040. * @returns the class name
  68041. */
  68042. getClassName(): string;
  68043. /**
  68044. * Gets the input vector
  68045. */
  68046. get input(): NodeMaterialConnectionPoint;
  68047. /**
  68048. * Gets the input angle
  68049. */
  68050. get angle(): NodeMaterialConnectionPoint;
  68051. /**
  68052. * Gets the output component
  68053. */
  68054. get output(): NodeMaterialConnectionPoint;
  68055. autoConfigure(material: NodeMaterial): void;
  68056. protected _buildBlock(state: NodeMaterialBuildState): this;
  68057. }
  68058. }
  68059. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68062. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68063. /**
  68064. * Block used to get the reflected vector from a direction and a normal
  68065. */
  68066. export class ReflectBlock extends NodeMaterialBlock {
  68067. /**
  68068. * Creates a new ReflectBlock
  68069. * @param name defines the block name
  68070. */
  68071. constructor(name: string);
  68072. /**
  68073. * Gets the current class name
  68074. * @returns the class name
  68075. */
  68076. getClassName(): string;
  68077. /**
  68078. * Gets the incident component
  68079. */
  68080. get incident(): NodeMaterialConnectionPoint;
  68081. /**
  68082. * Gets the normal component
  68083. */
  68084. get normal(): NodeMaterialConnectionPoint;
  68085. /**
  68086. * Gets the output component
  68087. */
  68088. get output(): NodeMaterialConnectionPoint;
  68089. protected _buildBlock(state: NodeMaterialBuildState): this;
  68090. }
  68091. }
  68092. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68096. /**
  68097. * Block used to get the refracted vector from a direction and a normal
  68098. */
  68099. export class RefractBlock extends NodeMaterialBlock {
  68100. /**
  68101. * Creates a new RefractBlock
  68102. * @param name defines the block name
  68103. */
  68104. constructor(name: string);
  68105. /**
  68106. * Gets the current class name
  68107. * @returns the class name
  68108. */
  68109. getClassName(): string;
  68110. /**
  68111. * Gets the incident component
  68112. */
  68113. get incident(): NodeMaterialConnectionPoint;
  68114. /**
  68115. * Gets the normal component
  68116. */
  68117. get normal(): NodeMaterialConnectionPoint;
  68118. /**
  68119. * Gets the index of refraction component
  68120. */
  68121. get ior(): NodeMaterialConnectionPoint;
  68122. /**
  68123. * Gets the output component
  68124. */
  68125. get output(): NodeMaterialConnectionPoint;
  68126. protected _buildBlock(state: NodeMaterialBuildState): this;
  68127. }
  68128. }
  68129. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68131. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68132. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68133. /**
  68134. * Block used to desaturate a color
  68135. */
  68136. export class DesaturateBlock extends NodeMaterialBlock {
  68137. /**
  68138. * Creates a new DesaturateBlock
  68139. * @param name defines the block name
  68140. */
  68141. constructor(name: string);
  68142. /**
  68143. * Gets the current class name
  68144. * @returns the class name
  68145. */
  68146. getClassName(): string;
  68147. /**
  68148. * Gets the color operand input component
  68149. */
  68150. get color(): NodeMaterialConnectionPoint;
  68151. /**
  68152. * Gets the level operand input component
  68153. */
  68154. get level(): NodeMaterialConnectionPoint;
  68155. /**
  68156. * Gets the output component
  68157. */
  68158. get output(): NodeMaterialConnectionPoint;
  68159. protected _buildBlock(state: NodeMaterialBuildState): this;
  68160. }
  68161. }
  68162. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68163. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68164. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68165. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68166. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68167. import { Nullable } from "babylonjs/types";
  68168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68169. import { Scene } from "babylonjs/scene";
  68170. /**
  68171. * Block used to implement the ambient occlusion module of the PBR material
  68172. */
  68173. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68174. /**
  68175. * Create a new AmbientOcclusionBlock
  68176. * @param name defines the block name
  68177. */
  68178. constructor(name: string);
  68179. /**
  68180. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68181. */
  68182. useAmbientInGrayScale: boolean;
  68183. /**
  68184. * Initialize the block and prepare the context for build
  68185. * @param state defines the state that will be used for the build
  68186. */
  68187. initialize(state: NodeMaterialBuildState): void;
  68188. /**
  68189. * Gets the current class name
  68190. * @returns the class name
  68191. */
  68192. getClassName(): string;
  68193. /**
  68194. * Gets the texture input component
  68195. */
  68196. get texture(): NodeMaterialConnectionPoint;
  68197. /**
  68198. * Gets the texture intensity component
  68199. */
  68200. get intensity(): NodeMaterialConnectionPoint;
  68201. /**
  68202. * Gets the direct light intensity input component
  68203. */
  68204. get directLightIntensity(): NodeMaterialConnectionPoint;
  68205. /**
  68206. * Gets the ambient occlusion object output component
  68207. */
  68208. get ambientOcc(): NodeMaterialConnectionPoint;
  68209. /**
  68210. * Gets the main code of the block (fragment side)
  68211. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68212. * @returns the shader code
  68213. */
  68214. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68215. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68216. protected _buildBlock(state: NodeMaterialBuildState): this;
  68217. protected _dumpPropertiesCode(): string;
  68218. serialize(): any;
  68219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68220. }
  68221. }
  68222. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68225. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68226. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68228. import { Nullable } from "babylonjs/types";
  68229. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68230. import { Mesh } from "babylonjs/Meshes/mesh";
  68231. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68232. import { Effect } from "babylonjs/Materials/effect";
  68233. import { Scene } from "babylonjs/scene";
  68234. /**
  68235. * Block used to implement the reflection module of the PBR material
  68236. */
  68237. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68238. /** @hidden */
  68239. _defineLODReflectionAlpha: string;
  68240. /** @hidden */
  68241. _defineLinearSpecularReflection: string;
  68242. private _vEnvironmentIrradianceName;
  68243. /** @hidden */
  68244. _vReflectionMicrosurfaceInfosName: string;
  68245. /** @hidden */
  68246. _vReflectionInfosName: string;
  68247. /** @hidden */
  68248. _vReflectionFilteringInfoName: string;
  68249. private _scene;
  68250. /**
  68251. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68252. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68253. * It's less burden on the user side in the editor part.
  68254. */
  68255. /** @hidden */
  68256. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68257. /** @hidden */
  68258. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68259. /** @hidden */
  68260. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68261. /**
  68262. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68263. * diffuse part of the IBL.
  68264. */
  68265. useSphericalHarmonics: boolean;
  68266. /**
  68267. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68268. */
  68269. forceIrradianceInFragment: boolean;
  68270. /**
  68271. * Create a new ReflectionBlock
  68272. * @param name defines the block name
  68273. */
  68274. constructor(name: string);
  68275. /**
  68276. * Gets the current class name
  68277. * @returns the class name
  68278. */
  68279. getClassName(): string;
  68280. /**
  68281. * Gets the position input component
  68282. */
  68283. get position(): NodeMaterialConnectionPoint;
  68284. /**
  68285. * Gets the world position input component
  68286. */
  68287. get worldPosition(): NodeMaterialConnectionPoint;
  68288. /**
  68289. * Gets the world normal input component
  68290. */
  68291. get worldNormal(): NodeMaterialConnectionPoint;
  68292. /**
  68293. * Gets the world input component
  68294. */
  68295. get world(): NodeMaterialConnectionPoint;
  68296. /**
  68297. * Gets the camera (or eye) position component
  68298. */
  68299. get cameraPosition(): NodeMaterialConnectionPoint;
  68300. /**
  68301. * Gets the view input component
  68302. */
  68303. get view(): NodeMaterialConnectionPoint;
  68304. /**
  68305. * Gets the color input component
  68306. */
  68307. get color(): NodeMaterialConnectionPoint;
  68308. /**
  68309. * Gets the reflection object output component
  68310. */
  68311. get reflection(): NodeMaterialConnectionPoint;
  68312. /**
  68313. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68314. */
  68315. get hasTexture(): boolean;
  68316. /**
  68317. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68318. */
  68319. get reflectionColor(): string;
  68320. protected _getTexture(): Nullable<BaseTexture>;
  68321. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68322. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68323. /**
  68324. * Gets the code to inject in the vertex shader
  68325. * @param state current state of the node material building
  68326. * @returns the shader code
  68327. */
  68328. handleVertexSide(state: NodeMaterialBuildState): string;
  68329. /**
  68330. * Gets the main code of the block (fragment side)
  68331. * @param state current state of the node material building
  68332. * @param normalVarName name of the existing variable corresponding to the normal
  68333. * @returns the shader code
  68334. */
  68335. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68336. protected _buildBlock(state: NodeMaterialBuildState): this;
  68337. protected _dumpPropertiesCode(): string;
  68338. serialize(): any;
  68339. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68340. }
  68341. }
  68342. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68345. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68346. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68348. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68349. import { Scene } from "babylonjs/scene";
  68350. import { Nullable } from "babylonjs/types";
  68351. /**
  68352. * Block used to implement the sheen module of the PBR material
  68353. */
  68354. export class SheenBlock extends NodeMaterialBlock {
  68355. /**
  68356. * Create a new SheenBlock
  68357. * @param name defines the block name
  68358. */
  68359. constructor(name: string);
  68360. /**
  68361. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68362. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68363. * making it easier to setup and tweak the effect
  68364. */
  68365. albedoScaling: boolean;
  68366. /**
  68367. * Defines if the sheen is linked to the sheen color.
  68368. */
  68369. linkSheenWithAlbedo: boolean;
  68370. /**
  68371. * Initialize the block and prepare the context for build
  68372. * @param state defines the state that will be used for the build
  68373. */
  68374. initialize(state: NodeMaterialBuildState): void;
  68375. /**
  68376. * Gets the current class name
  68377. * @returns the class name
  68378. */
  68379. getClassName(): string;
  68380. /**
  68381. * Gets the intensity input component
  68382. */
  68383. get intensity(): NodeMaterialConnectionPoint;
  68384. /**
  68385. * Gets the color input component
  68386. */
  68387. get color(): NodeMaterialConnectionPoint;
  68388. /**
  68389. * Gets the roughness input component
  68390. */
  68391. get roughness(): NodeMaterialConnectionPoint;
  68392. /**
  68393. * Gets the sheen object output component
  68394. */
  68395. get sheen(): NodeMaterialConnectionPoint;
  68396. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68397. /**
  68398. * Gets the main code of the block (fragment side)
  68399. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68400. * @returns the shader code
  68401. */
  68402. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68403. protected _buildBlock(state: NodeMaterialBuildState): this;
  68404. protected _dumpPropertiesCode(): string;
  68405. serialize(): any;
  68406. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68407. }
  68408. }
  68409. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68410. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68415. import { Scene } from "babylonjs/scene";
  68416. import { Nullable } from "babylonjs/types";
  68417. import { Mesh } from "babylonjs/Meshes/mesh";
  68418. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68419. import { Effect } from "babylonjs/Materials/effect";
  68420. /**
  68421. * Block used to implement the reflectivity module of the PBR material
  68422. */
  68423. export class ReflectivityBlock extends NodeMaterialBlock {
  68424. private _metallicReflectanceColor;
  68425. private _metallicF0Factor;
  68426. /** @hidden */
  68427. _vMetallicReflectanceFactorsName: string;
  68428. /**
  68429. * The property below is set by the main PBR block prior to calling methods of this class.
  68430. */
  68431. /** @hidden */
  68432. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68433. /**
  68434. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68435. */
  68436. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68437. /**
  68438. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68439. */
  68440. useMetallnessFromMetallicTextureBlue: boolean;
  68441. /**
  68442. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68443. */
  68444. useRoughnessFromMetallicTextureAlpha: boolean;
  68445. /**
  68446. * Specifies if the metallic texture contains the roughness information in its green channel.
  68447. */
  68448. useRoughnessFromMetallicTextureGreen: boolean;
  68449. /**
  68450. * Create a new ReflectivityBlock
  68451. * @param name defines the block name
  68452. */
  68453. constructor(name: string);
  68454. /**
  68455. * Initialize the block and prepare the context for build
  68456. * @param state defines the state that will be used for the build
  68457. */
  68458. initialize(state: NodeMaterialBuildState): void;
  68459. /**
  68460. * Gets the current class name
  68461. * @returns the class name
  68462. */
  68463. getClassName(): string;
  68464. /**
  68465. * Gets the metallic input component
  68466. */
  68467. get metallic(): NodeMaterialConnectionPoint;
  68468. /**
  68469. * Gets the roughness input component
  68470. */
  68471. get roughness(): NodeMaterialConnectionPoint;
  68472. /**
  68473. * Gets the texture input component
  68474. */
  68475. get texture(): NodeMaterialConnectionPoint;
  68476. /**
  68477. * Gets the reflectivity object output component
  68478. */
  68479. get reflectivity(): NodeMaterialConnectionPoint;
  68480. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68481. /**
  68482. * Gets the main code of the block (fragment side)
  68483. * @param state current state of the node material building
  68484. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68485. * @returns the shader code
  68486. */
  68487. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68488. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68489. protected _buildBlock(state: NodeMaterialBuildState): this;
  68490. protected _dumpPropertiesCode(): string;
  68491. serialize(): any;
  68492. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68493. }
  68494. }
  68495. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68496. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68497. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68498. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68499. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68501. /**
  68502. * Block used to implement the anisotropy module of the PBR material
  68503. */
  68504. export class AnisotropyBlock extends NodeMaterialBlock {
  68505. /**
  68506. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68507. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68508. * It's less burden on the user side in the editor part.
  68509. */
  68510. /** @hidden */
  68511. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68512. /** @hidden */
  68513. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68514. /**
  68515. * Create a new AnisotropyBlock
  68516. * @param name defines the block name
  68517. */
  68518. constructor(name: string);
  68519. /**
  68520. * Initialize the block and prepare the context for build
  68521. * @param state defines the state that will be used for the build
  68522. */
  68523. initialize(state: NodeMaterialBuildState): void;
  68524. /**
  68525. * Gets the current class name
  68526. * @returns the class name
  68527. */
  68528. getClassName(): string;
  68529. /**
  68530. * Gets the intensity input component
  68531. */
  68532. get intensity(): NodeMaterialConnectionPoint;
  68533. /**
  68534. * Gets the direction input component
  68535. */
  68536. get direction(): NodeMaterialConnectionPoint;
  68537. /**
  68538. * Gets the texture input component
  68539. */
  68540. get texture(): NodeMaterialConnectionPoint;
  68541. /**
  68542. * Gets the uv input component
  68543. */
  68544. get uv(): NodeMaterialConnectionPoint;
  68545. /**
  68546. * Gets the worldTangent input component
  68547. */
  68548. get worldTangent(): NodeMaterialConnectionPoint;
  68549. /**
  68550. * Gets the anisotropy object output component
  68551. */
  68552. get anisotropy(): NodeMaterialConnectionPoint;
  68553. private _generateTBNSpace;
  68554. /**
  68555. * Gets the main code of the block (fragment side)
  68556. * @param state current state of the node material building
  68557. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68558. * @returns the shader code
  68559. */
  68560. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68562. protected _buildBlock(state: NodeMaterialBuildState): this;
  68563. }
  68564. }
  68565. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68569. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68571. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68572. import { Nullable } from "babylonjs/types";
  68573. import { Mesh } from "babylonjs/Meshes/mesh";
  68574. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68575. import { Effect } from "babylonjs/Materials/effect";
  68576. /**
  68577. * Block used to implement the clear coat module of the PBR material
  68578. */
  68579. export class ClearCoatBlock extends NodeMaterialBlock {
  68580. private _scene;
  68581. /**
  68582. * Create a new ClearCoatBlock
  68583. * @param name defines the block name
  68584. */
  68585. constructor(name: string);
  68586. /**
  68587. * Initialize the block and prepare the context for build
  68588. * @param state defines the state that will be used for the build
  68589. */
  68590. initialize(state: NodeMaterialBuildState): void;
  68591. /**
  68592. * Gets the current class name
  68593. * @returns the class name
  68594. */
  68595. getClassName(): string;
  68596. /**
  68597. * Gets the intensity input component
  68598. */
  68599. get intensity(): NodeMaterialConnectionPoint;
  68600. /**
  68601. * Gets the roughness input component
  68602. */
  68603. get roughness(): NodeMaterialConnectionPoint;
  68604. /**
  68605. * Gets the ior input component
  68606. */
  68607. get ior(): NodeMaterialConnectionPoint;
  68608. /**
  68609. * Gets the texture input component
  68610. */
  68611. get texture(): NodeMaterialConnectionPoint;
  68612. /**
  68613. * Gets the bump texture input component
  68614. */
  68615. get bumpTexture(): NodeMaterialConnectionPoint;
  68616. /**
  68617. * Gets the uv input component
  68618. */
  68619. get uv(): NodeMaterialConnectionPoint;
  68620. /**
  68621. * Gets the tint color input component
  68622. */
  68623. get tintColor(): NodeMaterialConnectionPoint;
  68624. /**
  68625. * Gets the tint "at distance" input component
  68626. */
  68627. get tintAtDistance(): NodeMaterialConnectionPoint;
  68628. /**
  68629. * Gets the tint thickness input component
  68630. */
  68631. get tintThickness(): NodeMaterialConnectionPoint;
  68632. /**
  68633. * Gets the world tangent input component
  68634. */
  68635. get worldTangent(): NodeMaterialConnectionPoint;
  68636. /**
  68637. * Gets the clear coat object output component
  68638. */
  68639. get clearcoat(): NodeMaterialConnectionPoint;
  68640. autoConfigure(material: NodeMaterial): void;
  68641. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68642. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68643. private _generateTBNSpace;
  68644. /**
  68645. * Gets the main code of the block (fragment side)
  68646. * @param state current state of the node material building
  68647. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68648. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68649. * @param worldPosVarName name of the variable holding the world position
  68650. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68651. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68652. * @param worldNormalVarName name of the variable holding the world normal
  68653. * @returns the shader code
  68654. */
  68655. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68656. protected _buildBlock(state: NodeMaterialBuildState): this;
  68657. }
  68658. }
  68659. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68662. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68663. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68665. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68666. import { Nullable } from "babylonjs/types";
  68667. /**
  68668. * Block used to implement the sub surface module of the PBR material
  68669. */
  68670. export class SubSurfaceBlock extends NodeMaterialBlock {
  68671. /**
  68672. * Create a new SubSurfaceBlock
  68673. * @param name defines the block name
  68674. */
  68675. constructor(name: string);
  68676. /**
  68677. * Stores the intensity of the different subsurface effects in the thickness texture.
  68678. * * the green channel is the translucency intensity.
  68679. * * the blue channel is the scattering intensity.
  68680. * * the alpha channel is the refraction intensity.
  68681. */
  68682. useMaskFromThicknessTexture: boolean;
  68683. /**
  68684. * Initialize the block and prepare the context for build
  68685. * @param state defines the state that will be used for the build
  68686. */
  68687. initialize(state: NodeMaterialBuildState): void;
  68688. /**
  68689. * Gets the current class name
  68690. * @returns the class name
  68691. */
  68692. getClassName(): string;
  68693. /**
  68694. * Gets the min thickness input component
  68695. */
  68696. get minThickness(): NodeMaterialConnectionPoint;
  68697. /**
  68698. * Gets the max thickness input component
  68699. */
  68700. get maxThickness(): NodeMaterialConnectionPoint;
  68701. /**
  68702. * Gets the thickness texture component
  68703. */
  68704. get thicknessTexture(): NodeMaterialConnectionPoint;
  68705. /**
  68706. * Gets the tint color input component
  68707. */
  68708. get tintColor(): NodeMaterialConnectionPoint;
  68709. /**
  68710. * Gets the translucency intensity input component
  68711. */
  68712. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68713. /**
  68714. * Gets the translucency diffusion distance input component
  68715. */
  68716. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68717. /**
  68718. * Gets the refraction object parameters
  68719. */
  68720. get refraction(): NodeMaterialConnectionPoint;
  68721. /**
  68722. * Gets the sub surface object output component
  68723. */
  68724. get subsurface(): NodeMaterialConnectionPoint;
  68725. autoConfigure(material: NodeMaterial): void;
  68726. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68727. /**
  68728. * Gets the main code of the block (fragment side)
  68729. * @param state current state of the node material building
  68730. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68731. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68732. * @param worldPosVarName name of the variable holding the world position
  68733. * @returns the shader code
  68734. */
  68735. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68736. protected _buildBlock(state: NodeMaterialBuildState): this;
  68737. }
  68738. }
  68739. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68740. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68741. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68742. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68743. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68744. import { Light } from "babylonjs/Lights/light";
  68745. import { Nullable } from "babylonjs/types";
  68746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68747. import { Effect } from "babylonjs/Materials/effect";
  68748. import { Mesh } from "babylonjs/Meshes/mesh";
  68749. import { Scene } from "babylonjs/scene";
  68750. /**
  68751. * Block used to implement the PBR metallic/roughness model
  68752. */
  68753. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68754. /**
  68755. * Gets or sets the light associated with this block
  68756. */
  68757. light: Nullable<Light>;
  68758. private _lightId;
  68759. private _scene;
  68760. private _environmentBRDFTexture;
  68761. private _environmentBrdfSamplerName;
  68762. private _vNormalWName;
  68763. private _invertNormalName;
  68764. /**
  68765. * Create a new ReflectionBlock
  68766. * @param name defines the block name
  68767. */
  68768. constructor(name: string);
  68769. /**
  68770. * Intensity of the direct lights e.g. the four lights available in your scene.
  68771. * This impacts both the direct diffuse and specular highlights.
  68772. */
  68773. directIntensity: number;
  68774. /**
  68775. * Intensity of the environment e.g. how much the environment will light the object
  68776. * either through harmonics for rough material or through the refelction for shiny ones.
  68777. */
  68778. environmentIntensity: number;
  68779. /**
  68780. * This is a special control allowing the reduction of the specular highlights coming from the
  68781. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68782. */
  68783. specularIntensity: number;
  68784. /**
  68785. * Defines the falloff type used in this material.
  68786. * It by default is Physical.
  68787. */
  68788. lightFalloff: number;
  68789. /**
  68790. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68791. */
  68792. useAlphaFromAlbedoTexture: boolean;
  68793. /**
  68794. * Specifies that alpha test should be used
  68795. */
  68796. useAlphaTest: boolean;
  68797. /**
  68798. * Defines the alpha limits in alpha test mode.
  68799. */
  68800. alphaTestCutoff: number;
  68801. /**
  68802. * Specifies that alpha blending should be used
  68803. */
  68804. useAlphaBlending: boolean;
  68805. /**
  68806. * Defines if the alpha value should be determined via the rgb values.
  68807. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68808. */
  68809. opacityRGB: boolean;
  68810. /**
  68811. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68812. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68813. */
  68814. useRadianceOverAlpha: boolean;
  68815. /**
  68816. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68817. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68818. */
  68819. useSpecularOverAlpha: boolean;
  68820. /**
  68821. * Enables specular anti aliasing in the PBR shader.
  68822. * It will both interacts on the Geometry for analytical and IBL lighting.
  68823. * It also prefilter the roughness map based on the bump values.
  68824. */
  68825. enableSpecularAntiAliasing: boolean;
  68826. /**
  68827. * Enables realtime filtering on the texture.
  68828. */
  68829. realTimeFiltering: boolean;
  68830. /**
  68831. * Quality switch for realtime filtering
  68832. */
  68833. realTimeFilteringQuality: number;
  68834. /**
  68835. * Defines if the material uses energy conservation.
  68836. */
  68837. useEnergyConservation: boolean;
  68838. /**
  68839. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68840. * too much the area relying on ambient texture to define their ambient occlusion.
  68841. */
  68842. useRadianceOcclusion: boolean;
  68843. /**
  68844. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68845. * makes the reflect vector face the model (under horizon).
  68846. */
  68847. useHorizonOcclusion: boolean;
  68848. /**
  68849. * If set to true, no lighting calculations will be applied.
  68850. */
  68851. unlit: boolean;
  68852. /**
  68853. * Force normal to face away from face.
  68854. */
  68855. forceNormalForward: boolean;
  68856. /**
  68857. * Defines the material debug mode.
  68858. * It helps seeing only some components of the material while troubleshooting.
  68859. */
  68860. debugMode: number;
  68861. /**
  68862. * Specify from where on screen the debug mode should start.
  68863. * The value goes from -1 (full screen) to 1 (not visible)
  68864. * It helps with side by side comparison against the final render
  68865. * This defaults to 0
  68866. */
  68867. debugLimit: number;
  68868. /**
  68869. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68870. * You can use the factor to better multiply the final value.
  68871. */
  68872. debugFactor: number;
  68873. /**
  68874. * Initialize the block and prepare the context for build
  68875. * @param state defines the state that will be used for the build
  68876. */
  68877. initialize(state: NodeMaterialBuildState): void;
  68878. /**
  68879. * Gets the current class name
  68880. * @returns the class name
  68881. */
  68882. getClassName(): string;
  68883. /**
  68884. * Gets the world position input component
  68885. */
  68886. get worldPosition(): NodeMaterialConnectionPoint;
  68887. /**
  68888. * Gets the world normal input component
  68889. */
  68890. get worldNormal(): NodeMaterialConnectionPoint;
  68891. /**
  68892. * Gets the perturbed normal input component
  68893. */
  68894. get perturbedNormal(): NodeMaterialConnectionPoint;
  68895. /**
  68896. * Gets the camera position input component
  68897. */
  68898. get cameraPosition(): NodeMaterialConnectionPoint;
  68899. /**
  68900. * Gets the base color input component
  68901. */
  68902. get baseColor(): NodeMaterialConnectionPoint;
  68903. /**
  68904. * Gets the opacity texture input component
  68905. */
  68906. get opacityTexture(): NodeMaterialConnectionPoint;
  68907. /**
  68908. * Gets the ambient color input component
  68909. */
  68910. get ambientColor(): NodeMaterialConnectionPoint;
  68911. /**
  68912. * Gets the reflectivity object parameters
  68913. */
  68914. get reflectivity(): NodeMaterialConnectionPoint;
  68915. /**
  68916. * Gets the ambient occlusion object parameters
  68917. */
  68918. get ambientOcc(): NodeMaterialConnectionPoint;
  68919. /**
  68920. * Gets the reflection object parameters
  68921. */
  68922. get reflection(): NodeMaterialConnectionPoint;
  68923. /**
  68924. * Gets the sheen object parameters
  68925. */
  68926. get sheen(): NodeMaterialConnectionPoint;
  68927. /**
  68928. * Gets the clear coat object parameters
  68929. */
  68930. get clearcoat(): NodeMaterialConnectionPoint;
  68931. /**
  68932. * Gets the sub surface object parameters
  68933. */
  68934. get subsurface(): NodeMaterialConnectionPoint;
  68935. /**
  68936. * Gets the anisotropy object parameters
  68937. */
  68938. get anisotropy(): NodeMaterialConnectionPoint;
  68939. /**
  68940. * Gets the ambient output component
  68941. */
  68942. get ambient(): NodeMaterialConnectionPoint;
  68943. /**
  68944. * Gets the diffuse output component
  68945. */
  68946. get diffuse(): NodeMaterialConnectionPoint;
  68947. /**
  68948. * Gets the specular output component
  68949. */
  68950. get specular(): NodeMaterialConnectionPoint;
  68951. /**
  68952. * Gets the sheen output component
  68953. */
  68954. get sheenDir(): NodeMaterialConnectionPoint;
  68955. /**
  68956. * Gets the clear coat output component
  68957. */
  68958. get clearcoatDir(): NodeMaterialConnectionPoint;
  68959. /**
  68960. * Gets the indirect diffuse output component
  68961. */
  68962. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68963. /**
  68964. * Gets the indirect specular output component
  68965. */
  68966. get specularIndirect(): NodeMaterialConnectionPoint;
  68967. /**
  68968. * Gets the indirect sheen output component
  68969. */
  68970. get sheenIndirect(): NodeMaterialConnectionPoint;
  68971. /**
  68972. * Gets the indirect clear coat output component
  68973. */
  68974. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68975. /**
  68976. * Gets the refraction output component
  68977. */
  68978. get refraction(): NodeMaterialConnectionPoint;
  68979. /**
  68980. * Gets the global lighting output component
  68981. */
  68982. get lighting(): NodeMaterialConnectionPoint;
  68983. /**
  68984. * Gets the shadow output component
  68985. */
  68986. get shadow(): NodeMaterialConnectionPoint;
  68987. /**
  68988. * Gets the alpha output component
  68989. */
  68990. get alpha(): NodeMaterialConnectionPoint;
  68991. autoConfigure(material: NodeMaterial): void;
  68992. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68993. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68994. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68995. private _injectVertexCode;
  68996. /**
  68997. * Gets the code corresponding to the albedo/opacity module
  68998. * @returns the shader code
  68999. */
  69000. getAlbedoOpacityCode(): string;
  69001. protected _buildBlock(state: NodeMaterialBuildState): this;
  69002. protected _dumpPropertiesCode(): string;
  69003. serialize(): any;
  69004. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69005. }
  69006. }
  69007. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69008. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69009. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69010. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  69011. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  69012. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69013. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69014. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69015. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69016. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69017. }
  69018. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69019. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69020. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69021. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69022. }
  69023. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69027. /**
  69028. * Block used to compute value of one parameter modulo another
  69029. */
  69030. export class ModBlock extends NodeMaterialBlock {
  69031. /**
  69032. * Creates a new ModBlock
  69033. * @param name defines the block name
  69034. */
  69035. constructor(name: string);
  69036. /**
  69037. * Gets the current class name
  69038. * @returns the class name
  69039. */
  69040. getClassName(): string;
  69041. /**
  69042. * Gets the left operand input component
  69043. */
  69044. get left(): NodeMaterialConnectionPoint;
  69045. /**
  69046. * Gets the right operand input component
  69047. */
  69048. get right(): NodeMaterialConnectionPoint;
  69049. /**
  69050. * Gets the output component
  69051. */
  69052. get output(): NodeMaterialConnectionPoint;
  69053. protected _buildBlock(state: NodeMaterialBuildState): this;
  69054. }
  69055. }
  69056. declare module "babylonjs/Materials/Node/Blocks/index" {
  69057. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69058. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69059. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69060. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69061. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69062. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69063. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69064. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69065. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69066. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69067. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69068. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69069. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69070. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69071. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69072. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69073. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69074. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69075. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69076. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69077. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69078. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69079. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69080. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69081. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69082. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69083. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69084. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69085. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69086. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69087. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69088. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69089. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69090. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69091. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69092. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69093. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69094. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69095. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69096. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69097. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69098. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69099. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69100. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69101. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69102. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69103. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69104. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69105. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69106. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69107. }
  69108. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69109. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69110. }
  69111. declare module "babylonjs/Materials/Node/index" {
  69112. export * from "babylonjs/Materials/Node/Enums/index";
  69113. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69114. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69115. export * from "babylonjs/Materials/Node/nodeMaterial";
  69116. export * from "babylonjs/Materials/Node/Blocks/index";
  69117. export * from "babylonjs/Materials/Node/Optimizers/index";
  69118. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69119. }
  69120. declare module "babylonjs/Materials/index" {
  69121. export * from "babylonjs/Materials/Background/index";
  69122. export * from "babylonjs/Materials/colorCurves";
  69123. export * from "babylonjs/Materials/iEffectFallbacks";
  69124. export * from "babylonjs/Materials/effectFallbacks";
  69125. export * from "babylonjs/Materials/effect";
  69126. export * from "babylonjs/Materials/fresnelParameters";
  69127. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69128. export * from "babylonjs/Materials/material";
  69129. export * from "babylonjs/Materials/materialDefines";
  69130. export * from "babylonjs/Materials/thinMaterialHelper";
  69131. export * from "babylonjs/Materials/materialHelper";
  69132. export * from "babylonjs/Materials/multiMaterial";
  69133. export * from "babylonjs/Materials/PBR/index";
  69134. export * from "babylonjs/Materials/pushMaterial";
  69135. export * from "babylonjs/Materials/shaderMaterial";
  69136. export * from "babylonjs/Materials/standardMaterial";
  69137. export * from "babylonjs/Materials/Textures/index";
  69138. export * from "babylonjs/Materials/uniformBuffer";
  69139. export * from "babylonjs/Materials/materialFlags";
  69140. export * from "babylonjs/Materials/Node/index";
  69141. export * from "babylonjs/Materials/effectRenderer";
  69142. export * from "babylonjs/Materials/shadowDepthWrapper";
  69143. }
  69144. declare module "babylonjs/Maths/index" {
  69145. export * from "babylonjs/Maths/math.scalar";
  69146. export * from "babylonjs/Maths/math";
  69147. export * from "babylonjs/Maths/sphericalPolynomial";
  69148. }
  69149. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69150. import { IDisposable } from "babylonjs/scene";
  69151. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69152. /**
  69153. * Configuration for Draco compression
  69154. */
  69155. export interface IDracoCompressionConfiguration {
  69156. /**
  69157. * Configuration for the decoder.
  69158. */
  69159. decoder: {
  69160. /**
  69161. * The url to the WebAssembly module.
  69162. */
  69163. wasmUrl?: string;
  69164. /**
  69165. * The url to the WebAssembly binary.
  69166. */
  69167. wasmBinaryUrl?: string;
  69168. /**
  69169. * The url to the fallback JavaScript module.
  69170. */
  69171. fallbackUrl?: string;
  69172. };
  69173. }
  69174. /**
  69175. * Draco compression (https://google.github.io/draco/)
  69176. *
  69177. * This class wraps the Draco module.
  69178. *
  69179. * **Encoder**
  69180. *
  69181. * The encoder is not currently implemented.
  69182. *
  69183. * **Decoder**
  69184. *
  69185. * 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.
  69186. *
  69187. * To update the configuration, use the following code:
  69188. * ```javascript
  69189. * DracoCompression.Configuration = {
  69190. * decoder: {
  69191. * wasmUrl: "<url to the WebAssembly library>",
  69192. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69193. * fallbackUrl: "<url to the fallback JavaScript library>",
  69194. * }
  69195. * };
  69196. * ```
  69197. *
  69198. * 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.
  69199. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69200. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69201. *
  69202. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69203. * ```javascript
  69204. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69205. * ```
  69206. *
  69207. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69208. */
  69209. export class DracoCompression implements IDisposable {
  69210. private _workerPoolPromise?;
  69211. private _decoderModulePromise?;
  69212. /**
  69213. * The configuration. Defaults to the following urls:
  69214. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69215. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69216. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69217. */
  69218. static Configuration: IDracoCompressionConfiguration;
  69219. /**
  69220. * Returns true if the decoder configuration is available.
  69221. */
  69222. static get DecoderAvailable(): boolean;
  69223. /**
  69224. * Default number of workers to create when creating the draco compression object.
  69225. */
  69226. static DefaultNumWorkers: number;
  69227. private static GetDefaultNumWorkers;
  69228. private static _Default;
  69229. /**
  69230. * Default instance for the draco compression object.
  69231. */
  69232. static get Default(): DracoCompression;
  69233. /**
  69234. * Constructor
  69235. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69236. */
  69237. constructor(numWorkers?: number);
  69238. /**
  69239. * Stop all async operations and release resources.
  69240. */
  69241. dispose(): void;
  69242. /**
  69243. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69244. * @returns a promise that resolves when ready
  69245. */
  69246. whenReadyAsync(): Promise<void>;
  69247. /**
  69248. * Decode Draco compressed mesh data to vertex data.
  69249. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69250. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69251. * @returns A promise that resolves with the decoded vertex data
  69252. */
  69253. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69254. [kind: string]: number;
  69255. }): Promise<VertexData>;
  69256. }
  69257. }
  69258. declare module "babylonjs/Meshes/Compression/index" {
  69259. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69260. }
  69261. declare module "babylonjs/Meshes/csg" {
  69262. import { Nullable } from "babylonjs/types";
  69263. import { Scene } from "babylonjs/scene";
  69264. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69265. import { Mesh } from "babylonjs/Meshes/mesh";
  69266. import { Material } from "babylonjs/Materials/material";
  69267. /**
  69268. * Class for building Constructive Solid Geometry
  69269. */
  69270. export class CSG {
  69271. private polygons;
  69272. /**
  69273. * The world matrix
  69274. */
  69275. matrix: Matrix;
  69276. /**
  69277. * Stores the position
  69278. */
  69279. position: Vector3;
  69280. /**
  69281. * Stores the rotation
  69282. */
  69283. rotation: Vector3;
  69284. /**
  69285. * Stores the rotation quaternion
  69286. */
  69287. rotationQuaternion: Nullable<Quaternion>;
  69288. /**
  69289. * Stores the scaling vector
  69290. */
  69291. scaling: Vector3;
  69292. /**
  69293. * Convert the Mesh to CSG
  69294. * @param mesh The Mesh to convert to CSG
  69295. * @returns A new CSG from the Mesh
  69296. */
  69297. static FromMesh(mesh: Mesh): CSG;
  69298. /**
  69299. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69300. * @param polygons Polygons used to construct a CSG solid
  69301. */
  69302. private static FromPolygons;
  69303. /**
  69304. * Clones, or makes a deep copy, of the CSG
  69305. * @returns A new CSG
  69306. */
  69307. clone(): CSG;
  69308. /**
  69309. * Unions this CSG with another CSG
  69310. * @param csg The CSG to union against this CSG
  69311. * @returns The unioned CSG
  69312. */
  69313. union(csg: CSG): CSG;
  69314. /**
  69315. * Unions this CSG with another CSG in place
  69316. * @param csg The CSG to union against this CSG
  69317. */
  69318. unionInPlace(csg: CSG): void;
  69319. /**
  69320. * Subtracts this CSG with another CSG
  69321. * @param csg The CSG to subtract against this CSG
  69322. * @returns A new CSG
  69323. */
  69324. subtract(csg: CSG): CSG;
  69325. /**
  69326. * Subtracts this CSG with another CSG in place
  69327. * @param csg The CSG to subtact against this CSG
  69328. */
  69329. subtractInPlace(csg: CSG): void;
  69330. /**
  69331. * Intersect this CSG with another CSG
  69332. * @param csg The CSG to intersect against this CSG
  69333. * @returns A new CSG
  69334. */
  69335. intersect(csg: CSG): CSG;
  69336. /**
  69337. * Intersects this CSG with another CSG in place
  69338. * @param csg The CSG to intersect against this CSG
  69339. */
  69340. intersectInPlace(csg: CSG): void;
  69341. /**
  69342. * Return a new CSG solid with solid and empty space switched. This solid is
  69343. * not modified.
  69344. * @returns A new CSG solid with solid and empty space switched
  69345. */
  69346. inverse(): CSG;
  69347. /**
  69348. * Inverses the CSG in place
  69349. */
  69350. inverseInPlace(): void;
  69351. /**
  69352. * This is used to keep meshes transformations so they can be restored
  69353. * when we build back a Babylon Mesh
  69354. * NB : All CSG operations are performed in world coordinates
  69355. * @param csg The CSG to copy the transform attributes from
  69356. * @returns This CSG
  69357. */
  69358. copyTransformAttributes(csg: CSG): CSG;
  69359. /**
  69360. * Build Raw mesh from CSG
  69361. * Coordinates here are in world space
  69362. * @param name The name of the mesh geometry
  69363. * @param scene The Scene
  69364. * @param keepSubMeshes Specifies if the submeshes should be kept
  69365. * @returns A new Mesh
  69366. */
  69367. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69368. /**
  69369. * Build Mesh from CSG taking material and transforms into account
  69370. * @param name The name of the Mesh
  69371. * @param material The material of the Mesh
  69372. * @param scene The Scene
  69373. * @param keepSubMeshes Specifies if submeshes should be kept
  69374. * @returns The new Mesh
  69375. */
  69376. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69377. }
  69378. }
  69379. declare module "babylonjs/Meshes/trailMesh" {
  69380. import { Mesh } from "babylonjs/Meshes/mesh";
  69381. import { Scene } from "babylonjs/scene";
  69382. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69383. /**
  69384. * Class used to create a trail following a mesh
  69385. */
  69386. export class TrailMesh extends Mesh {
  69387. private _generator;
  69388. private _autoStart;
  69389. private _running;
  69390. private _diameter;
  69391. private _length;
  69392. private _sectionPolygonPointsCount;
  69393. private _sectionVectors;
  69394. private _sectionNormalVectors;
  69395. private _beforeRenderObserver;
  69396. /**
  69397. * @constructor
  69398. * @param name The value used by scene.getMeshByName() to do a lookup.
  69399. * @param generator The mesh or transform node to generate a trail.
  69400. * @param scene The scene to add this mesh to.
  69401. * @param diameter Diameter of trailing mesh. Default is 1.
  69402. * @param length Length of trailing mesh. Default is 60.
  69403. * @param autoStart Automatically start trailing mesh. Default true.
  69404. */
  69405. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69406. /**
  69407. * "TrailMesh"
  69408. * @returns "TrailMesh"
  69409. */
  69410. getClassName(): string;
  69411. private _createMesh;
  69412. /**
  69413. * Start trailing mesh.
  69414. */
  69415. start(): void;
  69416. /**
  69417. * Stop trailing mesh.
  69418. */
  69419. stop(): void;
  69420. /**
  69421. * Update trailing mesh geometry.
  69422. */
  69423. update(): void;
  69424. /**
  69425. * Returns a new TrailMesh object.
  69426. * @param name is a string, the name given to the new mesh
  69427. * @param newGenerator use new generator object for cloned trail mesh
  69428. * @returns a new mesh
  69429. */
  69430. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69431. /**
  69432. * Serializes this trail mesh
  69433. * @param serializationObject object to write serialization to
  69434. */
  69435. serialize(serializationObject: any): void;
  69436. /**
  69437. * Parses a serialized trail mesh
  69438. * @param parsedMesh the serialized mesh
  69439. * @param scene the scene to create the trail mesh in
  69440. * @returns the created trail mesh
  69441. */
  69442. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69443. }
  69444. }
  69445. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69446. import { Nullable } from "babylonjs/types";
  69447. import { Scene } from "babylonjs/scene";
  69448. import { Vector4 } from "babylonjs/Maths/math.vector";
  69449. import { Color4 } from "babylonjs/Maths/math.color";
  69450. import { Mesh } from "babylonjs/Meshes/mesh";
  69451. /**
  69452. * Class containing static functions to help procedurally build meshes
  69453. */
  69454. export class TiledBoxBuilder {
  69455. /**
  69456. * Creates a box mesh
  69457. * 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)
  69458. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69462. * @param name defines the name of the mesh
  69463. * @param options defines the options used to create the mesh
  69464. * @param scene defines the hosting scene
  69465. * @returns the box mesh
  69466. */
  69467. static CreateTiledBox(name: string, options: {
  69468. pattern?: number;
  69469. width?: number;
  69470. height?: number;
  69471. depth?: number;
  69472. tileSize?: number;
  69473. tileWidth?: number;
  69474. tileHeight?: number;
  69475. alignHorizontal?: number;
  69476. alignVertical?: number;
  69477. faceUV?: Vector4[];
  69478. faceColors?: Color4[];
  69479. sideOrientation?: number;
  69480. updatable?: boolean;
  69481. }, scene?: Nullable<Scene>): Mesh;
  69482. }
  69483. }
  69484. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69485. import { Vector4 } from "babylonjs/Maths/math.vector";
  69486. import { Mesh } from "babylonjs/Meshes/mesh";
  69487. /**
  69488. * Class containing static functions to help procedurally build meshes
  69489. */
  69490. export class TorusKnotBuilder {
  69491. /**
  69492. * Creates a torus knot mesh
  69493. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69494. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69495. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69496. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69500. * @param name defines the name of the mesh
  69501. * @param options defines the options used to create the mesh
  69502. * @param scene defines the hosting scene
  69503. * @returns the torus knot mesh
  69504. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69505. */
  69506. static CreateTorusKnot(name: string, options: {
  69507. radius?: number;
  69508. tube?: number;
  69509. radialSegments?: number;
  69510. tubularSegments?: number;
  69511. p?: number;
  69512. q?: number;
  69513. updatable?: boolean;
  69514. sideOrientation?: number;
  69515. frontUVs?: Vector4;
  69516. backUVs?: Vector4;
  69517. }, scene: any): Mesh;
  69518. }
  69519. }
  69520. declare module "babylonjs/Meshes/polygonMesh" {
  69521. import { Scene } from "babylonjs/scene";
  69522. import { Vector2 } from "babylonjs/Maths/math.vector";
  69523. import { Mesh } from "babylonjs/Meshes/mesh";
  69524. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69525. import { Path2 } from "babylonjs/Maths/math.path";
  69526. /**
  69527. * Polygon
  69528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69529. */
  69530. export class Polygon {
  69531. /**
  69532. * Creates a rectangle
  69533. * @param xmin bottom X coord
  69534. * @param ymin bottom Y coord
  69535. * @param xmax top X coord
  69536. * @param ymax top Y coord
  69537. * @returns points that make the resulting rectation
  69538. */
  69539. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69540. /**
  69541. * Creates a circle
  69542. * @param radius radius of circle
  69543. * @param cx scale in x
  69544. * @param cy scale in y
  69545. * @param numberOfSides number of sides that make up the circle
  69546. * @returns points that make the resulting circle
  69547. */
  69548. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69549. /**
  69550. * Creates a polygon from input string
  69551. * @param input Input polygon data
  69552. * @returns the parsed points
  69553. */
  69554. static Parse(input: string): Vector2[];
  69555. /**
  69556. * Starts building a polygon from x and y coordinates
  69557. * @param x x coordinate
  69558. * @param y y coordinate
  69559. * @returns the started path2
  69560. */
  69561. static StartingAt(x: number, y: number): Path2;
  69562. }
  69563. /**
  69564. * Builds a polygon
  69565. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69566. */
  69567. export class PolygonMeshBuilder {
  69568. private _points;
  69569. private _outlinepoints;
  69570. private _holes;
  69571. private _name;
  69572. private _scene;
  69573. private _epoints;
  69574. private _eholes;
  69575. private _addToepoint;
  69576. /**
  69577. * Babylon reference to the earcut plugin.
  69578. */
  69579. bjsEarcut: any;
  69580. /**
  69581. * Creates a PolygonMeshBuilder
  69582. * @param name name of the builder
  69583. * @param contours Path of the polygon
  69584. * @param scene scene to add to when creating the mesh
  69585. * @param earcutInjection can be used to inject your own earcut reference
  69586. */
  69587. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69588. /**
  69589. * Adds a whole within the polygon
  69590. * @param hole Array of points defining the hole
  69591. * @returns this
  69592. */
  69593. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69594. /**
  69595. * Creates the polygon
  69596. * @param updatable If the mesh should be updatable
  69597. * @param depth The depth of the mesh created
  69598. * @returns the created mesh
  69599. */
  69600. build(updatable?: boolean, depth?: number): Mesh;
  69601. /**
  69602. * Creates the polygon
  69603. * @param depth The depth of the mesh created
  69604. * @returns the created VertexData
  69605. */
  69606. buildVertexData(depth?: number): VertexData;
  69607. /**
  69608. * Adds a side to the polygon
  69609. * @param positions points that make the polygon
  69610. * @param normals normals of the polygon
  69611. * @param uvs uvs of the polygon
  69612. * @param indices indices of the polygon
  69613. * @param bounds bounds of the polygon
  69614. * @param points points of the polygon
  69615. * @param depth depth of the polygon
  69616. * @param flip flip of the polygon
  69617. */
  69618. private addSide;
  69619. }
  69620. }
  69621. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69622. import { Scene } from "babylonjs/scene";
  69623. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69624. import { Color4 } from "babylonjs/Maths/math.color";
  69625. import { Mesh } from "babylonjs/Meshes/mesh";
  69626. import { Nullable } from "babylonjs/types";
  69627. /**
  69628. * Class containing static functions to help procedurally build meshes
  69629. */
  69630. export class PolygonBuilder {
  69631. /**
  69632. * Creates a polygon mesh
  69633. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69634. * * 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
  69635. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69638. * * Remember you can only change the shape positions, not their number when updating a polygon
  69639. * @param name defines the name of the mesh
  69640. * @param options defines the options used to create the mesh
  69641. * @param scene defines the hosting scene
  69642. * @param earcutInjection can be used to inject your own earcut reference
  69643. * @returns the polygon mesh
  69644. */
  69645. static CreatePolygon(name: string, options: {
  69646. shape: Vector3[];
  69647. holes?: Vector3[][];
  69648. depth?: number;
  69649. faceUV?: Vector4[];
  69650. faceColors?: Color4[];
  69651. updatable?: boolean;
  69652. sideOrientation?: number;
  69653. frontUVs?: Vector4;
  69654. backUVs?: Vector4;
  69655. wrap?: boolean;
  69656. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69657. /**
  69658. * Creates an extruded polygon mesh, with depth in the Y direction.
  69659. * * 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)
  69660. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69661. * @param name defines the name of the mesh
  69662. * @param options defines the options used to create the mesh
  69663. * @param scene defines the hosting scene
  69664. * @param earcutInjection can be used to inject your own earcut reference
  69665. * @returns the polygon mesh
  69666. */
  69667. static ExtrudePolygon(name: string, options: {
  69668. shape: Vector3[];
  69669. holes?: Vector3[][];
  69670. depth?: number;
  69671. faceUV?: Vector4[];
  69672. faceColors?: Color4[];
  69673. updatable?: boolean;
  69674. sideOrientation?: number;
  69675. frontUVs?: Vector4;
  69676. backUVs?: Vector4;
  69677. wrap?: boolean;
  69678. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69679. }
  69680. }
  69681. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69682. import { Scene } from "babylonjs/scene";
  69683. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69684. import { Mesh } from "babylonjs/Meshes/mesh";
  69685. import { Nullable } from "babylonjs/types";
  69686. /**
  69687. * Class containing static functions to help procedurally build meshes
  69688. */
  69689. export class LatheBuilder {
  69690. /**
  69691. * Creates lathe mesh.
  69692. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69693. * * 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
  69694. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69695. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69696. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69697. * * 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
  69698. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69699. * * 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
  69700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69702. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69704. * @param name defines the name of the mesh
  69705. * @param options defines the options used to create the mesh
  69706. * @param scene defines the hosting scene
  69707. * @returns the lathe mesh
  69708. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69709. */
  69710. static CreateLathe(name: string, options: {
  69711. shape: Vector3[];
  69712. radius?: number;
  69713. tessellation?: number;
  69714. clip?: number;
  69715. arc?: number;
  69716. closed?: boolean;
  69717. updatable?: boolean;
  69718. sideOrientation?: number;
  69719. frontUVs?: Vector4;
  69720. backUVs?: Vector4;
  69721. cap?: number;
  69722. invertUV?: boolean;
  69723. }, scene?: Nullable<Scene>): Mesh;
  69724. }
  69725. }
  69726. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69727. import { Nullable } from "babylonjs/types";
  69728. import { Scene } from "babylonjs/scene";
  69729. import { Vector4 } from "babylonjs/Maths/math.vector";
  69730. import { Mesh } from "babylonjs/Meshes/mesh";
  69731. /**
  69732. * Class containing static functions to help procedurally build meshes
  69733. */
  69734. export class TiledPlaneBuilder {
  69735. /**
  69736. * Creates a tiled plane mesh
  69737. * * The parameter `pattern` will, depending on value, do nothing or
  69738. * * * flip (reflect about central vertical) alternate tiles across and up
  69739. * * * flip every tile on alternate rows
  69740. * * * rotate (180 degs) alternate tiles across and up
  69741. * * * rotate every tile on alternate rows
  69742. * * * flip and rotate alternate tiles across and up
  69743. * * * flip and rotate every tile on alternate rows
  69744. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69745. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69748. * * 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)
  69749. * * 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)
  69750. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69751. * @param name defines the name of the mesh
  69752. * @param options defines the options used to create the mesh
  69753. * @param scene defines the hosting scene
  69754. * @returns the box mesh
  69755. */
  69756. static CreateTiledPlane(name: string, options: {
  69757. pattern?: number;
  69758. tileSize?: number;
  69759. tileWidth?: number;
  69760. tileHeight?: number;
  69761. size?: number;
  69762. width?: number;
  69763. height?: number;
  69764. alignHorizontal?: number;
  69765. alignVertical?: number;
  69766. sideOrientation?: number;
  69767. frontUVs?: Vector4;
  69768. backUVs?: Vector4;
  69769. updatable?: boolean;
  69770. }, scene?: Nullable<Scene>): Mesh;
  69771. }
  69772. }
  69773. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69774. import { Nullable } from "babylonjs/types";
  69775. import { Scene } from "babylonjs/scene";
  69776. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69777. import { Mesh } from "babylonjs/Meshes/mesh";
  69778. /**
  69779. * Class containing static functions to help procedurally build meshes
  69780. */
  69781. export class TubeBuilder {
  69782. /**
  69783. * Creates a tube mesh.
  69784. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69785. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69786. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69787. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69788. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69789. * * 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)
  69790. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69791. * * 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
  69792. * * 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
  69793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69795. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69797. * @param name defines the name of the mesh
  69798. * @param options defines the options used to create the mesh
  69799. * @param scene defines the hosting scene
  69800. * @returns the tube mesh
  69801. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69802. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69803. */
  69804. static CreateTube(name: string, options: {
  69805. path: Vector3[];
  69806. radius?: number;
  69807. tessellation?: number;
  69808. radiusFunction?: {
  69809. (i: number, distance: number): number;
  69810. };
  69811. cap?: number;
  69812. arc?: number;
  69813. updatable?: boolean;
  69814. sideOrientation?: number;
  69815. frontUVs?: Vector4;
  69816. backUVs?: Vector4;
  69817. instance?: Mesh;
  69818. invertUV?: boolean;
  69819. }, scene?: Nullable<Scene>): Mesh;
  69820. }
  69821. }
  69822. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69823. import { Scene } from "babylonjs/scene";
  69824. import { Vector4 } from "babylonjs/Maths/math.vector";
  69825. import { Mesh } from "babylonjs/Meshes/mesh";
  69826. import { Nullable } from "babylonjs/types";
  69827. /**
  69828. * Class containing static functions to help procedurally build meshes
  69829. */
  69830. export class IcoSphereBuilder {
  69831. /**
  69832. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69833. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69834. * * 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`)
  69835. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69836. * * 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
  69837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69840. * @param name defines the name of the mesh
  69841. * @param options defines the options used to create the mesh
  69842. * @param scene defines the hosting scene
  69843. * @returns the icosahedron mesh
  69844. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69845. */
  69846. static CreateIcoSphere(name: string, options: {
  69847. radius?: number;
  69848. radiusX?: number;
  69849. radiusY?: number;
  69850. radiusZ?: number;
  69851. flat?: boolean;
  69852. subdivisions?: number;
  69853. sideOrientation?: number;
  69854. frontUVs?: Vector4;
  69855. backUVs?: Vector4;
  69856. updatable?: boolean;
  69857. }, scene?: Nullable<Scene>): Mesh;
  69858. }
  69859. }
  69860. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69861. import { Vector3 } from "babylonjs/Maths/math.vector";
  69862. import { Mesh } from "babylonjs/Meshes/mesh";
  69863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69864. /**
  69865. * Class containing static functions to help procedurally build meshes
  69866. */
  69867. export class DecalBuilder {
  69868. /**
  69869. * Creates a decal mesh.
  69870. * 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
  69871. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69872. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69873. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69874. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69875. * @param name defines the name of the mesh
  69876. * @param sourceMesh defines the mesh where the decal must be applied
  69877. * @param options defines the options used to create the mesh
  69878. * @param scene defines the hosting scene
  69879. * @returns the decal mesh
  69880. * @see https://doc.babylonjs.com/how_to/decals
  69881. */
  69882. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69883. position?: Vector3;
  69884. normal?: Vector3;
  69885. size?: Vector3;
  69886. angle?: number;
  69887. }): Mesh;
  69888. }
  69889. }
  69890. declare module "babylonjs/Meshes/meshBuilder" {
  69891. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69892. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69893. import { Nullable } from "babylonjs/types";
  69894. import { Scene } from "babylonjs/scene";
  69895. import { Mesh } from "babylonjs/Meshes/mesh";
  69896. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69897. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69899. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69900. import { Plane } from "babylonjs/Maths/math.plane";
  69901. /**
  69902. * Class containing static functions to help procedurally build meshes
  69903. */
  69904. export class MeshBuilder {
  69905. /**
  69906. * Creates a box mesh
  69907. * * The parameter `size` sets the size (float) of each box side (default 1)
  69908. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69909. * * 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)
  69910. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69914. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69915. * @param name defines the name of the mesh
  69916. * @param options defines the options used to create the mesh
  69917. * @param scene defines the hosting scene
  69918. * @returns the box mesh
  69919. */
  69920. static CreateBox(name: string, options: {
  69921. size?: number;
  69922. width?: number;
  69923. height?: number;
  69924. depth?: number;
  69925. faceUV?: Vector4[];
  69926. faceColors?: Color4[];
  69927. sideOrientation?: number;
  69928. frontUVs?: Vector4;
  69929. backUVs?: Vector4;
  69930. wrap?: boolean;
  69931. topBaseAt?: number;
  69932. bottomBaseAt?: number;
  69933. updatable?: boolean;
  69934. }, scene?: Nullable<Scene>): Mesh;
  69935. /**
  69936. * Creates a tiled box mesh
  69937. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69939. * @param name defines the name of the mesh
  69940. * @param options defines the options used to create the mesh
  69941. * @param scene defines the hosting scene
  69942. * @returns the tiled box mesh
  69943. */
  69944. static CreateTiledBox(name: string, options: {
  69945. pattern?: number;
  69946. size?: number;
  69947. width?: number;
  69948. height?: number;
  69949. depth: number;
  69950. tileSize?: number;
  69951. tileWidth?: number;
  69952. tileHeight?: number;
  69953. faceUV?: Vector4[];
  69954. faceColors?: Color4[];
  69955. alignHorizontal?: number;
  69956. alignVertical?: number;
  69957. sideOrientation?: number;
  69958. updatable?: boolean;
  69959. }, scene?: Nullable<Scene>): Mesh;
  69960. /**
  69961. * Creates a sphere mesh
  69962. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69963. * * 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`)
  69964. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69965. * * 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
  69966. * * 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)
  69967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69970. * @param name defines the name of the mesh
  69971. * @param options defines the options used to create the mesh
  69972. * @param scene defines the hosting scene
  69973. * @returns the sphere mesh
  69974. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69975. */
  69976. static CreateSphere(name: string, options: {
  69977. segments?: number;
  69978. diameter?: number;
  69979. diameterX?: number;
  69980. diameterY?: number;
  69981. diameterZ?: number;
  69982. arc?: number;
  69983. slice?: number;
  69984. sideOrientation?: number;
  69985. frontUVs?: Vector4;
  69986. backUVs?: Vector4;
  69987. updatable?: boolean;
  69988. }, scene?: Nullable<Scene>): Mesh;
  69989. /**
  69990. * Creates a plane polygonal mesh. By default, this is a disc
  69991. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69992. * * 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
  69993. * * 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
  69994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69997. * @param name defines the name of the mesh
  69998. * @param options defines the options used to create the mesh
  69999. * @param scene defines the hosting scene
  70000. * @returns the plane polygonal mesh
  70001. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70002. */
  70003. static CreateDisc(name: string, options: {
  70004. radius?: number;
  70005. tessellation?: number;
  70006. arc?: number;
  70007. updatable?: boolean;
  70008. sideOrientation?: number;
  70009. frontUVs?: Vector4;
  70010. backUVs?: Vector4;
  70011. }, scene?: Nullable<Scene>): Mesh;
  70012. /**
  70013. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70014. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70015. * * 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`)
  70016. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70017. * * 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
  70018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70021. * @param name defines the name of the mesh
  70022. * @param options defines the options used to create the mesh
  70023. * @param scene defines the hosting scene
  70024. * @returns the icosahedron mesh
  70025. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70026. */
  70027. static CreateIcoSphere(name: string, options: {
  70028. radius?: number;
  70029. radiusX?: number;
  70030. radiusY?: number;
  70031. radiusZ?: number;
  70032. flat?: boolean;
  70033. subdivisions?: number;
  70034. sideOrientation?: number;
  70035. frontUVs?: Vector4;
  70036. backUVs?: Vector4;
  70037. updatable?: boolean;
  70038. }, scene?: Nullable<Scene>): Mesh;
  70039. /**
  70040. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70041. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70042. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70043. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70044. * * 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
  70045. * * 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
  70046. * * 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
  70047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70049. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70050. * * 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
  70051. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70052. * * 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
  70053. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70055. * @param name defines the name of the mesh
  70056. * @param options defines the options used to create the mesh
  70057. * @param scene defines the hosting scene
  70058. * @returns the ribbon mesh
  70059. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70060. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70061. */
  70062. static CreateRibbon(name: string, options: {
  70063. pathArray: Vector3[][];
  70064. closeArray?: boolean;
  70065. closePath?: boolean;
  70066. offset?: number;
  70067. updatable?: boolean;
  70068. sideOrientation?: number;
  70069. frontUVs?: Vector4;
  70070. backUVs?: Vector4;
  70071. instance?: Mesh;
  70072. invertUV?: boolean;
  70073. uvs?: Vector2[];
  70074. colors?: Color4[];
  70075. }, scene?: Nullable<Scene>): Mesh;
  70076. /**
  70077. * Creates a cylinder or a cone mesh
  70078. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70079. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70080. * * 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.
  70081. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70082. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70083. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70084. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70085. * * 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).
  70086. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70087. * * 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).
  70088. * * 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
  70089. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70090. * * 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
  70091. * * 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.
  70092. * * If `enclose` is false, a ring surface is one element.
  70093. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70094. * * 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
  70095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70098. * @param name defines the name of the mesh
  70099. * @param options defines the options used to create the mesh
  70100. * @param scene defines the hosting scene
  70101. * @returns the cylinder mesh
  70102. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70103. */
  70104. static CreateCylinder(name: string, options: {
  70105. height?: number;
  70106. diameterTop?: number;
  70107. diameterBottom?: number;
  70108. diameter?: number;
  70109. tessellation?: number;
  70110. subdivisions?: number;
  70111. arc?: number;
  70112. faceColors?: Color4[];
  70113. faceUV?: Vector4[];
  70114. updatable?: boolean;
  70115. hasRings?: boolean;
  70116. enclose?: boolean;
  70117. cap?: number;
  70118. sideOrientation?: number;
  70119. frontUVs?: Vector4;
  70120. backUVs?: Vector4;
  70121. }, scene?: Nullable<Scene>): Mesh;
  70122. /**
  70123. * Creates a torus mesh
  70124. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70125. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70126. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70130. * @param name defines the name of the mesh
  70131. * @param options defines the options used to create the mesh
  70132. * @param scene defines the hosting scene
  70133. * @returns the torus mesh
  70134. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70135. */
  70136. static CreateTorus(name: string, options: {
  70137. diameter?: number;
  70138. thickness?: number;
  70139. tessellation?: number;
  70140. updatable?: boolean;
  70141. sideOrientation?: number;
  70142. frontUVs?: Vector4;
  70143. backUVs?: Vector4;
  70144. }, scene?: Nullable<Scene>): Mesh;
  70145. /**
  70146. * Creates a torus knot mesh
  70147. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70148. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70149. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70150. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70154. * @param name defines the name of the mesh
  70155. * @param options defines the options used to create the mesh
  70156. * @param scene defines the hosting scene
  70157. * @returns the torus knot mesh
  70158. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70159. */
  70160. static CreateTorusKnot(name: string, options: {
  70161. radius?: number;
  70162. tube?: number;
  70163. radialSegments?: number;
  70164. tubularSegments?: number;
  70165. p?: number;
  70166. q?: number;
  70167. updatable?: boolean;
  70168. sideOrientation?: number;
  70169. frontUVs?: Vector4;
  70170. backUVs?: Vector4;
  70171. }, scene?: Nullable<Scene>): Mesh;
  70172. /**
  70173. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70174. * * 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
  70175. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70176. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70177. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70178. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70179. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70180. * * 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
  70181. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70183. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70184. * @param name defines the name of the new line system
  70185. * @param options defines the options used to create the line system
  70186. * @param scene defines the hosting scene
  70187. * @returns a new line system mesh
  70188. */
  70189. static CreateLineSystem(name: string, options: {
  70190. lines: Vector3[][];
  70191. updatable?: boolean;
  70192. instance?: Nullable<LinesMesh>;
  70193. colors?: Nullable<Color4[][]>;
  70194. useVertexAlpha?: boolean;
  70195. }, scene: Nullable<Scene>): LinesMesh;
  70196. /**
  70197. * Creates a line mesh
  70198. * 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
  70199. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70200. * * The parameter `points` is an array successive Vector3
  70201. * * 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
  70202. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70203. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70204. * * When updating an instance, remember that only point positions can change, not the number of points
  70205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70207. * @param name defines the name of the new line system
  70208. * @param options defines the options used to create the line system
  70209. * @param scene defines the hosting scene
  70210. * @returns a new line mesh
  70211. */
  70212. static CreateLines(name: string, options: {
  70213. points: Vector3[];
  70214. updatable?: boolean;
  70215. instance?: Nullable<LinesMesh>;
  70216. colors?: Color4[];
  70217. useVertexAlpha?: boolean;
  70218. }, scene?: Nullable<Scene>): LinesMesh;
  70219. /**
  70220. * Creates a dashed line mesh
  70221. * * 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
  70222. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70223. * * The parameter `points` is an array successive Vector3
  70224. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70225. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70226. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70227. * * 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
  70228. * * When updating an instance, remember that only point positions can change, not the number of points
  70229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70230. * @param name defines the name of the mesh
  70231. * @param options defines the options used to create the mesh
  70232. * @param scene defines the hosting scene
  70233. * @returns the dashed line mesh
  70234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70235. */
  70236. static CreateDashedLines(name: string, options: {
  70237. points: Vector3[];
  70238. dashSize?: number;
  70239. gapSize?: number;
  70240. dashNb?: number;
  70241. updatable?: boolean;
  70242. instance?: LinesMesh;
  70243. }, scene?: Nullable<Scene>): LinesMesh;
  70244. /**
  70245. * 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.
  70246. * * 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.
  70247. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70248. * * 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.
  70249. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70250. * * 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
  70251. * * 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
  70252. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70257. * @param name defines the name of the mesh
  70258. * @param options defines the options used to create the mesh
  70259. * @param scene defines the hosting scene
  70260. * @returns the extruded shape mesh
  70261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70263. */
  70264. static ExtrudeShape(name: string, options: {
  70265. shape: Vector3[];
  70266. path: Vector3[];
  70267. scale?: number;
  70268. rotation?: number;
  70269. cap?: number;
  70270. updatable?: boolean;
  70271. sideOrientation?: number;
  70272. frontUVs?: Vector4;
  70273. backUVs?: Vector4;
  70274. instance?: Mesh;
  70275. invertUV?: boolean;
  70276. }, scene?: Nullable<Scene>): Mesh;
  70277. /**
  70278. * Creates an custom extruded shape mesh.
  70279. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70280. * * 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.
  70281. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70282. * * 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
  70283. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70284. * * 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
  70285. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70286. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70287. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70288. * * 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
  70289. * * 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
  70290. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70293. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70295. * @param name defines the name of the mesh
  70296. * @param options defines the options used to create the mesh
  70297. * @param scene defines the hosting scene
  70298. * @returns the custom extruded shape mesh
  70299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70302. */
  70303. static ExtrudeShapeCustom(name: string, options: {
  70304. shape: Vector3[];
  70305. path: Vector3[];
  70306. scaleFunction?: any;
  70307. rotationFunction?: any;
  70308. ribbonCloseArray?: boolean;
  70309. ribbonClosePath?: boolean;
  70310. cap?: number;
  70311. updatable?: boolean;
  70312. sideOrientation?: number;
  70313. frontUVs?: Vector4;
  70314. backUVs?: Vector4;
  70315. instance?: Mesh;
  70316. invertUV?: boolean;
  70317. }, scene?: Nullable<Scene>): Mesh;
  70318. /**
  70319. * Creates lathe mesh.
  70320. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70321. * * 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
  70322. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70323. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70324. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70325. * * 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
  70326. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70327. * * 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
  70328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70330. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70332. * @param name defines the name of the mesh
  70333. * @param options defines the options used to create the mesh
  70334. * @param scene defines the hosting scene
  70335. * @returns the lathe mesh
  70336. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70337. */
  70338. static CreateLathe(name: string, options: {
  70339. shape: Vector3[];
  70340. radius?: number;
  70341. tessellation?: number;
  70342. clip?: number;
  70343. arc?: number;
  70344. closed?: boolean;
  70345. updatable?: boolean;
  70346. sideOrientation?: number;
  70347. frontUVs?: Vector4;
  70348. backUVs?: Vector4;
  70349. cap?: number;
  70350. invertUV?: boolean;
  70351. }, scene?: Nullable<Scene>): Mesh;
  70352. /**
  70353. * Creates a tiled plane mesh
  70354. * * You can set a limited pattern arrangement with the tiles
  70355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70358. * @param name defines the name of the mesh
  70359. * @param options defines the options used to create the mesh
  70360. * @param scene defines the hosting scene
  70361. * @returns the plane mesh
  70362. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70363. */
  70364. static CreateTiledPlane(name: string, options: {
  70365. pattern?: number;
  70366. tileSize?: number;
  70367. tileWidth?: number;
  70368. tileHeight?: number;
  70369. size?: number;
  70370. width?: number;
  70371. height?: number;
  70372. alignHorizontal?: number;
  70373. alignVertical?: number;
  70374. sideOrientation?: number;
  70375. frontUVs?: Vector4;
  70376. backUVs?: Vector4;
  70377. updatable?: boolean;
  70378. }, scene?: Nullable<Scene>): Mesh;
  70379. /**
  70380. * Creates a plane mesh
  70381. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70382. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70383. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70387. * @param name defines the name of the mesh
  70388. * @param options defines the options used to create the mesh
  70389. * @param scene defines the hosting scene
  70390. * @returns the plane mesh
  70391. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70392. */
  70393. static CreatePlane(name: string, options: {
  70394. size?: number;
  70395. width?: number;
  70396. height?: number;
  70397. sideOrientation?: number;
  70398. frontUVs?: Vector4;
  70399. backUVs?: Vector4;
  70400. updatable?: boolean;
  70401. sourcePlane?: Plane;
  70402. }, scene?: Nullable<Scene>): Mesh;
  70403. /**
  70404. * Creates a ground mesh
  70405. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70406. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70408. * @param name defines the name of the mesh
  70409. * @param options defines the options used to create the mesh
  70410. * @param scene defines the hosting scene
  70411. * @returns the ground mesh
  70412. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70413. */
  70414. static CreateGround(name: string, options: {
  70415. width?: number;
  70416. height?: number;
  70417. subdivisions?: number;
  70418. subdivisionsX?: number;
  70419. subdivisionsY?: number;
  70420. updatable?: boolean;
  70421. }, scene?: Nullable<Scene>): Mesh;
  70422. /**
  70423. * Creates a tiled ground mesh
  70424. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70425. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70426. * * 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
  70427. * * 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
  70428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70429. * @param name defines the name of the mesh
  70430. * @param options defines the options used to create the mesh
  70431. * @param scene defines the hosting scene
  70432. * @returns the tiled ground mesh
  70433. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70434. */
  70435. static CreateTiledGround(name: string, options: {
  70436. xmin: number;
  70437. zmin: number;
  70438. xmax: number;
  70439. zmax: number;
  70440. subdivisions?: {
  70441. w: number;
  70442. h: number;
  70443. };
  70444. precision?: {
  70445. w: number;
  70446. h: number;
  70447. };
  70448. updatable?: boolean;
  70449. }, scene?: Nullable<Scene>): Mesh;
  70450. /**
  70451. * Creates a ground mesh from a height map
  70452. * * The parameter `url` sets the URL of the height map image resource.
  70453. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70454. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70455. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70456. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70457. * * 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.
  70458. * * 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).
  70459. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70461. * @param name defines the name of the mesh
  70462. * @param url defines the url to the height map
  70463. * @param options defines the options used to create the mesh
  70464. * @param scene defines the hosting scene
  70465. * @returns the ground mesh
  70466. * @see https://doc.babylonjs.com/babylon101/height_map
  70467. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70468. */
  70469. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70470. width?: number;
  70471. height?: number;
  70472. subdivisions?: number;
  70473. minHeight?: number;
  70474. maxHeight?: number;
  70475. colorFilter?: Color3;
  70476. alphaFilter?: number;
  70477. updatable?: boolean;
  70478. onReady?: (mesh: GroundMesh) => void;
  70479. }, scene?: Nullable<Scene>): GroundMesh;
  70480. /**
  70481. * Creates a polygon mesh
  70482. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70483. * * 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
  70484. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70487. * * Remember you can only change the shape positions, not their number when updating a polygon
  70488. * @param name defines the name of the mesh
  70489. * @param options defines the options used to create the mesh
  70490. * @param scene defines the hosting scene
  70491. * @param earcutInjection can be used to inject your own earcut reference
  70492. * @returns the polygon mesh
  70493. */
  70494. static CreatePolygon(name: string, options: {
  70495. shape: Vector3[];
  70496. holes?: Vector3[][];
  70497. depth?: number;
  70498. faceUV?: Vector4[];
  70499. faceColors?: Color4[];
  70500. updatable?: boolean;
  70501. sideOrientation?: number;
  70502. frontUVs?: Vector4;
  70503. backUVs?: Vector4;
  70504. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70505. /**
  70506. * Creates an extruded polygon mesh, with depth in the Y direction.
  70507. * * 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)
  70508. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70509. * @param name defines the name of the mesh
  70510. * @param options defines the options used to create the mesh
  70511. * @param scene defines the hosting scene
  70512. * @param earcutInjection can be used to inject your own earcut reference
  70513. * @returns the polygon mesh
  70514. */
  70515. static ExtrudePolygon(name: string, options: {
  70516. shape: Vector3[];
  70517. holes?: Vector3[][];
  70518. depth?: number;
  70519. faceUV?: Vector4[];
  70520. faceColors?: Color4[];
  70521. updatable?: boolean;
  70522. sideOrientation?: number;
  70523. frontUVs?: Vector4;
  70524. backUVs?: Vector4;
  70525. wrap?: boolean;
  70526. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70527. /**
  70528. * Creates a tube mesh.
  70529. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70530. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70531. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70532. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70533. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70534. * * 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)
  70535. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70536. * * 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
  70537. * * 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
  70538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70540. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70542. * @param name defines the name of the mesh
  70543. * @param options defines the options used to create the mesh
  70544. * @param scene defines the hosting scene
  70545. * @returns the tube mesh
  70546. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70547. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70548. */
  70549. static CreateTube(name: string, options: {
  70550. path: Vector3[];
  70551. radius?: number;
  70552. tessellation?: number;
  70553. radiusFunction?: {
  70554. (i: number, distance: number): number;
  70555. };
  70556. cap?: number;
  70557. arc?: number;
  70558. updatable?: boolean;
  70559. sideOrientation?: number;
  70560. frontUVs?: Vector4;
  70561. backUVs?: Vector4;
  70562. instance?: Mesh;
  70563. invertUV?: boolean;
  70564. }, scene?: Nullable<Scene>): Mesh;
  70565. /**
  70566. * Creates a polyhedron mesh
  70567. * * 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
  70568. * * The parameter `size` (positive float, default 1) sets the polygon size
  70569. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70570. * * 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`
  70571. * * 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
  70572. * * 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)`)
  70573. * * 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
  70574. * * 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
  70575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70578. * @param name defines the name of the mesh
  70579. * @param options defines the options used to create the mesh
  70580. * @param scene defines the hosting scene
  70581. * @returns the polyhedron mesh
  70582. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70583. */
  70584. static CreatePolyhedron(name: string, options: {
  70585. type?: number;
  70586. size?: number;
  70587. sizeX?: number;
  70588. sizeY?: number;
  70589. sizeZ?: number;
  70590. custom?: any;
  70591. faceUV?: Vector4[];
  70592. faceColors?: Color4[];
  70593. flat?: boolean;
  70594. updatable?: boolean;
  70595. sideOrientation?: number;
  70596. frontUVs?: Vector4;
  70597. backUVs?: Vector4;
  70598. }, scene?: Nullable<Scene>): Mesh;
  70599. /**
  70600. * Creates a decal mesh.
  70601. * 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
  70602. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70603. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70604. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70605. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70606. * @param name defines the name of the mesh
  70607. * @param sourceMesh defines the mesh where the decal must be applied
  70608. * @param options defines the options used to create the mesh
  70609. * @param scene defines the hosting scene
  70610. * @returns the decal mesh
  70611. * @see https://doc.babylonjs.com/how_to/decals
  70612. */
  70613. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70614. position?: Vector3;
  70615. normal?: Vector3;
  70616. size?: Vector3;
  70617. angle?: number;
  70618. }): Mesh;
  70619. /**
  70620. * Creates a Capsule Mesh
  70621. * @param name defines the name of the mesh.
  70622. * @param options the constructors options used to shape the mesh.
  70623. * @param scene defines the scene the mesh is scoped to.
  70624. * @returns the capsule mesh
  70625. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70626. */
  70627. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70628. }
  70629. }
  70630. declare module "babylonjs/Meshes/meshSimplification" {
  70631. import { Mesh } from "babylonjs/Meshes/mesh";
  70632. /**
  70633. * A simplifier interface for future simplification implementations
  70634. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70635. */
  70636. export interface ISimplifier {
  70637. /**
  70638. * Simplification of a given mesh according to the given settings.
  70639. * Since this requires computation, it is assumed that the function runs async.
  70640. * @param settings The settings of the simplification, including quality and distance
  70641. * @param successCallback A callback that will be called after the mesh was simplified.
  70642. * @param errorCallback in case of an error, this callback will be called. optional.
  70643. */
  70644. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70645. }
  70646. /**
  70647. * Expected simplification settings.
  70648. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70649. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70650. */
  70651. export interface ISimplificationSettings {
  70652. /**
  70653. * Gets or sets the expected quality
  70654. */
  70655. quality: number;
  70656. /**
  70657. * Gets or sets the distance when this optimized version should be used
  70658. */
  70659. distance: number;
  70660. /**
  70661. * Gets an already optimized mesh
  70662. */
  70663. optimizeMesh?: boolean;
  70664. }
  70665. /**
  70666. * Class used to specify simplification options
  70667. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70668. */
  70669. export class SimplificationSettings implements ISimplificationSettings {
  70670. /** expected quality */
  70671. quality: number;
  70672. /** distance when this optimized version should be used */
  70673. distance: number;
  70674. /** already optimized mesh */
  70675. optimizeMesh?: boolean | undefined;
  70676. /**
  70677. * Creates a SimplificationSettings
  70678. * @param quality expected quality
  70679. * @param distance distance when this optimized version should be used
  70680. * @param optimizeMesh already optimized mesh
  70681. */
  70682. constructor(
  70683. /** expected quality */
  70684. quality: number,
  70685. /** distance when this optimized version should be used */
  70686. distance: number,
  70687. /** already optimized mesh */
  70688. optimizeMesh?: boolean | undefined);
  70689. }
  70690. /**
  70691. * Interface used to define a simplification task
  70692. */
  70693. export interface ISimplificationTask {
  70694. /**
  70695. * Array of settings
  70696. */
  70697. settings: Array<ISimplificationSettings>;
  70698. /**
  70699. * Simplification type
  70700. */
  70701. simplificationType: SimplificationType;
  70702. /**
  70703. * Mesh to simplify
  70704. */
  70705. mesh: Mesh;
  70706. /**
  70707. * Callback called on success
  70708. */
  70709. successCallback?: () => void;
  70710. /**
  70711. * Defines if parallel processing can be used
  70712. */
  70713. parallelProcessing: boolean;
  70714. }
  70715. /**
  70716. * Queue used to order the simplification tasks
  70717. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70718. */
  70719. export class SimplificationQueue {
  70720. private _simplificationArray;
  70721. /**
  70722. * Gets a boolean indicating that the process is still running
  70723. */
  70724. running: boolean;
  70725. /**
  70726. * Creates a new queue
  70727. */
  70728. constructor();
  70729. /**
  70730. * Adds a new simplification task
  70731. * @param task defines a task to add
  70732. */
  70733. addTask(task: ISimplificationTask): void;
  70734. /**
  70735. * Execute next task
  70736. */
  70737. executeNext(): void;
  70738. /**
  70739. * Execute a simplification task
  70740. * @param task defines the task to run
  70741. */
  70742. runSimplification(task: ISimplificationTask): void;
  70743. private getSimplifier;
  70744. }
  70745. /**
  70746. * The implemented types of simplification
  70747. * At the moment only Quadratic Error Decimation is implemented
  70748. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70749. */
  70750. export enum SimplificationType {
  70751. /** Quadratic error decimation */
  70752. QUADRATIC = 0
  70753. }
  70754. /**
  70755. * An implementation of the Quadratic Error simplification algorithm.
  70756. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70757. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70758. * @author RaananW
  70759. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70760. */
  70761. export class QuadraticErrorSimplification implements ISimplifier {
  70762. private _mesh;
  70763. private triangles;
  70764. private vertices;
  70765. private references;
  70766. private _reconstructedMesh;
  70767. /** Gets or sets the number pf sync interations */
  70768. syncIterations: number;
  70769. /** Gets or sets the aggressiveness of the simplifier */
  70770. aggressiveness: number;
  70771. /** Gets or sets the number of allowed iterations for decimation */
  70772. decimationIterations: number;
  70773. /** Gets or sets the espilon to use for bounding box computation */
  70774. boundingBoxEpsilon: number;
  70775. /**
  70776. * Creates a new QuadraticErrorSimplification
  70777. * @param _mesh defines the target mesh
  70778. */
  70779. constructor(_mesh: Mesh);
  70780. /**
  70781. * Simplification of a given mesh according to the given settings.
  70782. * Since this requires computation, it is assumed that the function runs async.
  70783. * @param settings The settings of the simplification, including quality and distance
  70784. * @param successCallback A callback that will be called after the mesh was simplified.
  70785. */
  70786. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70787. private runDecimation;
  70788. private initWithMesh;
  70789. private init;
  70790. private reconstructMesh;
  70791. private initDecimatedMesh;
  70792. private isFlipped;
  70793. private updateTriangles;
  70794. private identifyBorder;
  70795. private updateMesh;
  70796. private vertexError;
  70797. private calculateError;
  70798. }
  70799. }
  70800. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70801. import { Scene } from "babylonjs/scene";
  70802. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70803. import { ISceneComponent } from "babylonjs/sceneComponent";
  70804. module "babylonjs/scene" {
  70805. interface Scene {
  70806. /** @hidden (Backing field) */
  70807. _simplificationQueue: SimplificationQueue;
  70808. /**
  70809. * Gets or sets the simplification queue attached to the scene
  70810. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70811. */
  70812. simplificationQueue: SimplificationQueue;
  70813. }
  70814. }
  70815. module "babylonjs/Meshes/mesh" {
  70816. interface Mesh {
  70817. /**
  70818. * Simplify the mesh according to the given array of settings.
  70819. * Function will return immediately and will simplify async
  70820. * @param settings a collection of simplification settings
  70821. * @param parallelProcessing should all levels calculate parallel or one after the other
  70822. * @param simplificationType the type of simplification to run
  70823. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70824. * @returns the current mesh
  70825. */
  70826. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70827. }
  70828. }
  70829. /**
  70830. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70831. * created in a scene
  70832. */
  70833. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70834. /**
  70835. * The component name helpfull to identify the component in the list of scene components.
  70836. */
  70837. readonly name: string;
  70838. /**
  70839. * The scene the component belongs to.
  70840. */
  70841. scene: Scene;
  70842. /**
  70843. * Creates a new instance of the component for the given scene
  70844. * @param scene Defines the scene to register the component in
  70845. */
  70846. constructor(scene: Scene);
  70847. /**
  70848. * Registers the component in a given scene
  70849. */
  70850. register(): void;
  70851. /**
  70852. * Rebuilds the elements related to this component in case of
  70853. * context lost for instance.
  70854. */
  70855. rebuild(): void;
  70856. /**
  70857. * Disposes the component and the associated ressources
  70858. */
  70859. dispose(): void;
  70860. private _beforeCameraUpdate;
  70861. }
  70862. }
  70863. declare module "babylonjs/Meshes/Builders/index" {
  70864. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70865. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70866. export * from "babylonjs/Meshes/Builders/discBuilder";
  70867. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70868. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70869. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70870. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70871. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70872. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70873. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70874. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70875. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70876. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70877. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70878. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70879. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70880. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70881. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70882. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70883. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70884. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70885. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70886. }
  70887. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70888. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70889. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70890. import { Matrix } from "babylonjs/Maths/math.vector";
  70891. module "babylonjs/Meshes/mesh" {
  70892. interface Mesh {
  70893. /**
  70894. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70895. */
  70896. thinInstanceEnablePicking: boolean;
  70897. /**
  70898. * Creates a new thin instance
  70899. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70900. * @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
  70901. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70902. */
  70903. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70904. /**
  70905. * Adds the transformation (matrix) of the current mesh as a thin instance
  70906. * @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
  70907. * @returns the thin instance index number
  70908. */
  70909. thinInstanceAddSelf(refresh: boolean): number;
  70910. /**
  70911. * Registers a custom attribute to be used with thin instances
  70912. * @param kind name of the attribute
  70913. * @param stride size in floats of the attribute
  70914. */
  70915. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70916. /**
  70917. * Sets the matrix of a thin instance
  70918. * @param index index of the thin instance
  70919. * @param matrix matrix to set
  70920. * @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
  70921. */
  70922. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70923. /**
  70924. * Sets the value of a custom attribute for a thin instance
  70925. * @param kind name of the attribute
  70926. * @param index index of the thin instance
  70927. * @param value value to set
  70928. * @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
  70929. */
  70930. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70931. /**
  70932. * 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.
  70933. */
  70934. thinInstanceCount: number;
  70935. /**
  70936. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70937. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70938. * @param buffer buffer to set
  70939. * @param stride size in floats of each value of the buffer
  70940. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70941. */
  70942. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70943. /**
  70944. * Gets the list of world matrices
  70945. * @return an array containing all the world matrices from the thin instances
  70946. */
  70947. thinInstanceGetWorldMatrices(): Matrix[];
  70948. /**
  70949. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70950. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70951. */
  70952. thinInstanceBufferUpdated(kind: string): void;
  70953. /**
  70954. * Applies a partial update to a buffer directly on the GPU
  70955. * 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
  70956. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70957. * @param data the data to set in the GPU buffer
  70958. * @param offset the offset in the GPU buffer where to update the data
  70959. */
  70960. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70961. /**
  70962. * Refreshes the bounding info, taking into account all the thin instances defined
  70963. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70964. */
  70965. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70966. /** @hidden */
  70967. _thinInstanceInitializeUserStorage(): void;
  70968. /** @hidden */
  70969. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70970. /** @hidden */
  70971. _userThinInstanceBuffersStorage: {
  70972. data: {
  70973. [key: string]: Float32Array;
  70974. };
  70975. sizes: {
  70976. [key: string]: number;
  70977. };
  70978. vertexBuffers: {
  70979. [key: string]: Nullable<VertexBuffer>;
  70980. };
  70981. strides: {
  70982. [key: string]: number;
  70983. };
  70984. };
  70985. }
  70986. }
  70987. }
  70988. declare module "babylonjs/Meshes/index" {
  70989. export * from "babylonjs/Meshes/abstractMesh";
  70990. export * from "babylonjs/Meshes/buffer";
  70991. export * from "babylonjs/Meshes/Compression/index";
  70992. export * from "babylonjs/Meshes/csg";
  70993. export * from "babylonjs/Meshes/geometry";
  70994. export * from "babylonjs/Meshes/groundMesh";
  70995. export * from "babylonjs/Meshes/trailMesh";
  70996. export * from "babylonjs/Meshes/instancedMesh";
  70997. export * from "babylonjs/Meshes/linesMesh";
  70998. export * from "babylonjs/Meshes/mesh";
  70999. export * from "babylonjs/Meshes/mesh.vertexData";
  71000. export * from "babylonjs/Meshes/meshBuilder";
  71001. export * from "babylonjs/Meshes/meshSimplification";
  71002. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71003. export * from "babylonjs/Meshes/polygonMesh";
  71004. export * from "babylonjs/Meshes/subMesh";
  71005. export * from "babylonjs/Meshes/meshLODLevel";
  71006. export * from "babylonjs/Meshes/transformNode";
  71007. export * from "babylonjs/Meshes/Builders/index";
  71008. export * from "babylonjs/Meshes/dataBuffer";
  71009. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71010. import "babylonjs/Meshes/thinInstanceMesh";
  71011. export * from "babylonjs/Meshes/thinInstanceMesh";
  71012. }
  71013. declare module "babylonjs/Morph/index" {
  71014. export * from "babylonjs/Morph/morphTarget";
  71015. export * from "babylonjs/Morph/morphTargetManager";
  71016. }
  71017. declare module "babylonjs/Navigation/INavigationEngine" {
  71018. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71019. import { Vector3 } from "babylonjs/Maths/math";
  71020. import { Mesh } from "babylonjs/Meshes/mesh";
  71021. import { Scene } from "babylonjs/scene";
  71022. /**
  71023. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71024. */
  71025. export interface INavigationEnginePlugin {
  71026. /**
  71027. * plugin name
  71028. */
  71029. name: string;
  71030. /**
  71031. * Creates a navigation mesh
  71032. * @param meshes array of all the geometry used to compute the navigatio mesh
  71033. * @param parameters bunch of parameters used to filter geometry
  71034. */
  71035. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71036. /**
  71037. * Create a navigation mesh debug mesh
  71038. * @param scene is where the mesh will be added
  71039. * @returns debug display mesh
  71040. */
  71041. createDebugNavMesh(scene: Scene): Mesh;
  71042. /**
  71043. * Get a navigation mesh constrained position, closest to the parameter position
  71044. * @param position world position
  71045. * @returns the closest point to position constrained by the navigation mesh
  71046. */
  71047. getClosestPoint(position: Vector3): Vector3;
  71048. /**
  71049. * Get a navigation mesh constrained position, closest to the parameter position
  71050. * @param position world position
  71051. * @param result output the closest point to position constrained by the navigation mesh
  71052. */
  71053. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71054. /**
  71055. * Get a navigation mesh constrained position, within a particular radius
  71056. * @param position world position
  71057. * @param maxRadius the maximum distance to the constrained world position
  71058. * @returns the closest point to position constrained by the navigation mesh
  71059. */
  71060. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71061. /**
  71062. * Get a navigation mesh constrained position, within a particular radius
  71063. * @param position world position
  71064. * @param maxRadius the maximum distance to the constrained world position
  71065. * @param result output the closest point to position constrained by the navigation mesh
  71066. */
  71067. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71068. /**
  71069. * Compute the final position from a segment made of destination-position
  71070. * @param position world position
  71071. * @param destination world position
  71072. * @returns the resulting point along the navmesh
  71073. */
  71074. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71075. /**
  71076. * Compute the final position from a segment made of destination-position
  71077. * @param position world position
  71078. * @param destination world position
  71079. * @param result output the resulting point along the navmesh
  71080. */
  71081. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71082. /**
  71083. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71084. * @param start world position
  71085. * @param end world position
  71086. * @returns array containing world position composing the path
  71087. */
  71088. computePath(start: Vector3, end: Vector3): Vector3[];
  71089. /**
  71090. * If this plugin is supported
  71091. * @returns true if plugin is supported
  71092. */
  71093. isSupported(): boolean;
  71094. /**
  71095. * Create a new Crowd so you can add agents
  71096. * @param maxAgents the maximum agent count in the crowd
  71097. * @param maxAgentRadius the maximum radius an agent can have
  71098. * @param scene to attach the crowd to
  71099. * @returns the crowd you can add agents to
  71100. */
  71101. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71102. /**
  71103. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71104. * The queries will try to find a solution within those bounds
  71105. * default is (1,1,1)
  71106. * @param extent x,y,z value that define the extent around the queries point of reference
  71107. */
  71108. setDefaultQueryExtent(extent: Vector3): void;
  71109. /**
  71110. * Get the Bounding box extent specified by setDefaultQueryExtent
  71111. * @returns the box extent values
  71112. */
  71113. getDefaultQueryExtent(): Vector3;
  71114. /**
  71115. * build the navmesh from a previously saved state using getNavmeshData
  71116. * @param data the Uint8Array returned by getNavmeshData
  71117. */
  71118. buildFromNavmeshData(data: Uint8Array): void;
  71119. /**
  71120. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71121. * @returns data the Uint8Array that can be saved and reused
  71122. */
  71123. getNavmeshData(): Uint8Array;
  71124. /**
  71125. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71126. * @param result output the box extent values
  71127. */
  71128. getDefaultQueryExtentToRef(result: Vector3): void;
  71129. /**
  71130. * Release all resources
  71131. */
  71132. dispose(): void;
  71133. }
  71134. /**
  71135. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71136. */
  71137. export interface ICrowd {
  71138. /**
  71139. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71140. * You can attach anything to that node. The node position is updated in the scene update tick.
  71141. * @param pos world position that will be constrained by the navigation mesh
  71142. * @param parameters agent parameters
  71143. * @param transform hooked to the agent that will be update by the scene
  71144. * @returns agent index
  71145. */
  71146. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71147. /**
  71148. * Returns the agent position in world space
  71149. * @param index agent index returned by addAgent
  71150. * @returns world space position
  71151. */
  71152. getAgentPosition(index: number): Vector3;
  71153. /**
  71154. * Gets the agent position result in world space
  71155. * @param index agent index returned by addAgent
  71156. * @param result output world space position
  71157. */
  71158. getAgentPositionToRef(index: number, result: Vector3): void;
  71159. /**
  71160. * Gets the agent velocity in world space
  71161. * @param index agent index returned by addAgent
  71162. * @returns world space velocity
  71163. */
  71164. getAgentVelocity(index: number): Vector3;
  71165. /**
  71166. * Gets the agent velocity result in world space
  71167. * @param index agent index returned by addAgent
  71168. * @param result output world space velocity
  71169. */
  71170. getAgentVelocityToRef(index: number, result: Vector3): void;
  71171. /**
  71172. * remove a particular agent previously created
  71173. * @param index agent index returned by addAgent
  71174. */
  71175. removeAgent(index: number): void;
  71176. /**
  71177. * get the list of all agents attached to this crowd
  71178. * @returns list of agent indices
  71179. */
  71180. getAgents(): number[];
  71181. /**
  71182. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71183. * @param deltaTime in seconds
  71184. */
  71185. update(deltaTime: number): void;
  71186. /**
  71187. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71188. * @param index agent index returned by addAgent
  71189. * @param destination targeted world position
  71190. */
  71191. agentGoto(index: number, destination: Vector3): void;
  71192. /**
  71193. * Teleport the agent to a new position
  71194. * @param index agent index returned by addAgent
  71195. * @param destination targeted world position
  71196. */
  71197. agentTeleport(index: number, destination: Vector3): void;
  71198. /**
  71199. * Update agent parameters
  71200. * @param index agent index returned by addAgent
  71201. * @param parameters agent parameters
  71202. */
  71203. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71204. /**
  71205. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71206. * The queries will try to find a solution within those bounds
  71207. * default is (1,1,1)
  71208. * @param extent x,y,z value that define the extent around the queries point of reference
  71209. */
  71210. setDefaultQueryExtent(extent: Vector3): void;
  71211. /**
  71212. * Get the Bounding box extent specified by setDefaultQueryExtent
  71213. * @returns the box extent values
  71214. */
  71215. getDefaultQueryExtent(): Vector3;
  71216. /**
  71217. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71218. * @param result output the box extent values
  71219. */
  71220. getDefaultQueryExtentToRef(result: Vector3): void;
  71221. /**
  71222. * Release all resources
  71223. */
  71224. dispose(): void;
  71225. }
  71226. /**
  71227. * Configures an agent
  71228. */
  71229. export interface IAgentParameters {
  71230. /**
  71231. * Agent radius. [Limit: >= 0]
  71232. */
  71233. radius: number;
  71234. /**
  71235. * Agent height. [Limit: > 0]
  71236. */
  71237. height: number;
  71238. /**
  71239. * Maximum allowed acceleration. [Limit: >= 0]
  71240. */
  71241. maxAcceleration: number;
  71242. /**
  71243. * Maximum allowed speed. [Limit: >= 0]
  71244. */
  71245. maxSpeed: number;
  71246. /**
  71247. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71248. */
  71249. collisionQueryRange: number;
  71250. /**
  71251. * The path visibility optimization range. [Limit: > 0]
  71252. */
  71253. pathOptimizationRange: number;
  71254. /**
  71255. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71256. */
  71257. separationWeight: number;
  71258. }
  71259. /**
  71260. * Configures the navigation mesh creation
  71261. */
  71262. export interface INavMeshParameters {
  71263. /**
  71264. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71265. */
  71266. cs: number;
  71267. /**
  71268. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71269. */
  71270. ch: number;
  71271. /**
  71272. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71273. */
  71274. walkableSlopeAngle: number;
  71275. /**
  71276. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71277. * be considered walkable. [Limit: >= 3] [Units: vx]
  71278. */
  71279. walkableHeight: number;
  71280. /**
  71281. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71282. */
  71283. walkableClimb: number;
  71284. /**
  71285. * The distance to erode/shrink the walkable area of the heightfield away from
  71286. * obstructions. [Limit: >=0] [Units: vx]
  71287. */
  71288. walkableRadius: number;
  71289. /**
  71290. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71291. */
  71292. maxEdgeLen: number;
  71293. /**
  71294. * The maximum distance a simplfied contour's border edges should deviate
  71295. * the original raw contour. [Limit: >=0] [Units: vx]
  71296. */
  71297. maxSimplificationError: number;
  71298. /**
  71299. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71300. */
  71301. minRegionArea: number;
  71302. /**
  71303. * Any regions with a span count smaller than this value will, if possible,
  71304. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71305. */
  71306. mergeRegionArea: number;
  71307. /**
  71308. * The maximum number of vertices allowed for polygons generated during the
  71309. * contour to polygon conversion process. [Limit: >= 3]
  71310. */
  71311. maxVertsPerPoly: number;
  71312. /**
  71313. * Sets the sampling distance to use when generating the detail mesh.
  71314. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71315. */
  71316. detailSampleDist: number;
  71317. /**
  71318. * The maximum distance the detail mesh surface should deviate from heightfield
  71319. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71320. */
  71321. detailSampleMaxError: number;
  71322. }
  71323. }
  71324. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71325. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71326. import { Mesh } from "babylonjs/Meshes/mesh";
  71327. import { Scene } from "babylonjs/scene";
  71328. import { Vector3 } from "babylonjs/Maths/math";
  71329. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71330. /**
  71331. * RecastJS navigation plugin
  71332. */
  71333. export class RecastJSPlugin implements INavigationEnginePlugin {
  71334. /**
  71335. * Reference to the Recast library
  71336. */
  71337. bjsRECAST: any;
  71338. /**
  71339. * plugin name
  71340. */
  71341. name: string;
  71342. /**
  71343. * the first navmesh created. We might extend this to support multiple navmeshes
  71344. */
  71345. navMesh: any;
  71346. /**
  71347. * Initializes the recastJS plugin
  71348. * @param recastInjection can be used to inject your own recast reference
  71349. */
  71350. constructor(recastInjection?: any);
  71351. /**
  71352. * Creates a navigation mesh
  71353. * @param meshes array of all the geometry used to compute the navigatio mesh
  71354. * @param parameters bunch of parameters used to filter geometry
  71355. */
  71356. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71357. /**
  71358. * Create a navigation mesh debug mesh
  71359. * @param scene is where the mesh will be added
  71360. * @returns debug display mesh
  71361. */
  71362. createDebugNavMesh(scene: Scene): Mesh;
  71363. /**
  71364. * Get a navigation mesh constrained position, closest to the parameter position
  71365. * @param position world position
  71366. * @returns the closest point to position constrained by the navigation mesh
  71367. */
  71368. getClosestPoint(position: Vector3): Vector3;
  71369. /**
  71370. * Get a navigation mesh constrained position, closest to the parameter position
  71371. * @param position world position
  71372. * @param result output the closest point to position constrained by the navigation mesh
  71373. */
  71374. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71375. /**
  71376. * Get a navigation mesh constrained position, within a particular radius
  71377. * @param position world position
  71378. * @param maxRadius the maximum distance to the constrained world position
  71379. * @returns the closest point to position constrained by the navigation mesh
  71380. */
  71381. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71382. /**
  71383. * Get a navigation mesh constrained position, within a particular radius
  71384. * @param position world position
  71385. * @param maxRadius the maximum distance to the constrained world position
  71386. * @param result output the closest point to position constrained by the navigation mesh
  71387. */
  71388. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71389. /**
  71390. * Compute the final position from a segment made of destination-position
  71391. * @param position world position
  71392. * @param destination world position
  71393. * @returns the resulting point along the navmesh
  71394. */
  71395. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71396. /**
  71397. * Compute the final position from a segment made of destination-position
  71398. * @param position world position
  71399. * @param destination world position
  71400. * @param result output the resulting point along the navmesh
  71401. */
  71402. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71403. /**
  71404. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71405. * @param start world position
  71406. * @param end world position
  71407. * @returns array containing world position composing the path
  71408. */
  71409. computePath(start: Vector3, end: Vector3): Vector3[];
  71410. /**
  71411. * Create a new Crowd so you can add agents
  71412. * @param maxAgents the maximum agent count in the crowd
  71413. * @param maxAgentRadius the maximum radius an agent can have
  71414. * @param scene to attach the crowd to
  71415. * @returns the crowd you can add agents to
  71416. */
  71417. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71418. /**
  71419. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71420. * The queries will try to find a solution within those bounds
  71421. * default is (1,1,1)
  71422. * @param extent x,y,z value that define the extent around the queries point of reference
  71423. */
  71424. setDefaultQueryExtent(extent: Vector3): void;
  71425. /**
  71426. * Get the Bounding box extent specified by setDefaultQueryExtent
  71427. * @returns the box extent values
  71428. */
  71429. getDefaultQueryExtent(): Vector3;
  71430. /**
  71431. * build the navmesh from a previously saved state using getNavmeshData
  71432. * @param data the Uint8Array returned by getNavmeshData
  71433. */
  71434. buildFromNavmeshData(data: Uint8Array): void;
  71435. /**
  71436. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71437. * @returns data the Uint8Array that can be saved and reused
  71438. */
  71439. getNavmeshData(): Uint8Array;
  71440. /**
  71441. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71442. * @param result output the box extent values
  71443. */
  71444. getDefaultQueryExtentToRef(result: Vector3): void;
  71445. /**
  71446. * Disposes
  71447. */
  71448. dispose(): void;
  71449. /**
  71450. * If this plugin is supported
  71451. * @returns true if plugin is supported
  71452. */
  71453. isSupported(): boolean;
  71454. }
  71455. /**
  71456. * Recast detour crowd implementation
  71457. */
  71458. export class RecastJSCrowd implements ICrowd {
  71459. /**
  71460. * Recast/detour plugin
  71461. */
  71462. bjsRECASTPlugin: RecastJSPlugin;
  71463. /**
  71464. * Link to the detour crowd
  71465. */
  71466. recastCrowd: any;
  71467. /**
  71468. * One transform per agent
  71469. */
  71470. transforms: TransformNode[];
  71471. /**
  71472. * All agents created
  71473. */
  71474. agents: number[];
  71475. /**
  71476. * Link to the scene is kept to unregister the crowd from the scene
  71477. */
  71478. private _scene;
  71479. /**
  71480. * Observer for crowd updates
  71481. */
  71482. private _onBeforeAnimationsObserver;
  71483. /**
  71484. * Constructor
  71485. * @param plugin recastJS plugin
  71486. * @param maxAgents the maximum agent count in the crowd
  71487. * @param maxAgentRadius the maximum radius an agent can have
  71488. * @param scene to attach the crowd to
  71489. * @returns the crowd you can add agents to
  71490. */
  71491. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71492. /**
  71493. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71494. * You can attach anything to that node. The node position is updated in the scene update tick.
  71495. * @param pos world position that will be constrained by the navigation mesh
  71496. * @param parameters agent parameters
  71497. * @param transform hooked to the agent that will be update by the scene
  71498. * @returns agent index
  71499. */
  71500. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71501. /**
  71502. * Returns the agent position in world space
  71503. * @param index agent index returned by addAgent
  71504. * @returns world space position
  71505. */
  71506. getAgentPosition(index: number): Vector3;
  71507. /**
  71508. * Returns the agent position result in world space
  71509. * @param index agent index returned by addAgent
  71510. * @param result output world space position
  71511. */
  71512. getAgentPositionToRef(index: number, result: Vector3): void;
  71513. /**
  71514. * Returns the agent velocity in world space
  71515. * @param index agent index returned by addAgent
  71516. * @returns world space velocity
  71517. */
  71518. getAgentVelocity(index: number): Vector3;
  71519. /**
  71520. * Returns the agent velocity result in world space
  71521. * @param index agent index returned by addAgent
  71522. * @param result output world space velocity
  71523. */
  71524. getAgentVelocityToRef(index: number, result: Vector3): void;
  71525. /**
  71526. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71527. * @param index agent index returned by addAgent
  71528. * @param destination targeted world position
  71529. */
  71530. agentGoto(index: number, destination: Vector3): void;
  71531. /**
  71532. * Teleport the agent to a new position
  71533. * @param index agent index returned by addAgent
  71534. * @param destination targeted world position
  71535. */
  71536. agentTeleport(index: number, destination: Vector3): void;
  71537. /**
  71538. * Update agent parameters
  71539. * @param index agent index returned by addAgent
  71540. * @param parameters agent parameters
  71541. */
  71542. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71543. /**
  71544. * remove a particular agent previously created
  71545. * @param index agent index returned by addAgent
  71546. */
  71547. removeAgent(index: number): void;
  71548. /**
  71549. * get the list of all agents attached to this crowd
  71550. * @returns list of agent indices
  71551. */
  71552. getAgents(): number[];
  71553. /**
  71554. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71555. * @param deltaTime in seconds
  71556. */
  71557. update(deltaTime: number): void;
  71558. /**
  71559. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71560. * The queries will try to find a solution within those bounds
  71561. * default is (1,1,1)
  71562. * @param extent x,y,z value that define the extent around the queries point of reference
  71563. */
  71564. setDefaultQueryExtent(extent: Vector3): void;
  71565. /**
  71566. * Get the Bounding box extent specified by setDefaultQueryExtent
  71567. * @returns the box extent values
  71568. */
  71569. getDefaultQueryExtent(): Vector3;
  71570. /**
  71571. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71572. * @param result output the box extent values
  71573. */
  71574. getDefaultQueryExtentToRef(result: Vector3): void;
  71575. /**
  71576. * Release all resources
  71577. */
  71578. dispose(): void;
  71579. }
  71580. }
  71581. declare module "babylonjs/Navigation/Plugins/index" {
  71582. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71583. }
  71584. declare module "babylonjs/Navigation/index" {
  71585. export * from "babylonjs/Navigation/INavigationEngine";
  71586. export * from "babylonjs/Navigation/Plugins/index";
  71587. }
  71588. declare module "babylonjs/Offline/database" {
  71589. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71590. /**
  71591. * Class used to enable access to IndexedDB
  71592. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71593. */
  71594. export class Database implements IOfflineProvider {
  71595. private _callbackManifestChecked;
  71596. private _currentSceneUrl;
  71597. private _db;
  71598. private _enableSceneOffline;
  71599. private _enableTexturesOffline;
  71600. private _manifestVersionFound;
  71601. private _mustUpdateRessources;
  71602. private _hasReachedQuota;
  71603. private _isSupported;
  71604. private _idbFactory;
  71605. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71606. private static IsUASupportingBlobStorage;
  71607. /**
  71608. * Gets a boolean indicating if Database storate is enabled (off by default)
  71609. */
  71610. static IDBStorageEnabled: boolean;
  71611. /**
  71612. * Gets a boolean indicating if scene must be saved in the database
  71613. */
  71614. get enableSceneOffline(): boolean;
  71615. /**
  71616. * Gets a boolean indicating if textures must be saved in the database
  71617. */
  71618. get enableTexturesOffline(): boolean;
  71619. /**
  71620. * Creates a new Database
  71621. * @param urlToScene defines the url to load the scene
  71622. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71623. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71624. */
  71625. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71626. private static _ParseURL;
  71627. private static _ReturnFullUrlLocation;
  71628. private _checkManifestFile;
  71629. /**
  71630. * Open the database and make it available
  71631. * @param successCallback defines the callback to call on success
  71632. * @param errorCallback defines the callback to call on error
  71633. */
  71634. open(successCallback: () => void, errorCallback: () => void): void;
  71635. /**
  71636. * Loads an image from the database
  71637. * @param url defines the url to load from
  71638. * @param image defines the target DOM image
  71639. */
  71640. loadImage(url: string, image: HTMLImageElement): void;
  71641. private _loadImageFromDBAsync;
  71642. private _saveImageIntoDBAsync;
  71643. private _checkVersionFromDB;
  71644. private _loadVersionFromDBAsync;
  71645. private _saveVersionIntoDBAsync;
  71646. /**
  71647. * Loads a file from database
  71648. * @param url defines the URL to load from
  71649. * @param sceneLoaded defines a callback to call on success
  71650. * @param progressCallBack defines a callback to call when progress changed
  71651. * @param errorCallback defines a callback to call on error
  71652. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71653. */
  71654. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71655. private _loadFileAsync;
  71656. private _saveFileAsync;
  71657. /**
  71658. * Validates if xhr data is correct
  71659. * @param xhr defines the request to validate
  71660. * @param dataType defines the expected data type
  71661. * @returns true if data is correct
  71662. */
  71663. private static _ValidateXHRData;
  71664. }
  71665. }
  71666. declare module "babylonjs/Offline/index" {
  71667. export * from "babylonjs/Offline/database";
  71668. export * from "babylonjs/Offline/IOfflineProvider";
  71669. }
  71670. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71671. /** @hidden */
  71672. export var gpuUpdateParticlesPixelShader: {
  71673. name: string;
  71674. shader: string;
  71675. };
  71676. }
  71677. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71678. /** @hidden */
  71679. export var gpuUpdateParticlesVertexShader: {
  71680. name: string;
  71681. shader: string;
  71682. };
  71683. }
  71684. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71685. /** @hidden */
  71686. export var clipPlaneFragmentDeclaration2: {
  71687. name: string;
  71688. shader: string;
  71689. };
  71690. }
  71691. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71692. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71693. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71694. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71695. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71696. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71697. /** @hidden */
  71698. export var gpuRenderParticlesPixelShader: {
  71699. name: string;
  71700. shader: string;
  71701. };
  71702. }
  71703. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71704. /** @hidden */
  71705. export var clipPlaneVertexDeclaration2: {
  71706. name: string;
  71707. shader: string;
  71708. };
  71709. }
  71710. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71711. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71712. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71713. /** @hidden */
  71714. export var gpuRenderParticlesVertexShader: {
  71715. name: string;
  71716. shader: string;
  71717. };
  71718. }
  71719. declare module "babylonjs/Particles/gpuParticleSystem" {
  71720. import { Nullable } from "babylonjs/types";
  71721. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71722. import { Observable } from "babylonjs/Misc/observable";
  71723. import { Matrix } from "babylonjs/Maths/math.vector";
  71724. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71725. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71726. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71727. import { IDisposable } from "babylonjs/scene";
  71728. import { Effect } from "babylonjs/Materials/effect";
  71729. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71730. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71731. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71732. import { Scene } from "babylonjs/scene";
  71733. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71734. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71735. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71736. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71737. /**
  71738. * This represents a GPU particle system in Babylon
  71739. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71740. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71741. */
  71742. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71743. /**
  71744. * The layer mask we are rendering the particles through.
  71745. */
  71746. layerMask: number;
  71747. private _capacity;
  71748. private _activeCount;
  71749. private _currentActiveCount;
  71750. private _accumulatedCount;
  71751. private _renderEffect;
  71752. private _updateEffect;
  71753. private _buffer0;
  71754. private _buffer1;
  71755. private _spriteBuffer;
  71756. private _updateVAO;
  71757. private _renderVAO;
  71758. private _targetIndex;
  71759. private _sourceBuffer;
  71760. private _targetBuffer;
  71761. private _currentRenderId;
  71762. private _started;
  71763. private _stopped;
  71764. private _timeDelta;
  71765. private _randomTexture;
  71766. private _randomTexture2;
  71767. private _attributesStrideSize;
  71768. private _updateEffectOptions;
  71769. private _randomTextureSize;
  71770. private _actualFrame;
  71771. private _customEffect;
  71772. private readonly _rawTextureWidth;
  71773. /**
  71774. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71775. */
  71776. static get IsSupported(): boolean;
  71777. /**
  71778. * An event triggered when the system is disposed.
  71779. */
  71780. onDisposeObservable: Observable<IParticleSystem>;
  71781. /**
  71782. * An event triggered when the system is stopped
  71783. */
  71784. onStoppedObservable: Observable<IParticleSystem>;
  71785. /**
  71786. * Gets the maximum number of particles active at the same time.
  71787. * @returns The max number of active particles.
  71788. */
  71789. getCapacity(): number;
  71790. /**
  71791. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71792. * to override the particles.
  71793. */
  71794. forceDepthWrite: boolean;
  71795. /**
  71796. * Gets or set the number of active particles
  71797. */
  71798. get activeParticleCount(): number;
  71799. set activeParticleCount(value: number);
  71800. private _preWarmDone;
  71801. /**
  71802. * Specifies if the particles are updated in emitter local space or world space.
  71803. */
  71804. isLocal: boolean;
  71805. /** Gets or sets a matrix to use to compute projection */
  71806. defaultProjectionMatrix: Matrix;
  71807. /**
  71808. * Is this system ready to be used/rendered
  71809. * @return true if the system is ready
  71810. */
  71811. isReady(): boolean;
  71812. /**
  71813. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71814. * @returns True if it has been started, otherwise false.
  71815. */
  71816. isStarted(): boolean;
  71817. /**
  71818. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71819. * @returns True if it has been stopped, otherwise false.
  71820. */
  71821. isStopped(): boolean;
  71822. /**
  71823. * Gets a boolean indicating that the system is stopping
  71824. * @returns true if the system is currently stopping
  71825. */
  71826. isStopping(): boolean;
  71827. /**
  71828. * Gets the number of particles active at the same time.
  71829. * @returns The number of active particles.
  71830. */
  71831. getActiveCount(): number;
  71832. /**
  71833. * Starts the particle system and begins to emit
  71834. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71835. */
  71836. start(delay?: number): void;
  71837. /**
  71838. * Stops the particle system.
  71839. */
  71840. stop(): void;
  71841. /**
  71842. * Remove all active particles
  71843. */
  71844. reset(): void;
  71845. /**
  71846. * Returns the string "GPUParticleSystem"
  71847. * @returns a string containing the class name
  71848. */
  71849. getClassName(): string;
  71850. /**
  71851. * Gets the custom effect used to render the particles
  71852. * @param blendMode Blend mode for which the effect should be retrieved
  71853. * @returns The effect
  71854. */
  71855. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71856. /**
  71857. * Sets the custom effect used to render the particles
  71858. * @param effect The effect to set
  71859. * @param blendMode Blend mode for which the effect should be set
  71860. */
  71861. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71862. /** @hidden */
  71863. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71864. /**
  71865. * Observable that will be called just before the particles are drawn
  71866. */
  71867. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71868. /**
  71869. * Gets the name of the particle vertex shader
  71870. */
  71871. get vertexShaderName(): string;
  71872. private _colorGradientsTexture;
  71873. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71874. /**
  71875. * Adds a new color gradient
  71876. * @param gradient defines the gradient to use (between 0 and 1)
  71877. * @param color1 defines the color to affect to the specified gradient
  71878. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71879. * @returns the current particle system
  71880. */
  71881. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71882. private _refreshColorGradient;
  71883. /** Force the system to rebuild all gradients that need to be resync */
  71884. forceRefreshGradients(): void;
  71885. /**
  71886. * Remove a specific color gradient
  71887. * @param gradient defines the gradient to remove
  71888. * @returns the current particle system
  71889. */
  71890. removeColorGradient(gradient: number): GPUParticleSystem;
  71891. private _angularSpeedGradientsTexture;
  71892. private _sizeGradientsTexture;
  71893. private _velocityGradientsTexture;
  71894. private _limitVelocityGradientsTexture;
  71895. private _dragGradientsTexture;
  71896. private _addFactorGradient;
  71897. /**
  71898. * Adds a new size gradient
  71899. * @param gradient defines the gradient to use (between 0 and 1)
  71900. * @param factor defines the size factor to affect to the specified gradient
  71901. * @returns the current particle system
  71902. */
  71903. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71904. /**
  71905. * Remove a specific size gradient
  71906. * @param gradient defines the gradient to remove
  71907. * @returns the current particle system
  71908. */
  71909. removeSizeGradient(gradient: number): GPUParticleSystem;
  71910. private _refreshFactorGradient;
  71911. /**
  71912. * Adds a new angular speed gradient
  71913. * @param gradient defines the gradient to use (between 0 and 1)
  71914. * @param factor defines the angular speed to affect to the specified gradient
  71915. * @returns the current particle system
  71916. */
  71917. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71918. /**
  71919. * Remove a specific angular speed gradient
  71920. * @param gradient defines the gradient to remove
  71921. * @returns the current particle system
  71922. */
  71923. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71924. /**
  71925. * Adds a new velocity gradient
  71926. * @param gradient defines the gradient to use (between 0 and 1)
  71927. * @param factor defines the velocity to affect to the specified gradient
  71928. * @returns the current particle system
  71929. */
  71930. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71931. /**
  71932. * Remove a specific velocity gradient
  71933. * @param gradient defines the gradient to remove
  71934. * @returns the current particle system
  71935. */
  71936. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71937. /**
  71938. * Adds a new limit velocity gradient
  71939. * @param gradient defines the gradient to use (between 0 and 1)
  71940. * @param factor defines the limit velocity value to affect to the specified gradient
  71941. * @returns the current particle system
  71942. */
  71943. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71944. /**
  71945. * Remove a specific limit velocity gradient
  71946. * @param gradient defines the gradient to remove
  71947. * @returns the current particle system
  71948. */
  71949. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71950. /**
  71951. * Adds a new drag gradient
  71952. * @param gradient defines the gradient to use (between 0 and 1)
  71953. * @param factor defines the drag value to affect to the specified gradient
  71954. * @returns the current particle system
  71955. */
  71956. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71957. /**
  71958. * Remove a specific drag gradient
  71959. * @param gradient defines the gradient to remove
  71960. * @returns the current particle system
  71961. */
  71962. removeDragGradient(gradient: number): GPUParticleSystem;
  71963. /**
  71964. * Not supported by GPUParticleSystem
  71965. * @param gradient defines the gradient to use (between 0 and 1)
  71966. * @param factor defines the emit rate value to affect to the specified gradient
  71967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71968. * @returns the current particle system
  71969. */
  71970. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71971. /**
  71972. * Not supported by GPUParticleSystem
  71973. * @param gradient defines the gradient to remove
  71974. * @returns the current particle system
  71975. */
  71976. removeEmitRateGradient(gradient: number): IParticleSystem;
  71977. /**
  71978. * Not supported by GPUParticleSystem
  71979. * @param gradient defines the gradient to use (between 0 and 1)
  71980. * @param factor defines the start size value to affect to the specified gradient
  71981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71982. * @returns the current particle system
  71983. */
  71984. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71985. /**
  71986. * Not supported by GPUParticleSystem
  71987. * @param gradient defines the gradient to remove
  71988. * @returns the current particle system
  71989. */
  71990. removeStartSizeGradient(gradient: number): IParticleSystem;
  71991. /**
  71992. * Not supported by GPUParticleSystem
  71993. * @param gradient defines the gradient to use (between 0 and 1)
  71994. * @param min defines the color remap minimal range
  71995. * @param max defines the color remap maximal range
  71996. * @returns the current particle system
  71997. */
  71998. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71999. /**
  72000. * Not supported by GPUParticleSystem
  72001. * @param gradient defines the gradient to remove
  72002. * @returns the current particle system
  72003. */
  72004. removeColorRemapGradient(): IParticleSystem;
  72005. /**
  72006. * Not supported by GPUParticleSystem
  72007. * @param gradient defines the gradient to use (between 0 and 1)
  72008. * @param min defines the alpha remap minimal range
  72009. * @param max defines the alpha remap maximal range
  72010. * @returns the current particle system
  72011. */
  72012. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72013. /**
  72014. * Not supported by GPUParticleSystem
  72015. * @param gradient defines the gradient to remove
  72016. * @returns the current particle system
  72017. */
  72018. removeAlphaRemapGradient(): IParticleSystem;
  72019. /**
  72020. * Not supported by GPUParticleSystem
  72021. * @param gradient defines the gradient to use (between 0 and 1)
  72022. * @param color defines the color to affect to the specified gradient
  72023. * @returns the current particle system
  72024. */
  72025. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72026. /**
  72027. * Not supported by GPUParticleSystem
  72028. * @param gradient defines the gradient to remove
  72029. * @returns the current particle system
  72030. */
  72031. removeRampGradient(): IParticleSystem;
  72032. /**
  72033. * Not supported by GPUParticleSystem
  72034. * @returns the list of ramp gradients
  72035. */
  72036. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72037. /**
  72038. * Not supported by GPUParticleSystem
  72039. * Gets or sets a boolean indicating that ramp gradients must be used
  72040. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72041. */
  72042. get useRampGradients(): boolean;
  72043. set useRampGradients(value: boolean);
  72044. /**
  72045. * Not supported by GPUParticleSystem
  72046. * @param gradient defines the gradient to use (between 0 and 1)
  72047. * @param factor defines the life time factor to affect to the specified gradient
  72048. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72049. * @returns the current particle system
  72050. */
  72051. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72052. /**
  72053. * Not supported by GPUParticleSystem
  72054. * @param gradient defines the gradient to remove
  72055. * @returns the current particle system
  72056. */
  72057. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72058. /**
  72059. * Instantiates a GPU particle system.
  72060. * 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.
  72061. * @param name The name of the particle system
  72062. * @param options The options used to create the system
  72063. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72064. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72065. * @param customEffect a custom effect used to change the way particles are rendered by default
  72066. */
  72067. constructor(name: string, options: Partial<{
  72068. capacity: number;
  72069. randomTextureSize: number;
  72070. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72071. protected _reset(): void;
  72072. private _createUpdateVAO;
  72073. private _createRenderVAO;
  72074. private _initialize;
  72075. /** @hidden */
  72076. _recreateUpdateEffect(): void;
  72077. private _getEffect;
  72078. /**
  72079. * Fill the defines array according to the current settings of the particle system
  72080. * @param defines Array to be updated
  72081. * @param blendMode blend mode to take into account when updating the array
  72082. */
  72083. fillDefines(defines: Array<string>, blendMode?: number): void;
  72084. /**
  72085. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72086. * @param uniforms Uniforms array to fill
  72087. * @param attributes Attributes array to fill
  72088. * @param samplers Samplers array to fill
  72089. */
  72090. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72091. /** @hidden */
  72092. _recreateRenderEffect(): Effect;
  72093. /**
  72094. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72095. * @param preWarm defines if we are in the pre-warmimg phase
  72096. */
  72097. animate(preWarm?: boolean): void;
  72098. private _createFactorGradientTexture;
  72099. private _createSizeGradientTexture;
  72100. private _createAngularSpeedGradientTexture;
  72101. private _createVelocityGradientTexture;
  72102. private _createLimitVelocityGradientTexture;
  72103. private _createDragGradientTexture;
  72104. private _createColorGradientTexture;
  72105. /**
  72106. * Renders the particle system in its current state
  72107. * @param preWarm defines if the system should only update the particles but not render them
  72108. * @returns the current number of particles
  72109. */
  72110. render(preWarm?: boolean): number;
  72111. /**
  72112. * Rebuilds the particle system
  72113. */
  72114. rebuild(): void;
  72115. private _releaseBuffers;
  72116. private _releaseVAOs;
  72117. /**
  72118. * Disposes the particle system and free the associated resources
  72119. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72120. */
  72121. dispose(disposeTexture?: boolean): void;
  72122. /**
  72123. * Clones the particle system.
  72124. * @param name The name of the cloned object
  72125. * @param newEmitter The new emitter to use
  72126. * @returns the cloned particle system
  72127. */
  72128. clone(name: string, newEmitter: any): GPUParticleSystem;
  72129. /**
  72130. * Serializes the particle system to a JSON object
  72131. * @param serializeTexture defines if the texture must be serialized as well
  72132. * @returns the JSON object
  72133. */
  72134. serialize(serializeTexture?: boolean): any;
  72135. /**
  72136. * Parses a JSON object to create a GPU particle system.
  72137. * @param parsedParticleSystem The JSON object to parse
  72138. * @param sceneOrEngine The scene or the engine to create the particle system in
  72139. * @param rootUrl The root url to use to load external dependencies like texture
  72140. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72141. * @returns the parsed GPU particle system
  72142. */
  72143. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72144. }
  72145. }
  72146. declare module "babylonjs/Particles/particleSystemSet" {
  72147. import { Nullable } from "babylonjs/types";
  72148. import { Color3 } from "babylonjs/Maths/math.color";
  72149. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72151. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72152. import { Scene, IDisposable } from "babylonjs/scene";
  72153. /**
  72154. * Represents a set of particle systems working together to create a specific effect
  72155. */
  72156. export class ParticleSystemSet implements IDisposable {
  72157. /**
  72158. * Gets or sets base Assets URL
  72159. */
  72160. static BaseAssetsUrl: string;
  72161. private _emitterCreationOptions;
  72162. private _emitterNode;
  72163. /**
  72164. * Gets the particle system list
  72165. */
  72166. systems: IParticleSystem[];
  72167. /**
  72168. * Gets the emitter node used with this set
  72169. */
  72170. get emitterNode(): Nullable<TransformNode>;
  72171. /**
  72172. * Creates a new emitter mesh as a sphere
  72173. * @param options defines the options used to create the sphere
  72174. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72175. * @param scene defines the hosting scene
  72176. */
  72177. setEmitterAsSphere(options: {
  72178. diameter: number;
  72179. segments: number;
  72180. color: Color3;
  72181. }, renderingGroupId: number, scene: Scene): void;
  72182. /**
  72183. * Starts all particle systems of the set
  72184. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72185. */
  72186. start(emitter?: AbstractMesh): void;
  72187. /**
  72188. * Release all associated resources
  72189. */
  72190. dispose(): void;
  72191. /**
  72192. * Serialize the set into a JSON compatible object
  72193. * @param serializeTexture defines if the texture must be serialized as well
  72194. * @returns a JSON compatible representation of the set
  72195. */
  72196. serialize(serializeTexture?: boolean): any;
  72197. /**
  72198. * Parse a new ParticleSystemSet from a serialized source
  72199. * @param data defines a JSON compatible representation of the set
  72200. * @param scene defines the hosting scene
  72201. * @param gpu defines if we want GPU particles or CPU particles
  72202. * @returns a new ParticleSystemSet
  72203. */
  72204. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72205. }
  72206. }
  72207. declare module "babylonjs/Particles/particleHelper" {
  72208. import { Nullable } from "babylonjs/types";
  72209. import { Scene } from "babylonjs/scene";
  72210. import { Vector3 } from "babylonjs/Maths/math.vector";
  72211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72212. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72213. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72214. /**
  72215. * This class is made for on one-liner static method to help creating particle system set.
  72216. */
  72217. export class ParticleHelper {
  72218. /**
  72219. * Gets or sets base Assets URL
  72220. */
  72221. static BaseAssetsUrl: string;
  72222. /** Define the Url to load snippets */
  72223. static SnippetUrl: string;
  72224. /**
  72225. * Create a default particle system that you can tweak
  72226. * @param emitter defines the emitter to use
  72227. * @param capacity defines the system capacity (default is 500 particles)
  72228. * @param scene defines the hosting scene
  72229. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72230. * @returns the new Particle system
  72231. */
  72232. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72233. /**
  72234. * This is the main static method (one-liner) of this helper to create different particle systems
  72235. * @param type This string represents the type to the particle system to create
  72236. * @param scene The scene where the particle system should live
  72237. * @param gpu If the system will use gpu
  72238. * @returns the ParticleSystemSet created
  72239. */
  72240. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72241. /**
  72242. * Static function used to export a particle system to a ParticleSystemSet variable.
  72243. * Please note that the emitter shape is not exported
  72244. * @param systems defines the particle systems to export
  72245. * @returns the created particle system set
  72246. */
  72247. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72248. /**
  72249. * Creates a particle system from a snippet saved in a remote file
  72250. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72251. * @param url defines the url to load from
  72252. * @param scene defines the hosting scene
  72253. * @param gpu If the system will use gpu
  72254. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72255. * @returns a promise that will resolve to the new particle system
  72256. */
  72257. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72258. /**
  72259. * Creates a particle system from a snippet saved by the particle system editor
  72260. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72261. * @param scene defines the hosting scene
  72262. * @param gpu If the system will use gpu
  72263. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72264. * @returns a promise that will resolve to the new particle system
  72265. */
  72266. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72267. }
  72268. }
  72269. declare module "babylonjs/Particles/particleSystemComponent" {
  72270. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72271. import { Effect } from "babylonjs/Materials/effect";
  72272. import "babylonjs/Shaders/particles.vertex";
  72273. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72274. module "babylonjs/Engines/engine" {
  72275. interface Engine {
  72276. /**
  72277. * Create an effect to use with particle systems.
  72278. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72279. * the particle system for which you want to create a custom effect in the last parameter
  72280. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72281. * @param uniformsNames defines a list of attribute names
  72282. * @param samplers defines an array of string used to represent textures
  72283. * @param defines defines the string containing the defines to use to compile the shaders
  72284. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72285. * @param onCompiled defines a function to call when the effect creation is successful
  72286. * @param onError defines a function to call when the effect creation has failed
  72287. * @param particleSystem the particle system you want to create the effect for
  72288. * @returns the new Effect
  72289. */
  72290. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72291. }
  72292. }
  72293. module "babylonjs/Meshes/mesh" {
  72294. interface Mesh {
  72295. /**
  72296. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72297. * @returns an array of IParticleSystem
  72298. */
  72299. getEmittedParticleSystems(): IParticleSystem[];
  72300. /**
  72301. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72302. * @returns an array of IParticleSystem
  72303. */
  72304. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72305. }
  72306. }
  72307. }
  72308. declare module "babylonjs/Particles/pointsCloudSystem" {
  72309. import { Color4 } from "babylonjs/Maths/math";
  72310. import { Mesh } from "babylonjs/Meshes/mesh";
  72311. import { Scene, IDisposable } from "babylonjs/scene";
  72312. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72313. /** Defines the 4 color options */
  72314. export enum PointColor {
  72315. /** color value */
  72316. Color = 2,
  72317. /** uv value */
  72318. UV = 1,
  72319. /** random value */
  72320. Random = 0,
  72321. /** stated value */
  72322. Stated = 3
  72323. }
  72324. /**
  72325. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72326. * 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.
  72327. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72328. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72329. *
  72330. * Full documentation here : TO BE ENTERED
  72331. */
  72332. export class PointsCloudSystem implements IDisposable {
  72333. /**
  72334. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72335. * Example : var p = SPS.particles[i];
  72336. */
  72337. particles: CloudPoint[];
  72338. /**
  72339. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72340. */
  72341. nbParticles: number;
  72342. /**
  72343. * This a counter for your own usage. It's not set by any SPS functions.
  72344. */
  72345. counter: number;
  72346. /**
  72347. * The PCS name. This name is also given to the underlying mesh.
  72348. */
  72349. name: string;
  72350. /**
  72351. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72352. */
  72353. mesh: Mesh;
  72354. /**
  72355. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72356. * Please read :
  72357. */
  72358. vars: any;
  72359. /**
  72360. * @hidden
  72361. */
  72362. _size: number;
  72363. private _scene;
  72364. private _promises;
  72365. private _positions;
  72366. private _indices;
  72367. private _normals;
  72368. private _colors;
  72369. private _uvs;
  72370. private _indices32;
  72371. private _positions32;
  72372. private _colors32;
  72373. private _uvs32;
  72374. private _updatable;
  72375. private _isVisibilityBoxLocked;
  72376. private _alwaysVisible;
  72377. private _groups;
  72378. private _groupCounter;
  72379. private _computeParticleColor;
  72380. private _computeParticleTexture;
  72381. private _computeParticleRotation;
  72382. private _computeBoundingBox;
  72383. private _isReady;
  72384. /**
  72385. * Creates a PCS (Points Cloud System) object
  72386. * @param name (String) is the PCS name, this will be the underlying mesh name
  72387. * @param pointSize (number) is the size for each point
  72388. * @param scene (Scene) is the scene in which the PCS is added
  72389. * @param options defines the options of the PCS e.g.
  72390. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72391. */
  72392. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72393. updatable?: boolean;
  72394. });
  72395. /**
  72396. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72397. * If no points were added to the PCS, the returned mesh is just a single point.
  72398. * @returns a promise for the created mesh
  72399. */
  72400. buildMeshAsync(): Promise<Mesh>;
  72401. /**
  72402. * @hidden
  72403. */
  72404. private _buildMesh;
  72405. private _addParticle;
  72406. private _randomUnitVector;
  72407. private _getColorIndicesForCoord;
  72408. private _setPointsColorOrUV;
  72409. private _colorFromTexture;
  72410. private _calculateDensity;
  72411. /**
  72412. * Adds points to the PCS in random positions within a unit sphere
  72413. * @param nb (positive integer) the number of particles to be created from this model
  72414. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72415. * @returns the number of groups in the system
  72416. */
  72417. addPoints(nb: number, pointFunction?: any): number;
  72418. /**
  72419. * Adds points to the PCS from the surface of the model shape
  72420. * @param mesh is any Mesh object that will be used as a surface model for the points
  72421. * @param nb (positive integer) the number of particles to be created from this model
  72422. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72423. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72424. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72425. * @returns the number of groups in the system
  72426. */
  72427. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72428. /**
  72429. * Adds points to the PCS inside the model shape
  72430. * @param mesh is any Mesh object that will be used as a surface model for the points
  72431. * @param nb (positive integer) the number of particles to be created from this model
  72432. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72433. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72434. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72435. * @returns the number of groups in the system
  72436. */
  72437. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72438. /**
  72439. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72440. * This method calls `updateParticle()` for each particle of the SPS.
  72441. * For an animated SPS, it is usually called within the render loop.
  72442. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72443. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72444. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72445. * @returns the PCS.
  72446. */
  72447. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72448. /**
  72449. * Disposes the PCS.
  72450. */
  72451. dispose(): void;
  72452. /**
  72453. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72454. * doc :
  72455. * @returns the PCS.
  72456. */
  72457. refreshVisibleSize(): PointsCloudSystem;
  72458. /**
  72459. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72460. * @param size the size (float) of the visibility box
  72461. * note : this doesn't lock the PCS mesh bounding box.
  72462. * doc :
  72463. */
  72464. setVisibilityBox(size: number): void;
  72465. /**
  72466. * Gets whether the PCS is always visible or not
  72467. * doc :
  72468. */
  72469. get isAlwaysVisible(): boolean;
  72470. /**
  72471. * Sets the PCS as always visible or not
  72472. * doc :
  72473. */
  72474. set isAlwaysVisible(val: boolean);
  72475. /**
  72476. * Tells to `setParticles()` to compute the particle rotations or not
  72477. * Default value : false. The PCS is faster when it's set to false
  72478. * Note : particle rotations are only applied to parent particles
  72479. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72480. */
  72481. set computeParticleRotation(val: boolean);
  72482. /**
  72483. * Tells to `setParticles()` to compute the particle colors or not.
  72484. * Default value : true. The PCS is faster when it's set to false.
  72485. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72486. */
  72487. set computeParticleColor(val: boolean);
  72488. set computeParticleTexture(val: boolean);
  72489. /**
  72490. * Gets if `setParticles()` computes the particle colors or not.
  72491. * Default value : false. The PCS is faster when it's set to false.
  72492. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72493. */
  72494. get computeParticleColor(): boolean;
  72495. /**
  72496. * Gets if `setParticles()` computes the particle textures or not.
  72497. * Default value : false. The PCS is faster when it's set to false.
  72498. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72499. */
  72500. get computeParticleTexture(): boolean;
  72501. /**
  72502. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72503. */
  72504. set computeBoundingBox(val: boolean);
  72505. /**
  72506. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72507. */
  72508. get computeBoundingBox(): boolean;
  72509. /**
  72510. * This function does nothing. It may be overwritten to set all the particle first values.
  72511. * The PCS doesn't call this function, you may have to call it by your own.
  72512. * doc :
  72513. */
  72514. initParticles(): void;
  72515. /**
  72516. * This function does nothing. It may be overwritten to recycle a particle
  72517. * The PCS doesn't call this function, you can to call it
  72518. * doc :
  72519. * @param particle The particle to recycle
  72520. * @returns the recycled particle
  72521. */
  72522. recycleParticle(particle: CloudPoint): CloudPoint;
  72523. /**
  72524. * Updates a particle : this function should be overwritten by the user.
  72525. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72526. * doc :
  72527. * @example : just set a particle position or velocity and recycle conditions
  72528. * @param particle The particle to update
  72529. * @returns the updated particle
  72530. */
  72531. updateParticle(particle: CloudPoint): CloudPoint;
  72532. /**
  72533. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72534. * This does nothing and may be overwritten by the user.
  72535. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72536. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72537. * @param update the boolean update value actually passed to setParticles()
  72538. */
  72539. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72540. /**
  72541. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72542. * This will be passed three parameters.
  72543. * This does nothing and may be overwritten by the user.
  72544. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72545. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72546. * @param update the boolean update value actually passed to setParticles()
  72547. */
  72548. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72549. }
  72550. }
  72551. declare module "babylonjs/Particles/cloudPoint" {
  72552. import { Nullable } from "babylonjs/types";
  72553. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72554. import { Mesh } from "babylonjs/Meshes/mesh";
  72555. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72556. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72557. /**
  72558. * Represents one particle of a points cloud system.
  72559. */
  72560. export class CloudPoint {
  72561. /**
  72562. * particle global index
  72563. */
  72564. idx: number;
  72565. /**
  72566. * The color of the particle
  72567. */
  72568. color: Nullable<Color4>;
  72569. /**
  72570. * The world space position of the particle.
  72571. */
  72572. position: Vector3;
  72573. /**
  72574. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72575. */
  72576. rotation: Vector3;
  72577. /**
  72578. * The world space rotation quaternion of the particle.
  72579. */
  72580. rotationQuaternion: Nullable<Quaternion>;
  72581. /**
  72582. * The uv of the particle.
  72583. */
  72584. uv: Nullable<Vector2>;
  72585. /**
  72586. * The current speed of the particle.
  72587. */
  72588. velocity: Vector3;
  72589. /**
  72590. * The pivot point in the particle local space.
  72591. */
  72592. pivot: Vector3;
  72593. /**
  72594. * Must the particle be translated from its pivot point in its local space ?
  72595. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72596. * Default : false
  72597. */
  72598. translateFromPivot: boolean;
  72599. /**
  72600. * Index of this particle in the global "positions" array (Internal use)
  72601. * @hidden
  72602. */
  72603. _pos: number;
  72604. /**
  72605. * @hidden Index of this particle in the global "indices" array (Internal use)
  72606. */
  72607. _ind: number;
  72608. /**
  72609. * Group this particle belongs to
  72610. */
  72611. _group: PointsGroup;
  72612. /**
  72613. * Group id of this particle
  72614. */
  72615. groupId: number;
  72616. /**
  72617. * Index of the particle in its group id (Internal use)
  72618. */
  72619. idxInGroup: number;
  72620. /**
  72621. * @hidden Particle BoundingInfo object (Internal use)
  72622. */
  72623. _boundingInfo: BoundingInfo;
  72624. /**
  72625. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72626. */
  72627. _pcs: PointsCloudSystem;
  72628. /**
  72629. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72630. */
  72631. _stillInvisible: boolean;
  72632. /**
  72633. * @hidden Last computed particle rotation matrix
  72634. */
  72635. _rotationMatrix: number[];
  72636. /**
  72637. * Parent particle Id, if any.
  72638. * Default null.
  72639. */
  72640. parentId: Nullable<number>;
  72641. /**
  72642. * @hidden Internal global position in the PCS.
  72643. */
  72644. _globalPosition: Vector3;
  72645. /**
  72646. * Creates a Point Cloud object.
  72647. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72648. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72649. * @param group (PointsGroup) is the group the particle belongs to
  72650. * @param groupId (integer) is the group identifier in the PCS.
  72651. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72652. * @param pcs defines the PCS it is associated to
  72653. */
  72654. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72655. /**
  72656. * get point size
  72657. */
  72658. get size(): Vector3;
  72659. /**
  72660. * Set point size
  72661. */
  72662. set size(scale: Vector3);
  72663. /**
  72664. * Legacy support, changed quaternion to rotationQuaternion
  72665. */
  72666. get quaternion(): Nullable<Quaternion>;
  72667. /**
  72668. * Legacy support, changed quaternion to rotationQuaternion
  72669. */
  72670. set quaternion(q: Nullable<Quaternion>);
  72671. /**
  72672. * Returns a boolean. True if the particle intersects a mesh, else false
  72673. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72674. * @param target is the object (point or mesh) what the intersection is computed against
  72675. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72676. * @returns true if it intersects
  72677. */
  72678. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72679. /**
  72680. * get the rotation matrix of the particle
  72681. * @hidden
  72682. */
  72683. getRotationMatrix(m: Matrix): void;
  72684. }
  72685. /**
  72686. * Represents a group of points in a points cloud system
  72687. * * PCS internal tool, don't use it manually.
  72688. */
  72689. export class PointsGroup {
  72690. /**
  72691. * The group id
  72692. * @hidden
  72693. */
  72694. groupID: number;
  72695. /**
  72696. * image data for group (internal use)
  72697. * @hidden
  72698. */
  72699. _groupImageData: Nullable<ArrayBufferView>;
  72700. /**
  72701. * Image Width (internal use)
  72702. * @hidden
  72703. */
  72704. _groupImgWidth: number;
  72705. /**
  72706. * Image Height (internal use)
  72707. * @hidden
  72708. */
  72709. _groupImgHeight: number;
  72710. /**
  72711. * Custom position function (internal use)
  72712. * @hidden
  72713. */
  72714. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72715. /**
  72716. * density per facet for surface points
  72717. * @hidden
  72718. */
  72719. _groupDensity: number[];
  72720. /**
  72721. * Only when points are colored by texture carries pointer to texture list array
  72722. * @hidden
  72723. */
  72724. _textureNb: number;
  72725. /**
  72726. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72727. * PCS internal tool, don't use it manually.
  72728. * @hidden
  72729. */
  72730. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72731. }
  72732. }
  72733. declare module "babylonjs/Particles/index" {
  72734. export * from "babylonjs/Particles/baseParticleSystem";
  72735. export * from "babylonjs/Particles/EmitterTypes/index";
  72736. export * from "babylonjs/Particles/gpuParticleSystem";
  72737. export * from "babylonjs/Particles/IParticleSystem";
  72738. export * from "babylonjs/Particles/particle";
  72739. export * from "babylonjs/Particles/particleHelper";
  72740. export * from "babylonjs/Particles/particleSystem";
  72741. import "babylonjs/Particles/particleSystemComponent";
  72742. export * from "babylonjs/Particles/particleSystemComponent";
  72743. export * from "babylonjs/Particles/particleSystemSet";
  72744. export * from "babylonjs/Particles/solidParticle";
  72745. export * from "babylonjs/Particles/solidParticleSystem";
  72746. export * from "babylonjs/Particles/cloudPoint";
  72747. export * from "babylonjs/Particles/pointsCloudSystem";
  72748. export * from "babylonjs/Particles/subEmitter";
  72749. }
  72750. declare module "babylonjs/Physics/physicsEngineComponent" {
  72751. import { Nullable } from "babylonjs/types";
  72752. import { Observable, Observer } from "babylonjs/Misc/observable";
  72753. import { Vector3 } from "babylonjs/Maths/math.vector";
  72754. import { Mesh } from "babylonjs/Meshes/mesh";
  72755. import { ISceneComponent } from "babylonjs/sceneComponent";
  72756. import { Scene } from "babylonjs/scene";
  72757. import { Node } from "babylonjs/node";
  72758. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72759. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72760. module "babylonjs/scene" {
  72761. interface Scene {
  72762. /** @hidden (Backing field) */
  72763. _physicsEngine: Nullable<IPhysicsEngine>;
  72764. /** @hidden */
  72765. _physicsTimeAccumulator: number;
  72766. /**
  72767. * Gets the current physics engine
  72768. * @returns a IPhysicsEngine or null if none attached
  72769. */
  72770. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72771. /**
  72772. * Enables physics to the current scene
  72773. * @param gravity defines the scene's gravity for the physics engine
  72774. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72775. * @return a boolean indicating if the physics engine was initialized
  72776. */
  72777. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72778. /**
  72779. * Disables and disposes the physics engine associated with the scene
  72780. */
  72781. disablePhysicsEngine(): void;
  72782. /**
  72783. * Gets a boolean indicating if there is an active physics engine
  72784. * @returns a boolean indicating if there is an active physics engine
  72785. */
  72786. isPhysicsEnabled(): boolean;
  72787. /**
  72788. * Deletes a physics compound impostor
  72789. * @param compound defines the compound to delete
  72790. */
  72791. deleteCompoundImpostor(compound: any): void;
  72792. /**
  72793. * An event triggered when physic simulation is about to be run
  72794. */
  72795. onBeforePhysicsObservable: Observable<Scene>;
  72796. /**
  72797. * An event triggered when physic simulation has been done
  72798. */
  72799. onAfterPhysicsObservable: Observable<Scene>;
  72800. }
  72801. }
  72802. module "babylonjs/Meshes/abstractMesh" {
  72803. interface AbstractMesh {
  72804. /** @hidden */
  72805. _physicsImpostor: Nullable<PhysicsImpostor>;
  72806. /**
  72807. * Gets or sets impostor used for physic simulation
  72808. * @see https://doc.babylonjs.com/features/physics_engine
  72809. */
  72810. physicsImpostor: Nullable<PhysicsImpostor>;
  72811. /**
  72812. * Gets the current physics impostor
  72813. * @see https://doc.babylonjs.com/features/physics_engine
  72814. * @returns a physics impostor or null
  72815. */
  72816. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72817. /** Apply a physic impulse to the mesh
  72818. * @param force defines the force to apply
  72819. * @param contactPoint defines where to apply the force
  72820. * @returns the current mesh
  72821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72822. */
  72823. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72824. /**
  72825. * Creates a physic joint between two meshes
  72826. * @param otherMesh defines the other mesh to use
  72827. * @param pivot1 defines the pivot to use on this mesh
  72828. * @param pivot2 defines the pivot to use on the other mesh
  72829. * @param options defines additional options (can be plugin dependent)
  72830. * @returns the current mesh
  72831. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72832. */
  72833. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72834. /** @hidden */
  72835. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72836. }
  72837. }
  72838. /**
  72839. * Defines the physics engine scene component responsible to manage a physics engine
  72840. */
  72841. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72842. /**
  72843. * The component name helpful to identify the component in the list of scene components.
  72844. */
  72845. readonly name: string;
  72846. /**
  72847. * The scene the component belongs to.
  72848. */
  72849. scene: Scene;
  72850. /**
  72851. * Creates a new instance of the component for the given scene
  72852. * @param scene Defines the scene to register the component in
  72853. */
  72854. constructor(scene: Scene);
  72855. /**
  72856. * Registers the component in a given scene
  72857. */
  72858. register(): void;
  72859. /**
  72860. * Rebuilds the elements related to this component in case of
  72861. * context lost for instance.
  72862. */
  72863. rebuild(): void;
  72864. /**
  72865. * Disposes the component and the associated ressources
  72866. */
  72867. dispose(): void;
  72868. }
  72869. }
  72870. declare module "babylonjs/Physics/physicsHelper" {
  72871. import { Nullable } from "babylonjs/types";
  72872. import { Vector3 } from "babylonjs/Maths/math.vector";
  72873. import { Mesh } from "babylonjs/Meshes/mesh";
  72874. import { Scene } from "babylonjs/scene";
  72875. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72876. /**
  72877. * A helper for physics simulations
  72878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72879. */
  72880. export class PhysicsHelper {
  72881. private _scene;
  72882. private _physicsEngine;
  72883. /**
  72884. * Initializes the Physics helper
  72885. * @param scene Babylon.js scene
  72886. */
  72887. constructor(scene: Scene);
  72888. /**
  72889. * Applies a radial explosion impulse
  72890. * @param origin the origin of the explosion
  72891. * @param radiusOrEventOptions the radius or the options of radial explosion
  72892. * @param strength the explosion strength
  72893. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72894. * @returns A physics radial explosion event, or null
  72895. */
  72896. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72897. /**
  72898. * Applies a radial explosion force
  72899. * @param origin the origin of the explosion
  72900. * @param radiusOrEventOptions the radius or the options of radial explosion
  72901. * @param strength the explosion strength
  72902. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72903. * @returns A physics radial explosion event, or null
  72904. */
  72905. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72906. /**
  72907. * Creates a gravitational field
  72908. * @param origin the origin of the explosion
  72909. * @param radiusOrEventOptions the radius or the options of radial explosion
  72910. * @param strength the explosion strength
  72911. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72912. * @returns A physics gravitational field event, or null
  72913. */
  72914. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72915. /**
  72916. * Creates a physics updraft event
  72917. * @param origin the origin of the updraft
  72918. * @param radiusOrEventOptions the radius or the options of the updraft
  72919. * @param strength the strength of the updraft
  72920. * @param height the height of the updraft
  72921. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72922. * @returns A physics updraft event, or null
  72923. */
  72924. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72925. /**
  72926. * Creates a physics vortex event
  72927. * @param origin the of the vortex
  72928. * @param radiusOrEventOptions the radius or the options of the vortex
  72929. * @param strength the strength of the vortex
  72930. * @param height the height of the vortex
  72931. * @returns a Physics vortex event, or null
  72932. * A physics vortex event or null
  72933. */
  72934. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72935. }
  72936. /**
  72937. * Represents a physics radial explosion event
  72938. */
  72939. class PhysicsRadialExplosionEvent {
  72940. private _scene;
  72941. private _options;
  72942. private _sphere;
  72943. private _dataFetched;
  72944. /**
  72945. * Initializes a radial explosioin event
  72946. * @param _scene BabylonJS scene
  72947. * @param _options The options for the vortex event
  72948. */
  72949. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72950. /**
  72951. * Returns the data related to the radial explosion event (sphere).
  72952. * @returns The radial explosion event data
  72953. */
  72954. getData(): PhysicsRadialExplosionEventData;
  72955. /**
  72956. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72957. * @param impostor A physics imposter
  72958. * @param origin the origin of the explosion
  72959. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72960. */
  72961. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72962. /**
  72963. * Triggers affecterd impostors callbacks
  72964. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72965. */
  72966. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72967. /**
  72968. * Disposes the sphere.
  72969. * @param force Specifies if the sphere should be disposed by force
  72970. */
  72971. dispose(force?: boolean): void;
  72972. /*** Helpers ***/
  72973. private _prepareSphere;
  72974. private _intersectsWithSphere;
  72975. }
  72976. /**
  72977. * Represents a gravitational field event
  72978. */
  72979. class PhysicsGravitationalFieldEvent {
  72980. private _physicsHelper;
  72981. private _scene;
  72982. private _origin;
  72983. private _options;
  72984. private _tickCallback;
  72985. private _sphere;
  72986. private _dataFetched;
  72987. /**
  72988. * Initializes the physics gravitational field event
  72989. * @param _physicsHelper A physics helper
  72990. * @param _scene BabylonJS scene
  72991. * @param _origin The origin position of the gravitational field event
  72992. * @param _options The options for the vortex event
  72993. */
  72994. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72995. /**
  72996. * Returns the data related to the gravitational field event (sphere).
  72997. * @returns A gravitational field event
  72998. */
  72999. getData(): PhysicsGravitationalFieldEventData;
  73000. /**
  73001. * Enables the gravitational field.
  73002. */
  73003. enable(): void;
  73004. /**
  73005. * Disables the gravitational field.
  73006. */
  73007. disable(): void;
  73008. /**
  73009. * Disposes the sphere.
  73010. * @param force The force to dispose from the gravitational field event
  73011. */
  73012. dispose(force?: boolean): void;
  73013. private _tick;
  73014. }
  73015. /**
  73016. * Represents a physics updraft event
  73017. */
  73018. class PhysicsUpdraftEvent {
  73019. private _scene;
  73020. private _origin;
  73021. private _options;
  73022. private _physicsEngine;
  73023. private _originTop;
  73024. private _originDirection;
  73025. private _tickCallback;
  73026. private _cylinder;
  73027. private _cylinderPosition;
  73028. private _dataFetched;
  73029. /**
  73030. * Initializes the physics updraft event
  73031. * @param _scene BabylonJS scene
  73032. * @param _origin The origin position of the updraft
  73033. * @param _options The options for the updraft event
  73034. */
  73035. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73036. /**
  73037. * Returns the data related to the updraft event (cylinder).
  73038. * @returns A physics updraft event
  73039. */
  73040. getData(): PhysicsUpdraftEventData;
  73041. /**
  73042. * Enables the updraft.
  73043. */
  73044. enable(): void;
  73045. /**
  73046. * Disables the updraft.
  73047. */
  73048. disable(): void;
  73049. /**
  73050. * Disposes the cylinder.
  73051. * @param force Specifies if the updraft should be disposed by force
  73052. */
  73053. dispose(force?: boolean): void;
  73054. private getImpostorHitData;
  73055. private _tick;
  73056. /*** Helpers ***/
  73057. private _prepareCylinder;
  73058. private _intersectsWithCylinder;
  73059. }
  73060. /**
  73061. * Represents a physics vortex event
  73062. */
  73063. class PhysicsVortexEvent {
  73064. private _scene;
  73065. private _origin;
  73066. private _options;
  73067. private _physicsEngine;
  73068. private _originTop;
  73069. private _tickCallback;
  73070. private _cylinder;
  73071. private _cylinderPosition;
  73072. private _dataFetched;
  73073. /**
  73074. * Initializes the physics vortex event
  73075. * @param _scene The BabylonJS scene
  73076. * @param _origin The origin position of the vortex
  73077. * @param _options The options for the vortex event
  73078. */
  73079. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73080. /**
  73081. * Returns the data related to the vortex event (cylinder).
  73082. * @returns The physics vortex event data
  73083. */
  73084. getData(): PhysicsVortexEventData;
  73085. /**
  73086. * Enables the vortex.
  73087. */
  73088. enable(): void;
  73089. /**
  73090. * Disables the cortex.
  73091. */
  73092. disable(): void;
  73093. /**
  73094. * Disposes the sphere.
  73095. * @param force
  73096. */
  73097. dispose(force?: boolean): void;
  73098. private getImpostorHitData;
  73099. private _tick;
  73100. /*** Helpers ***/
  73101. private _prepareCylinder;
  73102. private _intersectsWithCylinder;
  73103. }
  73104. /**
  73105. * Options fot the radial explosion event
  73106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73107. */
  73108. export class PhysicsRadialExplosionEventOptions {
  73109. /**
  73110. * The radius of the sphere for the radial explosion.
  73111. */
  73112. radius: number;
  73113. /**
  73114. * The strenth of the explosion.
  73115. */
  73116. strength: number;
  73117. /**
  73118. * The strenght of the force in correspondence to the distance of the affected object
  73119. */
  73120. falloff: PhysicsRadialImpulseFalloff;
  73121. /**
  73122. * Sphere options for the radial explosion.
  73123. */
  73124. sphere: {
  73125. segments: number;
  73126. diameter: number;
  73127. };
  73128. /**
  73129. * Sphere options for the radial explosion.
  73130. */
  73131. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73132. }
  73133. /**
  73134. * Options fot the updraft event
  73135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73136. */
  73137. export class PhysicsUpdraftEventOptions {
  73138. /**
  73139. * The radius of the cylinder for the vortex
  73140. */
  73141. radius: number;
  73142. /**
  73143. * The strenth of the updraft.
  73144. */
  73145. strength: number;
  73146. /**
  73147. * The height of the cylinder for the updraft.
  73148. */
  73149. height: number;
  73150. /**
  73151. * The mode for the the updraft.
  73152. */
  73153. updraftMode: PhysicsUpdraftMode;
  73154. }
  73155. /**
  73156. * Options fot the vortex event
  73157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73158. */
  73159. export class PhysicsVortexEventOptions {
  73160. /**
  73161. * The radius of the cylinder for the vortex
  73162. */
  73163. radius: number;
  73164. /**
  73165. * The strenth of the vortex.
  73166. */
  73167. strength: number;
  73168. /**
  73169. * The height of the cylinder for the vortex.
  73170. */
  73171. height: number;
  73172. /**
  73173. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73174. */
  73175. centripetalForceThreshold: number;
  73176. /**
  73177. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73178. */
  73179. centripetalForceMultiplier: number;
  73180. /**
  73181. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73182. */
  73183. centrifugalForceMultiplier: number;
  73184. /**
  73185. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73186. */
  73187. updraftForceMultiplier: number;
  73188. }
  73189. /**
  73190. * The strenght of the force in correspondence to the distance of the affected object
  73191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73192. */
  73193. export enum PhysicsRadialImpulseFalloff {
  73194. /** Defines that impulse is constant in strength across it's whole radius */
  73195. Constant = 0,
  73196. /** Defines that impulse gets weaker if it's further from the origin */
  73197. Linear = 1
  73198. }
  73199. /**
  73200. * The strength of the force in correspondence to the distance of the affected object
  73201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73202. */
  73203. export enum PhysicsUpdraftMode {
  73204. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73205. Center = 0,
  73206. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73207. Perpendicular = 1
  73208. }
  73209. /**
  73210. * Interface for a physics hit data
  73211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73212. */
  73213. export interface PhysicsHitData {
  73214. /**
  73215. * The force applied at the contact point
  73216. */
  73217. force: Vector3;
  73218. /**
  73219. * The contact point
  73220. */
  73221. contactPoint: Vector3;
  73222. /**
  73223. * The distance from the origin to the contact point
  73224. */
  73225. distanceFromOrigin: number;
  73226. }
  73227. /**
  73228. * Interface for radial explosion event data
  73229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73230. */
  73231. export interface PhysicsRadialExplosionEventData {
  73232. /**
  73233. * A sphere used for the radial explosion event
  73234. */
  73235. sphere: Mesh;
  73236. }
  73237. /**
  73238. * Interface for gravitational field event data
  73239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73240. */
  73241. export interface PhysicsGravitationalFieldEventData {
  73242. /**
  73243. * A sphere mesh used for the gravitational field event
  73244. */
  73245. sphere: Mesh;
  73246. }
  73247. /**
  73248. * Interface for updraft event data
  73249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73250. */
  73251. export interface PhysicsUpdraftEventData {
  73252. /**
  73253. * A cylinder used for the updraft event
  73254. */
  73255. cylinder: Mesh;
  73256. }
  73257. /**
  73258. * Interface for vortex event data
  73259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73260. */
  73261. export interface PhysicsVortexEventData {
  73262. /**
  73263. * A cylinder used for the vortex event
  73264. */
  73265. cylinder: Mesh;
  73266. }
  73267. /**
  73268. * Interface for an affected physics impostor
  73269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73270. */
  73271. export interface PhysicsAffectedImpostorWithData {
  73272. /**
  73273. * The impostor affected by the effect
  73274. */
  73275. impostor: PhysicsImpostor;
  73276. /**
  73277. * The data about the hit/horce from the explosion
  73278. */
  73279. hitData: PhysicsHitData;
  73280. }
  73281. }
  73282. declare module "babylonjs/Physics/Plugins/index" {
  73283. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73284. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73285. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73286. }
  73287. declare module "babylonjs/Physics/index" {
  73288. export * from "babylonjs/Physics/IPhysicsEngine";
  73289. export * from "babylonjs/Physics/physicsEngine";
  73290. export * from "babylonjs/Physics/physicsEngineComponent";
  73291. export * from "babylonjs/Physics/physicsHelper";
  73292. export * from "babylonjs/Physics/physicsImpostor";
  73293. export * from "babylonjs/Physics/physicsJoint";
  73294. export * from "babylonjs/Physics/Plugins/index";
  73295. }
  73296. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73297. /** @hidden */
  73298. export var blackAndWhitePixelShader: {
  73299. name: string;
  73300. shader: string;
  73301. };
  73302. }
  73303. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73304. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73305. import { Camera } from "babylonjs/Cameras/camera";
  73306. import { Engine } from "babylonjs/Engines/engine";
  73307. import "babylonjs/Shaders/blackAndWhite.fragment";
  73308. import { Nullable } from "babylonjs/types";
  73309. import { Scene } from "babylonjs/scene";
  73310. /**
  73311. * Post process used to render in black and white
  73312. */
  73313. export class BlackAndWhitePostProcess extends PostProcess {
  73314. /**
  73315. * Linear about to convert he result to black and white (default: 1)
  73316. */
  73317. degree: number;
  73318. /**
  73319. * Gets a string identifying the name of the class
  73320. * @returns "BlackAndWhitePostProcess" string
  73321. */
  73322. getClassName(): string;
  73323. /**
  73324. * Creates a black and white post process
  73325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73326. * @param name The name of the effect.
  73327. * @param options The required width/height ratio to downsize to before computing the render pass.
  73328. * @param camera The camera to apply the render pass to.
  73329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73330. * @param engine The engine which the post process will be applied. (default: current engine)
  73331. * @param reusable If the post process can be reused on the same frame. (default: false)
  73332. */
  73333. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73334. /** @hidden */
  73335. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73336. }
  73337. }
  73338. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73339. import { Nullable } from "babylonjs/types";
  73340. import { Camera } from "babylonjs/Cameras/camera";
  73341. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73342. import { Engine } from "babylonjs/Engines/engine";
  73343. /**
  73344. * This represents a set of one or more post processes in Babylon.
  73345. * A post process can be used to apply a shader to a texture after it is rendered.
  73346. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73347. */
  73348. export class PostProcessRenderEffect {
  73349. private _postProcesses;
  73350. private _getPostProcesses;
  73351. private _singleInstance;
  73352. private _cameras;
  73353. private _indicesForCamera;
  73354. /**
  73355. * Name of the effect
  73356. * @hidden
  73357. */
  73358. _name: string;
  73359. /**
  73360. * Instantiates a post process render effect.
  73361. * A post process can be used to apply a shader to a texture after it is rendered.
  73362. * @param engine The engine the effect is tied to
  73363. * @param name The name of the effect
  73364. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73365. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73366. */
  73367. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73368. /**
  73369. * Checks if all the post processes in the effect are supported.
  73370. */
  73371. get isSupported(): boolean;
  73372. /**
  73373. * Updates the current state of the effect
  73374. * @hidden
  73375. */
  73376. _update(): void;
  73377. /**
  73378. * Attaches the effect on cameras
  73379. * @param cameras The camera to attach to.
  73380. * @hidden
  73381. */
  73382. _attachCameras(cameras: Camera): void;
  73383. /**
  73384. * Attaches the effect on cameras
  73385. * @param cameras The camera to attach to.
  73386. * @hidden
  73387. */
  73388. _attachCameras(cameras: Camera[]): void;
  73389. /**
  73390. * Detaches the effect on cameras
  73391. * @param cameras The camera to detatch from.
  73392. * @hidden
  73393. */
  73394. _detachCameras(cameras: Camera): void;
  73395. /**
  73396. * Detatches the effect on cameras
  73397. * @param cameras The camera to detatch from.
  73398. * @hidden
  73399. */
  73400. _detachCameras(cameras: Camera[]): void;
  73401. /**
  73402. * Enables the effect on given cameras
  73403. * @param cameras The camera to enable.
  73404. * @hidden
  73405. */
  73406. _enable(cameras: Camera): void;
  73407. /**
  73408. * Enables the effect on given cameras
  73409. * @param cameras The camera to enable.
  73410. * @hidden
  73411. */
  73412. _enable(cameras: Nullable<Camera[]>): void;
  73413. /**
  73414. * Disables the effect on the given cameras
  73415. * @param cameras The camera to disable.
  73416. * @hidden
  73417. */
  73418. _disable(cameras: Camera): void;
  73419. /**
  73420. * Disables the effect on the given cameras
  73421. * @param cameras The camera to disable.
  73422. * @hidden
  73423. */
  73424. _disable(cameras: Nullable<Camera[]>): void;
  73425. /**
  73426. * Gets a list of the post processes contained in the effect.
  73427. * @param camera The camera to get the post processes on.
  73428. * @returns The list of the post processes in the effect.
  73429. */
  73430. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73431. }
  73432. }
  73433. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73434. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73435. /** @hidden */
  73436. export var extractHighlightsPixelShader: {
  73437. name: string;
  73438. shader: string;
  73439. };
  73440. }
  73441. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73442. import { Nullable } from "babylonjs/types";
  73443. import { Camera } from "babylonjs/Cameras/camera";
  73444. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73445. import { Engine } from "babylonjs/Engines/engine";
  73446. import "babylonjs/Shaders/extractHighlights.fragment";
  73447. /**
  73448. * 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.
  73449. */
  73450. export class ExtractHighlightsPostProcess extends PostProcess {
  73451. /**
  73452. * The luminance threshold, pixels below this value will be set to black.
  73453. */
  73454. threshold: number;
  73455. /** @hidden */
  73456. _exposure: number;
  73457. /**
  73458. * Post process which has the input texture to be used when performing highlight extraction
  73459. * @hidden
  73460. */
  73461. _inputPostProcess: Nullable<PostProcess>;
  73462. /**
  73463. * Gets a string identifying the name of the class
  73464. * @returns "ExtractHighlightsPostProcess" string
  73465. */
  73466. getClassName(): string;
  73467. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73468. }
  73469. }
  73470. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73471. /** @hidden */
  73472. export var bloomMergePixelShader: {
  73473. name: string;
  73474. shader: string;
  73475. };
  73476. }
  73477. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73478. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73479. import { Nullable } from "babylonjs/types";
  73480. import { Engine } from "babylonjs/Engines/engine";
  73481. import { Camera } from "babylonjs/Cameras/camera";
  73482. import "babylonjs/Shaders/bloomMerge.fragment";
  73483. /**
  73484. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73485. */
  73486. export class BloomMergePostProcess extends PostProcess {
  73487. /** Weight of the bloom to be added to the original input. */
  73488. weight: number;
  73489. /**
  73490. * Gets a string identifying the name of the class
  73491. * @returns "BloomMergePostProcess" string
  73492. */
  73493. getClassName(): string;
  73494. /**
  73495. * Creates a new instance of @see BloomMergePostProcess
  73496. * @param name The name of the effect.
  73497. * @param originalFromInput Post process which's input will be used for the merge.
  73498. * @param blurred Blurred highlights post process which's output will be used.
  73499. * @param weight Weight of the bloom to be added to the original input.
  73500. * @param options The required width/height ratio to downsize to before computing the render pass.
  73501. * @param camera The camera to apply the render pass to.
  73502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73503. * @param engine The engine which the post process will be applied. (default: current engine)
  73504. * @param reusable If the post process can be reused on the same frame. (default: false)
  73505. * @param textureType Type of textures used when performing the post process. (default: 0)
  73506. * @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)
  73507. */
  73508. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73509. /** Weight of the bloom to be added to the original input. */
  73510. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73511. }
  73512. }
  73513. declare module "babylonjs/PostProcesses/bloomEffect" {
  73514. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73515. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73516. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73517. import { Camera } from "babylonjs/Cameras/camera";
  73518. import { Scene } from "babylonjs/scene";
  73519. /**
  73520. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73521. */
  73522. export class BloomEffect extends PostProcessRenderEffect {
  73523. private bloomScale;
  73524. /**
  73525. * @hidden Internal
  73526. */
  73527. _effects: Array<PostProcess>;
  73528. /**
  73529. * @hidden Internal
  73530. */
  73531. _downscale: ExtractHighlightsPostProcess;
  73532. private _blurX;
  73533. private _blurY;
  73534. private _merge;
  73535. /**
  73536. * The luminance threshold to find bright areas of the image to bloom.
  73537. */
  73538. get threshold(): number;
  73539. set threshold(value: number);
  73540. /**
  73541. * The strength of the bloom.
  73542. */
  73543. get weight(): number;
  73544. set weight(value: number);
  73545. /**
  73546. * Specifies the size of the bloom blur kernel, relative to the final output size
  73547. */
  73548. get kernel(): number;
  73549. set kernel(value: number);
  73550. /**
  73551. * Creates a new instance of @see BloomEffect
  73552. * @param scene The scene the effect belongs to.
  73553. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73554. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73555. * @param bloomWeight The the strength of bloom.
  73556. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73557. * @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)
  73558. */
  73559. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73560. /**
  73561. * Disposes each of the internal effects for a given camera.
  73562. * @param camera The camera to dispose the effect on.
  73563. */
  73564. disposeEffects(camera: Camera): void;
  73565. /**
  73566. * @hidden Internal
  73567. */
  73568. _updateEffects(): void;
  73569. /**
  73570. * Internal
  73571. * @returns if all the contained post processes are ready.
  73572. * @hidden
  73573. */
  73574. _isReady(): boolean;
  73575. }
  73576. }
  73577. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73578. /** @hidden */
  73579. export var chromaticAberrationPixelShader: {
  73580. name: string;
  73581. shader: string;
  73582. };
  73583. }
  73584. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73585. import { Vector2 } from "babylonjs/Maths/math.vector";
  73586. import { Nullable } from "babylonjs/types";
  73587. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73588. import { Camera } from "babylonjs/Cameras/camera";
  73589. import { Engine } from "babylonjs/Engines/engine";
  73590. import "babylonjs/Shaders/chromaticAberration.fragment";
  73591. import { Scene } from "babylonjs/scene";
  73592. /**
  73593. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73594. */
  73595. export class ChromaticAberrationPostProcess extends PostProcess {
  73596. /**
  73597. * The amount of seperation of rgb channels (default: 30)
  73598. */
  73599. aberrationAmount: number;
  73600. /**
  73601. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73602. */
  73603. radialIntensity: number;
  73604. /**
  73605. * 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))
  73606. */
  73607. direction: Vector2;
  73608. /**
  73609. * 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))
  73610. */
  73611. centerPosition: Vector2;
  73612. /** The width of the screen to apply the effect on */
  73613. screenWidth: number;
  73614. /** The height of the screen to apply the effect on */
  73615. screenHeight: number;
  73616. /**
  73617. * Gets a string identifying the name of the class
  73618. * @returns "ChromaticAberrationPostProcess" string
  73619. */
  73620. getClassName(): string;
  73621. /**
  73622. * Creates a new instance ChromaticAberrationPostProcess
  73623. * @param name The name of the effect.
  73624. * @param screenWidth The width of the screen to apply the effect on.
  73625. * @param screenHeight The height of the screen to apply the effect on.
  73626. * @param options The required width/height ratio to downsize to before computing the render pass.
  73627. * @param camera The camera to apply the render pass to.
  73628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73629. * @param engine The engine which the post process will be applied. (default: current engine)
  73630. * @param reusable If the post process can be reused on the same frame. (default: false)
  73631. * @param textureType Type of textures used when performing the post process. (default: 0)
  73632. * @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)
  73633. */
  73634. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73635. /** @hidden */
  73636. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73637. }
  73638. }
  73639. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73640. /** @hidden */
  73641. export var circleOfConfusionPixelShader: {
  73642. name: string;
  73643. shader: string;
  73644. };
  73645. }
  73646. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73647. import { Nullable } from "babylonjs/types";
  73648. import { Engine } from "babylonjs/Engines/engine";
  73649. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73650. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73651. import { Camera } from "babylonjs/Cameras/camera";
  73652. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73653. /**
  73654. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73655. */
  73656. export class CircleOfConfusionPostProcess extends PostProcess {
  73657. /**
  73658. * 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.
  73659. */
  73660. lensSize: number;
  73661. /**
  73662. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73663. */
  73664. fStop: number;
  73665. /**
  73666. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73667. */
  73668. focusDistance: number;
  73669. /**
  73670. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73671. */
  73672. focalLength: number;
  73673. /**
  73674. * Gets a string identifying the name of the class
  73675. * @returns "CircleOfConfusionPostProcess" string
  73676. */
  73677. getClassName(): string;
  73678. private _depthTexture;
  73679. /**
  73680. * Creates a new instance CircleOfConfusionPostProcess
  73681. * @param name The name of the effect.
  73682. * @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.
  73683. * @param options The required width/height ratio to downsize to before computing the render pass.
  73684. * @param camera The camera to apply the render pass to.
  73685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73686. * @param engine The engine which the post process will be applied. (default: current engine)
  73687. * @param reusable If the post process can be reused on the same frame. (default: false)
  73688. * @param textureType Type of textures used when performing the post process. (default: 0)
  73689. * @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)
  73690. */
  73691. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73692. /**
  73693. * 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.
  73694. */
  73695. set depthTexture(value: RenderTargetTexture);
  73696. }
  73697. }
  73698. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73699. /** @hidden */
  73700. export var colorCorrectionPixelShader: {
  73701. name: string;
  73702. shader: string;
  73703. };
  73704. }
  73705. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73706. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73707. import { Engine } from "babylonjs/Engines/engine";
  73708. import { Camera } from "babylonjs/Cameras/camera";
  73709. import "babylonjs/Shaders/colorCorrection.fragment";
  73710. import { Nullable } from "babylonjs/types";
  73711. import { Scene } from "babylonjs/scene";
  73712. /**
  73713. *
  73714. * This post-process allows the modification of rendered colors by using
  73715. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73716. *
  73717. * The object needs to be provided an url to a texture containing the color
  73718. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73719. * Use an image editing software to tweak the LUT to match your needs.
  73720. *
  73721. * For an example of a color LUT, see here:
  73722. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73723. * For explanations on color grading, see here:
  73724. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73725. *
  73726. */
  73727. export class ColorCorrectionPostProcess extends PostProcess {
  73728. private _colorTableTexture;
  73729. /**
  73730. * Gets the color table url used to create the LUT texture
  73731. */
  73732. colorTableUrl: string;
  73733. /**
  73734. * Gets a string identifying the name of the class
  73735. * @returns "ColorCorrectionPostProcess" string
  73736. */
  73737. getClassName(): string;
  73738. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73739. /** @hidden */
  73740. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73741. }
  73742. }
  73743. declare module "babylonjs/Shaders/convolution.fragment" {
  73744. /** @hidden */
  73745. export var convolutionPixelShader: {
  73746. name: string;
  73747. shader: string;
  73748. };
  73749. }
  73750. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73751. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73752. import { Nullable } from "babylonjs/types";
  73753. import { Camera } from "babylonjs/Cameras/camera";
  73754. import { Engine } from "babylonjs/Engines/engine";
  73755. import "babylonjs/Shaders/convolution.fragment";
  73756. import { Scene } from "babylonjs/scene";
  73757. /**
  73758. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73759. * input texture to perform effects such as edge detection or sharpening
  73760. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73761. */
  73762. export class ConvolutionPostProcess extends PostProcess {
  73763. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73764. kernel: number[];
  73765. /**
  73766. * Gets a string identifying the name of the class
  73767. * @returns "ConvolutionPostProcess" string
  73768. */
  73769. getClassName(): string;
  73770. /**
  73771. * Creates a new instance ConvolutionPostProcess
  73772. * @param name The name of the effect.
  73773. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73774. * @param options The required width/height ratio to downsize to before computing the render pass.
  73775. * @param camera The camera to apply the render pass to.
  73776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73777. * @param engine The engine which the post process will be applied. (default: current engine)
  73778. * @param reusable If the post process can be reused on the same frame. (default: false)
  73779. * @param textureType Type of textures used when performing the post process. (default: 0)
  73780. */
  73781. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73782. /** @hidden */
  73783. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73784. /**
  73785. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73786. */
  73787. static EdgeDetect0Kernel: number[];
  73788. /**
  73789. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73790. */
  73791. static EdgeDetect1Kernel: number[];
  73792. /**
  73793. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73794. */
  73795. static EdgeDetect2Kernel: number[];
  73796. /**
  73797. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73798. */
  73799. static SharpenKernel: number[];
  73800. /**
  73801. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73802. */
  73803. static EmbossKernel: number[];
  73804. /**
  73805. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73806. */
  73807. static GaussianKernel: number[];
  73808. }
  73809. }
  73810. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73811. import { Nullable } from "babylonjs/types";
  73812. import { Vector2 } from "babylonjs/Maths/math.vector";
  73813. import { Camera } from "babylonjs/Cameras/camera";
  73814. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73815. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73816. import { Engine } from "babylonjs/Engines/engine";
  73817. import { Scene } from "babylonjs/scene";
  73818. /**
  73819. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73820. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73821. * based on samples that have a large difference in distance than the center pixel.
  73822. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73823. */
  73824. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73825. /**
  73826. * The direction the blur should be applied
  73827. */
  73828. direction: Vector2;
  73829. /**
  73830. * Gets a string identifying the name of the class
  73831. * @returns "DepthOfFieldBlurPostProcess" string
  73832. */
  73833. getClassName(): string;
  73834. /**
  73835. * Creates a new instance CircleOfConfusionPostProcess
  73836. * @param name The name of the effect.
  73837. * @param scene The scene the effect belongs to.
  73838. * @param direction The direction the blur should be applied.
  73839. * @param kernel The size of the kernel used to blur.
  73840. * @param options The required width/height ratio to downsize to before computing the render pass.
  73841. * @param camera The camera to apply the render pass to.
  73842. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73843. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73844. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73845. * @param engine The engine which the post process will be applied. (default: current engine)
  73846. * @param reusable If the post process can be reused on the same frame. (default: false)
  73847. * @param textureType Type of textures used when performing the post process. (default: 0)
  73848. * @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)
  73849. */
  73850. 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);
  73851. }
  73852. }
  73853. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73854. /** @hidden */
  73855. export var depthOfFieldMergePixelShader: {
  73856. name: string;
  73857. shader: string;
  73858. };
  73859. }
  73860. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73861. import { Nullable } from "babylonjs/types";
  73862. import { Camera } from "babylonjs/Cameras/camera";
  73863. import { Effect } from "babylonjs/Materials/effect";
  73864. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73865. import { Engine } from "babylonjs/Engines/engine";
  73866. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73867. /**
  73868. * Options to be set when merging outputs from the default pipeline.
  73869. */
  73870. export class DepthOfFieldMergePostProcessOptions {
  73871. /**
  73872. * The original image to merge on top of
  73873. */
  73874. originalFromInput: PostProcess;
  73875. /**
  73876. * Parameters to perform the merge of the depth of field effect
  73877. */
  73878. depthOfField?: {
  73879. circleOfConfusion: PostProcess;
  73880. blurSteps: Array<PostProcess>;
  73881. };
  73882. /**
  73883. * Parameters to perform the merge of bloom effect
  73884. */
  73885. bloom?: {
  73886. blurred: PostProcess;
  73887. weight: number;
  73888. };
  73889. }
  73890. /**
  73891. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73892. */
  73893. export class DepthOfFieldMergePostProcess extends PostProcess {
  73894. private blurSteps;
  73895. /**
  73896. * Gets a string identifying the name of the class
  73897. * @returns "DepthOfFieldMergePostProcess" string
  73898. */
  73899. getClassName(): string;
  73900. /**
  73901. * Creates a new instance of DepthOfFieldMergePostProcess
  73902. * @param name The name of the effect.
  73903. * @param originalFromInput Post process which's input will be used for the merge.
  73904. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73905. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73906. * @param options The required width/height ratio to downsize to before computing the render pass.
  73907. * @param camera The camera to apply the render pass to.
  73908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73909. * @param engine The engine which the post process will be applied. (default: current engine)
  73910. * @param reusable If the post process can be reused on the same frame. (default: false)
  73911. * @param textureType Type of textures used when performing the post process. (default: 0)
  73912. * @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)
  73913. */
  73914. 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);
  73915. /**
  73916. * Updates the effect with the current post process compile time values and recompiles the shader.
  73917. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73918. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73919. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73920. * @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
  73921. * @param onCompiled Called when the shader has been compiled.
  73922. * @param onError Called if there is an error when compiling a shader.
  73923. */
  73924. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73925. }
  73926. }
  73927. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73928. import { Nullable } from "babylonjs/types";
  73929. import { Camera } from "babylonjs/Cameras/camera";
  73930. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73931. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73932. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73933. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73934. import { Scene } from "babylonjs/scene";
  73935. /**
  73936. * Specifies the level of max blur that should be applied when using the depth of field effect
  73937. */
  73938. export enum DepthOfFieldEffectBlurLevel {
  73939. /**
  73940. * Subtle blur
  73941. */
  73942. Low = 0,
  73943. /**
  73944. * Medium blur
  73945. */
  73946. Medium = 1,
  73947. /**
  73948. * Large blur
  73949. */
  73950. High = 2
  73951. }
  73952. /**
  73953. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73954. */
  73955. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73956. private _circleOfConfusion;
  73957. /**
  73958. * @hidden Internal, blurs from high to low
  73959. */
  73960. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73961. private _depthOfFieldBlurY;
  73962. private _dofMerge;
  73963. /**
  73964. * @hidden Internal post processes in depth of field effect
  73965. */
  73966. _effects: Array<PostProcess>;
  73967. /**
  73968. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73969. */
  73970. set focalLength(value: number);
  73971. get focalLength(): number;
  73972. /**
  73973. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73974. */
  73975. set fStop(value: number);
  73976. get fStop(): number;
  73977. /**
  73978. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73979. */
  73980. set focusDistance(value: number);
  73981. get focusDistance(): number;
  73982. /**
  73983. * 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.
  73984. */
  73985. set lensSize(value: number);
  73986. get lensSize(): number;
  73987. /**
  73988. * Creates a new instance DepthOfFieldEffect
  73989. * @param scene The scene the effect belongs to.
  73990. * @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.
  73991. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73992. * @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)
  73993. */
  73994. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73995. /**
  73996. * Get the current class name of the current effet
  73997. * @returns "DepthOfFieldEffect"
  73998. */
  73999. getClassName(): string;
  74000. /**
  74001. * 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.
  74002. */
  74003. set depthTexture(value: RenderTargetTexture);
  74004. /**
  74005. * Disposes each of the internal effects for a given camera.
  74006. * @param camera The camera to dispose the effect on.
  74007. */
  74008. disposeEffects(camera: Camera): void;
  74009. /**
  74010. * @hidden Internal
  74011. */
  74012. _updateEffects(): void;
  74013. /**
  74014. * Internal
  74015. * @returns if all the contained post processes are ready.
  74016. * @hidden
  74017. */
  74018. _isReady(): boolean;
  74019. }
  74020. }
  74021. declare module "babylonjs/Shaders/displayPass.fragment" {
  74022. /** @hidden */
  74023. export var displayPassPixelShader: {
  74024. name: string;
  74025. shader: string;
  74026. };
  74027. }
  74028. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74029. import { Nullable } from "babylonjs/types";
  74030. import { Camera } from "babylonjs/Cameras/camera";
  74031. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74032. import { Engine } from "babylonjs/Engines/engine";
  74033. import "babylonjs/Shaders/displayPass.fragment";
  74034. import { Scene } from "babylonjs/scene";
  74035. /**
  74036. * DisplayPassPostProcess which produces an output the same as it's input
  74037. */
  74038. export class DisplayPassPostProcess extends PostProcess {
  74039. /**
  74040. * Gets a string identifying the name of the class
  74041. * @returns "DisplayPassPostProcess" string
  74042. */
  74043. getClassName(): string;
  74044. /**
  74045. * Creates the DisplayPassPostProcess
  74046. * @param name The name of the effect.
  74047. * @param options The required width/height ratio to downsize to before computing the render pass.
  74048. * @param camera The camera to apply the render pass to.
  74049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74050. * @param engine The engine which the post process will be applied. (default: current engine)
  74051. * @param reusable If the post process can be reused on the same frame. (default: false)
  74052. */
  74053. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74054. /** @hidden */
  74055. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74056. }
  74057. }
  74058. declare module "babylonjs/Shaders/filter.fragment" {
  74059. /** @hidden */
  74060. export var filterPixelShader: {
  74061. name: string;
  74062. shader: string;
  74063. };
  74064. }
  74065. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74066. import { Nullable } from "babylonjs/types";
  74067. import { Matrix } from "babylonjs/Maths/math.vector";
  74068. import { Camera } from "babylonjs/Cameras/camera";
  74069. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74070. import { Engine } from "babylonjs/Engines/engine";
  74071. import "babylonjs/Shaders/filter.fragment";
  74072. import { Scene } from "babylonjs/scene";
  74073. /**
  74074. * Applies a kernel filter to the image
  74075. */
  74076. export class FilterPostProcess extends PostProcess {
  74077. /** The matrix to be applied to the image */
  74078. kernelMatrix: Matrix;
  74079. /**
  74080. * Gets a string identifying the name of the class
  74081. * @returns "FilterPostProcess" string
  74082. */
  74083. getClassName(): string;
  74084. /**
  74085. *
  74086. * @param name The name of the effect.
  74087. * @param kernelMatrix The matrix to be applied to the image
  74088. * @param options The required width/height ratio to downsize to before computing the render pass.
  74089. * @param camera The camera to apply the render pass to.
  74090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74091. * @param engine The engine which the post process will be applied. (default: current engine)
  74092. * @param reusable If the post process can be reused on the same frame. (default: false)
  74093. */
  74094. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74095. /** @hidden */
  74096. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74097. }
  74098. }
  74099. declare module "babylonjs/Shaders/fxaa.fragment" {
  74100. /** @hidden */
  74101. export var fxaaPixelShader: {
  74102. name: string;
  74103. shader: string;
  74104. };
  74105. }
  74106. declare module "babylonjs/Shaders/fxaa.vertex" {
  74107. /** @hidden */
  74108. export var fxaaVertexShader: {
  74109. name: string;
  74110. shader: string;
  74111. };
  74112. }
  74113. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74114. import { Nullable } from "babylonjs/types";
  74115. import { Camera } from "babylonjs/Cameras/camera";
  74116. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74117. import { Engine } from "babylonjs/Engines/engine";
  74118. import "babylonjs/Shaders/fxaa.fragment";
  74119. import "babylonjs/Shaders/fxaa.vertex";
  74120. import { Scene } from "babylonjs/scene";
  74121. /**
  74122. * Fxaa post process
  74123. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74124. */
  74125. export class FxaaPostProcess extends PostProcess {
  74126. /**
  74127. * Gets a string identifying the name of the class
  74128. * @returns "FxaaPostProcess" string
  74129. */
  74130. getClassName(): string;
  74131. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74132. private _getDefines;
  74133. /** @hidden */
  74134. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74135. }
  74136. }
  74137. declare module "babylonjs/Shaders/grain.fragment" {
  74138. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74139. /** @hidden */
  74140. export var grainPixelShader: {
  74141. name: string;
  74142. shader: string;
  74143. };
  74144. }
  74145. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74146. import { Nullable } from "babylonjs/types";
  74147. import { Camera } from "babylonjs/Cameras/camera";
  74148. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74149. import { Engine } from "babylonjs/Engines/engine";
  74150. import "babylonjs/Shaders/grain.fragment";
  74151. import { Scene } from "babylonjs/scene";
  74152. /**
  74153. * The GrainPostProcess adds noise to the image at mid luminance levels
  74154. */
  74155. export class GrainPostProcess extends PostProcess {
  74156. /**
  74157. * The intensity of the grain added (default: 30)
  74158. */
  74159. intensity: number;
  74160. /**
  74161. * If the grain should be randomized on every frame
  74162. */
  74163. animated: boolean;
  74164. /**
  74165. * Gets a string identifying the name of the class
  74166. * @returns "GrainPostProcess" string
  74167. */
  74168. getClassName(): string;
  74169. /**
  74170. * Creates a new instance of @see GrainPostProcess
  74171. * @param name The name of the effect.
  74172. * @param options The required width/height ratio to downsize to before computing the render pass.
  74173. * @param camera The camera to apply the render pass to.
  74174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74175. * @param engine The engine which the post process will be applied. (default: current engine)
  74176. * @param reusable If the post process can be reused on the same frame. (default: false)
  74177. * @param textureType Type of textures used when performing the post process. (default: 0)
  74178. * @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)
  74179. */
  74180. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74181. /** @hidden */
  74182. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74183. }
  74184. }
  74185. declare module "babylonjs/Shaders/highlights.fragment" {
  74186. /** @hidden */
  74187. export var highlightsPixelShader: {
  74188. name: string;
  74189. shader: string;
  74190. };
  74191. }
  74192. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74193. import { Nullable } from "babylonjs/types";
  74194. import { Camera } from "babylonjs/Cameras/camera";
  74195. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74196. import { Engine } from "babylonjs/Engines/engine";
  74197. import "babylonjs/Shaders/highlights.fragment";
  74198. /**
  74199. * Extracts highlights from the image
  74200. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74201. */
  74202. export class HighlightsPostProcess extends PostProcess {
  74203. /**
  74204. * Gets a string identifying the name of the class
  74205. * @returns "HighlightsPostProcess" string
  74206. */
  74207. getClassName(): string;
  74208. /**
  74209. * Extracts highlights from the image
  74210. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74211. * @param name The name of the effect.
  74212. * @param options The required width/height ratio to downsize to before computing the render pass.
  74213. * @param camera The camera to apply the render pass to.
  74214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74215. * @param engine The engine which the post process will be applied. (default: current engine)
  74216. * @param reusable If the post process can be reused on the same frame. (default: false)
  74217. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74218. */
  74219. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74220. }
  74221. }
  74222. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74223. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74224. /**
  74225. * Contains all parameters needed for the prepass to perform
  74226. * motion blur
  74227. */
  74228. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74229. /**
  74230. * Is motion blur enabled
  74231. */
  74232. enabled: boolean;
  74233. /**
  74234. * Name of the configuration
  74235. */
  74236. name: string;
  74237. /**
  74238. * Textures that should be present in the MRT for this effect to work
  74239. */
  74240. readonly texturesRequired: number[];
  74241. }
  74242. }
  74243. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74244. import { Nullable } from "babylonjs/types";
  74245. import { Scene } from "babylonjs/scene";
  74246. import { ISceneComponent } from "babylonjs/sceneComponent";
  74247. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74248. module "babylonjs/scene" {
  74249. interface Scene {
  74250. /** @hidden (Backing field) */
  74251. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74252. /**
  74253. * Gets or Sets the current geometry buffer associated to the scene.
  74254. */
  74255. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74256. /**
  74257. * Enables a GeometryBufferRender and associates it with the scene
  74258. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74259. * @returns the GeometryBufferRenderer
  74260. */
  74261. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74262. /**
  74263. * Disables the GeometryBufferRender associated with the scene
  74264. */
  74265. disableGeometryBufferRenderer(): void;
  74266. }
  74267. }
  74268. /**
  74269. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74270. * in several rendering techniques.
  74271. */
  74272. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74273. /**
  74274. * The component name helpful to identify the component in the list of scene components.
  74275. */
  74276. readonly name: string;
  74277. /**
  74278. * The scene the component belongs to.
  74279. */
  74280. scene: Scene;
  74281. /**
  74282. * Creates a new instance of the component for the given scene
  74283. * @param scene Defines the scene to register the component in
  74284. */
  74285. constructor(scene: Scene);
  74286. /**
  74287. * Registers the component in a given scene
  74288. */
  74289. register(): void;
  74290. /**
  74291. * Rebuilds the elements related to this component in case of
  74292. * context lost for instance.
  74293. */
  74294. rebuild(): void;
  74295. /**
  74296. * Disposes the component and the associated ressources
  74297. */
  74298. dispose(): void;
  74299. private _gatherRenderTargets;
  74300. }
  74301. }
  74302. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74303. /** @hidden */
  74304. export var motionBlurPixelShader: {
  74305. name: string;
  74306. shader: string;
  74307. };
  74308. }
  74309. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74310. import { Nullable } from "babylonjs/types";
  74311. import { Camera } from "babylonjs/Cameras/camera";
  74312. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74314. import "babylonjs/Animations/animatable";
  74315. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74316. import "babylonjs/Shaders/motionBlur.fragment";
  74317. import { Engine } from "babylonjs/Engines/engine";
  74318. import { Scene } from "babylonjs/scene";
  74319. /**
  74320. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74321. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74322. * As an example, all you have to do is to create the post-process:
  74323. * var mb = new BABYLON.MotionBlurPostProcess(
  74324. * 'mb', // The name of the effect.
  74325. * scene, // The scene containing the objects to blur according to their velocity.
  74326. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74327. * camera // The camera to apply the render pass to.
  74328. * );
  74329. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74330. */
  74331. export class MotionBlurPostProcess extends PostProcess {
  74332. /**
  74333. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74334. */
  74335. motionStrength: number;
  74336. /**
  74337. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74338. */
  74339. get motionBlurSamples(): number;
  74340. /**
  74341. * Sets the number of iterations to be used for motion blur quality
  74342. */
  74343. set motionBlurSamples(samples: number);
  74344. private _motionBlurSamples;
  74345. private _forceGeometryBuffer;
  74346. private _geometryBufferRenderer;
  74347. private _prePassRenderer;
  74348. /**
  74349. * Gets a string identifying the name of the class
  74350. * @returns "MotionBlurPostProcess" string
  74351. */
  74352. getClassName(): string;
  74353. /**
  74354. * Creates a new instance MotionBlurPostProcess
  74355. * @param name The name of the effect.
  74356. * @param scene The scene containing the objects to blur according to their velocity.
  74357. * @param options The required width/height ratio to downsize to before computing the render pass.
  74358. * @param camera The camera to apply the render pass to.
  74359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74360. * @param engine The engine which the post process will be applied. (default: current engine)
  74361. * @param reusable If the post process can be reused on the same frame. (default: false)
  74362. * @param textureType Type of textures used when performing the post process. (default: 0)
  74363. * @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)
  74364. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74365. */
  74366. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74367. /**
  74368. * Excludes the given skinned mesh from computing bones velocities.
  74369. * 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.
  74370. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74371. */
  74372. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74373. /**
  74374. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74375. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74376. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74377. */
  74378. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74379. /**
  74380. * Disposes the post process.
  74381. * @param camera The camera to dispose the post process on.
  74382. */
  74383. dispose(camera?: Camera): void;
  74384. /** @hidden */
  74385. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74386. }
  74387. }
  74388. declare module "babylonjs/Shaders/refraction.fragment" {
  74389. /** @hidden */
  74390. export var refractionPixelShader: {
  74391. name: string;
  74392. shader: string;
  74393. };
  74394. }
  74395. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74396. import { Color3 } from "babylonjs/Maths/math.color";
  74397. import { Camera } from "babylonjs/Cameras/camera";
  74398. import { Texture } from "babylonjs/Materials/Textures/texture";
  74399. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74400. import { Engine } from "babylonjs/Engines/engine";
  74401. import "babylonjs/Shaders/refraction.fragment";
  74402. import { Scene } from "babylonjs/scene";
  74403. /**
  74404. * Post process which applies a refractin texture
  74405. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74406. */
  74407. export class RefractionPostProcess extends PostProcess {
  74408. private _refTexture;
  74409. private _ownRefractionTexture;
  74410. /** the base color of the refraction (used to taint the rendering) */
  74411. color: Color3;
  74412. /** simulated refraction depth */
  74413. depth: number;
  74414. /** the coefficient of the base color (0 to remove base color tainting) */
  74415. colorLevel: number;
  74416. /** Gets the url used to load the refraction texture */
  74417. refractionTextureUrl: string;
  74418. /**
  74419. * Gets or sets the refraction texture
  74420. * Please note that you are responsible for disposing the texture if you set it manually
  74421. */
  74422. get refractionTexture(): Texture;
  74423. set refractionTexture(value: Texture);
  74424. /**
  74425. * Gets a string identifying the name of the class
  74426. * @returns "RefractionPostProcess" string
  74427. */
  74428. getClassName(): string;
  74429. /**
  74430. * Initializes the RefractionPostProcess
  74431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74432. * @param name The name of the effect.
  74433. * @param refractionTextureUrl Url of the refraction texture to use
  74434. * @param color the base color of the refraction (used to taint the rendering)
  74435. * @param depth simulated refraction depth
  74436. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74437. * @param camera The camera to apply the render pass to.
  74438. * @param options The required width/height ratio to downsize to before computing the render pass.
  74439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74440. * @param engine The engine which the post process will be applied. (default: current engine)
  74441. * @param reusable If the post process can be reused on the same frame. (default: false)
  74442. */
  74443. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74444. /**
  74445. * Disposes of the post process
  74446. * @param camera Camera to dispose post process on
  74447. */
  74448. dispose(camera: Camera): void;
  74449. /** @hidden */
  74450. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74451. }
  74452. }
  74453. declare module "babylonjs/Shaders/sharpen.fragment" {
  74454. /** @hidden */
  74455. export var sharpenPixelShader: {
  74456. name: string;
  74457. shader: string;
  74458. };
  74459. }
  74460. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74461. import { Nullable } from "babylonjs/types";
  74462. import { Camera } from "babylonjs/Cameras/camera";
  74463. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74464. import "babylonjs/Shaders/sharpen.fragment";
  74465. import { Engine } from "babylonjs/Engines/engine";
  74466. import { Scene } from "babylonjs/scene";
  74467. /**
  74468. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74469. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74470. */
  74471. export class SharpenPostProcess extends PostProcess {
  74472. /**
  74473. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74474. */
  74475. colorAmount: number;
  74476. /**
  74477. * How much sharpness should be applied (default: 0.3)
  74478. */
  74479. edgeAmount: number;
  74480. /**
  74481. * Gets a string identifying the name of the class
  74482. * @returns "SharpenPostProcess" string
  74483. */
  74484. getClassName(): string;
  74485. /**
  74486. * Creates a new instance ConvolutionPostProcess
  74487. * @param name The name of the effect.
  74488. * @param options The required width/height ratio to downsize to before computing the render pass.
  74489. * @param camera The camera to apply the render pass to.
  74490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74491. * @param engine The engine which the post process will be applied. (default: current engine)
  74492. * @param reusable If the post process can be reused on the same frame. (default: false)
  74493. * @param textureType Type of textures used when performing the post process. (default: 0)
  74494. * @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)
  74495. */
  74496. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74497. /** @hidden */
  74498. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74499. }
  74500. }
  74501. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74502. import { Nullable } from "babylonjs/types";
  74503. import { Camera } from "babylonjs/Cameras/camera";
  74504. import { Engine } from "babylonjs/Engines/engine";
  74505. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74506. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74507. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74508. /**
  74509. * PostProcessRenderPipeline
  74510. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74511. */
  74512. export class PostProcessRenderPipeline {
  74513. private engine;
  74514. private _renderEffects;
  74515. private _renderEffectsForIsolatedPass;
  74516. /**
  74517. * List of inspectable custom properties (used by the Inspector)
  74518. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74519. */
  74520. inspectableCustomProperties: IInspectable[];
  74521. /**
  74522. * @hidden
  74523. */
  74524. protected _cameras: Camera[];
  74525. /** @hidden */
  74526. _name: string;
  74527. /**
  74528. * Gets pipeline name
  74529. */
  74530. get name(): string;
  74531. /** Gets the list of attached cameras */
  74532. get cameras(): Camera[];
  74533. /**
  74534. * Initializes a PostProcessRenderPipeline
  74535. * @param engine engine to add the pipeline to
  74536. * @param name name of the pipeline
  74537. */
  74538. constructor(engine: Engine, name: string);
  74539. /**
  74540. * Gets the class name
  74541. * @returns "PostProcessRenderPipeline"
  74542. */
  74543. getClassName(): string;
  74544. /**
  74545. * If all the render effects in the pipeline are supported
  74546. */
  74547. get isSupported(): boolean;
  74548. /**
  74549. * Adds an effect to the pipeline
  74550. * @param renderEffect the effect to add
  74551. */
  74552. addEffect(renderEffect: PostProcessRenderEffect): void;
  74553. /** @hidden */
  74554. _rebuild(): void;
  74555. /** @hidden */
  74556. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74557. /** @hidden */
  74558. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74559. /** @hidden */
  74560. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74561. /** @hidden */
  74562. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74563. /** @hidden */
  74564. _attachCameras(cameras: Camera, unique: boolean): void;
  74565. /** @hidden */
  74566. _attachCameras(cameras: Camera[], unique: boolean): void;
  74567. /** @hidden */
  74568. _detachCameras(cameras: Camera): void;
  74569. /** @hidden */
  74570. _detachCameras(cameras: Nullable<Camera[]>): void;
  74571. /** @hidden */
  74572. _update(): void;
  74573. /** @hidden */
  74574. _reset(): void;
  74575. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74576. /**
  74577. * Sets the required values to the prepass renderer.
  74578. * @param prePassRenderer defines the prepass renderer to setup.
  74579. * @returns true if the pre pass is needed.
  74580. */
  74581. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74582. /**
  74583. * Disposes of the pipeline
  74584. */
  74585. dispose(): void;
  74586. }
  74587. }
  74588. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74589. import { Camera } from "babylonjs/Cameras/camera";
  74590. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74591. /**
  74592. * PostProcessRenderPipelineManager class
  74593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74594. */
  74595. export class PostProcessRenderPipelineManager {
  74596. private _renderPipelines;
  74597. /**
  74598. * Initializes a PostProcessRenderPipelineManager
  74599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74600. */
  74601. constructor();
  74602. /**
  74603. * Gets the list of supported render pipelines
  74604. */
  74605. get supportedPipelines(): PostProcessRenderPipeline[];
  74606. /**
  74607. * Adds a pipeline to the manager
  74608. * @param renderPipeline The pipeline to add
  74609. */
  74610. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74611. /**
  74612. * Attaches a camera to the pipeline
  74613. * @param renderPipelineName The name of the pipeline to attach to
  74614. * @param cameras the camera to attach
  74615. * @param unique if the camera can be attached multiple times to the pipeline
  74616. */
  74617. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74618. /**
  74619. * Detaches a camera from the pipeline
  74620. * @param renderPipelineName The name of the pipeline to detach from
  74621. * @param cameras the camera to detach
  74622. */
  74623. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74624. /**
  74625. * Enables an effect by name on a pipeline
  74626. * @param renderPipelineName the name of the pipeline to enable the effect in
  74627. * @param renderEffectName the name of the effect to enable
  74628. * @param cameras the cameras that the effect should be enabled on
  74629. */
  74630. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74631. /**
  74632. * Disables an effect by name on a pipeline
  74633. * @param renderPipelineName the name of the pipeline to disable the effect in
  74634. * @param renderEffectName the name of the effect to disable
  74635. * @param cameras the cameras that the effect should be disabled on
  74636. */
  74637. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74638. /**
  74639. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74640. */
  74641. update(): void;
  74642. /** @hidden */
  74643. _rebuild(): void;
  74644. /**
  74645. * Disposes of the manager and pipelines
  74646. */
  74647. dispose(): void;
  74648. }
  74649. }
  74650. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74651. import { ISceneComponent } from "babylonjs/sceneComponent";
  74652. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74653. import { Scene } from "babylonjs/scene";
  74654. module "babylonjs/scene" {
  74655. interface Scene {
  74656. /** @hidden (Backing field) */
  74657. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74658. /**
  74659. * Gets the postprocess render pipeline manager
  74660. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74661. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74662. */
  74663. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74664. }
  74665. }
  74666. /**
  74667. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74668. */
  74669. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74670. /**
  74671. * The component name helpfull to identify the component in the list of scene components.
  74672. */
  74673. readonly name: string;
  74674. /**
  74675. * The scene the component belongs to.
  74676. */
  74677. scene: Scene;
  74678. /**
  74679. * Creates a new instance of the component for the given scene
  74680. * @param scene Defines the scene to register the component in
  74681. */
  74682. constructor(scene: Scene);
  74683. /**
  74684. * Registers the component in a given scene
  74685. */
  74686. register(): void;
  74687. /**
  74688. * Rebuilds the elements related to this component in case of
  74689. * context lost for instance.
  74690. */
  74691. rebuild(): void;
  74692. /**
  74693. * Disposes the component and the associated ressources
  74694. */
  74695. dispose(): void;
  74696. private _gatherRenderTargets;
  74697. }
  74698. }
  74699. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74700. import { Nullable } from "babylonjs/types";
  74701. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74702. import { Camera } from "babylonjs/Cameras/camera";
  74703. import { IDisposable } from "babylonjs/scene";
  74704. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74705. import { Scene } from "babylonjs/scene";
  74706. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74707. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74708. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74709. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74710. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74711. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74712. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74713. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74714. import { Animation } from "babylonjs/Animations/animation";
  74715. /**
  74716. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74717. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74718. */
  74719. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74720. private _scene;
  74721. private _camerasToBeAttached;
  74722. /**
  74723. * ID of the sharpen post process,
  74724. */
  74725. private readonly SharpenPostProcessId;
  74726. /**
  74727. * @ignore
  74728. * ID of the image processing post process;
  74729. */
  74730. readonly ImageProcessingPostProcessId: string;
  74731. /**
  74732. * @ignore
  74733. * ID of the Fast Approximate Anti-Aliasing post process;
  74734. */
  74735. readonly FxaaPostProcessId: string;
  74736. /**
  74737. * ID of the chromatic aberration post process,
  74738. */
  74739. private readonly ChromaticAberrationPostProcessId;
  74740. /**
  74741. * ID of the grain post process
  74742. */
  74743. private readonly GrainPostProcessId;
  74744. /**
  74745. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74746. */
  74747. sharpen: SharpenPostProcess;
  74748. private _sharpenEffect;
  74749. private bloom;
  74750. /**
  74751. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74752. */
  74753. depthOfField: DepthOfFieldEffect;
  74754. /**
  74755. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74756. */
  74757. fxaa: FxaaPostProcess;
  74758. /**
  74759. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74760. */
  74761. imageProcessing: ImageProcessingPostProcess;
  74762. /**
  74763. * Chromatic aberration post process which will shift rgb colors in the image
  74764. */
  74765. chromaticAberration: ChromaticAberrationPostProcess;
  74766. private _chromaticAberrationEffect;
  74767. /**
  74768. * Grain post process which add noise to the image
  74769. */
  74770. grain: GrainPostProcess;
  74771. private _grainEffect;
  74772. /**
  74773. * Glow post process which adds a glow to emissive areas of the image
  74774. */
  74775. private _glowLayer;
  74776. /**
  74777. * Animations which can be used to tweak settings over a period of time
  74778. */
  74779. animations: Animation[];
  74780. private _imageProcessingConfigurationObserver;
  74781. private _sharpenEnabled;
  74782. private _bloomEnabled;
  74783. private _depthOfFieldEnabled;
  74784. private _depthOfFieldBlurLevel;
  74785. private _fxaaEnabled;
  74786. private _imageProcessingEnabled;
  74787. private _defaultPipelineTextureType;
  74788. private _bloomScale;
  74789. private _chromaticAberrationEnabled;
  74790. private _grainEnabled;
  74791. private _buildAllowed;
  74792. /**
  74793. * Gets active scene
  74794. */
  74795. get scene(): Scene;
  74796. /**
  74797. * Enable or disable the sharpen process from the pipeline
  74798. */
  74799. set sharpenEnabled(enabled: boolean);
  74800. get sharpenEnabled(): boolean;
  74801. private _resizeObserver;
  74802. private _hardwareScaleLevel;
  74803. private _bloomKernel;
  74804. /**
  74805. * Specifies the size of the bloom blur kernel, relative to the final output size
  74806. */
  74807. get bloomKernel(): number;
  74808. set bloomKernel(value: number);
  74809. /**
  74810. * Specifies the weight of the bloom in the final rendering
  74811. */
  74812. private _bloomWeight;
  74813. /**
  74814. * Specifies the luma threshold for the area that will be blurred by the bloom
  74815. */
  74816. private _bloomThreshold;
  74817. private _hdr;
  74818. /**
  74819. * The strength of the bloom.
  74820. */
  74821. set bloomWeight(value: number);
  74822. get bloomWeight(): number;
  74823. /**
  74824. * The strength of the bloom.
  74825. */
  74826. set bloomThreshold(value: number);
  74827. get bloomThreshold(): number;
  74828. /**
  74829. * The scale of the bloom, lower value will provide better performance.
  74830. */
  74831. set bloomScale(value: number);
  74832. get bloomScale(): number;
  74833. /**
  74834. * Enable or disable the bloom from the pipeline
  74835. */
  74836. set bloomEnabled(enabled: boolean);
  74837. get bloomEnabled(): boolean;
  74838. private _rebuildBloom;
  74839. /**
  74840. * If the depth of field is enabled.
  74841. */
  74842. get depthOfFieldEnabled(): boolean;
  74843. set depthOfFieldEnabled(enabled: boolean);
  74844. /**
  74845. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74846. */
  74847. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74848. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74849. /**
  74850. * If the anti aliasing is enabled.
  74851. */
  74852. set fxaaEnabled(enabled: boolean);
  74853. get fxaaEnabled(): boolean;
  74854. private _samples;
  74855. /**
  74856. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74857. */
  74858. set samples(sampleCount: number);
  74859. get samples(): number;
  74860. /**
  74861. * If image processing is enabled.
  74862. */
  74863. set imageProcessingEnabled(enabled: boolean);
  74864. get imageProcessingEnabled(): boolean;
  74865. /**
  74866. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74867. */
  74868. set glowLayerEnabled(enabled: boolean);
  74869. get glowLayerEnabled(): boolean;
  74870. /**
  74871. * Gets the glow layer (or null if not defined)
  74872. */
  74873. get glowLayer(): Nullable<GlowLayer>;
  74874. /**
  74875. * Enable or disable the chromaticAberration process from the pipeline
  74876. */
  74877. set chromaticAberrationEnabled(enabled: boolean);
  74878. get chromaticAberrationEnabled(): boolean;
  74879. /**
  74880. * Enable or disable the grain process from the pipeline
  74881. */
  74882. set grainEnabled(enabled: boolean);
  74883. get grainEnabled(): boolean;
  74884. /**
  74885. * @constructor
  74886. * @param name - The rendering pipeline name (default: "")
  74887. * @param hdr - If high dynamic range textures should be used (default: true)
  74888. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74889. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74890. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74891. */
  74892. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74893. /**
  74894. * Get the class name
  74895. * @returns "DefaultRenderingPipeline"
  74896. */
  74897. getClassName(): string;
  74898. /**
  74899. * Force the compilation of the entire pipeline.
  74900. */
  74901. prepare(): void;
  74902. private _hasCleared;
  74903. private _prevPostProcess;
  74904. private _prevPrevPostProcess;
  74905. private _setAutoClearAndTextureSharing;
  74906. private _depthOfFieldSceneObserver;
  74907. private _buildPipeline;
  74908. private _disposePostProcesses;
  74909. /**
  74910. * Adds a camera to the pipeline
  74911. * @param camera the camera to be added
  74912. */
  74913. addCamera(camera: Camera): void;
  74914. /**
  74915. * Removes a camera from the pipeline
  74916. * @param camera the camera to remove
  74917. */
  74918. removeCamera(camera: Camera): void;
  74919. /**
  74920. * Dispose of the pipeline and stop all post processes
  74921. */
  74922. dispose(): void;
  74923. /**
  74924. * Serialize the rendering pipeline (Used when exporting)
  74925. * @returns the serialized object
  74926. */
  74927. serialize(): any;
  74928. /**
  74929. * Parse the serialized pipeline
  74930. * @param source Source pipeline.
  74931. * @param scene The scene to load the pipeline to.
  74932. * @param rootUrl The URL of the serialized pipeline.
  74933. * @returns An instantiated pipeline from the serialized object.
  74934. */
  74935. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74936. }
  74937. }
  74938. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74939. /** @hidden */
  74940. export var lensHighlightsPixelShader: {
  74941. name: string;
  74942. shader: string;
  74943. };
  74944. }
  74945. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74946. /** @hidden */
  74947. export var depthOfFieldPixelShader: {
  74948. name: string;
  74949. shader: string;
  74950. };
  74951. }
  74952. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74953. import { Camera } from "babylonjs/Cameras/camera";
  74954. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74955. import { Scene } from "babylonjs/scene";
  74956. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74957. import "babylonjs/Shaders/chromaticAberration.fragment";
  74958. import "babylonjs/Shaders/lensHighlights.fragment";
  74959. import "babylonjs/Shaders/depthOfField.fragment";
  74960. /**
  74961. * BABYLON.JS Chromatic Aberration GLSL Shader
  74962. * Author: Olivier Guyot
  74963. * Separates very slightly R, G and B colors on the edges of the screen
  74964. * Inspired by Francois Tarlier & Martins Upitis
  74965. */
  74966. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74967. /**
  74968. * @ignore
  74969. * The chromatic aberration PostProcess id in the pipeline
  74970. */
  74971. LensChromaticAberrationEffect: string;
  74972. /**
  74973. * @ignore
  74974. * The highlights enhancing PostProcess id in the pipeline
  74975. */
  74976. HighlightsEnhancingEffect: string;
  74977. /**
  74978. * @ignore
  74979. * The depth-of-field PostProcess id in the pipeline
  74980. */
  74981. LensDepthOfFieldEffect: string;
  74982. private _scene;
  74983. private _depthTexture;
  74984. private _grainTexture;
  74985. private _chromaticAberrationPostProcess;
  74986. private _highlightsPostProcess;
  74987. private _depthOfFieldPostProcess;
  74988. private _edgeBlur;
  74989. private _grainAmount;
  74990. private _chromaticAberration;
  74991. private _distortion;
  74992. private _highlightsGain;
  74993. private _highlightsThreshold;
  74994. private _dofDistance;
  74995. private _dofAperture;
  74996. private _dofDarken;
  74997. private _dofPentagon;
  74998. private _blurNoise;
  74999. /**
  75000. * @constructor
  75001. *
  75002. * Effect parameters are as follow:
  75003. * {
  75004. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75005. * edge_blur: number; // from 0 to x (1 for realism)
  75006. * distortion: number; // from 0 to x (1 for realism)
  75007. * grain_amount: number; // from 0 to 1
  75008. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75009. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75010. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75011. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75012. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75013. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75014. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75015. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75016. * }
  75017. * Note: if an effect parameter is unset, effect is disabled
  75018. *
  75019. * @param name The rendering pipeline name
  75020. * @param parameters - An object containing all parameters (see above)
  75021. * @param scene The scene linked to this pipeline
  75022. * @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)
  75023. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75024. */
  75025. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75026. /**
  75027. * Get the class name
  75028. * @returns "LensRenderingPipeline"
  75029. */
  75030. getClassName(): string;
  75031. /**
  75032. * Gets associated scene
  75033. */
  75034. get scene(): Scene;
  75035. /**
  75036. * Gets or sets the edge blur
  75037. */
  75038. get edgeBlur(): number;
  75039. set edgeBlur(value: number);
  75040. /**
  75041. * Gets or sets the grain amount
  75042. */
  75043. get grainAmount(): number;
  75044. set grainAmount(value: number);
  75045. /**
  75046. * Gets or sets the chromatic aberration amount
  75047. */
  75048. get chromaticAberration(): number;
  75049. set chromaticAberration(value: number);
  75050. /**
  75051. * Gets or sets the depth of field aperture
  75052. */
  75053. get dofAperture(): number;
  75054. set dofAperture(value: number);
  75055. /**
  75056. * Gets or sets the edge distortion
  75057. */
  75058. get edgeDistortion(): number;
  75059. set edgeDistortion(value: number);
  75060. /**
  75061. * Gets or sets the depth of field distortion
  75062. */
  75063. get dofDistortion(): number;
  75064. set dofDistortion(value: number);
  75065. /**
  75066. * Gets or sets the darken out of focus amount
  75067. */
  75068. get darkenOutOfFocus(): number;
  75069. set darkenOutOfFocus(value: number);
  75070. /**
  75071. * Gets or sets a boolean indicating if blur noise is enabled
  75072. */
  75073. get blurNoise(): boolean;
  75074. set blurNoise(value: boolean);
  75075. /**
  75076. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75077. */
  75078. get pentagonBokeh(): boolean;
  75079. set pentagonBokeh(value: boolean);
  75080. /**
  75081. * Gets or sets the highlight grain amount
  75082. */
  75083. get highlightsGain(): number;
  75084. set highlightsGain(value: number);
  75085. /**
  75086. * Gets or sets the highlight threshold
  75087. */
  75088. get highlightsThreshold(): number;
  75089. set highlightsThreshold(value: number);
  75090. /**
  75091. * Sets the amount of blur at the edges
  75092. * @param amount blur amount
  75093. */
  75094. setEdgeBlur(amount: number): void;
  75095. /**
  75096. * Sets edge blur to 0
  75097. */
  75098. disableEdgeBlur(): void;
  75099. /**
  75100. * Sets the amout of grain
  75101. * @param amount Amount of grain
  75102. */
  75103. setGrainAmount(amount: number): void;
  75104. /**
  75105. * Set grain amount to 0
  75106. */
  75107. disableGrain(): void;
  75108. /**
  75109. * Sets the chromatic aberration amount
  75110. * @param amount amount of chromatic aberration
  75111. */
  75112. setChromaticAberration(amount: number): void;
  75113. /**
  75114. * Sets chromatic aberration amount to 0
  75115. */
  75116. disableChromaticAberration(): void;
  75117. /**
  75118. * Sets the EdgeDistortion amount
  75119. * @param amount amount of EdgeDistortion
  75120. */
  75121. setEdgeDistortion(amount: number): void;
  75122. /**
  75123. * Sets edge distortion to 0
  75124. */
  75125. disableEdgeDistortion(): void;
  75126. /**
  75127. * Sets the FocusDistance amount
  75128. * @param amount amount of FocusDistance
  75129. */
  75130. setFocusDistance(amount: number): void;
  75131. /**
  75132. * Disables depth of field
  75133. */
  75134. disableDepthOfField(): void;
  75135. /**
  75136. * Sets the Aperture amount
  75137. * @param amount amount of Aperture
  75138. */
  75139. setAperture(amount: number): void;
  75140. /**
  75141. * Sets the DarkenOutOfFocus amount
  75142. * @param amount amount of DarkenOutOfFocus
  75143. */
  75144. setDarkenOutOfFocus(amount: number): void;
  75145. private _pentagonBokehIsEnabled;
  75146. /**
  75147. * Creates a pentagon bokeh effect
  75148. */
  75149. enablePentagonBokeh(): void;
  75150. /**
  75151. * Disables the pentagon bokeh effect
  75152. */
  75153. disablePentagonBokeh(): void;
  75154. /**
  75155. * Enables noise blur
  75156. */
  75157. enableNoiseBlur(): void;
  75158. /**
  75159. * Disables noise blur
  75160. */
  75161. disableNoiseBlur(): void;
  75162. /**
  75163. * Sets the HighlightsGain amount
  75164. * @param amount amount of HighlightsGain
  75165. */
  75166. setHighlightsGain(amount: number): void;
  75167. /**
  75168. * Sets the HighlightsThreshold amount
  75169. * @param amount amount of HighlightsThreshold
  75170. */
  75171. setHighlightsThreshold(amount: number): void;
  75172. /**
  75173. * Disables highlights
  75174. */
  75175. disableHighlights(): void;
  75176. /**
  75177. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75178. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75179. */
  75180. dispose(disableDepthRender?: boolean): void;
  75181. private _createChromaticAberrationPostProcess;
  75182. private _createHighlightsPostProcess;
  75183. private _createDepthOfFieldPostProcess;
  75184. private _createGrainTexture;
  75185. }
  75186. }
  75187. declare module "babylonjs/Rendering/ssao2Configuration" {
  75188. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75189. /**
  75190. * Contains all parameters needed for the prepass to perform
  75191. * screen space subsurface scattering
  75192. */
  75193. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75194. /**
  75195. * Is subsurface enabled
  75196. */
  75197. enabled: boolean;
  75198. /**
  75199. * Name of the configuration
  75200. */
  75201. name: string;
  75202. /**
  75203. * Textures that should be present in the MRT for this effect to work
  75204. */
  75205. readonly texturesRequired: number[];
  75206. }
  75207. }
  75208. declare module "babylonjs/Shaders/ssao2.fragment" {
  75209. /** @hidden */
  75210. export var ssao2PixelShader: {
  75211. name: string;
  75212. shader: string;
  75213. };
  75214. }
  75215. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75216. /** @hidden */
  75217. export var ssaoCombinePixelShader: {
  75218. name: string;
  75219. shader: string;
  75220. };
  75221. }
  75222. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75223. import { Camera } from "babylonjs/Cameras/camera";
  75224. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75225. import { Scene } from "babylonjs/scene";
  75226. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75227. import "babylonjs/Shaders/ssao2.fragment";
  75228. import "babylonjs/Shaders/ssaoCombine.fragment";
  75229. /**
  75230. * Render pipeline to produce ssao effect
  75231. */
  75232. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75233. /**
  75234. * @ignore
  75235. * The PassPostProcess id in the pipeline that contains the original scene color
  75236. */
  75237. SSAOOriginalSceneColorEffect: string;
  75238. /**
  75239. * @ignore
  75240. * The SSAO PostProcess id in the pipeline
  75241. */
  75242. SSAORenderEffect: string;
  75243. /**
  75244. * @ignore
  75245. * The horizontal blur PostProcess id in the pipeline
  75246. */
  75247. SSAOBlurHRenderEffect: string;
  75248. /**
  75249. * @ignore
  75250. * The vertical blur PostProcess id in the pipeline
  75251. */
  75252. SSAOBlurVRenderEffect: string;
  75253. /**
  75254. * @ignore
  75255. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75256. */
  75257. SSAOCombineRenderEffect: string;
  75258. /**
  75259. * The output strength of the SSAO post-process. Default value is 1.0.
  75260. */
  75261. totalStrength: number;
  75262. /**
  75263. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75264. */
  75265. maxZ: number;
  75266. /**
  75267. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75268. */
  75269. minZAspect: number;
  75270. private _samples;
  75271. /**
  75272. * Number of samples used for the SSAO calculations. Default value is 8
  75273. */
  75274. set samples(n: number);
  75275. get samples(): number;
  75276. private _textureSamples;
  75277. /**
  75278. * Number of samples to use for antialiasing
  75279. */
  75280. set textureSamples(n: number);
  75281. get textureSamples(): number;
  75282. /**
  75283. * Force rendering the geometry through geometry buffer
  75284. */
  75285. private _forceGeometryBuffer;
  75286. /**
  75287. * Ratio object used for SSAO ratio and blur ratio
  75288. */
  75289. private _ratio;
  75290. /**
  75291. * Dynamically generated sphere sampler.
  75292. */
  75293. private _sampleSphere;
  75294. /**
  75295. * Blur filter offsets
  75296. */
  75297. private _samplerOffsets;
  75298. private _expensiveBlur;
  75299. /**
  75300. * If bilateral blur should be used
  75301. */
  75302. set expensiveBlur(b: boolean);
  75303. get expensiveBlur(): boolean;
  75304. /**
  75305. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75306. */
  75307. radius: number;
  75308. /**
  75309. * The base color of the SSAO post-process
  75310. * The final result is "base + ssao" between [0, 1]
  75311. */
  75312. base: number;
  75313. /**
  75314. * Support test.
  75315. */
  75316. static get IsSupported(): boolean;
  75317. private _scene;
  75318. private _randomTexture;
  75319. private _originalColorPostProcess;
  75320. private _ssaoPostProcess;
  75321. private _blurHPostProcess;
  75322. private _blurVPostProcess;
  75323. private _ssaoCombinePostProcess;
  75324. private _prePassRenderer;
  75325. /**
  75326. * Gets active scene
  75327. */
  75328. get scene(): Scene;
  75329. /**
  75330. * @constructor
  75331. * @param name The rendering pipeline name
  75332. * @param scene The scene linked to this pipeline
  75333. * @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 }
  75334. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75335. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75336. */
  75337. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75338. /**
  75339. * Get the class name
  75340. * @returns "SSAO2RenderingPipeline"
  75341. */
  75342. getClassName(): string;
  75343. /**
  75344. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75345. */
  75346. dispose(disableGeometryBufferRenderer?: boolean): void;
  75347. private _createBlurPostProcess;
  75348. /** @hidden */
  75349. _rebuild(): void;
  75350. private _bits;
  75351. private _radicalInverse_VdC;
  75352. private _hammersley;
  75353. private _hemisphereSample_uniform;
  75354. private _generateHemisphere;
  75355. private _getDefinesForSSAO;
  75356. private _createSSAOPostProcess;
  75357. private _createSSAOCombinePostProcess;
  75358. private _createRandomTexture;
  75359. /**
  75360. * Serialize the rendering pipeline (Used when exporting)
  75361. * @returns the serialized object
  75362. */
  75363. serialize(): any;
  75364. /**
  75365. * Parse the serialized pipeline
  75366. * @param source Source pipeline.
  75367. * @param scene The scene to load the pipeline to.
  75368. * @param rootUrl The URL of the serialized pipeline.
  75369. * @returns An instantiated pipeline from the serialized object.
  75370. */
  75371. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75372. }
  75373. }
  75374. declare module "babylonjs/Shaders/ssao.fragment" {
  75375. /** @hidden */
  75376. export var ssaoPixelShader: {
  75377. name: string;
  75378. shader: string;
  75379. };
  75380. }
  75381. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75382. import { Camera } from "babylonjs/Cameras/camera";
  75383. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75384. import { Scene } from "babylonjs/scene";
  75385. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75386. import "babylonjs/Shaders/ssao.fragment";
  75387. import "babylonjs/Shaders/ssaoCombine.fragment";
  75388. /**
  75389. * Render pipeline to produce ssao effect
  75390. */
  75391. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75392. /**
  75393. * @ignore
  75394. * The PassPostProcess id in the pipeline that contains the original scene color
  75395. */
  75396. SSAOOriginalSceneColorEffect: string;
  75397. /**
  75398. * @ignore
  75399. * The SSAO PostProcess id in the pipeline
  75400. */
  75401. SSAORenderEffect: string;
  75402. /**
  75403. * @ignore
  75404. * The horizontal blur PostProcess id in the pipeline
  75405. */
  75406. SSAOBlurHRenderEffect: string;
  75407. /**
  75408. * @ignore
  75409. * The vertical blur PostProcess id in the pipeline
  75410. */
  75411. SSAOBlurVRenderEffect: string;
  75412. /**
  75413. * @ignore
  75414. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75415. */
  75416. SSAOCombineRenderEffect: string;
  75417. /**
  75418. * The output strength of the SSAO post-process. Default value is 1.0.
  75419. */
  75420. totalStrength: number;
  75421. /**
  75422. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75423. */
  75424. radius: number;
  75425. /**
  75426. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75427. * Must not be equal to fallOff and superior to fallOff.
  75428. * Default value is 0.0075
  75429. */
  75430. area: number;
  75431. /**
  75432. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75433. * Must not be equal to area and inferior to area.
  75434. * Default value is 0.000001
  75435. */
  75436. fallOff: number;
  75437. /**
  75438. * The base color of the SSAO post-process
  75439. * The final result is "base + ssao" between [0, 1]
  75440. */
  75441. base: number;
  75442. private _scene;
  75443. private _depthTexture;
  75444. private _randomTexture;
  75445. private _originalColorPostProcess;
  75446. private _ssaoPostProcess;
  75447. private _blurHPostProcess;
  75448. private _blurVPostProcess;
  75449. private _ssaoCombinePostProcess;
  75450. private _firstUpdate;
  75451. /**
  75452. * Gets active scene
  75453. */
  75454. get scene(): Scene;
  75455. /**
  75456. * @constructor
  75457. * @param name - The rendering pipeline name
  75458. * @param scene - The scene linked to this pipeline
  75459. * @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 }
  75460. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75461. */
  75462. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75463. /**
  75464. * Get the class name
  75465. * @returns "SSAORenderingPipeline"
  75466. */
  75467. getClassName(): string;
  75468. /**
  75469. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75470. */
  75471. dispose(disableDepthRender?: boolean): void;
  75472. private _createBlurPostProcess;
  75473. /** @hidden */
  75474. _rebuild(): void;
  75475. private _createSSAOPostProcess;
  75476. private _createSSAOCombinePostProcess;
  75477. private _createRandomTexture;
  75478. }
  75479. }
  75480. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75481. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75482. /**
  75483. * Contains all parameters needed for the prepass to perform
  75484. * screen space reflections
  75485. */
  75486. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75487. /**
  75488. * Is ssr enabled
  75489. */
  75490. enabled: boolean;
  75491. /**
  75492. * Name of the configuration
  75493. */
  75494. name: string;
  75495. /**
  75496. * Textures that should be present in the MRT for this effect to work
  75497. */
  75498. readonly texturesRequired: number[];
  75499. }
  75500. }
  75501. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75502. /** @hidden */
  75503. export var screenSpaceReflectionPixelShader: {
  75504. name: string;
  75505. shader: string;
  75506. };
  75507. }
  75508. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75509. import { Nullable } from "babylonjs/types";
  75510. import { Camera } from "babylonjs/Cameras/camera";
  75511. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75512. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75513. import { Engine } from "babylonjs/Engines/engine";
  75514. import { Scene } from "babylonjs/scene";
  75515. /**
  75516. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75517. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75518. */
  75519. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75520. /**
  75521. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75522. */
  75523. threshold: number;
  75524. /**
  75525. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75526. */
  75527. strength: number;
  75528. /**
  75529. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75530. */
  75531. reflectionSpecularFalloffExponent: number;
  75532. /**
  75533. * 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]
  75534. */
  75535. step: number;
  75536. /**
  75537. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75538. */
  75539. roughnessFactor: number;
  75540. private _forceGeometryBuffer;
  75541. private _geometryBufferRenderer;
  75542. private _prePassRenderer;
  75543. private _enableSmoothReflections;
  75544. private _reflectionSamples;
  75545. private _smoothSteps;
  75546. /**
  75547. * Gets a string identifying the name of the class
  75548. * @returns "ScreenSpaceReflectionPostProcess" string
  75549. */
  75550. getClassName(): string;
  75551. /**
  75552. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75553. * @param name The name of the effect.
  75554. * @param scene The scene containing the objects to calculate reflections.
  75555. * @param options The required width/height ratio to downsize to before computing the render pass.
  75556. * @param camera The camera to apply the render pass to.
  75557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75558. * @param engine The engine which the post process will be applied. (default: current engine)
  75559. * @param reusable If the post process can be reused on the same frame. (default: false)
  75560. * @param textureType Type of textures used when performing the post process. (default: 0)
  75561. * @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)
  75562. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75563. */
  75564. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75565. /**
  75566. * Gets wether or not smoothing reflections is enabled.
  75567. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75568. */
  75569. get enableSmoothReflections(): boolean;
  75570. /**
  75571. * Sets wether or not smoothing reflections is enabled.
  75572. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75573. */
  75574. set enableSmoothReflections(enabled: boolean);
  75575. /**
  75576. * Gets the number of samples taken while computing reflections. More samples count is high,
  75577. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75578. */
  75579. get reflectionSamples(): number;
  75580. /**
  75581. * Sets the number of samples taken while computing reflections. More samples count is high,
  75582. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75583. */
  75584. set reflectionSamples(samples: number);
  75585. /**
  75586. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75587. * more the post-process will require GPU power and can generate a drop in FPS.
  75588. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75589. */
  75590. get smoothSteps(): number;
  75591. set smoothSteps(steps: number);
  75592. private _updateEffectDefines;
  75593. /** @hidden */
  75594. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75595. }
  75596. }
  75597. declare module "babylonjs/Shaders/standard.fragment" {
  75598. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75599. /** @hidden */
  75600. export var standardPixelShader: {
  75601. name: string;
  75602. shader: string;
  75603. };
  75604. }
  75605. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75606. import { Nullable } from "babylonjs/types";
  75607. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75608. import { Camera } from "babylonjs/Cameras/camera";
  75609. import { Texture } from "babylonjs/Materials/Textures/texture";
  75610. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75611. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75612. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75613. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75614. import { IDisposable } from "babylonjs/scene";
  75615. import { SpotLight } from "babylonjs/Lights/spotLight";
  75616. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75617. import { Scene } from "babylonjs/scene";
  75618. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75619. import { Animation } from "babylonjs/Animations/animation";
  75620. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75621. import "babylonjs/Shaders/standard.fragment";
  75622. /**
  75623. * Standard rendering pipeline
  75624. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75625. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75626. */
  75627. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75628. /**
  75629. * Public members
  75630. */
  75631. /**
  75632. * Post-process which contains the original scene color before the pipeline applies all the effects
  75633. */
  75634. originalPostProcess: Nullable<PostProcess>;
  75635. /**
  75636. * Post-process used to down scale an image x4
  75637. */
  75638. downSampleX4PostProcess: Nullable<PostProcess>;
  75639. /**
  75640. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75641. */
  75642. brightPassPostProcess: Nullable<PostProcess>;
  75643. /**
  75644. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75645. */
  75646. blurHPostProcesses: PostProcess[];
  75647. /**
  75648. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75649. */
  75650. blurVPostProcesses: PostProcess[];
  75651. /**
  75652. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75653. */
  75654. textureAdderPostProcess: Nullable<PostProcess>;
  75655. /**
  75656. * Post-process used to create volumetric lighting effect
  75657. */
  75658. volumetricLightPostProcess: Nullable<PostProcess>;
  75659. /**
  75660. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75661. */
  75662. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75663. /**
  75664. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75665. */
  75666. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75667. /**
  75668. * Post-process used to merge the volumetric light effect and the real scene color
  75669. */
  75670. volumetricLightMergePostProces: Nullable<PostProcess>;
  75671. /**
  75672. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75673. */
  75674. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75675. /**
  75676. * Base post-process used to calculate the average luminance of the final image for HDR
  75677. */
  75678. luminancePostProcess: Nullable<PostProcess>;
  75679. /**
  75680. * Post-processes used to create down sample post-processes in order to get
  75681. * the average luminance of the final image for HDR
  75682. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75683. */
  75684. luminanceDownSamplePostProcesses: PostProcess[];
  75685. /**
  75686. * Post-process used to create a HDR effect (light adaptation)
  75687. */
  75688. hdrPostProcess: Nullable<PostProcess>;
  75689. /**
  75690. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75691. */
  75692. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75693. /**
  75694. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75695. */
  75696. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75697. /**
  75698. * Post-process used to merge the final HDR post-process and the real scene color
  75699. */
  75700. hdrFinalPostProcess: Nullable<PostProcess>;
  75701. /**
  75702. * Post-process used to create a lens flare effect
  75703. */
  75704. lensFlarePostProcess: Nullable<PostProcess>;
  75705. /**
  75706. * Post-process that merges the result of the lens flare post-process and the real scene color
  75707. */
  75708. lensFlareComposePostProcess: Nullable<PostProcess>;
  75709. /**
  75710. * Post-process used to create a motion blur effect
  75711. */
  75712. motionBlurPostProcess: Nullable<PostProcess>;
  75713. /**
  75714. * Post-process used to create a depth of field effect
  75715. */
  75716. depthOfFieldPostProcess: Nullable<PostProcess>;
  75717. /**
  75718. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75719. */
  75720. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75721. /**
  75722. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75723. */
  75724. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75725. /**
  75726. * Represents the brightness threshold in order to configure the illuminated surfaces
  75727. */
  75728. brightThreshold: number;
  75729. /**
  75730. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75731. */
  75732. blurWidth: number;
  75733. /**
  75734. * Sets if the blur for highlighted surfaces must be only horizontal
  75735. */
  75736. horizontalBlur: boolean;
  75737. /**
  75738. * Gets the overall exposure used by the pipeline
  75739. */
  75740. get exposure(): number;
  75741. /**
  75742. * Sets the overall exposure used by the pipeline
  75743. */
  75744. set exposure(value: number);
  75745. /**
  75746. * Texture used typically to simulate "dirty" on camera lens
  75747. */
  75748. lensTexture: Nullable<Texture>;
  75749. /**
  75750. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75751. */
  75752. volumetricLightCoefficient: number;
  75753. /**
  75754. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75755. */
  75756. volumetricLightPower: number;
  75757. /**
  75758. * Used the set the blur intensity to smooth the volumetric lights
  75759. */
  75760. volumetricLightBlurScale: number;
  75761. /**
  75762. * Light (spot or directional) used to generate the volumetric lights rays
  75763. * The source light must have a shadow generate so the pipeline can get its
  75764. * depth map
  75765. */
  75766. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75767. /**
  75768. * For eye adaptation, represents the minimum luminance the eye can see
  75769. */
  75770. hdrMinimumLuminance: number;
  75771. /**
  75772. * For eye adaptation, represents the decrease luminance speed
  75773. */
  75774. hdrDecreaseRate: number;
  75775. /**
  75776. * For eye adaptation, represents the increase luminance speed
  75777. */
  75778. hdrIncreaseRate: number;
  75779. /**
  75780. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75781. */
  75782. get hdrAutoExposure(): boolean;
  75783. /**
  75784. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75785. */
  75786. set hdrAutoExposure(value: boolean);
  75787. /**
  75788. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75789. */
  75790. lensColorTexture: Nullable<Texture>;
  75791. /**
  75792. * The overall strengh for the lens flare effect
  75793. */
  75794. lensFlareStrength: number;
  75795. /**
  75796. * Dispersion coefficient for lens flare ghosts
  75797. */
  75798. lensFlareGhostDispersal: number;
  75799. /**
  75800. * Main lens flare halo width
  75801. */
  75802. lensFlareHaloWidth: number;
  75803. /**
  75804. * Based on the lens distortion effect, defines how much the lens flare result
  75805. * is distorted
  75806. */
  75807. lensFlareDistortionStrength: number;
  75808. /**
  75809. * Configures the blur intensity used for for lens flare (halo)
  75810. */
  75811. lensFlareBlurWidth: number;
  75812. /**
  75813. * Lens star texture must be used to simulate rays on the flares and is available
  75814. * in the documentation
  75815. */
  75816. lensStarTexture: Nullable<Texture>;
  75817. /**
  75818. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75819. * flare effect by taking account of the dirt texture
  75820. */
  75821. lensFlareDirtTexture: Nullable<Texture>;
  75822. /**
  75823. * Represents the focal length for the depth of field effect
  75824. */
  75825. depthOfFieldDistance: number;
  75826. /**
  75827. * Represents the blur intensity for the blurred part of the depth of field effect
  75828. */
  75829. depthOfFieldBlurWidth: number;
  75830. /**
  75831. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75832. */
  75833. get motionStrength(): number;
  75834. /**
  75835. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75836. */
  75837. set motionStrength(strength: number);
  75838. /**
  75839. * Gets wether or not the motion blur post-process is object based or screen based.
  75840. */
  75841. get objectBasedMotionBlur(): boolean;
  75842. /**
  75843. * Sets wether or not the motion blur post-process should be object based or screen based
  75844. */
  75845. set objectBasedMotionBlur(value: boolean);
  75846. /**
  75847. * List of animations for the pipeline (IAnimatable implementation)
  75848. */
  75849. animations: Animation[];
  75850. /**
  75851. * Private members
  75852. */
  75853. private _scene;
  75854. private _currentDepthOfFieldSource;
  75855. private _basePostProcess;
  75856. private _fixedExposure;
  75857. private _currentExposure;
  75858. private _hdrAutoExposure;
  75859. private _hdrCurrentLuminance;
  75860. private _motionStrength;
  75861. private _isObjectBasedMotionBlur;
  75862. private _floatTextureType;
  75863. private _camerasToBeAttached;
  75864. private _ratio;
  75865. private _bloomEnabled;
  75866. private _depthOfFieldEnabled;
  75867. private _vlsEnabled;
  75868. private _lensFlareEnabled;
  75869. private _hdrEnabled;
  75870. private _motionBlurEnabled;
  75871. private _fxaaEnabled;
  75872. private _screenSpaceReflectionsEnabled;
  75873. private _motionBlurSamples;
  75874. private _volumetricLightStepsCount;
  75875. private _samples;
  75876. /**
  75877. * @ignore
  75878. * Specifies if the bloom pipeline is enabled
  75879. */
  75880. get BloomEnabled(): boolean;
  75881. set BloomEnabled(enabled: boolean);
  75882. /**
  75883. * @ignore
  75884. * Specifies if the depth of field pipeline is enabed
  75885. */
  75886. get DepthOfFieldEnabled(): boolean;
  75887. set DepthOfFieldEnabled(enabled: boolean);
  75888. /**
  75889. * @ignore
  75890. * Specifies if the lens flare pipeline is enabed
  75891. */
  75892. get LensFlareEnabled(): boolean;
  75893. set LensFlareEnabled(enabled: boolean);
  75894. /**
  75895. * @ignore
  75896. * Specifies if the HDR pipeline is enabled
  75897. */
  75898. get HDREnabled(): boolean;
  75899. set HDREnabled(enabled: boolean);
  75900. /**
  75901. * @ignore
  75902. * Specifies if the volumetric lights scattering effect is enabled
  75903. */
  75904. get VLSEnabled(): boolean;
  75905. set VLSEnabled(enabled: boolean);
  75906. /**
  75907. * @ignore
  75908. * Specifies if the motion blur effect is enabled
  75909. */
  75910. get MotionBlurEnabled(): boolean;
  75911. set MotionBlurEnabled(enabled: boolean);
  75912. /**
  75913. * Specifies if anti-aliasing is enabled
  75914. */
  75915. get fxaaEnabled(): boolean;
  75916. set fxaaEnabled(enabled: boolean);
  75917. /**
  75918. * Specifies if screen space reflections are enabled.
  75919. */
  75920. get screenSpaceReflectionsEnabled(): boolean;
  75921. set screenSpaceReflectionsEnabled(enabled: boolean);
  75922. /**
  75923. * Specifies the number of steps used to calculate the volumetric lights
  75924. * Typically in interval [50, 200]
  75925. */
  75926. get volumetricLightStepsCount(): number;
  75927. set volumetricLightStepsCount(count: number);
  75928. /**
  75929. * Specifies the number of samples used for the motion blur effect
  75930. * Typically in interval [16, 64]
  75931. */
  75932. get motionBlurSamples(): number;
  75933. set motionBlurSamples(samples: number);
  75934. /**
  75935. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75936. */
  75937. get samples(): number;
  75938. set samples(sampleCount: number);
  75939. /**
  75940. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75941. * @constructor
  75942. * @param name The rendering pipeline name
  75943. * @param scene The scene linked to this pipeline
  75944. * @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)
  75945. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75946. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75947. */
  75948. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75949. private _buildPipeline;
  75950. private _createDownSampleX4PostProcess;
  75951. private _createBrightPassPostProcess;
  75952. private _createBlurPostProcesses;
  75953. private _createTextureAdderPostProcess;
  75954. private _createVolumetricLightPostProcess;
  75955. private _createLuminancePostProcesses;
  75956. private _createHdrPostProcess;
  75957. private _createLensFlarePostProcess;
  75958. private _createDepthOfFieldPostProcess;
  75959. private _createMotionBlurPostProcess;
  75960. private _getDepthTexture;
  75961. private _disposePostProcesses;
  75962. /**
  75963. * Dispose of the pipeline and stop all post processes
  75964. */
  75965. dispose(): void;
  75966. /**
  75967. * Serialize the rendering pipeline (Used when exporting)
  75968. * @returns the serialized object
  75969. */
  75970. serialize(): any;
  75971. /**
  75972. * Parse the serialized pipeline
  75973. * @param source Source pipeline.
  75974. * @param scene The scene to load the pipeline to.
  75975. * @param rootUrl The URL of the serialized pipeline.
  75976. * @returns An instantiated pipeline from the serialized object.
  75977. */
  75978. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75979. /**
  75980. * Luminance steps
  75981. */
  75982. static LuminanceSteps: number;
  75983. }
  75984. }
  75985. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75986. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75987. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75988. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75989. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75990. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75991. }
  75992. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75993. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75994. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75995. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75996. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75997. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75998. }
  75999. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76000. /** @hidden */
  76001. export var stereoscopicInterlacePixelShader: {
  76002. name: string;
  76003. shader: string;
  76004. };
  76005. }
  76006. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76007. import { Camera } from "babylonjs/Cameras/camera";
  76008. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76009. import { Engine } from "babylonjs/Engines/engine";
  76010. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76011. /**
  76012. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76013. */
  76014. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76015. private _stepSize;
  76016. private _passedProcess;
  76017. /**
  76018. * Gets a string identifying the name of the class
  76019. * @returns "StereoscopicInterlacePostProcessI" string
  76020. */
  76021. getClassName(): string;
  76022. /**
  76023. * Initializes a StereoscopicInterlacePostProcessI
  76024. * @param name The name of the effect.
  76025. * @param rigCameras The rig cameras to be appled to the post process
  76026. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76027. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76029. * @param engine The engine which the post process will be applied. (default: current engine)
  76030. * @param reusable If the post process can be reused on the same frame. (default: false)
  76031. */
  76032. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76033. }
  76034. /**
  76035. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76036. */
  76037. export class StereoscopicInterlacePostProcess extends PostProcess {
  76038. private _stepSize;
  76039. private _passedProcess;
  76040. /**
  76041. * Gets a string identifying the name of the class
  76042. * @returns "StereoscopicInterlacePostProcess" string
  76043. */
  76044. getClassName(): string;
  76045. /**
  76046. * Initializes a StereoscopicInterlacePostProcess
  76047. * @param name The name of the effect.
  76048. * @param rigCameras The rig cameras to be appled to the post process
  76049. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76051. * @param engine The engine which the post process will be applied. (default: current engine)
  76052. * @param reusable If the post process can be reused on the same frame. (default: false)
  76053. */
  76054. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76055. }
  76056. }
  76057. declare module "babylonjs/Shaders/tonemap.fragment" {
  76058. /** @hidden */
  76059. export var tonemapPixelShader: {
  76060. name: string;
  76061. shader: string;
  76062. };
  76063. }
  76064. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76065. import { Camera } from "babylonjs/Cameras/camera";
  76066. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76067. import "babylonjs/Shaders/tonemap.fragment";
  76068. import { Engine } from "babylonjs/Engines/engine";
  76069. /** Defines operator used for tonemapping */
  76070. export enum TonemappingOperator {
  76071. /** Hable */
  76072. Hable = 0,
  76073. /** Reinhard */
  76074. Reinhard = 1,
  76075. /** HejiDawson */
  76076. HejiDawson = 2,
  76077. /** Photographic */
  76078. Photographic = 3
  76079. }
  76080. /**
  76081. * Defines a post process to apply tone mapping
  76082. */
  76083. export class TonemapPostProcess extends PostProcess {
  76084. private _operator;
  76085. /** Defines the required exposure adjustement */
  76086. exposureAdjustment: number;
  76087. /**
  76088. * Gets a string identifying the name of the class
  76089. * @returns "TonemapPostProcess" string
  76090. */
  76091. getClassName(): string;
  76092. /**
  76093. * Creates a new TonemapPostProcess
  76094. * @param name defines the name of the postprocess
  76095. * @param _operator defines the operator to use
  76096. * @param exposureAdjustment defines the required exposure adjustement
  76097. * @param camera defines the camera to use (can be null)
  76098. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76099. * @param engine defines the hosting engine (can be ignore if camera is set)
  76100. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76101. */
  76102. constructor(name: string, _operator: TonemappingOperator,
  76103. /** Defines the required exposure adjustement */
  76104. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76105. }
  76106. }
  76107. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76108. /** @hidden */
  76109. export var volumetricLightScatteringPixelShader: {
  76110. name: string;
  76111. shader: string;
  76112. };
  76113. }
  76114. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76115. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76116. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76117. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76118. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76119. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76120. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76121. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76122. /** @hidden */
  76123. export var volumetricLightScatteringPassVertexShader: {
  76124. name: string;
  76125. shader: string;
  76126. };
  76127. }
  76128. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76129. /** @hidden */
  76130. export var volumetricLightScatteringPassPixelShader: {
  76131. name: string;
  76132. shader: string;
  76133. };
  76134. }
  76135. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76136. import { Vector3 } from "babylonjs/Maths/math.vector";
  76137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76138. import { Mesh } from "babylonjs/Meshes/mesh";
  76139. import { Camera } from "babylonjs/Cameras/camera";
  76140. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76141. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76142. import { Scene } from "babylonjs/scene";
  76143. import "babylonjs/Meshes/Builders/planeBuilder";
  76144. import "babylonjs/Shaders/depth.vertex";
  76145. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76146. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76147. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76148. import { Engine } from "babylonjs/Engines/engine";
  76149. /**
  76150. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76151. */
  76152. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76153. private _volumetricLightScatteringPass;
  76154. private _volumetricLightScatteringRTT;
  76155. private _viewPort;
  76156. private _screenCoordinates;
  76157. private _cachedDefines;
  76158. /**
  76159. * If not undefined, the mesh position is computed from the attached node position
  76160. */
  76161. attachedNode: {
  76162. position: Vector3;
  76163. };
  76164. /**
  76165. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76166. */
  76167. customMeshPosition: Vector3;
  76168. /**
  76169. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76170. */
  76171. useCustomMeshPosition: boolean;
  76172. /**
  76173. * If the post-process should inverse the light scattering direction
  76174. */
  76175. invert: boolean;
  76176. /**
  76177. * The internal mesh used by the post-process
  76178. */
  76179. mesh: Mesh;
  76180. /**
  76181. * @hidden
  76182. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76183. */
  76184. get useDiffuseColor(): boolean;
  76185. set useDiffuseColor(useDiffuseColor: boolean);
  76186. /**
  76187. * Array containing the excluded meshes not rendered in the internal pass
  76188. */
  76189. excludedMeshes: AbstractMesh[];
  76190. /**
  76191. * Controls the overall intensity of the post-process
  76192. */
  76193. exposure: number;
  76194. /**
  76195. * Dissipates each sample's contribution in range [0, 1]
  76196. */
  76197. decay: number;
  76198. /**
  76199. * Controls the overall intensity of each sample
  76200. */
  76201. weight: number;
  76202. /**
  76203. * Controls the density of each sample
  76204. */
  76205. density: number;
  76206. /**
  76207. * @constructor
  76208. * @param name The post-process name
  76209. * @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)
  76210. * @param camera The camera that the post-process will be attached to
  76211. * @param mesh The mesh used to create the light scattering
  76212. * @param samples The post-process quality, default 100
  76213. * @param samplingModeThe post-process filtering mode
  76214. * @param engine The babylon engine
  76215. * @param reusable If the post-process is reusable
  76216. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76217. */
  76218. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76219. /**
  76220. * Returns the string "VolumetricLightScatteringPostProcess"
  76221. * @returns "VolumetricLightScatteringPostProcess"
  76222. */
  76223. getClassName(): string;
  76224. private _isReady;
  76225. /**
  76226. * Sets the new light position for light scattering effect
  76227. * @param position The new custom light position
  76228. */
  76229. setCustomMeshPosition(position: Vector3): void;
  76230. /**
  76231. * Returns the light position for light scattering effect
  76232. * @return Vector3 The custom light position
  76233. */
  76234. getCustomMeshPosition(): Vector3;
  76235. /**
  76236. * Disposes the internal assets and detaches the post-process from the camera
  76237. */
  76238. dispose(camera: Camera): void;
  76239. /**
  76240. * Returns the render target texture used by the post-process
  76241. * @return the render target texture used by the post-process
  76242. */
  76243. getPass(): RenderTargetTexture;
  76244. private _meshExcluded;
  76245. private _createPass;
  76246. private _updateMeshScreenCoordinates;
  76247. /**
  76248. * Creates a default mesh for the Volumeric Light Scattering post-process
  76249. * @param name The mesh name
  76250. * @param scene The scene where to create the mesh
  76251. * @return the default mesh
  76252. */
  76253. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76254. }
  76255. }
  76256. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76257. /** @hidden */
  76258. export var screenSpaceCurvaturePixelShader: {
  76259. name: string;
  76260. shader: string;
  76261. };
  76262. }
  76263. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76264. import { Nullable } from "babylonjs/types";
  76265. import { Camera } from "babylonjs/Cameras/camera";
  76266. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76267. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76268. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76269. import { Engine } from "babylonjs/Engines/engine";
  76270. import { Scene } from "babylonjs/scene";
  76271. /**
  76272. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76273. */
  76274. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76275. /**
  76276. * Defines how much ridge the curvature effect displays.
  76277. */
  76278. ridge: number;
  76279. /**
  76280. * Defines how much valley the curvature effect displays.
  76281. */
  76282. valley: number;
  76283. private _geometryBufferRenderer;
  76284. /**
  76285. * Gets a string identifying the name of the class
  76286. * @returns "ScreenSpaceCurvaturePostProcess" string
  76287. */
  76288. getClassName(): string;
  76289. /**
  76290. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76291. * @param name The name of the effect.
  76292. * @param scene The scene containing the objects to blur according to their velocity.
  76293. * @param options The required width/height ratio to downsize to before computing the render pass.
  76294. * @param camera The camera to apply the render pass to.
  76295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76296. * @param engine The engine which the post process will be applied. (default: current engine)
  76297. * @param reusable If the post process can be reused on the same frame. (default: false)
  76298. * @param textureType Type of textures used when performing the post process. (default: 0)
  76299. * @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)
  76300. */
  76301. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76302. /**
  76303. * Support test.
  76304. */
  76305. static get IsSupported(): boolean;
  76306. /** @hidden */
  76307. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76308. }
  76309. }
  76310. declare module "babylonjs/PostProcesses/index" {
  76311. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76312. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76313. export * from "babylonjs/PostProcesses/bloomEffect";
  76314. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76315. export * from "babylonjs/PostProcesses/blurPostProcess";
  76316. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76317. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76318. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76319. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76320. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76321. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76322. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76323. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76324. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76325. export * from "babylonjs/PostProcesses/filterPostProcess";
  76326. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76327. export * from "babylonjs/PostProcesses/grainPostProcess";
  76328. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76329. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76330. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76331. export * from "babylonjs/PostProcesses/passPostProcess";
  76332. export * from "babylonjs/PostProcesses/postProcess";
  76333. export * from "babylonjs/PostProcesses/postProcessManager";
  76334. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76335. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76336. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76337. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76338. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76339. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76340. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76341. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76342. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76343. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76344. }
  76345. declare module "babylonjs/Probes/index" {
  76346. export * from "babylonjs/Probes/reflectionProbe";
  76347. }
  76348. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76349. import { Scene } from "babylonjs/scene";
  76350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76351. import { SmartArray } from "babylonjs/Misc/smartArray";
  76352. import { ISceneComponent } from "babylonjs/sceneComponent";
  76353. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76354. import "babylonjs/Meshes/Builders/boxBuilder";
  76355. import "babylonjs/Shaders/color.fragment";
  76356. import "babylonjs/Shaders/color.vertex";
  76357. import { Color3 } from "babylonjs/Maths/math.color";
  76358. import { Observable } from "babylonjs/Misc/observable";
  76359. module "babylonjs/scene" {
  76360. interface Scene {
  76361. /** @hidden (Backing field) */
  76362. _boundingBoxRenderer: BoundingBoxRenderer;
  76363. /** @hidden (Backing field) */
  76364. _forceShowBoundingBoxes: boolean;
  76365. /**
  76366. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76367. */
  76368. forceShowBoundingBoxes: boolean;
  76369. /**
  76370. * Gets the bounding box renderer associated with the scene
  76371. * @returns a BoundingBoxRenderer
  76372. */
  76373. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76374. }
  76375. }
  76376. module "babylonjs/Meshes/abstractMesh" {
  76377. interface AbstractMesh {
  76378. /** @hidden (Backing field) */
  76379. _showBoundingBox: boolean;
  76380. /**
  76381. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76382. */
  76383. showBoundingBox: boolean;
  76384. }
  76385. }
  76386. /**
  76387. * Component responsible of rendering the bounding box of the meshes in a scene.
  76388. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76389. */
  76390. export class BoundingBoxRenderer implements ISceneComponent {
  76391. /**
  76392. * The component name helpfull to identify the component in the list of scene components.
  76393. */
  76394. readonly name: string;
  76395. /**
  76396. * The scene the component belongs to.
  76397. */
  76398. scene: Scene;
  76399. /**
  76400. * Color of the bounding box lines placed in front of an object
  76401. */
  76402. frontColor: Color3;
  76403. /**
  76404. * Color of the bounding box lines placed behind an object
  76405. */
  76406. backColor: Color3;
  76407. /**
  76408. * Defines if the renderer should show the back lines or not
  76409. */
  76410. showBackLines: boolean;
  76411. /**
  76412. * Observable raised before rendering a bounding box
  76413. */
  76414. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76415. /**
  76416. * Observable raised after rendering a bounding box
  76417. */
  76418. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76419. /**
  76420. * @hidden
  76421. */
  76422. renderList: SmartArray<BoundingBox>;
  76423. private _colorShader;
  76424. private _vertexBuffers;
  76425. private _indexBuffer;
  76426. private _fillIndexBuffer;
  76427. private _fillIndexData;
  76428. /**
  76429. * Instantiates a new bounding box renderer in a scene.
  76430. * @param scene the scene the renderer renders in
  76431. */
  76432. constructor(scene: Scene);
  76433. /**
  76434. * Registers the component in a given scene
  76435. */
  76436. register(): void;
  76437. private _evaluateSubMesh;
  76438. private _activeMesh;
  76439. private _prepareRessources;
  76440. private _createIndexBuffer;
  76441. /**
  76442. * Rebuilds the elements related to this component in case of
  76443. * context lost for instance.
  76444. */
  76445. rebuild(): void;
  76446. /**
  76447. * @hidden
  76448. */
  76449. reset(): void;
  76450. /**
  76451. * Render the bounding boxes of a specific rendering group
  76452. * @param renderingGroupId defines the rendering group to render
  76453. */
  76454. render(renderingGroupId: number): void;
  76455. /**
  76456. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76457. * @param mesh Define the mesh to render the occlusion bounding box for
  76458. */
  76459. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76460. /**
  76461. * Dispose and release the resources attached to this renderer.
  76462. */
  76463. dispose(): void;
  76464. }
  76465. }
  76466. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76467. import { Nullable } from "babylonjs/types";
  76468. import { Scene } from "babylonjs/scene";
  76469. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76470. import { Camera } from "babylonjs/Cameras/camera";
  76471. import { ISceneComponent } from "babylonjs/sceneComponent";
  76472. module "babylonjs/scene" {
  76473. interface Scene {
  76474. /** @hidden (Backing field) */
  76475. _depthRenderer: {
  76476. [id: string]: DepthRenderer;
  76477. };
  76478. /**
  76479. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76480. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76481. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76482. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76483. * @returns the created depth renderer
  76484. */
  76485. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76486. /**
  76487. * Disables a depth renderer for a given camera
  76488. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76489. */
  76490. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76491. }
  76492. }
  76493. /**
  76494. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76495. * in several rendering techniques.
  76496. */
  76497. export class DepthRendererSceneComponent implements ISceneComponent {
  76498. /**
  76499. * The component name helpfull to identify the component in the list of scene components.
  76500. */
  76501. readonly name: string;
  76502. /**
  76503. * The scene the component belongs to.
  76504. */
  76505. scene: Scene;
  76506. /**
  76507. * Creates a new instance of the component for the given scene
  76508. * @param scene Defines the scene to register the component in
  76509. */
  76510. constructor(scene: Scene);
  76511. /**
  76512. * Registers the component in a given scene
  76513. */
  76514. register(): void;
  76515. /**
  76516. * Rebuilds the elements related to this component in case of
  76517. * context lost for instance.
  76518. */
  76519. rebuild(): void;
  76520. /**
  76521. * Disposes the component and the associated ressources
  76522. */
  76523. dispose(): void;
  76524. private _gatherRenderTargets;
  76525. private _gatherActiveCameraRenderTargets;
  76526. }
  76527. }
  76528. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76529. import { Nullable } from "babylonjs/types";
  76530. import { Scene } from "babylonjs/scene";
  76531. import { ISceneComponent } from "babylonjs/sceneComponent";
  76532. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76533. module "babylonjs/abstractScene" {
  76534. interface AbstractScene {
  76535. /** @hidden (Backing field) */
  76536. _prePassRenderer: Nullable<PrePassRenderer>;
  76537. /**
  76538. * Gets or Sets the current prepass renderer associated to the scene.
  76539. */
  76540. prePassRenderer: Nullable<PrePassRenderer>;
  76541. /**
  76542. * Enables the prepass and associates it with the scene
  76543. * @returns the PrePassRenderer
  76544. */
  76545. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76546. /**
  76547. * Disables the prepass associated with the scene
  76548. */
  76549. disablePrePassRenderer(): void;
  76550. }
  76551. }
  76552. /**
  76553. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76554. * in several rendering techniques.
  76555. */
  76556. export class PrePassRendererSceneComponent implements ISceneComponent {
  76557. /**
  76558. * The component name helpful to identify the component in the list of scene components.
  76559. */
  76560. readonly name: string;
  76561. /**
  76562. * The scene the component belongs to.
  76563. */
  76564. scene: Scene;
  76565. /**
  76566. * Creates a new instance of the component for the given scene
  76567. * @param scene Defines the scene to register the component in
  76568. */
  76569. constructor(scene: Scene);
  76570. /**
  76571. * Registers the component in a given scene
  76572. */
  76573. register(): void;
  76574. private _beforeCameraDraw;
  76575. private _afterCameraDraw;
  76576. private _beforeClearStage;
  76577. /**
  76578. * Rebuilds the elements related to this component in case of
  76579. * context lost for instance.
  76580. */
  76581. rebuild(): void;
  76582. /**
  76583. * Disposes the component and the associated ressources
  76584. */
  76585. dispose(): void;
  76586. }
  76587. }
  76588. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76589. /** @hidden */
  76590. export var fibonacci: {
  76591. name: string;
  76592. shader: string;
  76593. };
  76594. }
  76595. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76596. /** @hidden */
  76597. export var diffusionProfile: {
  76598. name: string;
  76599. shader: string;
  76600. };
  76601. }
  76602. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76603. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76604. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76605. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76606. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76607. /** @hidden */
  76608. export var subSurfaceScatteringPixelShader: {
  76609. name: string;
  76610. shader: string;
  76611. };
  76612. }
  76613. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76614. import { Nullable } from "babylonjs/types";
  76615. import { Camera } from "babylonjs/Cameras/camera";
  76616. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76617. import { Engine } from "babylonjs/Engines/engine";
  76618. import { Scene } from "babylonjs/scene";
  76619. import "babylonjs/Shaders/imageProcessing.fragment";
  76620. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76621. import "babylonjs/Shaders/postprocess.vertex";
  76622. /**
  76623. * Sub surface scattering post process
  76624. */
  76625. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76626. /**
  76627. * Gets a string identifying the name of the class
  76628. * @returns "SubSurfaceScatteringPostProcess" string
  76629. */
  76630. getClassName(): string;
  76631. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76632. }
  76633. }
  76634. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76635. import { Scene } from "babylonjs/scene";
  76636. import { Color3 } from "babylonjs/Maths/math.color";
  76637. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76638. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76639. /**
  76640. * Contains all parameters needed for the prepass to perform
  76641. * screen space subsurface scattering
  76642. */
  76643. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76644. /** @hidden */
  76645. static _SceneComponentInitialization: (scene: Scene) => void;
  76646. private _ssDiffusionS;
  76647. private _ssFilterRadii;
  76648. private _ssDiffusionD;
  76649. /**
  76650. * Post process to attach for screen space subsurface scattering
  76651. */
  76652. postProcess: SubSurfaceScatteringPostProcess;
  76653. /**
  76654. * Diffusion profile color for subsurface scattering
  76655. */
  76656. get ssDiffusionS(): number[];
  76657. /**
  76658. * Diffusion profile max color channel value for subsurface scattering
  76659. */
  76660. get ssDiffusionD(): number[];
  76661. /**
  76662. * Diffusion profile filter radius for subsurface scattering
  76663. */
  76664. get ssFilterRadii(): number[];
  76665. /**
  76666. * Is subsurface enabled
  76667. */
  76668. enabled: boolean;
  76669. /**
  76670. * Name of the configuration
  76671. */
  76672. name: string;
  76673. /**
  76674. * Diffusion profile colors for subsurface scattering
  76675. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76676. * See ...
  76677. * Note that you can only store up to 5 of them
  76678. */
  76679. ssDiffusionProfileColors: Color3[];
  76680. /**
  76681. * Defines the ratio real world => scene units.
  76682. * Used for subsurface scattering
  76683. */
  76684. metersPerUnit: number;
  76685. /**
  76686. * Textures that should be present in the MRT for this effect to work
  76687. */
  76688. readonly texturesRequired: number[];
  76689. private _scene;
  76690. /**
  76691. * Builds a subsurface configuration object
  76692. * @param scene The scene
  76693. */
  76694. constructor(scene: Scene);
  76695. /**
  76696. * Adds a new diffusion profile.
  76697. * Useful for more realistic subsurface scattering on diverse materials.
  76698. * @param color The color of the diffusion profile. Should be the average color of the material.
  76699. * @return The index of the diffusion profile for the material subsurface configuration
  76700. */
  76701. addDiffusionProfile(color: Color3): number;
  76702. /**
  76703. * Creates the sss post process
  76704. * @return The created post process
  76705. */
  76706. createPostProcess(): SubSurfaceScatteringPostProcess;
  76707. /**
  76708. * Deletes all diffusion profiles.
  76709. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76710. */
  76711. clearAllDiffusionProfiles(): void;
  76712. /**
  76713. * Disposes this object
  76714. */
  76715. dispose(): void;
  76716. /**
  76717. * @hidden
  76718. * https://zero-radiance.github.io/post/sampling-diffusion/
  76719. *
  76720. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76721. * ------------------------------------------------------------------------------------
  76722. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76723. * PDF[r, phi, s] = r * R[r, phi, s]
  76724. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76725. * ------------------------------------------------------------------------------------
  76726. * We importance sample the color channel with the widest scattering distance.
  76727. */
  76728. getDiffusionProfileParameters(color: Color3): number;
  76729. /**
  76730. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76731. * 'u' is the random number (the value of the CDF): [0, 1).
  76732. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76733. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76734. */
  76735. private _sampleBurleyDiffusionProfile;
  76736. }
  76737. }
  76738. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76739. import { Nullable } from "babylonjs/types";
  76740. import { Scene } from "babylonjs/scene";
  76741. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76742. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76743. import { AbstractScene } from "babylonjs/abstractScene";
  76744. module "babylonjs/abstractScene" {
  76745. interface AbstractScene {
  76746. /** @hidden (Backing field) */
  76747. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76748. /**
  76749. * Gets or Sets the current prepass renderer associated to the scene.
  76750. */
  76751. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76752. /**
  76753. * Enables the subsurface effect for prepass
  76754. * @returns the SubSurfaceConfiguration
  76755. */
  76756. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76757. /**
  76758. * Disables the subsurface effect for prepass
  76759. */
  76760. disableSubSurfaceForPrePass(): void;
  76761. }
  76762. }
  76763. /**
  76764. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76765. * in several rendering techniques.
  76766. */
  76767. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76768. /**
  76769. * The component name helpful to identify the component in the list of scene components.
  76770. */
  76771. readonly name: string;
  76772. /**
  76773. * The scene the component belongs to.
  76774. */
  76775. scene: Scene;
  76776. /**
  76777. * Creates a new instance of the component for the given scene
  76778. * @param scene Defines the scene to register the component in
  76779. */
  76780. constructor(scene: Scene);
  76781. /**
  76782. * Registers the component in a given scene
  76783. */
  76784. register(): void;
  76785. /**
  76786. * Serializes the component data to the specified json object
  76787. * @param serializationObject The object to serialize to
  76788. */
  76789. serialize(serializationObject: any): void;
  76790. /**
  76791. * Adds all the elements from the container to the scene
  76792. * @param container the container holding the elements
  76793. */
  76794. addFromContainer(container: AbstractScene): void;
  76795. /**
  76796. * Removes all the elements in the container from the scene
  76797. * @param container contains the elements to remove
  76798. * @param dispose if the removed element should be disposed (default: false)
  76799. */
  76800. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76801. /**
  76802. * Rebuilds the elements related to this component in case of
  76803. * context lost for instance.
  76804. */
  76805. rebuild(): void;
  76806. /**
  76807. * Disposes the component and the associated ressources
  76808. */
  76809. dispose(): void;
  76810. }
  76811. }
  76812. declare module "babylonjs/Shaders/outline.fragment" {
  76813. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76814. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76815. /** @hidden */
  76816. export var outlinePixelShader: {
  76817. name: string;
  76818. shader: string;
  76819. };
  76820. }
  76821. declare module "babylonjs/Shaders/outline.vertex" {
  76822. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76823. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76824. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76825. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76826. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76827. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76828. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76829. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76830. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76831. /** @hidden */
  76832. export var outlineVertexShader: {
  76833. name: string;
  76834. shader: string;
  76835. };
  76836. }
  76837. declare module "babylonjs/Rendering/outlineRenderer" {
  76838. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76839. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76840. import { Scene } from "babylonjs/scene";
  76841. import { ISceneComponent } from "babylonjs/sceneComponent";
  76842. import "babylonjs/Shaders/outline.fragment";
  76843. import "babylonjs/Shaders/outline.vertex";
  76844. module "babylonjs/scene" {
  76845. interface Scene {
  76846. /** @hidden */
  76847. _outlineRenderer: OutlineRenderer;
  76848. /**
  76849. * Gets the outline renderer associated with the scene
  76850. * @returns a OutlineRenderer
  76851. */
  76852. getOutlineRenderer(): OutlineRenderer;
  76853. }
  76854. }
  76855. module "babylonjs/Meshes/abstractMesh" {
  76856. interface AbstractMesh {
  76857. /** @hidden (Backing field) */
  76858. _renderOutline: boolean;
  76859. /**
  76860. * Gets or sets a boolean indicating if the outline must be rendered as well
  76861. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76862. */
  76863. renderOutline: boolean;
  76864. /** @hidden (Backing field) */
  76865. _renderOverlay: boolean;
  76866. /**
  76867. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76868. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76869. */
  76870. renderOverlay: boolean;
  76871. }
  76872. }
  76873. /**
  76874. * This class is responsible to draw bothe outline/overlay of meshes.
  76875. * It should not be used directly but through the available method on mesh.
  76876. */
  76877. export class OutlineRenderer implements ISceneComponent {
  76878. /**
  76879. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76880. */
  76881. private static _StencilReference;
  76882. /**
  76883. * The name of the component. Each component must have a unique name.
  76884. */
  76885. name: string;
  76886. /**
  76887. * The scene the component belongs to.
  76888. */
  76889. scene: Scene;
  76890. /**
  76891. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76892. */
  76893. zOffset: number;
  76894. private _engine;
  76895. private _effect;
  76896. private _cachedDefines;
  76897. private _savedDepthWrite;
  76898. /**
  76899. * Instantiates a new outline renderer. (There could be only one per scene).
  76900. * @param scene Defines the scene it belongs to
  76901. */
  76902. constructor(scene: Scene);
  76903. /**
  76904. * Register the component to one instance of a scene.
  76905. */
  76906. register(): void;
  76907. /**
  76908. * Rebuilds the elements related to this component in case of
  76909. * context lost for instance.
  76910. */
  76911. rebuild(): void;
  76912. /**
  76913. * Disposes the component and the associated ressources.
  76914. */
  76915. dispose(): void;
  76916. /**
  76917. * Renders the outline in the canvas.
  76918. * @param subMesh Defines the sumesh to render
  76919. * @param batch Defines the batch of meshes in case of instances
  76920. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76921. */
  76922. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76923. /**
  76924. * Returns whether or not the outline renderer is ready for a given submesh.
  76925. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76926. * @param subMesh Defines the submesh to check readyness for
  76927. * @param useInstances Defines wheter wee are trying to render instances or not
  76928. * @returns true if ready otherwise false
  76929. */
  76930. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76931. private _beforeRenderingMesh;
  76932. private _afterRenderingMesh;
  76933. }
  76934. }
  76935. declare module "babylonjs/Rendering/index" {
  76936. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76937. export * from "babylonjs/Rendering/depthRenderer";
  76938. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76939. export * from "babylonjs/Rendering/edgesRenderer";
  76940. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76941. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76942. export * from "babylonjs/Rendering/prePassRenderer";
  76943. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76944. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76945. export * from "babylonjs/Rendering/outlineRenderer";
  76946. export * from "babylonjs/Rendering/renderingGroup";
  76947. export * from "babylonjs/Rendering/renderingManager";
  76948. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76949. }
  76950. declare module "babylonjs/Sprites/ISprites" {
  76951. /**
  76952. * Defines the basic options interface of a Sprite Frame Source Size.
  76953. */
  76954. export interface ISpriteJSONSpriteSourceSize {
  76955. /**
  76956. * number of the original width of the Frame
  76957. */
  76958. w: number;
  76959. /**
  76960. * number of the original height of the Frame
  76961. */
  76962. h: number;
  76963. }
  76964. /**
  76965. * Defines the basic options interface of a Sprite Frame Data.
  76966. */
  76967. export interface ISpriteJSONSpriteFrameData {
  76968. /**
  76969. * number of the x offset of the Frame
  76970. */
  76971. x: number;
  76972. /**
  76973. * number of the y offset of the Frame
  76974. */
  76975. y: number;
  76976. /**
  76977. * number of the width of the Frame
  76978. */
  76979. w: number;
  76980. /**
  76981. * number of the height of the Frame
  76982. */
  76983. h: number;
  76984. }
  76985. /**
  76986. * Defines the basic options interface of a JSON Sprite.
  76987. */
  76988. export interface ISpriteJSONSprite {
  76989. /**
  76990. * string name of the Frame
  76991. */
  76992. filename: string;
  76993. /**
  76994. * ISpriteJSONSpriteFrame basic object of the frame data
  76995. */
  76996. frame: ISpriteJSONSpriteFrameData;
  76997. /**
  76998. * boolean to flag is the frame was rotated.
  76999. */
  77000. rotated: boolean;
  77001. /**
  77002. * boolean to flag is the frame was trimmed.
  77003. */
  77004. trimmed: boolean;
  77005. /**
  77006. * ISpriteJSONSpriteFrame basic object of the source data
  77007. */
  77008. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77009. /**
  77010. * ISpriteJSONSpriteFrame basic object of the source data
  77011. */
  77012. sourceSize: ISpriteJSONSpriteSourceSize;
  77013. }
  77014. /**
  77015. * Defines the basic options interface of a JSON atlas.
  77016. */
  77017. export interface ISpriteJSONAtlas {
  77018. /**
  77019. * Array of objects that contain the frame data.
  77020. */
  77021. frames: Array<ISpriteJSONSprite>;
  77022. /**
  77023. * object basic object containing the sprite meta data.
  77024. */
  77025. meta?: object;
  77026. }
  77027. }
  77028. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77029. /** @hidden */
  77030. export var spriteMapPixelShader: {
  77031. name: string;
  77032. shader: string;
  77033. };
  77034. }
  77035. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77036. /** @hidden */
  77037. export var spriteMapVertexShader: {
  77038. name: string;
  77039. shader: string;
  77040. };
  77041. }
  77042. declare module "babylonjs/Sprites/spriteMap" {
  77043. import { IDisposable, Scene } from "babylonjs/scene";
  77044. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77045. import { Texture } from "babylonjs/Materials/Textures/texture";
  77046. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77047. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77048. import "babylonjs/Meshes/Builders/planeBuilder";
  77049. import "babylonjs/Shaders/spriteMap.fragment";
  77050. import "babylonjs/Shaders/spriteMap.vertex";
  77051. /**
  77052. * Defines the basic options interface of a SpriteMap
  77053. */
  77054. export interface ISpriteMapOptions {
  77055. /**
  77056. * Vector2 of the number of cells in the grid.
  77057. */
  77058. stageSize?: Vector2;
  77059. /**
  77060. * Vector2 of the size of the output plane in World Units.
  77061. */
  77062. outputSize?: Vector2;
  77063. /**
  77064. * Vector3 of the position of the output plane in World Units.
  77065. */
  77066. outputPosition?: Vector3;
  77067. /**
  77068. * Vector3 of the rotation of the output plane.
  77069. */
  77070. outputRotation?: Vector3;
  77071. /**
  77072. * number of layers that the system will reserve in resources.
  77073. */
  77074. layerCount?: number;
  77075. /**
  77076. * number of max animation frames a single cell will reserve in resources.
  77077. */
  77078. maxAnimationFrames?: number;
  77079. /**
  77080. * number cell index of the base tile when the system compiles.
  77081. */
  77082. baseTile?: number;
  77083. /**
  77084. * boolean flip the sprite after its been repositioned by the framing data.
  77085. */
  77086. flipU?: boolean;
  77087. /**
  77088. * Vector3 scalar of the global RGB values of the SpriteMap.
  77089. */
  77090. colorMultiply?: Vector3;
  77091. }
  77092. /**
  77093. * Defines the IDisposable interface in order to be cleanable from resources.
  77094. */
  77095. export interface ISpriteMap extends IDisposable {
  77096. /**
  77097. * String name of the SpriteMap.
  77098. */
  77099. name: string;
  77100. /**
  77101. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77102. */
  77103. atlasJSON: ISpriteJSONAtlas;
  77104. /**
  77105. * Texture of the SpriteMap.
  77106. */
  77107. spriteSheet: Texture;
  77108. /**
  77109. * The parameters to initialize the SpriteMap with.
  77110. */
  77111. options: ISpriteMapOptions;
  77112. }
  77113. /**
  77114. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77115. */
  77116. export class SpriteMap implements ISpriteMap {
  77117. /** The Name of the spriteMap */
  77118. name: string;
  77119. /** The JSON file with the frame and meta data */
  77120. atlasJSON: ISpriteJSONAtlas;
  77121. /** The systems Sprite Sheet Texture */
  77122. spriteSheet: Texture;
  77123. /** Arguments passed with the Constructor */
  77124. options: ISpriteMapOptions;
  77125. /** Public Sprite Storage array, parsed from atlasJSON */
  77126. sprites: Array<ISpriteJSONSprite>;
  77127. /** Returns the Number of Sprites in the System */
  77128. get spriteCount(): number;
  77129. /** Returns the Position of Output Plane*/
  77130. get position(): Vector3;
  77131. /** Returns the Position of Output Plane*/
  77132. set position(v: Vector3);
  77133. /** Returns the Rotation of Output Plane*/
  77134. get rotation(): Vector3;
  77135. /** Returns the Rotation of Output Plane*/
  77136. set rotation(v: Vector3);
  77137. /** Sets the AnimationMap*/
  77138. get animationMap(): RawTexture;
  77139. /** Sets the AnimationMap*/
  77140. set animationMap(v: RawTexture);
  77141. /** Scene that the SpriteMap was created in */
  77142. private _scene;
  77143. /** Texture Buffer of Float32 that holds tile frame data*/
  77144. private _frameMap;
  77145. /** Texture Buffers of Float32 that holds tileMap data*/
  77146. private _tileMaps;
  77147. /** Texture Buffer of Float32 that holds Animation Data*/
  77148. private _animationMap;
  77149. /** Custom ShaderMaterial Central to the System*/
  77150. private _material;
  77151. /** Custom ShaderMaterial Central to the System*/
  77152. private _output;
  77153. /** Systems Time Ticker*/
  77154. private _time;
  77155. /**
  77156. * Creates a new SpriteMap
  77157. * @param name defines the SpriteMaps Name
  77158. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77159. * @param spriteSheet is the Texture that the Sprites are on.
  77160. * @param options a basic deployment configuration
  77161. * @param scene The Scene that the map is deployed on
  77162. */
  77163. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77164. /**
  77165. * Returns tileID location
  77166. * @returns Vector2 the cell position ID
  77167. */
  77168. getTileID(): Vector2;
  77169. /**
  77170. * Gets the UV location of the mouse over the SpriteMap.
  77171. * @returns Vector2 the UV position of the mouse interaction
  77172. */
  77173. getMousePosition(): Vector2;
  77174. /**
  77175. * Creates the "frame" texture Buffer
  77176. * -------------------------------------
  77177. * Structure of frames
  77178. * "filename": "Falling-Water-2.png",
  77179. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77180. * "rotated": true,
  77181. * "trimmed": true,
  77182. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77183. * "sourceSize": {"w":32,"h":32}
  77184. * @returns RawTexture of the frameMap
  77185. */
  77186. private _createFrameBuffer;
  77187. /**
  77188. * Creates the tileMap texture Buffer
  77189. * @param buffer normally and array of numbers, or a false to generate from scratch
  77190. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77191. * @returns RawTexture of the tileMap
  77192. */
  77193. private _createTileBuffer;
  77194. /**
  77195. * Modifies the data of the tileMaps
  77196. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77197. * @param pos is the iVector2 Coordinates of the Tile
  77198. * @param tile The SpriteIndex of the new Tile
  77199. */
  77200. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77201. /**
  77202. * Creates the animationMap texture Buffer
  77203. * @param buffer normally and array of numbers, or a false to generate from scratch
  77204. * @returns RawTexture of the animationMap
  77205. */
  77206. private _createTileAnimationBuffer;
  77207. /**
  77208. * Modifies the data of the animationMap
  77209. * @param cellID is the Index of the Sprite
  77210. * @param _frame is the target Animation frame
  77211. * @param toCell is the Target Index of the next frame of the animation
  77212. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77213. * @param speed is a global scalar of the time variable on the map.
  77214. */
  77215. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77216. /**
  77217. * Exports the .tilemaps file
  77218. */
  77219. saveTileMaps(): void;
  77220. /**
  77221. * Imports the .tilemaps file
  77222. * @param url of the .tilemaps file
  77223. */
  77224. loadTileMaps(url: string): void;
  77225. /**
  77226. * Release associated resources
  77227. */
  77228. dispose(): void;
  77229. }
  77230. }
  77231. declare module "babylonjs/Sprites/spritePackedManager" {
  77232. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77233. import { Scene } from "babylonjs/scene";
  77234. /**
  77235. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77236. * @see https://doc.babylonjs.com/babylon101/sprites
  77237. */
  77238. export class SpritePackedManager extends SpriteManager {
  77239. /** defines the packed manager's name */
  77240. name: string;
  77241. /**
  77242. * Creates a new sprite manager from a packed sprite sheet
  77243. * @param name defines the manager's name
  77244. * @param imgUrl defines the sprite sheet url
  77245. * @param capacity defines the maximum allowed number of sprites
  77246. * @param scene defines the hosting scene
  77247. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77248. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77249. * @param samplingMode defines the smapling mode to use with spritesheet
  77250. * @param fromPacked set to true; do not alter
  77251. */
  77252. constructor(
  77253. /** defines the packed manager's name */
  77254. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77255. }
  77256. }
  77257. declare module "babylonjs/Sprites/index" {
  77258. export * from "babylonjs/Sprites/sprite";
  77259. export * from "babylonjs/Sprites/ISprites";
  77260. export * from "babylonjs/Sprites/spriteManager";
  77261. export * from "babylonjs/Sprites/spriteMap";
  77262. export * from "babylonjs/Sprites/spritePackedManager";
  77263. export * from "babylonjs/Sprites/spriteSceneComponent";
  77264. }
  77265. declare module "babylonjs/States/index" {
  77266. export * from "babylonjs/States/alphaCullingState";
  77267. export * from "babylonjs/States/depthCullingState";
  77268. export * from "babylonjs/States/stencilState";
  77269. }
  77270. declare module "babylonjs/Misc/assetsManager" {
  77271. import { Scene } from "babylonjs/scene";
  77272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77273. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77274. import { Skeleton } from "babylonjs/Bones/skeleton";
  77275. import { Observable } from "babylonjs/Misc/observable";
  77276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77277. import { Texture } from "babylonjs/Materials/Textures/texture";
  77278. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77279. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77280. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77281. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77282. import { AssetContainer } from "babylonjs/assetContainer";
  77283. /**
  77284. * Defines the list of states available for a task inside a AssetsManager
  77285. */
  77286. export enum AssetTaskState {
  77287. /**
  77288. * Initialization
  77289. */
  77290. INIT = 0,
  77291. /**
  77292. * Running
  77293. */
  77294. RUNNING = 1,
  77295. /**
  77296. * Done
  77297. */
  77298. DONE = 2,
  77299. /**
  77300. * Error
  77301. */
  77302. ERROR = 3
  77303. }
  77304. /**
  77305. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77306. */
  77307. export abstract class AbstractAssetTask {
  77308. /**
  77309. * Task name
  77310. */ name: string;
  77311. /**
  77312. * Callback called when the task is successful
  77313. */
  77314. onSuccess: (task: any) => void;
  77315. /**
  77316. * Callback called when the task is not successful
  77317. */
  77318. onError: (task: any, message?: string, exception?: any) => void;
  77319. /**
  77320. * Creates a new AssetsManager
  77321. * @param name defines the name of the task
  77322. */
  77323. constructor(
  77324. /**
  77325. * Task name
  77326. */ name: string);
  77327. private _isCompleted;
  77328. private _taskState;
  77329. private _errorObject;
  77330. /**
  77331. * Get if the task is completed
  77332. */
  77333. get isCompleted(): boolean;
  77334. /**
  77335. * Gets the current state of the task
  77336. */
  77337. get taskState(): AssetTaskState;
  77338. /**
  77339. * Gets the current error object (if task is in error)
  77340. */
  77341. get errorObject(): {
  77342. message?: string;
  77343. exception?: any;
  77344. };
  77345. /**
  77346. * Internal only
  77347. * @hidden
  77348. */
  77349. _setErrorObject(message?: string, exception?: any): void;
  77350. /**
  77351. * Execute the current task
  77352. * @param scene defines the scene where you want your assets to be loaded
  77353. * @param onSuccess is a callback called when the task is successfully executed
  77354. * @param onError is a callback called if an error occurs
  77355. */
  77356. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77357. /**
  77358. * Execute the current task
  77359. * @param scene defines the scene where you want your assets to be loaded
  77360. * @param onSuccess is a callback called when the task is successfully executed
  77361. * @param onError is a callback called if an error occurs
  77362. */
  77363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77364. /**
  77365. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77366. * This can be used with failed tasks that have the reason for failure fixed.
  77367. */
  77368. reset(): void;
  77369. private onErrorCallback;
  77370. private onDoneCallback;
  77371. }
  77372. /**
  77373. * Define the interface used by progress events raised during assets loading
  77374. */
  77375. export interface IAssetsProgressEvent {
  77376. /**
  77377. * Defines the number of remaining tasks to process
  77378. */
  77379. remainingCount: number;
  77380. /**
  77381. * Defines the total number of tasks
  77382. */
  77383. totalCount: number;
  77384. /**
  77385. * Defines the task that was just processed
  77386. */
  77387. task: AbstractAssetTask;
  77388. }
  77389. /**
  77390. * Class used to share progress information about assets loading
  77391. */
  77392. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77393. /**
  77394. * Defines the number of remaining tasks to process
  77395. */
  77396. remainingCount: number;
  77397. /**
  77398. * Defines the total number of tasks
  77399. */
  77400. totalCount: number;
  77401. /**
  77402. * Defines the task that was just processed
  77403. */
  77404. task: AbstractAssetTask;
  77405. /**
  77406. * Creates a AssetsProgressEvent
  77407. * @param remainingCount defines the number of remaining tasks to process
  77408. * @param totalCount defines the total number of tasks
  77409. * @param task defines the task that was just processed
  77410. */
  77411. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77412. }
  77413. /**
  77414. * Define a task used by AssetsManager to load assets into a container
  77415. */
  77416. export class ContainerAssetTask extends AbstractAssetTask {
  77417. /**
  77418. * Defines the name of the task
  77419. */
  77420. name: string;
  77421. /**
  77422. * Defines the list of mesh's names you want to load
  77423. */
  77424. meshesNames: any;
  77425. /**
  77426. * Defines the root url to use as a base to load your meshes and associated resources
  77427. */
  77428. rootUrl: string;
  77429. /**
  77430. * Defines the filename or File of the scene to load from
  77431. */
  77432. sceneFilename: string | File;
  77433. /**
  77434. * Get the loaded asset container
  77435. */
  77436. loadedContainer: AssetContainer;
  77437. /**
  77438. * Gets the list of loaded meshes
  77439. */
  77440. loadedMeshes: Array<AbstractMesh>;
  77441. /**
  77442. * Gets the list of loaded particle systems
  77443. */
  77444. loadedParticleSystems: Array<IParticleSystem>;
  77445. /**
  77446. * Gets the list of loaded skeletons
  77447. */
  77448. loadedSkeletons: Array<Skeleton>;
  77449. /**
  77450. * Gets the list of loaded animation groups
  77451. */
  77452. loadedAnimationGroups: Array<AnimationGroup>;
  77453. /**
  77454. * Callback called when the task is successful
  77455. */
  77456. onSuccess: (task: ContainerAssetTask) => void;
  77457. /**
  77458. * Callback called when the task is successful
  77459. */
  77460. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77461. /**
  77462. * Creates a new ContainerAssetTask
  77463. * @param name defines the name of the task
  77464. * @param meshesNames defines the list of mesh's names you want to load
  77465. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77466. * @param sceneFilename defines the filename or File of the scene to load from
  77467. */
  77468. constructor(
  77469. /**
  77470. * Defines the name of the task
  77471. */
  77472. name: string,
  77473. /**
  77474. * Defines the list of mesh's names you want to load
  77475. */
  77476. meshesNames: any,
  77477. /**
  77478. * Defines the root url to use as a base to load your meshes and associated resources
  77479. */
  77480. rootUrl: string,
  77481. /**
  77482. * Defines the filename or File of the scene to load from
  77483. */
  77484. sceneFilename: string | File);
  77485. /**
  77486. * Execute the current task
  77487. * @param scene defines the scene where you want your assets to be loaded
  77488. * @param onSuccess is a callback called when the task is successfully executed
  77489. * @param onError is a callback called if an error occurs
  77490. */
  77491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77492. }
  77493. /**
  77494. * Define a task used by AssetsManager to load meshes
  77495. */
  77496. export class MeshAssetTask extends AbstractAssetTask {
  77497. /**
  77498. * Defines the name of the task
  77499. */
  77500. name: string;
  77501. /**
  77502. * Defines the list of mesh's names you want to load
  77503. */
  77504. meshesNames: any;
  77505. /**
  77506. * Defines the root url to use as a base to load your meshes and associated resources
  77507. */
  77508. rootUrl: string;
  77509. /**
  77510. * Defines the filename or File of the scene to load from
  77511. */
  77512. sceneFilename: string | File;
  77513. /**
  77514. * Gets the list of loaded meshes
  77515. */
  77516. loadedMeshes: Array<AbstractMesh>;
  77517. /**
  77518. * Gets the list of loaded particle systems
  77519. */
  77520. loadedParticleSystems: Array<IParticleSystem>;
  77521. /**
  77522. * Gets the list of loaded skeletons
  77523. */
  77524. loadedSkeletons: Array<Skeleton>;
  77525. /**
  77526. * Gets the list of loaded animation groups
  77527. */
  77528. loadedAnimationGroups: Array<AnimationGroup>;
  77529. /**
  77530. * Callback called when the task is successful
  77531. */
  77532. onSuccess: (task: MeshAssetTask) => void;
  77533. /**
  77534. * Callback called when the task is successful
  77535. */
  77536. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77537. /**
  77538. * Creates a new MeshAssetTask
  77539. * @param name defines the name of the task
  77540. * @param meshesNames defines the list of mesh's names you want to load
  77541. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77542. * @param sceneFilename defines the filename or File of the scene to load from
  77543. */
  77544. constructor(
  77545. /**
  77546. * Defines the name of the task
  77547. */
  77548. name: string,
  77549. /**
  77550. * Defines the list of mesh's names you want to load
  77551. */
  77552. meshesNames: any,
  77553. /**
  77554. * Defines the root url to use as a base to load your meshes and associated resources
  77555. */
  77556. rootUrl: string,
  77557. /**
  77558. * Defines the filename or File of the scene to load from
  77559. */
  77560. sceneFilename: string | File);
  77561. /**
  77562. * Execute the current task
  77563. * @param scene defines the scene where you want your assets to be loaded
  77564. * @param onSuccess is a callback called when the task is successfully executed
  77565. * @param onError is a callback called if an error occurs
  77566. */
  77567. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77568. }
  77569. /**
  77570. * Define a task used by AssetsManager to load text content
  77571. */
  77572. export class TextFileAssetTask extends AbstractAssetTask {
  77573. /**
  77574. * Defines the name of the task
  77575. */
  77576. name: string;
  77577. /**
  77578. * Defines the location of the file to load
  77579. */
  77580. url: string;
  77581. /**
  77582. * Gets the loaded text string
  77583. */
  77584. text: string;
  77585. /**
  77586. * Callback called when the task is successful
  77587. */
  77588. onSuccess: (task: TextFileAssetTask) => void;
  77589. /**
  77590. * Callback called when the task is successful
  77591. */
  77592. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77593. /**
  77594. * Creates a new TextFileAssetTask object
  77595. * @param name defines the name of the task
  77596. * @param url defines the location of the file to load
  77597. */
  77598. constructor(
  77599. /**
  77600. * Defines the name of the task
  77601. */
  77602. name: string,
  77603. /**
  77604. * Defines the location of the file to load
  77605. */
  77606. url: string);
  77607. /**
  77608. * Execute the current task
  77609. * @param scene defines the scene where you want your assets to be loaded
  77610. * @param onSuccess is a callback called when the task is successfully executed
  77611. * @param onError is a callback called if an error occurs
  77612. */
  77613. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77614. }
  77615. /**
  77616. * Define a task used by AssetsManager to load binary data
  77617. */
  77618. export class BinaryFileAssetTask extends AbstractAssetTask {
  77619. /**
  77620. * Defines the name of the task
  77621. */
  77622. name: string;
  77623. /**
  77624. * Defines the location of the file to load
  77625. */
  77626. url: string;
  77627. /**
  77628. * Gets the lodaded data (as an array buffer)
  77629. */
  77630. data: ArrayBuffer;
  77631. /**
  77632. * Callback called when the task is successful
  77633. */
  77634. onSuccess: (task: BinaryFileAssetTask) => void;
  77635. /**
  77636. * Callback called when the task is successful
  77637. */
  77638. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77639. /**
  77640. * Creates a new BinaryFileAssetTask object
  77641. * @param name defines the name of the new task
  77642. * @param url defines the location of the file to load
  77643. */
  77644. constructor(
  77645. /**
  77646. * Defines the name of the task
  77647. */
  77648. name: string,
  77649. /**
  77650. * Defines the location of the file to load
  77651. */
  77652. url: string);
  77653. /**
  77654. * Execute the current task
  77655. * @param scene defines the scene where you want your assets to be loaded
  77656. * @param onSuccess is a callback called when the task is successfully executed
  77657. * @param onError is a callback called if an error occurs
  77658. */
  77659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77660. }
  77661. /**
  77662. * Define a task used by AssetsManager to load images
  77663. */
  77664. export class ImageAssetTask extends AbstractAssetTask {
  77665. /**
  77666. * Defines the name of the task
  77667. */
  77668. name: string;
  77669. /**
  77670. * Defines the location of the image to load
  77671. */
  77672. url: string;
  77673. /**
  77674. * Gets the loaded images
  77675. */
  77676. image: HTMLImageElement;
  77677. /**
  77678. * Callback called when the task is successful
  77679. */
  77680. onSuccess: (task: ImageAssetTask) => void;
  77681. /**
  77682. * Callback called when the task is successful
  77683. */
  77684. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77685. /**
  77686. * Creates a new ImageAssetTask
  77687. * @param name defines the name of the task
  77688. * @param url defines the location of the image to load
  77689. */
  77690. constructor(
  77691. /**
  77692. * Defines the name of the task
  77693. */
  77694. name: string,
  77695. /**
  77696. * Defines the location of the image to load
  77697. */
  77698. url: string);
  77699. /**
  77700. * Execute the current task
  77701. * @param scene defines the scene where you want your assets to be loaded
  77702. * @param onSuccess is a callback called when the task is successfully executed
  77703. * @param onError is a callback called if an error occurs
  77704. */
  77705. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77706. }
  77707. /**
  77708. * Defines the interface used by texture loading tasks
  77709. */
  77710. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77711. /**
  77712. * Gets the loaded texture
  77713. */
  77714. texture: TEX;
  77715. }
  77716. /**
  77717. * Define a task used by AssetsManager to load 2D textures
  77718. */
  77719. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77720. /**
  77721. * Defines the name of the task
  77722. */
  77723. name: string;
  77724. /**
  77725. * Defines the location of the file to load
  77726. */
  77727. url: string;
  77728. /**
  77729. * Defines if mipmap should not be generated (default is false)
  77730. */
  77731. noMipmap?: boolean | undefined;
  77732. /**
  77733. * Defines if texture must be inverted on Y axis (default is true)
  77734. */
  77735. invertY: boolean;
  77736. /**
  77737. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77738. */
  77739. samplingMode: number;
  77740. /**
  77741. * Gets the loaded texture
  77742. */
  77743. texture: Texture;
  77744. /**
  77745. * Callback called when the task is successful
  77746. */
  77747. onSuccess: (task: TextureAssetTask) => void;
  77748. /**
  77749. * Callback called when the task is successful
  77750. */
  77751. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77752. /**
  77753. * Creates a new TextureAssetTask object
  77754. * @param name defines the name of the task
  77755. * @param url defines the location of the file to load
  77756. * @param noMipmap defines if mipmap should not be generated (default is false)
  77757. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77758. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77759. */
  77760. constructor(
  77761. /**
  77762. * Defines the name of the task
  77763. */
  77764. name: string,
  77765. /**
  77766. * Defines the location of the file to load
  77767. */
  77768. url: string,
  77769. /**
  77770. * Defines if mipmap should not be generated (default is false)
  77771. */
  77772. noMipmap?: boolean | undefined,
  77773. /**
  77774. * Defines if texture must be inverted on Y axis (default is true)
  77775. */
  77776. invertY?: boolean,
  77777. /**
  77778. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77779. */
  77780. samplingMode?: number);
  77781. /**
  77782. * Execute the current task
  77783. * @param scene defines the scene where you want your assets to be loaded
  77784. * @param onSuccess is a callback called when the task is successfully executed
  77785. * @param onError is a callback called if an error occurs
  77786. */
  77787. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77788. }
  77789. /**
  77790. * Define a task used by AssetsManager to load cube textures
  77791. */
  77792. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77793. /**
  77794. * Defines the name of the task
  77795. */
  77796. name: string;
  77797. /**
  77798. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77799. */
  77800. url: string;
  77801. /**
  77802. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77803. */
  77804. extensions?: string[] | undefined;
  77805. /**
  77806. * Defines if mipmaps should not be generated (default is false)
  77807. */
  77808. noMipmap?: boolean | undefined;
  77809. /**
  77810. * Defines the explicit list of files (undefined by default)
  77811. */
  77812. files?: string[] | undefined;
  77813. /**
  77814. * Gets the loaded texture
  77815. */
  77816. texture: CubeTexture;
  77817. /**
  77818. * Callback called when the task is successful
  77819. */
  77820. onSuccess: (task: CubeTextureAssetTask) => void;
  77821. /**
  77822. * Callback called when the task is successful
  77823. */
  77824. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77825. /**
  77826. * Creates a new CubeTextureAssetTask
  77827. * @param name defines the name of the task
  77828. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77829. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77830. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77831. * @param files defines the explicit list of files (undefined by default)
  77832. */
  77833. constructor(
  77834. /**
  77835. * Defines the name of the task
  77836. */
  77837. name: string,
  77838. /**
  77839. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77840. */
  77841. url: string,
  77842. /**
  77843. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77844. */
  77845. extensions?: string[] | undefined,
  77846. /**
  77847. * Defines if mipmaps should not be generated (default is false)
  77848. */
  77849. noMipmap?: boolean | undefined,
  77850. /**
  77851. * Defines the explicit list of files (undefined by default)
  77852. */
  77853. files?: string[] | undefined);
  77854. /**
  77855. * Execute the current task
  77856. * @param scene defines the scene where you want your assets to be loaded
  77857. * @param onSuccess is a callback called when the task is successfully executed
  77858. * @param onError is a callback called if an error occurs
  77859. */
  77860. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77861. }
  77862. /**
  77863. * Define a task used by AssetsManager to load HDR cube textures
  77864. */
  77865. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77866. /**
  77867. * Defines the name of the task
  77868. */
  77869. name: string;
  77870. /**
  77871. * Defines the location of the file to load
  77872. */
  77873. url: string;
  77874. /**
  77875. * Defines the desired size (the more it increases the longer the generation will be)
  77876. */
  77877. size: number;
  77878. /**
  77879. * Defines if mipmaps should not be generated (default is false)
  77880. */
  77881. noMipmap: boolean;
  77882. /**
  77883. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77884. */
  77885. generateHarmonics: boolean;
  77886. /**
  77887. * 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)
  77888. */
  77889. gammaSpace: boolean;
  77890. /**
  77891. * Internal Use Only
  77892. */
  77893. reserved: boolean;
  77894. /**
  77895. * Gets the loaded texture
  77896. */
  77897. texture: HDRCubeTexture;
  77898. /**
  77899. * Callback called when the task is successful
  77900. */
  77901. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77902. /**
  77903. * Callback called when the task is successful
  77904. */
  77905. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77906. /**
  77907. * Creates a new HDRCubeTextureAssetTask object
  77908. * @param name defines the name of the task
  77909. * @param url defines the location of the file to load
  77910. * @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.
  77911. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77912. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77913. * @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)
  77914. * @param reserved Internal use only
  77915. */
  77916. constructor(
  77917. /**
  77918. * Defines the name of the task
  77919. */
  77920. name: string,
  77921. /**
  77922. * Defines the location of the file to load
  77923. */
  77924. url: string,
  77925. /**
  77926. * Defines the desired size (the more it increases the longer the generation will be)
  77927. */
  77928. size: number,
  77929. /**
  77930. * Defines if mipmaps should not be generated (default is false)
  77931. */
  77932. noMipmap?: boolean,
  77933. /**
  77934. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77935. */
  77936. generateHarmonics?: boolean,
  77937. /**
  77938. * 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)
  77939. */
  77940. gammaSpace?: boolean,
  77941. /**
  77942. * Internal Use Only
  77943. */
  77944. reserved?: boolean);
  77945. /**
  77946. * Execute the current task
  77947. * @param scene defines the scene where you want your assets to be loaded
  77948. * @param onSuccess is a callback called when the task is successfully executed
  77949. * @param onError is a callback called if an error occurs
  77950. */
  77951. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77952. }
  77953. /**
  77954. * Define a task used by AssetsManager to load Equirectangular cube textures
  77955. */
  77956. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77957. /**
  77958. * Defines the name of the task
  77959. */
  77960. name: string;
  77961. /**
  77962. * Defines the location of the file to load
  77963. */
  77964. url: string;
  77965. /**
  77966. * Defines the desired size (the more it increases the longer the generation will be)
  77967. */
  77968. size: number;
  77969. /**
  77970. * Defines if mipmaps should not be generated (default is false)
  77971. */
  77972. noMipmap: boolean;
  77973. /**
  77974. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77975. * but the standard material would require them in Gamma space) (default is true)
  77976. */
  77977. gammaSpace: boolean;
  77978. /**
  77979. * Gets the loaded texture
  77980. */
  77981. texture: EquiRectangularCubeTexture;
  77982. /**
  77983. * Callback called when the task is successful
  77984. */
  77985. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77986. /**
  77987. * Callback called when the task is successful
  77988. */
  77989. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77990. /**
  77991. * Creates a new EquiRectangularCubeTextureAssetTask object
  77992. * @param name defines the name of the task
  77993. * @param url defines the location of the file to load
  77994. * @param size defines the desired size (the more it increases the longer the generation will be)
  77995. * If the size is omitted this implies you are using a preprocessed cubemap.
  77996. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77997. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77998. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77999. * (default is true)
  78000. */
  78001. constructor(
  78002. /**
  78003. * Defines the name of the task
  78004. */
  78005. name: string,
  78006. /**
  78007. * Defines the location of the file to load
  78008. */
  78009. url: string,
  78010. /**
  78011. * Defines the desired size (the more it increases the longer the generation will be)
  78012. */
  78013. size: number,
  78014. /**
  78015. * Defines if mipmaps should not be generated (default is false)
  78016. */
  78017. noMipmap?: boolean,
  78018. /**
  78019. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78020. * but the standard material would require them in Gamma space) (default is true)
  78021. */
  78022. gammaSpace?: boolean);
  78023. /**
  78024. * Execute the current task
  78025. * @param scene defines the scene where you want your assets to be loaded
  78026. * @param onSuccess is a callback called when the task is successfully executed
  78027. * @param onError is a callback called if an error occurs
  78028. */
  78029. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78030. }
  78031. /**
  78032. * This class can be used to easily import assets into a scene
  78033. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78034. */
  78035. export class AssetsManager {
  78036. private _scene;
  78037. private _isLoading;
  78038. protected _tasks: AbstractAssetTask[];
  78039. protected _waitingTasksCount: number;
  78040. protected _totalTasksCount: number;
  78041. /**
  78042. * Callback called when all tasks are processed
  78043. */
  78044. onFinish: (tasks: AbstractAssetTask[]) => void;
  78045. /**
  78046. * Callback called when a task is successful
  78047. */
  78048. onTaskSuccess: (task: AbstractAssetTask) => void;
  78049. /**
  78050. * Callback called when a task had an error
  78051. */
  78052. onTaskError: (task: AbstractAssetTask) => void;
  78053. /**
  78054. * Callback called when a task is done (whatever the result is)
  78055. */
  78056. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78057. /**
  78058. * Observable called when all tasks are processed
  78059. */
  78060. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78061. /**
  78062. * Observable called when a task had an error
  78063. */
  78064. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78065. /**
  78066. * Observable called when all tasks were executed
  78067. */
  78068. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78069. /**
  78070. * Observable called when a task is done (whatever the result is)
  78071. */
  78072. onProgressObservable: Observable<IAssetsProgressEvent>;
  78073. /**
  78074. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78075. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78076. */
  78077. useDefaultLoadingScreen: boolean;
  78078. /**
  78079. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78080. * when all assets have been downloaded.
  78081. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78082. */
  78083. autoHideLoadingUI: boolean;
  78084. /**
  78085. * Creates a new AssetsManager
  78086. * @param scene defines the scene to work on
  78087. */
  78088. constructor(scene: Scene);
  78089. /**
  78090. * Add a ContainerAssetTask to the list of active tasks
  78091. * @param taskName defines the name of the new task
  78092. * @param meshesNames defines the name of meshes to load
  78093. * @param rootUrl defines the root url to use to locate files
  78094. * @param sceneFilename defines the filename of the scene file
  78095. * @returns a new ContainerAssetTask object
  78096. */
  78097. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78098. /**
  78099. * Add a MeshAssetTask to the list of active tasks
  78100. * @param taskName defines the name of the new task
  78101. * @param meshesNames defines the name of meshes to load
  78102. * @param rootUrl defines the root url to use to locate files
  78103. * @param sceneFilename defines the filename of the scene file
  78104. * @returns a new MeshAssetTask object
  78105. */
  78106. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78107. /**
  78108. * Add a TextFileAssetTask to the list of active tasks
  78109. * @param taskName defines the name of the new task
  78110. * @param url defines the url of the file to load
  78111. * @returns a new TextFileAssetTask object
  78112. */
  78113. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78114. /**
  78115. * Add a BinaryFileAssetTask to the list of active tasks
  78116. * @param taskName defines the name of the new task
  78117. * @param url defines the url of the file to load
  78118. * @returns a new BinaryFileAssetTask object
  78119. */
  78120. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78121. /**
  78122. * Add a ImageAssetTask to the list of active tasks
  78123. * @param taskName defines the name of the new task
  78124. * @param url defines the url of the file to load
  78125. * @returns a new ImageAssetTask object
  78126. */
  78127. addImageTask(taskName: string, url: string): ImageAssetTask;
  78128. /**
  78129. * Add a TextureAssetTask to the list of active tasks
  78130. * @param taskName defines the name of the new task
  78131. * @param url defines the url of the file to load
  78132. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78133. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78134. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78135. * @returns a new TextureAssetTask object
  78136. */
  78137. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78138. /**
  78139. * Add a CubeTextureAssetTask to the list of active tasks
  78140. * @param taskName defines the name of the new task
  78141. * @param url defines the url of the file to load
  78142. * @param extensions defines the extension to use to load the cube map (can be null)
  78143. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78144. * @param files defines the list of files to load (can be null)
  78145. * @returns a new CubeTextureAssetTask object
  78146. */
  78147. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78148. /**
  78149. *
  78150. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78151. * @param taskName defines the name of the new task
  78152. * @param url defines the url of the file to load
  78153. * @param size defines the size you want for the cubemap (can be null)
  78154. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78155. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78156. * @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)
  78157. * @param reserved Internal use only
  78158. * @returns a new HDRCubeTextureAssetTask object
  78159. */
  78160. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78161. /**
  78162. *
  78163. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78164. * @param taskName defines the name of the new task
  78165. * @param url defines the url of the file to load
  78166. * @param size defines the size you want for the cubemap (can be null)
  78167. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78168. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78169. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78170. * @returns a new EquiRectangularCubeTextureAssetTask object
  78171. */
  78172. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78173. /**
  78174. * Remove a task from the assets manager.
  78175. * @param task the task to remove
  78176. */
  78177. removeTask(task: AbstractAssetTask): void;
  78178. private _decreaseWaitingTasksCount;
  78179. private _runTask;
  78180. /**
  78181. * Reset the AssetsManager and remove all tasks
  78182. * @return the current instance of the AssetsManager
  78183. */
  78184. reset(): AssetsManager;
  78185. /**
  78186. * Start the loading process
  78187. * @return the current instance of the AssetsManager
  78188. */
  78189. load(): AssetsManager;
  78190. /**
  78191. * Start the loading process as an async operation
  78192. * @return a promise returning the list of failed tasks
  78193. */
  78194. loadAsync(): Promise<void>;
  78195. }
  78196. }
  78197. declare module "babylonjs/Misc/deferred" {
  78198. /**
  78199. * Wrapper class for promise with external resolve and reject.
  78200. */
  78201. export class Deferred<T> {
  78202. /**
  78203. * The promise associated with this deferred object.
  78204. */
  78205. readonly promise: Promise<T>;
  78206. private _resolve;
  78207. private _reject;
  78208. /**
  78209. * The resolve method of the promise associated with this deferred object.
  78210. */
  78211. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78212. /**
  78213. * The reject method of the promise associated with this deferred object.
  78214. */
  78215. get reject(): (reason?: any) => void;
  78216. /**
  78217. * Constructor for this deferred object.
  78218. */
  78219. constructor();
  78220. }
  78221. }
  78222. declare module "babylonjs/Misc/meshExploder" {
  78223. import { Mesh } from "babylonjs/Meshes/mesh";
  78224. /**
  78225. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78226. */
  78227. export class MeshExploder {
  78228. private _centerMesh;
  78229. private _meshes;
  78230. private _meshesOrigins;
  78231. private _toCenterVectors;
  78232. private _scaledDirection;
  78233. private _newPosition;
  78234. private _centerPosition;
  78235. /**
  78236. * Explodes meshes from a center mesh.
  78237. * @param meshes The meshes to explode.
  78238. * @param centerMesh The mesh to be center of explosion.
  78239. */
  78240. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78241. private _setCenterMesh;
  78242. /**
  78243. * Get class name
  78244. * @returns "MeshExploder"
  78245. */
  78246. getClassName(): string;
  78247. /**
  78248. * "Exploded meshes"
  78249. * @returns Array of meshes with the centerMesh at index 0.
  78250. */
  78251. getMeshes(): Array<Mesh>;
  78252. /**
  78253. * Explodes meshes giving a specific direction
  78254. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78255. */
  78256. explode(direction?: number): void;
  78257. }
  78258. }
  78259. declare module "babylonjs/Misc/filesInput" {
  78260. import { Engine } from "babylonjs/Engines/engine";
  78261. import { Scene } from "babylonjs/scene";
  78262. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78263. import { Nullable } from "babylonjs/types";
  78264. /**
  78265. * Class used to help managing file picking and drag'n'drop
  78266. */
  78267. export class FilesInput {
  78268. /**
  78269. * List of files ready to be loaded
  78270. */
  78271. static get FilesToLoad(): {
  78272. [key: string]: File;
  78273. };
  78274. /**
  78275. * Callback called when a file is processed
  78276. */
  78277. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78278. private _engine;
  78279. private _currentScene;
  78280. private _sceneLoadedCallback;
  78281. private _progressCallback;
  78282. private _additionalRenderLoopLogicCallback;
  78283. private _textureLoadingCallback;
  78284. private _startingProcessingFilesCallback;
  78285. private _onReloadCallback;
  78286. private _errorCallback;
  78287. private _elementToMonitor;
  78288. private _sceneFileToLoad;
  78289. private _filesToLoad;
  78290. /**
  78291. * Creates a new FilesInput
  78292. * @param engine defines the rendering engine
  78293. * @param scene defines the hosting scene
  78294. * @param sceneLoadedCallback callback called when scene is loaded
  78295. * @param progressCallback callback called to track progress
  78296. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78297. * @param textureLoadingCallback callback called when a texture is loading
  78298. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78299. * @param onReloadCallback callback called when a reload is requested
  78300. * @param errorCallback callback call if an error occurs
  78301. */
  78302. 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>);
  78303. private _dragEnterHandler;
  78304. private _dragOverHandler;
  78305. private _dropHandler;
  78306. /**
  78307. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78308. * @param elementToMonitor defines the DOM element to track
  78309. */
  78310. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78311. /** Gets the current list of files to load */
  78312. get filesToLoad(): File[];
  78313. /**
  78314. * Release all associated resources
  78315. */
  78316. dispose(): void;
  78317. private renderFunction;
  78318. private drag;
  78319. private drop;
  78320. private _traverseFolder;
  78321. private _processFiles;
  78322. /**
  78323. * Load files from a drop event
  78324. * @param event defines the drop event to use as source
  78325. */
  78326. loadFiles(event: any): void;
  78327. private _processReload;
  78328. /**
  78329. * Reload the current scene from the loaded files
  78330. */
  78331. reload(): void;
  78332. }
  78333. }
  78334. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78335. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78336. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78337. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78338. }
  78339. declare module "babylonjs/Misc/sceneOptimizer" {
  78340. import { Scene, IDisposable } from "babylonjs/scene";
  78341. import { Observable } from "babylonjs/Misc/observable";
  78342. /**
  78343. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78344. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78345. */
  78346. export class SceneOptimization {
  78347. /**
  78348. * Defines the priority of this optimization (0 by default which means first in the list)
  78349. */
  78350. priority: number;
  78351. /**
  78352. * Gets a string describing the action executed by the current optimization
  78353. * @returns description string
  78354. */
  78355. getDescription(): string;
  78356. /**
  78357. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78358. * @param scene defines the current scene where to apply this optimization
  78359. * @param optimizer defines the current optimizer
  78360. * @returns true if everything that can be done was applied
  78361. */
  78362. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78363. /**
  78364. * Creates the SceneOptimization object
  78365. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78366. * @param desc defines the description associated with the optimization
  78367. */
  78368. constructor(
  78369. /**
  78370. * Defines the priority of this optimization (0 by default which means first in the list)
  78371. */
  78372. priority?: number);
  78373. }
  78374. /**
  78375. * Defines an optimization used to reduce the size of render target textures
  78376. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78377. */
  78378. export class TextureOptimization extends SceneOptimization {
  78379. /**
  78380. * Defines the priority of this optimization (0 by default which means first in the list)
  78381. */
  78382. priority: number;
  78383. /**
  78384. * 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
  78385. */
  78386. maximumSize: number;
  78387. /**
  78388. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78389. */
  78390. step: number;
  78391. /**
  78392. * Gets a string describing the action executed by the current optimization
  78393. * @returns description string
  78394. */
  78395. getDescription(): string;
  78396. /**
  78397. * Creates the TextureOptimization object
  78398. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78399. * @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
  78400. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78401. */
  78402. constructor(
  78403. /**
  78404. * Defines the priority of this optimization (0 by default which means first in the list)
  78405. */
  78406. priority?: number,
  78407. /**
  78408. * 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
  78409. */
  78410. maximumSize?: number,
  78411. /**
  78412. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78413. */
  78414. step?: number);
  78415. /**
  78416. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78417. * @param scene defines the current scene where to apply this optimization
  78418. * @param optimizer defines the current optimizer
  78419. * @returns true if everything that can be done was applied
  78420. */
  78421. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78422. }
  78423. /**
  78424. * Defines an optimization used to increase or decrease the rendering resolution
  78425. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78426. */
  78427. export class HardwareScalingOptimization extends SceneOptimization {
  78428. /**
  78429. * Defines the priority of this optimization (0 by default which means first in the list)
  78430. */
  78431. priority: number;
  78432. /**
  78433. * Defines the maximum scale to use (2 by default)
  78434. */
  78435. maximumScale: number;
  78436. /**
  78437. * Defines the step to use between two passes (0.5 by default)
  78438. */
  78439. step: number;
  78440. private _currentScale;
  78441. private _directionOffset;
  78442. /**
  78443. * Gets a string describing the action executed by the current optimization
  78444. * @return description string
  78445. */
  78446. getDescription(): string;
  78447. /**
  78448. * Creates the HardwareScalingOptimization object
  78449. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78450. * @param maximumScale defines the maximum scale to use (2 by default)
  78451. * @param step defines the step to use between two passes (0.5 by default)
  78452. */
  78453. constructor(
  78454. /**
  78455. * Defines the priority of this optimization (0 by default which means first in the list)
  78456. */
  78457. priority?: number,
  78458. /**
  78459. * Defines the maximum scale to use (2 by default)
  78460. */
  78461. maximumScale?: number,
  78462. /**
  78463. * Defines the step to use between two passes (0.5 by default)
  78464. */
  78465. step?: number);
  78466. /**
  78467. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78468. * @param scene defines the current scene where to apply this optimization
  78469. * @param optimizer defines the current optimizer
  78470. * @returns true if everything that can be done was applied
  78471. */
  78472. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78473. }
  78474. /**
  78475. * Defines an optimization used to remove shadows
  78476. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78477. */
  78478. export class ShadowsOptimization extends SceneOptimization {
  78479. /**
  78480. * Gets a string describing the action executed by the current optimization
  78481. * @return description string
  78482. */
  78483. getDescription(): string;
  78484. /**
  78485. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78486. * @param scene defines the current scene where to apply this optimization
  78487. * @param optimizer defines the current optimizer
  78488. * @returns true if everything that can be done was applied
  78489. */
  78490. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78491. }
  78492. /**
  78493. * Defines an optimization used to turn post-processes off
  78494. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78495. */
  78496. export class PostProcessesOptimization extends SceneOptimization {
  78497. /**
  78498. * Gets a string describing the action executed by the current optimization
  78499. * @return description string
  78500. */
  78501. getDescription(): string;
  78502. /**
  78503. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78504. * @param scene defines the current scene where to apply this optimization
  78505. * @param optimizer defines the current optimizer
  78506. * @returns true if everything that can be done was applied
  78507. */
  78508. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78509. }
  78510. /**
  78511. * Defines an optimization used to turn lens flares off
  78512. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78513. */
  78514. export class LensFlaresOptimization extends SceneOptimization {
  78515. /**
  78516. * Gets a string describing the action executed by the current optimization
  78517. * @return description string
  78518. */
  78519. getDescription(): string;
  78520. /**
  78521. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78522. * @param scene defines the current scene where to apply this optimization
  78523. * @param optimizer defines the current optimizer
  78524. * @returns true if everything that can be done was applied
  78525. */
  78526. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78527. }
  78528. /**
  78529. * Defines an optimization based on user defined callback.
  78530. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78531. */
  78532. export class CustomOptimization extends SceneOptimization {
  78533. /**
  78534. * Callback called to apply the custom optimization.
  78535. */
  78536. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78537. /**
  78538. * Callback called to get custom description
  78539. */
  78540. onGetDescription: () => string;
  78541. /**
  78542. * Gets a string describing the action executed by the current optimization
  78543. * @returns description string
  78544. */
  78545. getDescription(): string;
  78546. /**
  78547. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78548. * @param scene defines the current scene where to apply this optimization
  78549. * @param optimizer defines the current optimizer
  78550. * @returns true if everything that can be done was applied
  78551. */
  78552. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78553. }
  78554. /**
  78555. * Defines an optimization used to turn particles off
  78556. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78557. */
  78558. export class ParticlesOptimization extends SceneOptimization {
  78559. /**
  78560. * Gets a string describing the action executed by the current optimization
  78561. * @return description string
  78562. */
  78563. getDescription(): string;
  78564. /**
  78565. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78566. * @param scene defines the current scene where to apply this optimization
  78567. * @param optimizer defines the current optimizer
  78568. * @returns true if everything that can be done was applied
  78569. */
  78570. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78571. }
  78572. /**
  78573. * Defines an optimization used to turn render targets off
  78574. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78575. */
  78576. export class RenderTargetsOptimization extends SceneOptimization {
  78577. /**
  78578. * Gets a string describing the action executed by the current optimization
  78579. * @return description string
  78580. */
  78581. getDescription(): string;
  78582. /**
  78583. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78584. * @param scene defines the current scene where to apply this optimization
  78585. * @param optimizer defines the current optimizer
  78586. * @returns true if everything that can be done was applied
  78587. */
  78588. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78589. }
  78590. /**
  78591. * Defines an optimization used to merge meshes with compatible materials
  78592. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78593. */
  78594. export class MergeMeshesOptimization extends SceneOptimization {
  78595. private static _UpdateSelectionTree;
  78596. /**
  78597. * Gets or sets a boolean which defines if optimization octree has to be updated
  78598. */
  78599. static get UpdateSelectionTree(): boolean;
  78600. /**
  78601. * Gets or sets a boolean which defines if optimization octree has to be updated
  78602. */
  78603. static set UpdateSelectionTree(value: boolean);
  78604. /**
  78605. * Gets a string describing the action executed by the current optimization
  78606. * @return description string
  78607. */
  78608. getDescription(): string;
  78609. private _canBeMerged;
  78610. /**
  78611. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78612. * @param scene defines the current scene where to apply this optimization
  78613. * @param optimizer defines the current optimizer
  78614. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78615. * @returns true if everything that can be done was applied
  78616. */
  78617. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78618. }
  78619. /**
  78620. * Defines a list of options used by SceneOptimizer
  78621. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78622. */
  78623. export class SceneOptimizerOptions {
  78624. /**
  78625. * Defines the target frame rate to reach (60 by default)
  78626. */
  78627. targetFrameRate: number;
  78628. /**
  78629. * Defines the interval between two checkes (2000ms by default)
  78630. */
  78631. trackerDuration: number;
  78632. /**
  78633. * Gets the list of optimizations to apply
  78634. */
  78635. optimizations: SceneOptimization[];
  78636. /**
  78637. * Creates a new list of options used by SceneOptimizer
  78638. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78639. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78640. */
  78641. constructor(
  78642. /**
  78643. * Defines the target frame rate to reach (60 by default)
  78644. */
  78645. targetFrameRate?: number,
  78646. /**
  78647. * Defines the interval between two checkes (2000ms by default)
  78648. */
  78649. trackerDuration?: number);
  78650. /**
  78651. * Add a new optimization
  78652. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78653. * @returns the current SceneOptimizerOptions
  78654. */
  78655. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78656. /**
  78657. * Add a new custom optimization
  78658. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78659. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78660. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78661. * @returns the current SceneOptimizerOptions
  78662. */
  78663. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78664. /**
  78665. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78666. * @param targetFrameRate defines the target frame rate (60 by default)
  78667. * @returns a SceneOptimizerOptions object
  78668. */
  78669. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78670. /**
  78671. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78672. * @param targetFrameRate defines the target frame rate (60 by default)
  78673. * @returns a SceneOptimizerOptions object
  78674. */
  78675. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78676. /**
  78677. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78678. * @param targetFrameRate defines the target frame rate (60 by default)
  78679. * @returns a SceneOptimizerOptions object
  78680. */
  78681. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78682. }
  78683. /**
  78684. * Class used to run optimizations in order to reach a target frame rate
  78685. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78686. */
  78687. export class SceneOptimizer implements IDisposable {
  78688. private _isRunning;
  78689. private _options;
  78690. private _scene;
  78691. private _currentPriorityLevel;
  78692. private _targetFrameRate;
  78693. private _trackerDuration;
  78694. private _currentFrameRate;
  78695. private _sceneDisposeObserver;
  78696. private _improvementMode;
  78697. /**
  78698. * Defines an observable called when the optimizer reaches the target frame rate
  78699. */
  78700. onSuccessObservable: Observable<SceneOptimizer>;
  78701. /**
  78702. * Defines an observable called when the optimizer enables an optimization
  78703. */
  78704. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78705. /**
  78706. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78707. */
  78708. onFailureObservable: Observable<SceneOptimizer>;
  78709. /**
  78710. * Gets a boolean indicating if the optimizer is in improvement mode
  78711. */
  78712. get isInImprovementMode(): boolean;
  78713. /**
  78714. * Gets the current priority level (0 at start)
  78715. */
  78716. get currentPriorityLevel(): number;
  78717. /**
  78718. * Gets the current frame rate checked by the SceneOptimizer
  78719. */
  78720. get currentFrameRate(): number;
  78721. /**
  78722. * Gets or sets the current target frame rate (60 by default)
  78723. */
  78724. get targetFrameRate(): number;
  78725. /**
  78726. * Gets or sets the current target frame rate (60 by default)
  78727. */
  78728. set targetFrameRate(value: number);
  78729. /**
  78730. * Gets or sets the current interval between two checks (every 2000ms by default)
  78731. */
  78732. get trackerDuration(): number;
  78733. /**
  78734. * Gets or sets the current interval between two checks (every 2000ms by default)
  78735. */
  78736. set trackerDuration(value: number);
  78737. /**
  78738. * Gets the list of active optimizations
  78739. */
  78740. get optimizations(): SceneOptimization[];
  78741. /**
  78742. * Creates a new SceneOptimizer
  78743. * @param scene defines the scene to work on
  78744. * @param options defines the options to use with the SceneOptimizer
  78745. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78746. * @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)
  78747. */
  78748. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78749. /**
  78750. * Stops the current optimizer
  78751. */
  78752. stop(): void;
  78753. /**
  78754. * Reset the optimizer to initial step (current priority level = 0)
  78755. */
  78756. reset(): void;
  78757. /**
  78758. * Start the optimizer. By default it will try to reach a specific framerate
  78759. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78760. */
  78761. start(): void;
  78762. private _checkCurrentState;
  78763. /**
  78764. * Release all resources
  78765. */
  78766. dispose(): void;
  78767. /**
  78768. * Helper function to create a SceneOptimizer with one single line of code
  78769. * @param scene defines the scene to work on
  78770. * @param options defines the options to use with the SceneOptimizer
  78771. * @param onSuccess defines a callback to call on success
  78772. * @param onFailure defines a callback to call on failure
  78773. * @returns the new SceneOptimizer object
  78774. */
  78775. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78776. }
  78777. }
  78778. declare module "babylonjs/Misc/sceneSerializer" {
  78779. import { Scene } from "babylonjs/scene";
  78780. /**
  78781. * Class used to serialize a scene into a string
  78782. */
  78783. export class SceneSerializer {
  78784. /**
  78785. * Clear cache used by a previous serialization
  78786. */
  78787. static ClearCache(): void;
  78788. /**
  78789. * Serialize a scene into a JSON compatible object
  78790. * @param scene defines the scene to serialize
  78791. * @returns a JSON compatible object
  78792. */
  78793. static Serialize(scene: Scene): any;
  78794. /**
  78795. * Serialize a mesh into a JSON compatible object
  78796. * @param toSerialize defines the mesh to serialize
  78797. * @param withParents defines if parents must be serialized as well
  78798. * @param withChildren defines if children must be serialized as well
  78799. * @returns a JSON compatible object
  78800. */
  78801. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78802. }
  78803. }
  78804. declare module "babylonjs/Misc/textureTools" {
  78805. import { Texture } from "babylonjs/Materials/Textures/texture";
  78806. /**
  78807. * Class used to host texture specific utilities
  78808. */
  78809. export class TextureTools {
  78810. /**
  78811. * Uses the GPU to create a copy texture rescaled at a given size
  78812. * @param texture Texture to copy from
  78813. * @param width defines the desired width
  78814. * @param height defines the desired height
  78815. * @param useBilinearMode defines if bilinear mode has to be used
  78816. * @return the generated texture
  78817. */
  78818. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78819. }
  78820. }
  78821. declare module "babylonjs/Misc/videoRecorder" {
  78822. import { Nullable } from "babylonjs/types";
  78823. import { Engine } from "babylonjs/Engines/engine";
  78824. /**
  78825. * This represents the different options available for the video capture.
  78826. */
  78827. export interface VideoRecorderOptions {
  78828. /** Defines the mime type of the video. */
  78829. mimeType: string;
  78830. /** Defines the FPS the video should be recorded at. */
  78831. fps: number;
  78832. /** Defines the chunk size for the recording data. */
  78833. recordChunckSize: number;
  78834. /** The audio tracks to attach to the recording. */
  78835. audioTracks?: MediaStreamTrack[];
  78836. }
  78837. /**
  78838. * This can help with recording videos from BabylonJS.
  78839. * This is based on the available WebRTC functionalities of the browser.
  78840. *
  78841. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78842. */
  78843. export class VideoRecorder {
  78844. private static readonly _defaultOptions;
  78845. /**
  78846. * Returns whether or not the VideoRecorder is available in your browser.
  78847. * @param engine Defines the Babylon Engine.
  78848. * @returns true if supported otherwise false.
  78849. */
  78850. static IsSupported(engine: Engine): boolean;
  78851. private readonly _options;
  78852. private _canvas;
  78853. private _mediaRecorder;
  78854. private _recordedChunks;
  78855. private _fileName;
  78856. private _resolve;
  78857. private _reject;
  78858. /**
  78859. * True when a recording is already in progress.
  78860. */
  78861. get isRecording(): boolean;
  78862. /**
  78863. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78864. * @param engine Defines the BabylonJS Engine you wish to record.
  78865. * @param options Defines options that can be used to customize the capture.
  78866. */
  78867. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78868. /**
  78869. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78870. */
  78871. stopRecording(): void;
  78872. /**
  78873. * Starts recording the canvas for a max duration specified in parameters.
  78874. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78875. * If null no automatic download will start and you can rely on the promise to get the data back.
  78876. * @param maxDuration Defines the maximum recording time in seconds.
  78877. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78878. * @return A promise callback at the end of the recording with the video data in Blob.
  78879. */
  78880. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78881. /**
  78882. * Releases internal resources used during the recording.
  78883. */
  78884. dispose(): void;
  78885. private _handleDataAvailable;
  78886. private _handleError;
  78887. private _handleStop;
  78888. }
  78889. }
  78890. declare module "babylonjs/Misc/screenshotTools" {
  78891. import { Camera } from "babylonjs/Cameras/camera";
  78892. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78893. import { Engine } from "babylonjs/Engines/engine";
  78894. /**
  78895. * Class containing a set of static utilities functions for screenshots
  78896. */
  78897. export class ScreenshotTools {
  78898. /**
  78899. * Captures a screenshot of the current rendering
  78900. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78901. * @param engine defines the rendering engine
  78902. * @param camera defines the source camera
  78903. * @param size This parameter can be set to a single number or to an object with the
  78904. * following (optional) properties: precision, width, height. If a single number is passed,
  78905. * it will be used for both width and height. If an object is passed, the screenshot size
  78906. * will be derived from the parameters. The precision property is a multiplier allowing
  78907. * rendering at a higher or lower resolution
  78908. * @param successCallback defines the callback receives a single parameter which contains the
  78909. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78910. * src parameter of an <img> to display it
  78911. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78912. * Check your browser for supported MIME types
  78913. */
  78914. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78915. /**
  78916. * Captures a screenshot of the current rendering
  78917. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78918. * @param engine defines the rendering engine
  78919. * @param camera defines the source camera
  78920. * @param size This parameter can be set to a single number or to an object with the
  78921. * following (optional) properties: precision, width, height. If a single number is passed,
  78922. * it will be used for both width and height. If an object is passed, the screenshot size
  78923. * will be derived from the parameters. The precision property is a multiplier allowing
  78924. * rendering at a higher or lower resolution
  78925. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78926. * Check your browser for supported MIME types
  78927. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78928. * to the src parameter of an <img> to display it
  78929. */
  78930. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78931. /**
  78932. * Generates an image screenshot from the specified camera.
  78933. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78934. * @param engine The engine to use for rendering
  78935. * @param camera The camera to use for rendering
  78936. * @param size This parameter can be set to a single number or to an object with the
  78937. * following (optional) properties: precision, width, height. If a single number is passed,
  78938. * it will be used for both width and height. If an object is passed, the screenshot size
  78939. * will be derived from the parameters. The precision property is a multiplier allowing
  78940. * rendering at a higher or lower resolution
  78941. * @param successCallback The callback receives a single parameter which contains the
  78942. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78943. * src parameter of an <img> to display it
  78944. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78945. * Check your browser for supported MIME types
  78946. * @param samples Texture samples (default: 1)
  78947. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78948. * @param fileName A name for for the downloaded file.
  78949. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78950. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78951. */
  78952. 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;
  78953. /**
  78954. * Generates an image screenshot from the specified camera.
  78955. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78956. * @param engine The engine to use for rendering
  78957. * @param camera The camera to use for rendering
  78958. * @param size This parameter can be set to a single number or to an object with the
  78959. * following (optional) properties: precision, width, height. If a single number is passed,
  78960. * it will be used for both width and height. If an object is passed, the screenshot size
  78961. * will be derived from the parameters. The precision property is a multiplier allowing
  78962. * rendering at a higher or lower resolution
  78963. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78964. * Check your browser for supported MIME types
  78965. * @param samples Texture samples (default: 1)
  78966. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78967. * @param fileName A name for for the downloaded file.
  78968. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78969. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78970. * to the src parameter of an <img> to display it
  78971. */
  78972. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78973. /**
  78974. * Gets height and width for screenshot size
  78975. * @private
  78976. */
  78977. private static _getScreenshotSize;
  78978. }
  78979. }
  78980. declare module "babylonjs/Misc/dataReader" {
  78981. /**
  78982. * Interface for a data buffer
  78983. */
  78984. export interface IDataBuffer {
  78985. /**
  78986. * Reads bytes from the data buffer.
  78987. * @param byteOffset The byte offset to read
  78988. * @param byteLength The byte length to read
  78989. * @returns A promise that resolves when the bytes are read
  78990. */
  78991. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78992. /**
  78993. * The byte length of the buffer.
  78994. */
  78995. readonly byteLength: number;
  78996. }
  78997. /**
  78998. * Utility class for reading from a data buffer
  78999. */
  79000. export class DataReader {
  79001. /**
  79002. * The data buffer associated with this data reader.
  79003. */
  79004. readonly buffer: IDataBuffer;
  79005. /**
  79006. * The current byte offset from the beginning of the data buffer.
  79007. */
  79008. byteOffset: number;
  79009. private _dataView;
  79010. private _dataByteOffset;
  79011. /**
  79012. * Constructor
  79013. * @param buffer The buffer to read
  79014. */
  79015. constructor(buffer: IDataBuffer);
  79016. /**
  79017. * Loads the given byte length.
  79018. * @param byteLength The byte length to load
  79019. * @returns A promise that resolves when the load is complete
  79020. */
  79021. loadAsync(byteLength: number): Promise<void>;
  79022. /**
  79023. * Read a unsigned 32-bit integer from the currently loaded data range.
  79024. * @returns The 32-bit integer read
  79025. */
  79026. readUint32(): number;
  79027. /**
  79028. * Read a byte array from the currently loaded data range.
  79029. * @param byteLength The byte length to read
  79030. * @returns The byte array read
  79031. */
  79032. readUint8Array(byteLength: number): Uint8Array;
  79033. /**
  79034. * Read a string from the currently loaded data range.
  79035. * @param byteLength The byte length to read
  79036. * @returns The string read
  79037. */
  79038. readString(byteLength: number): string;
  79039. /**
  79040. * Skips the given byte length the currently loaded data range.
  79041. * @param byteLength The byte length to skip
  79042. */
  79043. skipBytes(byteLength: number): void;
  79044. }
  79045. }
  79046. declare module "babylonjs/Misc/dataStorage" {
  79047. /**
  79048. * Class for storing data to local storage if available or in-memory storage otherwise
  79049. */
  79050. export class DataStorage {
  79051. private static _Storage;
  79052. private static _GetStorage;
  79053. /**
  79054. * Reads a string from the data storage
  79055. * @param key The key to read
  79056. * @param defaultValue The value if the key doesn't exist
  79057. * @returns The string value
  79058. */
  79059. static ReadString(key: string, defaultValue: string): string;
  79060. /**
  79061. * Writes a string to the data storage
  79062. * @param key The key to write
  79063. * @param value The value to write
  79064. */
  79065. static WriteString(key: string, value: string): void;
  79066. /**
  79067. * Reads a boolean from the data storage
  79068. * @param key The key to read
  79069. * @param defaultValue The value if the key doesn't exist
  79070. * @returns The boolean value
  79071. */
  79072. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79073. /**
  79074. * Writes a boolean to the data storage
  79075. * @param key The key to write
  79076. * @param value The value to write
  79077. */
  79078. static WriteBoolean(key: string, value: boolean): void;
  79079. /**
  79080. * Reads a number from the data storage
  79081. * @param key The key to read
  79082. * @param defaultValue The value if the key doesn't exist
  79083. * @returns The number value
  79084. */
  79085. static ReadNumber(key: string, defaultValue: number): number;
  79086. /**
  79087. * Writes a number to the data storage
  79088. * @param key The key to write
  79089. * @param value The value to write
  79090. */
  79091. static WriteNumber(key: string, value: number): void;
  79092. }
  79093. }
  79094. declare module "babylonjs/Misc/sceneRecorder" {
  79095. import { Scene } from "babylonjs/scene";
  79096. /**
  79097. * Class used to record delta files between 2 scene states
  79098. */
  79099. export class SceneRecorder {
  79100. private _trackedScene;
  79101. private _savedJSON;
  79102. /**
  79103. * Track a given scene. This means the current scene state will be considered the original state
  79104. * @param scene defines the scene to track
  79105. */
  79106. track(scene: Scene): void;
  79107. /**
  79108. * Get the delta between current state and original state
  79109. * @returns a string containing the delta
  79110. */
  79111. getDelta(): any;
  79112. private _compareArray;
  79113. private _compareObjects;
  79114. private _compareCollections;
  79115. private static GetShadowGeneratorById;
  79116. /**
  79117. * Apply a given delta to a given scene
  79118. * @param deltaJSON defines the JSON containing the delta
  79119. * @param scene defines the scene to apply the delta to
  79120. */
  79121. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79122. private static _ApplyPropertiesToEntity;
  79123. private static _ApplyDeltaForEntity;
  79124. }
  79125. }
  79126. declare module "babylonjs/Misc/trajectoryClassifier" {
  79127. import { DeepImmutable, Nullable } from "babylonjs/types";
  79128. import { Vector3 } from "babylonjs/Maths/math.vector";
  79129. /**
  79130. * A 3D trajectory consisting of an order list of vectors describing a
  79131. * path of motion through 3D space.
  79132. */
  79133. export class Trajectory {
  79134. private _points;
  79135. private readonly _segmentLength;
  79136. /**
  79137. * Serialize to JSON.
  79138. * @returns serialized JSON string
  79139. */
  79140. serialize(): string;
  79141. /**
  79142. * Deserialize from JSON.
  79143. * @param json serialized JSON string
  79144. * @returns deserialized Trajectory
  79145. */
  79146. static Deserialize(json: string): Trajectory;
  79147. /**
  79148. * Create a new empty Trajectory.
  79149. * @param segmentLength radius of discretization for Trajectory points
  79150. */
  79151. constructor(segmentLength?: number);
  79152. /**
  79153. * Get the length of the Trajectory.
  79154. * @returns length of the Trajectory
  79155. */
  79156. getLength(): number;
  79157. /**
  79158. * Append a new point to the Trajectory.
  79159. * NOTE: This implementation has many allocations.
  79160. * @param point point to append to the Trajectory
  79161. */
  79162. add(point: DeepImmutable<Vector3>): void;
  79163. /**
  79164. * Create a new Trajectory with a segment length chosen to make it
  79165. * probable that the new Trajectory will have a specified number of
  79166. * segments. This operation is imprecise.
  79167. * @param targetResolution number of segments desired
  79168. * @returns new Trajectory with approximately the requested number of segments
  79169. */
  79170. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79171. /**
  79172. * Convert Trajectory segments into tokenized representation. This
  79173. * representation is an array of numbers where each nth number is the
  79174. * index of the token which is most similar to the nth segment of the
  79175. * Trajectory.
  79176. * @param tokens list of vectors which serve as discrete tokens
  79177. * @returns list of indices of most similar token per segment
  79178. */
  79179. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79180. private static _forwardDir;
  79181. private static _inverseFromVec;
  79182. private static _upDir;
  79183. private static _fromToVec;
  79184. private static _lookMatrix;
  79185. /**
  79186. * Transform the rotation (i.e., direction) of a segment to isolate
  79187. * the relative transformation represented by the segment. This operation
  79188. * may or may not succeed due to singularities in the equations that define
  79189. * motion relativity in this context.
  79190. * @param priorVec the origin of the prior segment
  79191. * @param fromVec the origin of the current segment
  79192. * @param toVec the destination of the current segment
  79193. * @param result reference to output variable
  79194. * @returns whether or not transformation was successful
  79195. */
  79196. private static _transformSegmentDirToRef;
  79197. private static _bestMatch;
  79198. private static _score;
  79199. private static _bestScore;
  79200. /**
  79201. * Determine which token vector is most similar to the
  79202. * segment vector.
  79203. * @param segment segment vector
  79204. * @param tokens token vector list
  79205. * @returns index of the most similar token to the segment
  79206. */
  79207. private static _tokenizeSegment;
  79208. }
  79209. /**
  79210. * Class representing a set of known, named trajectories to which Trajectories can be
  79211. * added and using which Trajectories can be recognized.
  79212. */
  79213. export class TrajectoryClassifier {
  79214. private _maximumAllowableMatchCost;
  79215. private _vector3Alphabet;
  79216. private _levenshteinAlphabet;
  79217. private _nameToDescribedTrajectory;
  79218. /**
  79219. * Serialize to JSON.
  79220. * @returns JSON serialization
  79221. */
  79222. serialize(): string;
  79223. /**
  79224. * Deserialize from JSON.
  79225. * @param json JSON serialization
  79226. * @returns deserialized TrajectorySet
  79227. */
  79228. static Deserialize(json: string): TrajectoryClassifier;
  79229. /**
  79230. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79231. * VERY naive, need to be generating these things from known
  79232. * sets. Better version later, probably eliminating this one.
  79233. * @returns auto-generated TrajectorySet
  79234. */
  79235. static Generate(): TrajectoryClassifier;
  79236. private constructor();
  79237. /**
  79238. * Add a new Trajectory to the set with a given name.
  79239. * @param trajectory new Trajectory to be added
  79240. * @param classification name to which to add the Trajectory
  79241. */
  79242. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79243. /**
  79244. * Remove a known named trajectory and all Trajectories associated with it.
  79245. * @param classification name to remove
  79246. * @returns whether anything was removed
  79247. */
  79248. deleteClassification(classification: string): boolean;
  79249. /**
  79250. * Attempt to recognize a Trajectory from among all the classifications
  79251. * already known to the classifier.
  79252. * @param trajectory Trajectory to be recognized
  79253. * @returns classification of Trajectory if recognized, null otherwise
  79254. */
  79255. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79256. }
  79257. }
  79258. declare module "babylonjs/Misc/index" {
  79259. export * from "babylonjs/Misc/andOrNotEvaluator";
  79260. export * from "babylonjs/Misc/assetsManager";
  79261. export * from "babylonjs/Misc/basis";
  79262. export * from "babylonjs/Misc/dds";
  79263. export * from "babylonjs/Misc/decorators";
  79264. export * from "babylonjs/Misc/deferred";
  79265. export * from "babylonjs/Misc/environmentTextureTools";
  79266. export * from "babylonjs/Misc/meshExploder";
  79267. export * from "babylonjs/Misc/filesInput";
  79268. export * from "babylonjs/Misc/HighDynamicRange/index";
  79269. export * from "babylonjs/Misc/khronosTextureContainer";
  79270. export * from "babylonjs/Misc/observable";
  79271. export * from "babylonjs/Misc/performanceMonitor";
  79272. export * from "babylonjs/Misc/promise";
  79273. export * from "babylonjs/Misc/sceneOptimizer";
  79274. export * from "babylonjs/Misc/sceneSerializer";
  79275. export * from "babylonjs/Misc/smartArray";
  79276. export * from "babylonjs/Misc/stringDictionary";
  79277. export * from "babylonjs/Misc/tags";
  79278. export * from "babylonjs/Misc/textureTools";
  79279. export * from "babylonjs/Misc/tga";
  79280. export * from "babylonjs/Misc/tools";
  79281. export * from "babylonjs/Misc/videoRecorder";
  79282. export * from "babylonjs/Misc/virtualJoystick";
  79283. export * from "babylonjs/Misc/workerPool";
  79284. export * from "babylonjs/Misc/logger";
  79285. export * from "babylonjs/Misc/typeStore";
  79286. export * from "babylonjs/Misc/filesInputStore";
  79287. export * from "babylonjs/Misc/deepCopier";
  79288. export * from "babylonjs/Misc/pivotTools";
  79289. export * from "babylonjs/Misc/precisionDate";
  79290. export * from "babylonjs/Misc/screenshotTools";
  79291. export * from "babylonjs/Misc/typeStore";
  79292. export * from "babylonjs/Misc/webRequest";
  79293. export * from "babylonjs/Misc/iInspectable";
  79294. export * from "babylonjs/Misc/brdfTextureTools";
  79295. export * from "babylonjs/Misc/rgbdTextureTools";
  79296. export * from "babylonjs/Misc/gradients";
  79297. export * from "babylonjs/Misc/perfCounter";
  79298. export * from "babylonjs/Misc/fileRequest";
  79299. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79300. export * from "babylonjs/Misc/retryStrategy";
  79301. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79302. export * from "babylonjs/Misc/canvasGenerator";
  79303. export * from "babylonjs/Misc/fileTools";
  79304. export * from "babylonjs/Misc/stringTools";
  79305. export * from "babylonjs/Misc/dataReader";
  79306. export * from "babylonjs/Misc/minMaxReducer";
  79307. export * from "babylonjs/Misc/depthReducer";
  79308. export * from "babylonjs/Misc/dataStorage";
  79309. export * from "babylonjs/Misc/sceneRecorder";
  79310. export * from "babylonjs/Misc/khronosTextureContainer2";
  79311. export * from "babylonjs/Misc/trajectoryClassifier";
  79312. export * from "babylonjs/Misc/timer";
  79313. }
  79314. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79315. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79316. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79317. import { Observable } from "babylonjs/Misc/observable";
  79318. import { Matrix } from "babylonjs/Maths/math.vector";
  79319. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79320. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79321. /**
  79322. * An interface for all Hit test features
  79323. */
  79324. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79325. /**
  79326. * Triggered when new babylon (transformed) hit test results are available
  79327. */
  79328. onHitTestResultObservable: Observable<T[]>;
  79329. }
  79330. /**
  79331. * Options used for hit testing
  79332. */
  79333. export interface IWebXRLegacyHitTestOptions {
  79334. /**
  79335. * Only test when user interacted with the scene. Default - hit test every frame
  79336. */
  79337. testOnPointerDownOnly?: boolean;
  79338. /**
  79339. * The node to use to transform the local results to world coordinates
  79340. */
  79341. worldParentNode?: TransformNode;
  79342. }
  79343. /**
  79344. * Interface defining the babylon result of raycasting/hit-test
  79345. */
  79346. export interface IWebXRLegacyHitResult {
  79347. /**
  79348. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79349. */
  79350. transformationMatrix: Matrix;
  79351. /**
  79352. * The native hit test result
  79353. */
  79354. xrHitResult: XRHitResult | XRHitTestResult;
  79355. }
  79356. /**
  79357. * The currently-working hit-test module.
  79358. * Hit test (or Ray-casting) is used to interact with the real world.
  79359. * For further information read here - https://github.com/immersive-web/hit-test
  79360. */
  79361. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79362. /**
  79363. * options to use when constructing this feature
  79364. */
  79365. readonly options: IWebXRLegacyHitTestOptions;
  79366. private _direction;
  79367. private _mat;
  79368. private _onSelectEnabled;
  79369. private _origin;
  79370. /**
  79371. * The module's name
  79372. */
  79373. static readonly Name: string;
  79374. /**
  79375. * The (Babylon) version of this module.
  79376. * This is an integer representing the implementation version.
  79377. * This number does not correspond to the WebXR specs version
  79378. */
  79379. static readonly Version: number;
  79380. /**
  79381. * Populated with the last native XR Hit Results
  79382. */
  79383. lastNativeXRHitResults: XRHitResult[];
  79384. /**
  79385. * Triggered when new babylon (transformed) hit test results are available
  79386. */
  79387. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79388. /**
  79389. * Creates a new instance of the (legacy version) hit test feature
  79390. * @param _xrSessionManager an instance of WebXRSessionManager
  79391. * @param options options to use when constructing this feature
  79392. */
  79393. constructor(_xrSessionManager: WebXRSessionManager,
  79394. /**
  79395. * options to use when constructing this feature
  79396. */
  79397. options?: IWebXRLegacyHitTestOptions);
  79398. /**
  79399. * execute a hit test with an XR Ray
  79400. *
  79401. * @param xrSession a native xrSession that will execute this hit test
  79402. * @param xrRay the ray (position and direction) to use for ray-casting
  79403. * @param referenceSpace native XR reference space to use for the hit-test
  79404. * @param filter filter function that will filter the results
  79405. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79406. */
  79407. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79408. /**
  79409. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79410. * @param event the (select) event to use to select with
  79411. * @param referenceSpace the reference space to use for this hit test
  79412. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79413. */
  79414. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79415. /**
  79416. * attach this feature
  79417. * Will usually be called by the features manager
  79418. *
  79419. * @returns true if successful.
  79420. */
  79421. attach(): boolean;
  79422. /**
  79423. * detach this feature.
  79424. * Will usually be called by the features manager
  79425. *
  79426. * @returns true if successful.
  79427. */
  79428. detach(): boolean;
  79429. /**
  79430. * Dispose this feature and all of the resources attached
  79431. */
  79432. dispose(): void;
  79433. protected _onXRFrame(frame: XRFrame): void;
  79434. private _onHitTestResults;
  79435. private _onSelect;
  79436. }
  79437. }
  79438. declare module "babylonjs/XR/features/WebXRHitTest" {
  79439. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79440. import { Observable } from "babylonjs/Misc/observable";
  79441. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79442. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79443. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79444. /**
  79445. * Options used for hit testing (version 2)
  79446. */
  79447. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79448. /**
  79449. * Do not create a permanent hit test. Will usually be used when only
  79450. * transient inputs are needed.
  79451. */
  79452. disablePermanentHitTest?: boolean;
  79453. /**
  79454. * Enable transient (for example touch-based) hit test inspections
  79455. */
  79456. enableTransientHitTest?: boolean;
  79457. /**
  79458. * Offset ray for the permanent hit test
  79459. */
  79460. offsetRay?: Vector3;
  79461. /**
  79462. * Offset ray for the transient hit test
  79463. */
  79464. transientOffsetRay?: Vector3;
  79465. /**
  79466. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79467. */
  79468. useReferenceSpace?: boolean;
  79469. /**
  79470. * Override the default entity type(s) of the hit-test result
  79471. */
  79472. entityTypes?: XRHitTestTrackableType[];
  79473. }
  79474. /**
  79475. * Interface defining the babylon result of hit-test
  79476. */
  79477. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79478. /**
  79479. * The input source that generated this hit test (if transient)
  79480. */
  79481. inputSource?: XRInputSource;
  79482. /**
  79483. * Is this a transient hit test
  79484. */
  79485. isTransient?: boolean;
  79486. /**
  79487. * Position of the hit test result
  79488. */
  79489. position: Vector3;
  79490. /**
  79491. * Rotation of the hit test result
  79492. */
  79493. rotationQuaternion: Quaternion;
  79494. /**
  79495. * The native hit test result
  79496. */
  79497. xrHitResult: XRHitTestResult;
  79498. }
  79499. /**
  79500. * The currently-working hit-test module.
  79501. * Hit test (or Ray-casting) is used to interact with the real world.
  79502. * For further information read here - https://github.com/immersive-web/hit-test
  79503. *
  79504. * Tested on chrome (mobile) 80.
  79505. */
  79506. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79507. /**
  79508. * options to use when constructing this feature
  79509. */
  79510. readonly options: IWebXRHitTestOptions;
  79511. private _tmpMat;
  79512. private _tmpPos;
  79513. private _tmpQuat;
  79514. private _transientXrHitTestSource;
  79515. private _xrHitTestSource;
  79516. private initHitTestSource;
  79517. /**
  79518. * The module's name
  79519. */
  79520. static readonly Name: string;
  79521. /**
  79522. * The (Babylon) version of this module.
  79523. * This is an integer representing the implementation version.
  79524. * This number does not correspond to the WebXR specs version
  79525. */
  79526. static readonly Version: number;
  79527. /**
  79528. * When set to true, each hit test will have its own position/rotation objects
  79529. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79530. * the developers will clone them or copy them as they see fit.
  79531. */
  79532. autoCloneTransformation: boolean;
  79533. /**
  79534. * Triggered when new babylon (transformed) hit test results are available
  79535. * Note - this will be called when results come back from the device. It can be an empty array!!
  79536. */
  79537. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79538. /**
  79539. * Use this to temporarily pause hit test checks.
  79540. */
  79541. paused: boolean;
  79542. /**
  79543. * Creates a new instance of the hit test feature
  79544. * @param _xrSessionManager an instance of WebXRSessionManager
  79545. * @param options options to use when constructing this feature
  79546. */
  79547. constructor(_xrSessionManager: WebXRSessionManager,
  79548. /**
  79549. * options to use when constructing this feature
  79550. */
  79551. options?: IWebXRHitTestOptions);
  79552. /**
  79553. * attach this feature
  79554. * Will usually be called by the features manager
  79555. *
  79556. * @returns true if successful.
  79557. */
  79558. attach(): boolean;
  79559. /**
  79560. * detach this feature.
  79561. * Will usually be called by the features manager
  79562. *
  79563. * @returns true if successful.
  79564. */
  79565. detach(): boolean;
  79566. /**
  79567. * Dispose this feature and all of the resources attached
  79568. */
  79569. dispose(): void;
  79570. protected _onXRFrame(frame: XRFrame): void;
  79571. private _processWebXRHitTestResult;
  79572. }
  79573. }
  79574. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79575. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79576. import { Observable } from "babylonjs/Misc/observable";
  79577. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79578. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79579. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79580. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79581. /**
  79582. * Configuration options of the anchor system
  79583. */
  79584. export interface IWebXRAnchorSystemOptions {
  79585. /**
  79586. * a node that will be used to convert local to world coordinates
  79587. */
  79588. worldParentNode?: TransformNode;
  79589. /**
  79590. * If set to true a reference of the created anchors will be kept until the next session starts
  79591. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79592. */
  79593. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79594. }
  79595. /**
  79596. * A babylon container for an XR Anchor
  79597. */
  79598. export interface IWebXRAnchor {
  79599. /**
  79600. * A babylon-assigned ID for this anchor
  79601. */
  79602. id: number;
  79603. /**
  79604. * Transformation matrix to apply to an object attached to this anchor
  79605. */
  79606. transformationMatrix: Matrix;
  79607. /**
  79608. * The native anchor object
  79609. */
  79610. xrAnchor: XRAnchor;
  79611. /**
  79612. * if defined, this object will be constantly updated by the anchor's position and rotation
  79613. */
  79614. attachedNode?: TransformNode;
  79615. }
  79616. /**
  79617. * An implementation of the anchor system for WebXR.
  79618. * For further information see https://github.com/immersive-web/anchors/
  79619. */
  79620. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79621. private _options;
  79622. private _lastFrameDetected;
  79623. private _trackedAnchors;
  79624. private _referenceSpaceForFrameAnchors;
  79625. private _futureAnchors;
  79626. /**
  79627. * The module's name
  79628. */
  79629. static readonly Name: string;
  79630. /**
  79631. * The (Babylon) version of this module.
  79632. * This is an integer representing the implementation version.
  79633. * This number does not correspond to the WebXR specs version
  79634. */
  79635. static readonly Version: number;
  79636. /**
  79637. * Observers registered here will be executed when a new anchor was added to the session
  79638. */
  79639. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79640. /**
  79641. * Observers registered here will be executed when an anchor was removed from the session
  79642. */
  79643. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79644. /**
  79645. * Observers registered here will be executed when an existing anchor updates
  79646. * This can execute N times every frame
  79647. */
  79648. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79649. /**
  79650. * Set the reference space to use for anchor creation, when not using a hit test.
  79651. * Will default to the session's reference space if not defined
  79652. */
  79653. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79654. /**
  79655. * constructs a new anchor system
  79656. * @param _xrSessionManager an instance of WebXRSessionManager
  79657. * @param _options configuration object for this feature
  79658. */
  79659. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79660. private _tmpVector;
  79661. private _tmpQuaternion;
  79662. private _populateTmpTransformation;
  79663. /**
  79664. * Create a new anchor point using a hit test result at a specific point in the scene
  79665. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79666. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79667. *
  79668. * @param hitTestResult The hit test result to use for this anchor creation
  79669. * @param position an optional position offset for this anchor
  79670. * @param rotationQuaternion an optional rotation offset for this anchor
  79671. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79672. */
  79673. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79674. /**
  79675. * Add a new anchor at a specific position and rotation
  79676. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79677. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79678. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79679. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79680. *
  79681. * @param position the position in which to add an anchor
  79682. * @param rotationQuaternion an optional rotation for the anchor transformation
  79683. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79684. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79685. */
  79686. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79687. /**
  79688. * detach this feature.
  79689. * Will usually be called by the features manager
  79690. *
  79691. * @returns true if successful.
  79692. */
  79693. detach(): boolean;
  79694. /**
  79695. * Dispose this feature and all of the resources attached
  79696. */
  79697. dispose(): void;
  79698. protected _onXRFrame(frame: XRFrame): void;
  79699. /**
  79700. * avoiding using Array.find for global support.
  79701. * @param xrAnchor the plane to find in the array
  79702. */
  79703. private _findIndexInAnchorArray;
  79704. private _updateAnchorWithXRFrame;
  79705. private _createAnchorAtTransformation;
  79706. }
  79707. }
  79708. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79709. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79710. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79711. import { Observable } from "babylonjs/Misc/observable";
  79712. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79713. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79714. /**
  79715. * Options used in the plane detector module
  79716. */
  79717. export interface IWebXRPlaneDetectorOptions {
  79718. /**
  79719. * The node to use to transform the local results to world coordinates
  79720. */
  79721. worldParentNode?: TransformNode;
  79722. /**
  79723. * If set to true a reference of the created planes will be kept until the next session starts
  79724. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79725. */
  79726. doNotRemovePlanesOnSessionEnded?: boolean;
  79727. }
  79728. /**
  79729. * A babylon interface for a WebXR plane.
  79730. * A Plane is actually a polygon, built from N points in space
  79731. *
  79732. * Supported in chrome 79, not supported in canary 81 ATM
  79733. */
  79734. export interface IWebXRPlane {
  79735. /**
  79736. * a babylon-assigned ID for this polygon
  79737. */
  79738. id: number;
  79739. /**
  79740. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79741. */
  79742. polygonDefinition: Array<Vector3>;
  79743. /**
  79744. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79745. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79746. */
  79747. transformationMatrix: Matrix;
  79748. /**
  79749. * the native xr-plane object
  79750. */
  79751. xrPlane: XRPlane;
  79752. }
  79753. /**
  79754. * The plane detector is used to detect planes in the real world when in AR
  79755. * For more information see https://github.com/immersive-web/real-world-geometry/
  79756. */
  79757. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79758. private _options;
  79759. private _detectedPlanes;
  79760. private _enabled;
  79761. private _lastFrameDetected;
  79762. /**
  79763. * The module's name
  79764. */
  79765. static readonly Name: string;
  79766. /**
  79767. * The (Babylon) version of this module.
  79768. * This is an integer representing the implementation version.
  79769. * This number does not correspond to the WebXR specs version
  79770. */
  79771. static readonly Version: number;
  79772. /**
  79773. * Observers registered here will be executed when a new plane was added to the session
  79774. */
  79775. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79776. /**
  79777. * Observers registered here will be executed when a plane is no longer detected in the session
  79778. */
  79779. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79780. /**
  79781. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79782. * This can execute N times every frame
  79783. */
  79784. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79785. /**
  79786. * construct a new Plane Detector
  79787. * @param _xrSessionManager an instance of xr Session manager
  79788. * @param _options configuration to use when constructing this feature
  79789. */
  79790. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79791. /**
  79792. * detach this feature.
  79793. * Will usually be called by the features manager
  79794. *
  79795. * @returns true if successful.
  79796. */
  79797. detach(): boolean;
  79798. /**
  79799. * Dispose this feature and all of the resources attached
  79800. */
  79801. dispose(): void;
  79802. protected _onXRFrame(frame: XRFrame): void;
  79803. private _init;
  79804. private _updatePlaneWithXRPlane;
  79805. /**
  79806. * avoiding using Array.find for global support.
  79807. * @param xrPlane the plane to find in the array
  79808. */
  79809. private findIndexInPlaneArray;
  79810. }
  79811. }
  79812. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79813. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79815. import { Observable } from "babylonjs/Misc/observable";
  79816. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79817. /**
  79818. * Options interface for the background remover plugin
  79819. */
  79820. export interface IWebXRBackgroundRemoverOptions {
  79821. /**
  79822. * Further background meshes to disable when entering AR
  79823. */
  79824. backgroundMeshes?: AbstractMesh[];
  79825. /**
  79826. * flags to configure the removal of the environment helper.
  79827. * If not set, the entire background will be removed. If set, flags should be set as well.
  79828. */
  79829. environmentHelperRemovalFlags?: {
  79830. /**
  79831. * Should the skybox be removed (default false)
  79832. */
  79833. skyBox?: boolean;
  79834. /**
  79835. * Should the ground be removed (default false)
  79836. */
  79837. ground?: boolean;
  79838. };
  79839. /**
  79840. * don't disable the environment helper
  79841. */
  79842. ignoreEnvironmentHelper?: boolean;
  79843. }
  79844. /**
  79845. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79846. */
  79847. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79848. /**
  79849. * read-only options to be used in this module
  79850. */
  79851. readonly options: IWebXRBackgroundRemoverOptions;
  79852. /**
  79853. * The module's name
  79854. */
  79855. static readonly Name: string;
  79856. /**
  79857. * The (Babylon) version of this module.
  79858. * This is an integer representing the implementation version.
  79859. * This number does not correspond to the WebXR specs version
  79860. */
  79861. static readonly Version: number;
  79862. /**
  79863. * registered observers will be triggered when the background state changes
  79864. */
  79865. onBackgroundStateChangedObservable: Observable<boolean>;
  79866. /**
  79867. * constructs a new background remover module
  79868. * @param _xrSessionManager the session manager for this module
  79869. * @param options read-only options to be used in this module
  79870. */
  79871. constructor(_xrSessionManager: WebXRSessionManager,
  79872. /**
  79873. * read-only options to be used in this module
  79874. */
  79875. options?: IWebXRBackgroundRemoverOptions);
  79876. /**
  79877. * attach this feature
  79878. * Will usually be called by the features manager
  79879. *
  79880. * @returns true if successful.
  79881. */
  79882. attach(): boolean;
  79883. /**
  79884. * detach this feature.
  79885. * Will usually be called by the features manager
  79886. *
  79887. * @returns true if successful.
  79888. */
  79889. detach(): boolean;
  79890. /**
  79891. * Dispose this feature and all of the resources attached
  79892. */
  79893. dispose(): void;
  79894. protected _onXRFrame(_xrFrame: XRFrame): void;
  79895. private _setBackgroundState;
  79896. }
  79897. }
  79898. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79899. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79900. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79901. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79902. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79903. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79904. import { Nullable } from "babylonjs/types";
  79905. /**
  79906. * Options for the controller physics feature
  79907. */
  79908. export class IWebXRControllerPhysicsOptions {
  79909. /**
  79910. * Should the headset get its own impostor
  79911. */
  79912. enableHeadsetImpostor?: boolean;
  79913. /**
  79914. * Optional parameters for the headset impostor
  79915. */
  79916. headsetImpostorParams?: {
  79917. /**
  79918. * The type of impostor to create. Default is sphere
  79919. */
  79920. impostorType: number;
  79921. /**
  79922. * the size of the impostor. Defaults to 10cm
  79923. */
  79924. impostorSize?: number | {
  79925. width: number;
  79926. height: number;
  79927. depth: number;
  79928. };
  79929. /**
  79930. * Friction definitions
  79931. */
  79932. friction?: number;
  79933. /**
  79934. * Restitution
  79935. */
  79936. restitution?: number;
  79937. };
  79938. /**
  79939. * The physics properties of the future impostors
  79940. */
  79941. physicsProperties?: {
  79942. /**
  79943. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79944. * Note that this requires a physics engine that supports mesh impostors!
  79945. */
  79946. useControllerMesh?: boolean;
  79947. /**
  79948. * The type of impostor to create. Default is sphere
  79949. */
  79950. impostorType?: number;
  79951. /**
  79952. * the size of the impostor. Defaults to 10cm
  79953. */
  79954. impostorSize?: number | {
  79955. width: number;
  79956. height: number;
  79957. depth: number;
  79958. };
  79959. /**
  79960. * Friction definitions
  79961. */
  79962. friction?: number;
  79963. /**
  79964. * Restitution
  79965. */
  79966. restitution?: number;
  79967. };
  79968. /**
  79969. * the xr input to use with this pointer selection
  79970. */
  79971. xrInput: WebXRInput;
  79972. }
  79973. /**
  79974. * Add physics impostor to your webxr controllers,
  79975. * including naive calculation of their linear and angular velocity
  79976. */
  79977. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79978. private readonly _options;
  79979. private _attachController;
  79980. private _controllers;
  79981. private _debugMode;
  79982. private _delta;
  79983. private _headsetImpostor?;
  79984. private _headsetMesh?;
  79985. private _lastTimestamp;
  79986. private _tmpQuaternion;
  79987. private _tmpVector;
  79988. /**
  79989. * The module's name
  79990. */
  79991. static readonly Name: string;
  79992. /**
  79993. * The (Babylon) version of this module.
  79994. * This is an integer representing the implementation version.
  79995. * This number does not correspond to the webxr specs version
  79996. */
  79997. static readonly Version: number;
  79998. /**
  79999. * Construct a new Controller Physics Feature
  80000. * @param _xrSessionManager the corresponding xr session manager
  80001. * @param _options options to create this feature with
  80002. */
  80003. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80004. /**
  80005. * @hidden
  80006. * enable debugging - will show console outputs and the impostor mesh
  80007. */
  80008. _enablePhysicsDebug(): void;
  80009. /**
  80010. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80011. * @param xrController the controller to add
  80012. */
  80013. addController(xrController: WebXRInputSource): void;
  80014. /**
  80015. * attach this feature
  80016. * Will usually be called by the features manager
  80017. *
  80018. * @returns true if successful.
  80019. */
  80020. attach(): boolean;
  80021. /**
  80022. * detach this feature.
  80023. * Will usually be called by the features manager
  80024. *
  80025. * @returns true if successful.
  80026. */
  80027. detach(): boolean;
  80028. /**
  80029. * Get the headset impostor, if enabled
  80030. * @returns the impostor
  80031. */
  80032. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80033. /**
  80034. * Get the physics impostor of a specific controller.
  80035. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80036. * @param controller the controller or the controller id of which to get the impostor
  80037. * @returns the impostor or null
  80038. */
  80039. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80040. /**
  80041. * Update the physics properties provided in the constructor
  80042. * @param newProperties the new properties object
  80043. */
  80044. setPhysicsProperties(newProperties: {
  80045. impostorType?: number;
  80046. impostorSize?: number | {
  80047. width: number;
  80048. height: number;
  80049. depth: number;
  80050. };
  80051. friction?: number;
  80052. restitution?: number;
  80053. }): void;
  80054. protected _onXRFrame(_xrFrame: any): void;
  80055. private _detachController;
  80056. }
  80057. }
  80058. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80059. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80060. import { Observable } from "babylonjs/Misc/observable";
  80061. import { Vector3 } from "babylonjs/Maths/math.vector";
  80062. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80063. /**
  80064. * A babylon interface for a "WebXR" feature point.
  80065. * Represents the position and confidence value of a given feature point.
  80066. */
  80067. export interface IWebXRFeaturePoint {
  80068. /**
  80069. * Represents the position of the feature point in world space.
  80070. */
  80071. position: Vector3;
  80072. /**
  80073. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80074. */
  80075. confidenceValue: number;
  80076. }
  80077. /**
  80078. * The feature point system is used to detect feature points from real world geometry.
  80079. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80080. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80081. */
  80082. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80083. private _enabled;
  80084. private _featurePointCloud;
  80085. /**
  80086. * The module's name
  80087. */
  80088. static readonly Name: string;
  80089. /**
  80090. * The (Babylon) version of this module.
  80091. * This is an integer representing the implementation version.
  80092. * This number does not correspond to the WebXR specs version
  80093. */
  80094. static readonly Version: number;
  80095. /**
  80096. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80097. * Will notify the observers about which feature points have been added.
  80098. */
  80099. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80100. /**
  80101. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80102. * Will notify the observers about which feature points have been updated.
  80103. */
  80104. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80105. /**
  80106. * The current feature point cloud maintained across frames.
  80107. */
  80108. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80109. /**
  80110. * construct the feature point system
  80111. * @param _xrSessionManager an instance of xr Session manager
  80112. */
  80113. constructor(_xrSessionManager: WebXRSessionManager);
  80114. /**
  80115. * Detach this feature.
  80116. * Will usually be called by the features manager
  80117. *
  80118. * @returns true if successful.
  80119. */
  80120. detach(): boolean;
  80121. /**
  80122. * Dispose this feature and all of the resources attached
  80123. */
  80124. dispose(): void;
  80125. /**
  80126. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80127. */
  80128. protected _onXRFrame(frame: XRFrame): void;
  80129. /**
  80130. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80131. */
  80132. private _init;
  80133. }
  80134. }
  80135. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80136. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80137. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80139. import { Mesh } from "babylonjs/Meshes/mesh";
  80140. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80141. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80142. import { Nullable } from "babylonjs/types";
  80143. import { IDisposable } from "babylonjs/scene";
  80144. import { Observable } from "babylonjs/Misc/observable";
  80145. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80146. /**
  80147. * Configuration interface for the hand tracking feature
  80148. */
  80149. export interface IWebXRHandTrackingOptions {
  80150. /**
  80151. * The xrInput that will be used as source for new hands
  80152. */
  80153. xrInput: WebXRInput;
  80154. /**
  80155. * Configuration object for the joint meshes
  80156. */
  80157. jointMeshes?: {
  80158. /**
  80159. * Should the meshes created be invisible (defaults to false)
  80160. */
  80161. invisible?: boolean;
  80162. /**
  80163. * A source mesh to be used to create instances. Defaults to a sphere.
  80164. * This mesh will be the source for all other (25) meshes.
  80165. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80166. */
  80167. sourceMesh?: Mesh;
  80168. /**
  80169. * This function will be called after a mesh was created for a specific joint.
  80170. * Using this function you can either manipulate the instance or return a new mesh.
  80171. * When returning a new mesh the instance created before will be disposed
  80172. */
  80173. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80174. /**
  80175. * Should the source mesh stay visible. Defaults to false
  80176. */
  80177. keepOriginalVisible?: boolean;
  80178. /**
  80179. * Scale factor for all instances (defaults to 2)
  80180. */
  80181. scaleFactor?: number;
  80182. /**
  80183. * Should each instance have its own physics impostor
  80184. */
  80185. enablePhysics?: boolean;
  80186. /**
  80187. * If enabled, override default physics properties
  80188. */
  80189. physicsProps?: {
  80190. friction?: number;
  80191. restitution?: number;
  80192. impostorType?: number;
  80193. };
  80194. /**
  80195. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80196. */
  80197. handMesh?: AbstractMesh;
  80198. };
  80199. }
  80200. /**
  80201. * Parts of the hands divided to writs and finger names
  80202. */
  80203. export const enum HandPart {
  80204. /**
  80205. * HandPart - Wrist
  80206. */
  80207. WRIST = "wrist",
  80208. /**
  80209. * HandPart - The THumb
  80210. */
  80211. THUMB = "thumb",
  80212. /**
  80213. * HandPart - Index finger
  80214. */
  80215. INDEX = "index",
  80216. /**
  80217. * HandPart - Middle finger
  80218. */
  80219. MIDDLE = "middle",
  80220. /**
  80221. * HandPart - Ring finger
  80222. */
  80223. RING = "ring",
  80224. /**
  80225. * HandPart - Little finger
  80226. */
  80227. LITTLE = "little"
  80228. }
  80229. /**
  80230. * Representing a single hand (with its corresponding native XRHand object)
  80231. */
  80232. export class WebXRHand implements IDisposable {
  80233. /** the controller to which the hand correlates */
  80234. readonly xrController: WebXRInputSource;
  80235. /** the meshes to be used to track the hand joints */
  80236. readonly trackedMeshes: AbstractMesh[];
  80237. /**
  80238. * Hand-parts definition (key is HandPart)
  80239. */
  80240. handPartsDefinition: {
  80241. [key: string]: number[];
  80242. };
  80243. /**
  80244. * Populate the HandPartsDefinition object.
  80245. * This is called as a side effect since certain browsers don't have XRHand defined.
  80246. */
  80247. private generateHandPartsDefinition;
  80248. /**
  80249. * Construct a new hand object
  80250. * @param xrController the controller to which the hand correlates
  80251. * @param trackedMeshes the meshes to be used to track the hand joints
  80252. */
  80253. constructor(
  80254. /** the controller to which the hand correlates */
  80255. xrController: WebXRInputSource,
  80256. /** the meshes to be used to track the hand joints */
  80257. trackedMeshes: AbstractMesh[]);
  80258. /**
  80259. * Update this hand from the latest xr frame
  80260. * @param xrFrame xrFrame to update from
  80261. * @param referenceSpace The current viewer reference space
  80262. * @param scaleFactor optional scale factor for the meshes
  80263. */
  80264. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80265. /**
  80266. * Get meshes of part of the hand
  80267. * @param part the part of hand to get
  80268. * @returns An array of meshes that correlate to the hand part requested
  80269. */
  80270. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80271. /**
  80272. * Dispose this Hand object
  80273. */
  80274. dispose(): void;
  80275. }
  80276. /**
  80277. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80278. */
  80279. export class WebXRHandTracking extends WebXRAbstractFeature {
  80280. /**
  80281. * options to use when constructing this feature
  80282. */
  80283. readonly options: IWebXRHandTrackingOptions;
  80284. private static _idCounter;
  80285. /**
  80286. * The module's name
  80287. */
  80288. static readonly Name: string;
  80289. /**
  80290. * The (Babylon) version of this module.
  80291. * This is an integer representing the implementation version.
  80292. * This number does not correspond to the WebXR specs version
  80293. */
  80294. static readonly Version: number;
  80295. /**
  80296. * This observable will notify registered observers when a new hand object was added and initialized
  80297. */
  80298. onHandAddedObservable: Observable<WebXRHand>;
  80299. /**
  80300. * This observable will notify its observers right before the hand object is disposed
  80301. */
  80302. onHandRemovedObservable: Observable<WebXRHand>;
  80303. private _hands;
  80304. /**
  80305. * Creates a new instance of the hit test feature
  80306. * @param _xrSessionManager an instance of WebXRSessionManager
  80307. * @param options options to use when constructing this feature
  80308. */
  80309. constructor(_xrSessionManager: WebXRSessionManager,
  80310. /**
  80311. * options to use when constructing this feature
  80312. */
  80313. options: IWebXRHandTrackingOptions);
  80314. /**
  80315. * Check if the needed objects are defined.
  80316. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80317. */
  80318. isCompatible(): boolean;
  80319. /**
  80320. * attach this feature
  80321. * Will usually be called by the features manager
  80322. *
  80323. * @returns true if successful.
  80324. */
  80325. attach(): boolean;
  80326. /**
  80327. * detach this feature.
  80328. * Will usually be called by the features manager
  80329. *
  80330. * @returns true if successful.
  80331. */
  80332. detach(): boolean;
  80333. /**
  80334. * Dispose this feature and all of the resources attached
  80335. */
  80336. dispose(): void;
  80337. /**
  80338. * Get the hand object according to the controller id
  80339. * @param controllerId the controller id to which we want to get the hand
  80340. * @returns null if not found or the WebXRHand object if found
  80341. */
  80342. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80343. /**
  80344. * Get a hand object according to the requested handedness
  80345. * @param handedness the handedness to request
  80346. * @returns null if not found or the WebXRHand object if found
  80347. */
  80348. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80349. protected _onXRFrame(_xrFrame: XRFrame): void;
  80350. private _attachHand;
  80351. private _detachHand;
  80352. }
  80353. }
  80354. declare module "babylonjs/XR/features/index" {
  80355. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80356. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80357. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80358. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80359. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80360. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80361. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80362. export * from "babylonjs/XR/features/WebXRHitTest";
  80363. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80364. export * from "babylonjs/XR/features/WebXRHandTracking";
  80365. }
  80366. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80367. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80369. import { Scene } from "babylonjs/scene";
  80370. /**
  80371. * The motion controller class for all microsoft mixed reality controllers
  80372. */
  80373. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80374. protected readonly _mapping: {
  80375. defaultButton: {
  80376. valueNodeName: string;
  80377. unpressedNodeName: string;
  80378. pressedNodeName: string;
  80379. };
  80380. defaultAxis: {
  80381. valueNodeName: string;
  80382. minNodeName: string;
  80383. maxNodeName: string;
  80384. };
  80385. buttons: {
  80386. "xr-standard-trigger": {
  80387. rootNodeName: string;
  80388. componentProperty: string;
  80389. states: string[];
  80390. };
  80391. "xr-standard-squeeze": {
  80392. rootNodeName: string;
  80393. componentProperty: string;
  80394. states: string[];
  80395. };
  80396. "xr-standard-touchpad": {
  80397. rootNodeName: string;
  80398. labelAnchorNodeName: string;
  80399. touchPointNodeName: string;
  80400. };
  80401. "xr-standard-thumbstick": {
  80402. rootNodeName: string;
  80403. componentProperty: string;
  80404. states: string[];
  80405. };
  80406. };
  80407. axes: {
  80408. "xr-standard-touchpad": {
  80409. "x-axis": {
  80410. rootNodeName: string;
  80411. };
  80412. "y-axis": {
  80413. rootNodeName: string;
  80414. };
  80415. };
  80416. "xr-standard-thumbstick": {
  80417. "x-axis": {
  80418. rootNodeName: string;
  80419. };
  80420. "y-axis": {
  80421. rootNodeName: string;
  80422. };
  80423. };
  80424. };
  80425. };
  80426. /**
  80427. * The base url used to load the left and right controller models
  80428. */
  80429. static MODEL_BASE_URL: string;
  80430. /**
  80431. * The name of the left controller model file
  80432. */
  80433. static MODEL_LEFT_FILENAME: string;
  80434. /**
  80435. * The name of the right controller model file
  80436. */
  80437. static MODEL_RIGHT_FILENAME: string;
  80438. profileId: string;
  80439. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80440. protected _getFilenameAndPath(): {
  80441. filename: string;
  80442. path: string;
  80443. };
  80444. protected _getModelLoadingConstraints(): boolean;
  80445. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80446. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80447. protected _updateModel(): void;
  80448. }
  80449. }
  80450. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80451. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80453. import { Scene } from "babylonjs/scene";
  80454. /**
  80455. * The motion controller class for oculus touch (quest, rift).
  80456. * This class supports legacy mapping as well the standard xr mapping
  80457. */
  80458. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80459. private _forceLegacyControllers;
  80460. private _modelRootNode;
  80461. /**
  80462. * The base url used to load the left and right controller models
  80463. */
  80464. static MODEL_BASE_URL: string;
  80465. /**
  80466. * The name of the left controller model file
  80467. */
  80468. static MODEL_LEFT_FILENAME: string;
  80469. /**
  80470. * The name of the right controller model file
  80471. */
  80472. static MODEL_RIGHT_FILENAME: string;
  80473. /**
  80474. * Base Url for the Quest controller model.
  80475. */
  80476. static QUEST_MODEL_BASE_URL: string;
  80477. profileId: string;
  80478. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80479. protected _getFilenameAndPath(): {
  80480. filename: string;
  80481. path: string;
  80482. };
  80483. protected _getModelLoadingConstraints(): boolean;
  80484. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80485. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80486. protected _updateModel(): void;
  80487. /**
  80488. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80489. * between the touch and touch 2.
  80490. */
  80491. private _isQuest;
  80492. }
  80493. }
  80494. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80495. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80496. import { Scene } from "babylonjs/scene";
  80497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80498. /**
  80499. * The motion controller class for the standard HTC-Vive controllers
  80500. */
  80501. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80502. private _modelRootNode;
  80503. /**
  80504. * The base url used to load the left and right controller models
  80505. */
  80506. static MODEL_BASE_URL: string;
  80507. /**
  80508. * File name for the controller model.
  80509. */
  80510. static MODEL_FILENAME: string;
  80511. profileId: string;
  80512. /**
  80513. * Create a new Vive motion controller object
  80514. * @param scene the scene to use to create this controller
  80515. * @param gamepadObject the corresponding gamepad object
  80516. * @param handedness the handedness of the controller
  80517. */
  80518. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80519. protected _getFilenameAndPath(): {
  80520. filename: string;
  80521. path: string;
  80522. };
  80523. protected _getModelLoadingConstraints(): boolean;
  80524. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80525. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80526. protected _updateModel(): void;
  80527. }
  80528. }
  80529. declare module "babylonjs/XR/motionController/index" {
  80530. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80531. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80532. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80533. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80534. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80535. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80536. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80537. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80538. }
  80539. declare module "babylonjs/XR/index" {
  80540. export * from "babylonjs/XR/webXRCamera";
  80541. export * from "babylonjs/XR/webXREnterExitUI";
  80542. export * from "babylonjs/XR/webXRExperienceHelper";
  80543. export * from "babylonjs/XR/webXRInput";
  80544. export * from "babylonjs/XR/webXRInputSource";
  80545. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80546. export * from "babylonjs/XR/webXRTypes";
  80547. export * from "babylonjs/XR/webXRSessionManager";
  80548. export * from "babylonjs/XR/webXRDefaultExperience";
  80549. export * from "babylonjs/XR/webXRFeaturesManager";
  80550. export * from "babylonjs/XR/features/index";
  80551. export * from "babylonjs/XR/motionController/index";
  80552. }
  80553. declare module "babylonjs/index" {
  80554. export * from "babylonjs/abstractScene";
  80555. export * from "babylonjs/Actions/index";
  80556. export * from "babylonjs/Animations/index";
  80557. export * from "babylonjs/assetContainer";
  80558. export * from "babylonjs/Audio/index";
  80559. export * from "babylonjs/Behaviors/index";
  80560. export * from "babylonjs/Bones/index";
  80561. export * from "babylonjs/Cameras/index";
  80562. export * from "babylonjs/Collisions/index";
  80563. export * from "babylonjs/Culling/index";
  80564. export * from "babylonjs/Debug/index";
  80565. export * from "babylonjs/DeviceInput/index";
  80566. export * from "babylonjs/Engines/index";
  80567. export * from "babylonjs/Events/index";
  80568. export * from "babylonjs/Gamepads/index";
  80569. export * from "babylonjs/Gizmos/index";
  80570. export * from "babylonjs/Helpers/index";
  80571. export * from "babylonjs/Instrumentation/index";
  80572. export * from "babylonjs/Layers/index";
  80573. export * from "babylonjs/LensFlares/index";
  80574. export * from "babylonjs/Lights/index";
  80575. export * from "babylonjs/Loading/index";
  80576. export * from "babylonjs/Materials/index";
  80577. export * from "babylonjs/Maths/index";
  80578. export * from "babylonjs/Meshes/index";
  80579. export * from "babylonjs/Morph/index";
  80580. export * from "babylonjs/Navigation/index";
  80581. export * from "babylonjs/node";
  80582. export * from "babylonjs/Offline/index";
  80583. export * from "babylonjs/Particles/index";
  80584. export * from "babylonjs/Physics/index";
  80585. export * from "babylonjs/PostProcesses/index";
  80586. export * from "babylonjs/Probes/index";
  80587. export * from "babylonjs/Rendering/index";
  80588. export * from "babylonjs/scene";
  80589. export * from "babylonjs/sceneComponent";
  80590. export * from "babylonjs/Sprites/index";
  80591. export * from "babylonjs/States/index";
  80592. export * from "babylonjs/Misc/index";
  80593. export * from "babylonjs/XR/index";
  80594. export * from "babylonjs/types";
  80595. }
  80596. declare module "babylonjs/Animations/pathCursor" {
  80597. import { Vector3 } from "babylonjs/Maths/math.vector";
  80598. import { Path2 } from "babylonjs/Maths/math.path";
  80599. /**
  80600. * A cursor which tracks a point on a path
  80601. */
  80602. export class PathCursor {
  80603. private path;
  80604. /**
  80605. * Stores path cursor callbacks for when an onchange event is triggered
  80606. */
  80607. private _onchange;
  80608. /**
  80609. * The value of the path cursor
  80610. */
  80611. value: number;
  80612. /**
  80613. * The animation array of the path cursor
  80614. */
  80615. animations: Animation[];
  80616. /**
  80617. * Initializes the path cursor
  80618. * @param path The path to track
  80619. */
  80620. constructor(path: Path2);
  80621. /**
  80622. * Gets the cursor point on the path
  80623. * @returns A point on the path cursor at the cursor location
  80624. */
  80625. getPoint(): Vector3;
  80626. /**
  80627. * Moves the cursor ahead by the step amount
  80628. * @param step The amount to move the cursor forward
  80629. * @returns This path cursor
  80630. */
  80631. moveAhead(step?: number): PathCursor;
  80632. /**
  80633. * Moves the cursor behind by the step amount
  80634. * @param step The amount to move the cursor back
  80635. * @returns This path cursor
  80636. */
  80637. moveBack(step?: number): PathCursor;
  80638. /**
  80639. * Moves the cursor by the step amount
  80640. * If the step amount is greater than one, an exception is thrown
  80641. * @param step The amount to move the cursor
  80642. * @returns This path cursor
  80643. */
  80644. move(step: number): PathCursor;
  80645. /**
  80646. * Ensures that the value is limited between zero and one
  80647. * @returns This path cursor
  80648. */
  80649. private ensureLimits;
  80650. /**
  80651. * Runs onchange callbacks on change (used by the animation engine)
  80652. * @returns This path cursor
  80653. */
  80654. private raiseOnChange;
  80655. /**
  80656. * Executes a function on change
  80657. * @param f A path cursor onchange callback
  80658. * @returns This path cursor
  80659. */
  80660. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80661. }
  80662. }
  80663. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80664. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80665. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80666. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80667. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80668. }
  80669. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80670. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80671. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80672. }
  80673. declare module "babylonjs/Engines/Processors/index" {
  80674. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80675. export * from "babylonjs/Engines/Processors/Expressions/index";
  80676. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80677. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80678. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80679. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80680. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80681. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80682. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80683. }
  80684. declare module "babylonjs/Legacy/legacy" {
  80685. import * as Babylon from "babylonjs/index";
  80686. export * from "babylonjs/index";
  80687. }
  80688. declare module "babylonjs/Shaders/blur.fragment" {
  80689. /** @hidden */
  80690. export var blurPixelShader: {
  80691. name: string;
  80692. shader: string;
  80693. };
  80694. }
  80695. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80696. /** @hidden */
  80697. export var pointCloudVertexDeclaration: {
  80698. name: string;
  80699. shader: string;
  80700. };
  80701. }
  80702. declare module "babylonjs" {
  80703. export * from "babylonjs/Legacy/legacy";
  80704. }
  80705. declare module BABYLON {
  80706. /** Alias type for value that can be null */
  80707. export type Nullable<T> = T | null;
  80708. /**
  80709. * Alias type for number that are floats
  80710. * @ignorenaming
  80711. */
  80712. export type float = number;
  80713. /**
  80714. * Alias type for number that are doubles.
  80715. * @ignorenaming
  80716. */
  80717. export type double = number;
  80718. /**
  80719. * Alias type for number that are integer
  80720. * @ignorenaming
  80721. */
  80722. export type int = number;
  80723. /** Alias type for number array or Float32Array */
  80724. export type FloatArray = number[] | Float32Array;
  80725. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80726. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80727. /**
  80728. * Alias for types that can be used by a Buffer or VertexBuffer.
  80729. */
  80730. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80731. /**
  80732. * Alias type for primitive types
  80733. * @ignorenaming
  80734. */
  80735. type Primitive = undefined | null | boolean | string | number | Function;
  80736. /**
  80737. * Type modifier to make all the properties of an object Readonly
  80738. */
  80739. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80740. /**
  80741. * Type modifier to make all the properties of an object Readonly recursively
  80742. */
  80743. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80744. /**
  80745. * Type modifier to make object properties readonly.
  80746. */
  80747. export type DeepImmutableObject<T> = {
  80748. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80749. };
  80750. /** @hidden */
  80751. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80752. }
  80753. }
  80754. declare module BABYLON {
  80755. /**
  80756. * A class serves as a medium between the observable and its observers
  80757. */
  80758. export class EventState {
  80759. /**
  80760. * Create a new EventState
  80761. * @param mask defines the mask associated with this state
  80762. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80763. * @param target defines the original target of the state
  80764. * @param currentTarget defines the current target of the state
  80765. */
  80766. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80767. /**
  80768. * Initialize the current event state
  80769. * @param mask defines the mask associated with this state
  80770. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80771. * @param target defines the original target of the state
  80772. * @param currentTarget defines the current target of the state
  80773. * @returns the current event state
  80774. */
  80775. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80776. /**
  80777. * An Observer can set this property to true to prevent subsequent observers of being notified
  80778. */
  80779. skipNextObservers: boolean;
  80780. /**
  80781. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80782. */
  80783. mask: number;
  80784. /**
  80785. * The object that originally notified the event
  80786. */
  80787. target?: any;
  80788. /**
  80789. * The current object in the bubbling phase
  80790. */
  80791. currentTarget?: any;
  80792. /**
  80793. * This will be populated with the return value of the last function that was executed.
  80794. * If it is the first function in the callback chain it will be the event data.
  80795. */
  80796. lastReturnValue?: any;
  80797. /**
  80798. * User defined information that will be sent to observers
  80799. */
  80800. userInfo?: any;
  80801. }
  80802. /**
  80803. * Represent an Observer registered to a given Observable object.
  80804. */
  80805. export class Observer<T> {
  80806. /**
  80807. * Defines the callback to call when the observer is notified
  80808. */
  80809. callback: (eventData: T, eventState: EventState) => void;
  80810. /**
  80811. * Defines the mask of the observer (used to filter notifications)
  80812. */
  80813. mask: number;
  80814. /**
  80815. * Defines the current scope used to restore the JS context
  80816. */
  80817. scope: any;
  80818. /** @hidden */
  80819. _willBeUnregistered: boolean;
  80820. /**
  80821. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80822. */
  80823. unregisterOnNextCall: boolean;
  80824. /**
  80825. * Creates a new observer
  80826. * @param callback defines the callback to call when the observer is notified
  80827. * @param mask defines the mask of the observer (used to filter notifications)
  80828. * @param scope defines the current scope used to restore the JS context
  80829. */
  80830. constructor(
  80831. /**
  80832. * Defines the callback to call when the observer is notified
  80833. */
  80834. callback: (eventData: T, eventState: EventState) => void,
  80835. /**
  80836. * Defines the mask of the observer (used to filter notifications)
  80837. */
  80838. mask: number,
  80839. /**
  80840. * Defines the current scope used to restore the JS context
  80841. */
  80842. scope?: any);
  80843. }
  80844. /**
  80845. * Represent a list of observers registered to multiple Observables object.
  80846. */
  80847. export class MultiObserver<T> {
  80848. private _observers;
  80849. private _observables;
  80850. /**
  80851. * Release associated resources
  80852. */
  80853. dispose(): void;
  80854. /**
  80855. * Raise a callback when one of the observable will notify
  80856. * @param observables defines a list of observables to watch
  80857. * @param callback defines the callback to call on notification
  80858. * @param mask defines the mask used to filter notifications
  80859. * @param scope defines the current scope used to restore the JS context
  80860. * @returns the new MultiObserver
  80861. */
  80862. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80863. }
  80864. /**
  80865. * The Observable class is a simple implementation of the Observable pattern.
  80866. *
  80867. * 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.
  80868. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80869. * 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).
  80870. * 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.
  80871. */
  80872. export class Observable<T> {
  80873. private _observers;
  80874. private _eventState;
  80875. private _onObserverAdded;
  80876. /**
  80877. * Gets the list of observers
  80878. */
  80879. get observers(): Array<Observer<T>>;
  80880. /**
  80881. * Creates a new observable
  80882. * @param onObserverAdded defines a callback to call when a new observer is added
  80883. */
  80884. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80885. /**
  80886. * Create a new Observer with the specified callback
  80887. * @param callback the callback that will be executed for that Observer
  80888. * @param mask the mask used to filter observers
  80889. * @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.
  80890. * @param scope optional scope for the callback to be called from
  80891. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80892. * @returns the new observer created for the callback
  80893. */
  80894. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80895. /**
  80896. * Create a new Observer with the specified callback and unregisters after the next notification
  80897. * @param callback the callback that will be executed for that Observer
  80898. * @returns the new observer created for the callback
  80899. */
  80900. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80901. /**
  80902. * Remove an Observer from the Observable object
  80903. * @param observer the instance of the Observer to remove
  80904. * @returns false if it doesn't belong to this Observable
  80905. */
  80906. remove(observer: Nullable<Observer<T>>): boolean;
  80907. /**
  80908. * Remove a callback from the Observable object
  80909. * @param callback the callback to remove
  80910. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80911. * @returns false if it doesn't belong to this Observable
  80912. */
  80913. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80914. private _deferUnregister;
  80915. private _remove;
  80916. /**
  80917. * Moves the observable to the top of the observer list making it get called first when notified
  80918. * @param observer the observer to move
  80919. */
  80920. makeObserverTopPriority(observer: Observer<T>): void;
  80921. /**
  80922. * Moves the observable to the bottom of the observer list making it get called last when notified
  80923. * @param observer the observer to move
  80924. */
  80925. makeObserverBottomPriority(observer: Observer<T>): void;
  80926. /**
  80927. * Notify all Observers by calling their respective callback with the given data
  80928. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80929. * @param eventData defines the data to send to all observers
  80930. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80931. * @param target defines the original target of the state
  80932. * @param currentTarget defines the current target of the state
  80933. * @param userInfo defines any user info to send to observers
  80934. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80935. */
  80936. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  80937. /**
  80938. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80939. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80940. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80941. * and it is crucial that all callbacks will be executed.
  80942. * The order of the callbacks is kept, callbacks are not executed parallel.
  80943. *
  80944. * @param eventData The data to be sent to each callback
  80945. * @param mask is used to filter observers defaults to -1
  80946. * @param target defines the callback target (see EventState)
  80947. * @param currentTarget defines he current object in the bubbling phase
  80948. * @param userInfo defines any user info to send to observers
  80949. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80950. */
  80951. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  80952. /**
  80953. * Notify a specific observer
  80954. * @param observer defines the observer to notify
  80955. * @param eventData defines the data to be sent to each callback
  80956. * @param mask is used to filter observers defaults to -1
  80957. */
  80958. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80959. /**
  80960. * Gets a boolean indicating if the observable has at least one observer
  80961. * @returns true is the Observable has at least one Observer registered
  80962. */
  80963. hasObservers(): boolean;
  80964. /**
  80965. * Clear the list of observers
  80966. */
  80967. clear(): void;
  80968. /**
  80969. * Clone the current observable
  80970. * @returns a new observable
  80971. */
  80972. clone(): Observable<T>;
  80973. /**
  80974. * Does this observable handles observer registered with a given mask
  80975. * @param mask defines the mask to be tested
  80976. * @return whether or not one observer registered with the given mask is handeled
  80977. **/
  80978. hasSpecificMask(mask?: number): boolean;
  80979. }
  80980. }
  80981. declare module BABYLON {
  80982. /**
  80983. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80984. * Babylon.js
  80985. */
  80986. export class DomManagement {
  80987. /**
  80988. * Checks if the window object exists
  80989. * @returns true if the window object exists
  80990. */
  80991. static IsWindowObjectExist(): boolean;
  80992. /**
  80993. * Checks if the navigator object exists
  80994. * @returns true if the navigator object exists
  80995. */
  80996. static IsNavigatorAvailable(): boolean;
  80997. /**
  80998. * Check if the document object exists
  80999. * @returns true if the document object exists
  81000. */
  81001. static IsDocumentAvailable(): boolean;
  81002. /**
  81003. * Extracts text content from a DOM element hierarchy
  81004. * @param element defines the root element
  81005. * @returns a string
  81006. */
  81007. static GetDOMTextContent(element: HTMLElement): string;
  81008. }
  81009. }
  81010. declare module BABYLON {
  81011. /**
  81012. * Logger used througouht the application to allow configuration of
  81013. * the log level required for the messages.
  81014. */
  81015. export class Logger {
  81016. /**
  81017. * No log
  81018. */
  81019. static readonly NoneLogLevel: number;
  81020. /**
  81021. * Only message logs
  81022. */
  81023. static readonly MessageLogLevel: number;
  81024. /**
  81025. * Only warning logs
  81026. */
  81027. static readonly WarningLogLevel: number;
  81028. /**
  81029. * Only error logs
  81030. */
  81031. static readonly ErrorLogLevel: number;
  81032. /**
  81033. * All logs
  81034. */
  81035. static readonly AllLogLevel: number;
  81036. private static _LogCache;
  81037. /**
  81038. * Gets a value indicating the number of loading errors
  81039. * @ignorenaming
  81040. */
  81041. static errorsCount: number;
  81042. /**
  81043. * Callback called when a new log is added
  81044. */
  81045. static OnNewCacheEntry: (entry: string) => void;
  81046. private static _AddLogEntry;
  81047. private static _FormatMessage;
  81048. private static _LogDisabled;
  81049. private static _LogEnabled;
  81050. private static _WarnDisabled;
  81051. private static _WarnEnabled;
  81052. private static _ErrorDisabled;
  81053. private static _ErrorEnabled;
  81054. /**
  81055. * Log a message to the console
  81056. */
  81057. static Log: (message: string) => void;
  81058. /**
  81059. * Write a warning message to the console
  81060. */
  81061. static Warn: (message: string) => void;
  81062. /**
  81063. * Write an error message to the console
  81064. */
  81065. static Error: (message: string) => void;
  81066. /**
  81067. * Gets current log cache (list of logs)
  81068. */
  81069. static get LogCache(): string;
  81070. /**
  81071. * Clears the log cache
  81072. */
  81073. static ClearLogCache(): void;
  81074. /**
  81075. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81076. */
  81077. static set LogLevels(level: number);
  81078. }
  81079. }
  81080. declare module BABYLON {
  81081. /** @hidden */
  81082. export class _TypeStore {
  81083. /** @hidden */
  81084. static RegisteredTypes: {
  81085. [key: string]: Object;
  81086. };
  81087. /** @hidden */
  81088. static GetClass(fqdn: string): any;
  81089. }
  81090. }
  81091. declare module BABYLON {
  81092. /**
  81093. * Helper to manipulate strings
  81094. */
  81095. export class StringTools {
  81096. /**
  81097. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81098. * @param str Source string
  81099. * @param suffix Suffix to search for in the source string
  81100. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81101. */
  81102. static EndsWith(str: string, suffix: string): boolean;
  81103. /**
  81104. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81105. * @param str Source string
  81106. * @param suffix Suffix to search for in the source string
  81107. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81108. */
  81109. static StartsWith(str: string, suffix: string): boolean;
  81110. /**
  81111. * Decodes a buffer into a string
  81112. * @param buffer The buffer to decode
  81113. * @returns The decoded string
  81114. */
  81115. static Decode(buffer: Uint8Array | Uint16Array): string;
  81116. /**
  81117. * Encode a buffer to a base64 string
  81118. * @param buffer defines the buffer to encode
  81119. * @returns the encoded string
  81120. */
  81121. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81122. /**
  81123. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81124. * @param num the number to convert and pad
  81125. * @param length the expected length of the string
  81126. * @returns the padded string
  81127. */
  81128. static PadNumber(num: number, length: number): string;
  81129. }
  81130. }
  81131. declare module BABYLON {
  81132. /**
  81133. * Class containing a set of static utilities functions for deep copy.
  81134. */
  81135. export class DeepCopier {
  81136. /**
  81137. * Tries to copy an object by duplicating every property
  81138. * @param source defines the source object
  81139. * @param destination defines the target object
  81140. * @param doNotCopyList defines a list of properties to avoid
  81141. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81142. */
  81143. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81144. }
  81145. }
  81146. declare module BABYLON {
  81147. /**
  81148. * Class containing a set of static utilities functions for precision date
  81149. */
  81150. export class PrecisionDate {
  81151. /**
  81152. * Gets either window.performance.now() if supported or Date.now() else
  81153. */
  81154. static get Now(): number;
  81155. }
  81156. }
  81157. declare module BABYLON {
  81158. /** @hidden */
  81159. export class _DevTools {
  81160. static WarnImport(name: string): string;
  81161. }
  81162. }
  81163. declare module BABYLON {
  81164. /**
  81165. * Interface used to define the mechanism to get data from the network
  81166. */
  81167. export interface IWebRequest {
  81168. /**
  81169. * Returns client's response url
  81170. */
  81171. responseURL: string;
  81172. /**
  81173. * Returns client's status
  81174. */
  81175. status: number;
  81176. /**
  81177. * Returns client's status as a text
  81178. */
  81179. statusText: string;
  81180. }
  81181. }
  81182. declare module BABYLON {
  81183. /**
  81184. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81185. */
  81186. export class WebRequest implements IWebRequest {
  81187. private _xhr;
  81188. /**
  81189. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81190. * i.e. when loading files, where the server/service expects an Authorization header
  81191. */
  81192. static CustomRequestHeaders: {
  81193. [key: string]: string;
  81194. };
  81195. /**
  81196. * Add callback functions in this array to update all the requests before they get sent to the network
  81197. */
  81198. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81199. private _injectCustomRequestHeaders;
  81200. /**
  81201. * Gets or sets a function to be called when loading progress changes
  81202. */
  81203. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81204. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81205. /**
  81206. * Returns client's state
  81207. */
  81208. get readyState(): number;
  81209. /**
  81210. * Returns client's status
  81211. */
  81212. get status(): number;
  81213. /**
  81214. * Returns client's status as a text
  81215. */
  81216. get statusText(): string;
  81217. /**
  81218. * Returns client's response
  81219. */
  81220. get response(): any;
  81221. /**
  81222. * Returns client's response url
  81223. */
  81224. get responseURL(): string;
  81225. /**
  81226. * Returns client's response as text
  81227. */
  81228. get responseText(): string;
  81229. /**
  81230. * Gets or sets the expected response type
  81231. */
  81232. get responseType(): XMLHttpRequestResponseType;
  81233. set responseType(value: XMLHttpRequestResponseType);
  81234. /** @hidden */
  81235. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81236. /** @hidden */
  81237. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81238. /**
  81239. * Cancels any network activity
  81240. */
  81241. abort(): void;
  81242. /**
  81243. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81244. * @param body defines an optional request body
  81245. */
  81246. send(body?: Document | BodyInit | null): void;
  81247. /**
  81248. * Sets the request method, request URL
  81249. * @param method defines the method to use (GET, POST, etc..)
  81250. * @param url defines the url to connect with
  81251. */
  81252. open(method: string, url: string): void;
  81253. /**
  81254. * Sets the value of a request header.
  81255. * @param name The name of the header whose value is to be set
  81256. * @param value The value to set as the body of the header
  81257. */
  81258. setRequestHeader(name: string, value: string): void;
  81259. /**
  81260. * Get the string containing the text of a particular header's value.
  81261. * @param name The name of the header
  81262. * @returns The string containing the text of the given header name
  81263. */
  81264. getResponseHeader(name: string): Nullable<string>;
  81265. }
  81266. }
  81267. declare module BABYLON {
  81268. /**
  81269. * File request interface
  81270. */
  81271. export interface IFileRequest {
  81272. /**
  81273. * Raised when the request is complete (success or error).
  81274. */
  81275. onCompleteObservable: Observable<IFileRequest>;
  81276. /**
  81277. * Aborts the request for a file.
  81278. */
  81279. abort: () => void;
  81280. }
  81281. }
  81282. declare module BABYLON {
  81283. /**
  81284. * Define options used to create a render target texture
  81285. */
  81286. export class RenderTargetCreationOptions {
  81287. /**
  81288. * Specifies is mipmaps must be generated
  81289. */
  81290. generateMipMaps?: boolean;
  81291. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81292. generateDepthBuffer?: boolean;
  81293. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81294. generateStencilBuffer?: boolean;
  81295. /** Defines texture type (int by default) */
  81296. type?: number;
  81297. /** Defines sampling mode (trilinear by default) */
  81298. samplingMode?: number;
  81299. /** Defines format (RGBA by default) */
  81300. format?: number;
  81301. }
  81302. }
  81303. declare module BABYLON {
  81304. /** Defines the cross module used constants to avoid circular dependncies */
  81305. export class Constants {
  81306. /** Defines that alpha blending is disabled */
  81307. static readonly ALPHA_DISABLE: number;
  81308. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81309. static readonly ALPHA_ADD: number;
  81310. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81311. static readonly ALPHA_COMBINE: number;
  81312. /** Defines that alpha blending is DEST - SRC * DEST */
  81313. static readonly ALPHA_SUBTRACT: number;
  81314. /** Defines that alpha blending is SRC * DEST */
  81315. static readonly ALPHA_MULTIPLY: number;
  81316. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81317. static readonly ALPHA_MAXIMIZED: number;
  81318. /** Defines that alpha blending is SRC + DEST */
  81319. static readonly ALPHA_ONEONE: number;
  81320. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81321. static readonly ALPHA_PREMULTIPLIED: number;
  81322. /**
  81323. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81324. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81325. */
  81326. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81327. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81328. static readonly ALPHA_INTERPOLATE: number;
  81329. /**
  81330. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81331. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81332. */
  81333. static readonly ALPHA_SCREENMODE: number;
  81334. /**
  81335. * Defines that alpha blending is SRC + DST
  81336. * Alpha will be set to SRC ALPHA + DST ALPHA
  81337. */
  81338. static readonly ALPHA_ONEONE_ONEONE: number;
  81339. /**
  81340. * Defines that alpha blending is SRC * DST ALPHA + DST
  81341. * Alpha will be set to 0
  81342. */
  81343. static readonly ALPHA_ALPHATOCOLOR: number;
  81344. /**
  81345. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81346. */
  81347. static readonly ALPHA_REVERSEONEMINUS: number;
  81348. /**
  81349. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81350. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81351. */
  81352. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81353. /**
  81354. * Defines that alpha blending is SRC + DST
  81355. * Alpha will be set to SRC ALPHA
  81356. */
  81357. static readonly ALPHA_ONEONE_ONEZERO: number;
  81358. /**
  81359. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81360. * Alpha will be set to DST ALPHA
  81361. */
  81362. static readonly ALPHA_EXCLUSION: number;
  81363. /** Defines that alpha blending equation a SUM */
  81364. static readonly ALPHA_EQUATION_ADD: number;
  81365. /** Defines that alpha blending equation a SUBSTRACTION */
  81366. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81367. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81368. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81369. /** Defines that alpha blending equation a MAX operation */
  81370. static readonly ALPHA_EQUATION_MAX: number;
  81371. /** Defines that alpha blending equation a MIN operation */
  81372. static readonly ALPHA_EQUATION_MIN: number;
  81373. /**
  81374. * Defines that alpha blending equation a DARKEN operation:
  81375. * It takes the min of the src and sums the alpha channels.
  81376. */
  81377. static readonly ALPHA_EQUATION_DARKEN: number;
  81378. /** Defines that the ressource is not delayed*/
  81379. static readonly DELAYLOADSTATE_NONE: number;
  81380. /** Defines that the ressource was successfully delay loaded */
  81381. static readonly DELAYLOADSTATE_LOADED: number;
  81382. /** Defines that the ressource is currently delay loading */
  81383. static readonly DELAYLOADSTATE_LOADING: number;
  81384. /** Defines that the ressource is delayed and has not started loading */
  81385. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81386. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81387. static readonly NEVER: number;
  81388. /** 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 */
  81389. static readonly ALWAYS: number;
  81390. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81391. static readonly LESS: number;
  81392. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81393. static readonly EQUAL: number;
  81394. /** 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 */
  81395. static readonly LEQUAL: number;
  81396. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81397. static readonly GREATER: number;
  81398. /** 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 */
  81399. static readonly GEQUAL: number;
  81400. /** 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 */
  81401. static readonly NOTEQUAL: number;
  81402. /** Passed to stencilOperation to specify that stencil value must be kept */
  81403. static readonly KEEP: number;
  81404. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81405. static readonly REPLACE: number;
  81406. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81407. static readonly INCR: number;
  81408. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81409. static readonly DECR: number;
  81410. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81411. static readonly INVERT: number;
  81412. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81413. static readonly INCR_WRAP: number;
  81414. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81415. static readonly DECR_WRAP: number;
  81416. /** Texture is not repeating outside of 0..1 UVs */
  81417. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81418. /** Texture is repeating outside of 0..1 UVs */
  81419. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81420. /** Texture is repeating and mirrored */
  81421. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81422. /** ALPHA */
  81423. static readonly TEXTUREFORMAT_ALPHA: number;
  81424. /** LUMINANCE */
  81425. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81426. /** LUMINANCE_ALPHA */
  81427. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81428. /** RGB */
  81429. static readonly TEXTUREFORMAT_RGB: number;
  81430. /** RGBA */
  81431. static readonly TEXTUREFORMAT_RGBA: number;
  81432. /** RED */
  81433. static readonly TEXTUREFORMAT_RED: number;
  81434. /** RED (2nd reference) */
  81435. static readonly TEXTUREFORMAT_R: number;
  81436. /** RG */
  81437. static readonly TEXTUREFORMAT_RG: number;
  81438. /** RED_INTEGER */
  81439. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81440. /** RED_INTEGER (2nd reference) */
  81441. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81442. /** RG_INTEGER */
  81443. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81444. /** RGB_INTEGER */
  81445. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81446. /** RGBA_INTEGER */
  81447. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81448. /** UNSIGNED_BYTE */
  81449. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81450. /** UNSIGNED_BYTE (2nd reference) */
  81451. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81452. /** FLOAT */
  81453. static readonly TEXTURETYPE_FLOAT: number;
  81454. /** HALF_FLOAT */
  81455. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81456. /** BYTE */
  81457. static readonly TEXTURETYPE_BYTE: number;
  81458. /** SHORT */
  81459. static readonly TEXTURETYPE_SHORT: number;
  81460. /** UNSIGNED_SHORT */
  81461. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81462. /** INT */
  81463. static readonly TEXTURETYPE_INT: number;
  81464. /** UNSIGNED_INT */
  81465. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81466. /** UNSIGNED_SHORT_4_4_4_4 */
  81467. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81468. /** UNSIGNED_SHORT_5_5_5_1 */
  81469. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81470. /** UNSIGNED_SHORT_5_6_5 */
  81471. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81472. /** UNSIGNED_INT_2_10_10_10_REV */
  81473. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81474. /** UNSIGNED_INT_24_8 */
  81475. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81476. /** UNSIGNED_INT_10F_11F_11F_REV */
  81477. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81478. /** UNSIGNED_INT_5_9_9_9_REV */
  81479. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81480. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81481. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81482. /** nearest is mag = nearest and min = nearest and no mip */
  81483. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81484. /** mag = nearest and min = nearest and mip = none */
  81485. static readonly TEXTURE_NEAREST_NEAREST: number;
  81486. /** Bilinear is mag = linear and min = linear and no mip */
  81487. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81488. /** mag = linear and min = linear and mip = none */
  81489. static readonly TEXTURE_LINEAR_LINEAR: number;
  81490. /** Trilinear is mag = linear and min = linear and mip = linear */
  81491. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81492. /** Trilinear is mag = linear and min = linear and mip = linear */
  81493. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81494. /** mag = nearest and min = nearest and mip = nearest */
  81495. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81496. /** mag = nearest and min = linear and mip = nearest */
  81497. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81498. /** mag = nearest and min = linear and mip = linear */
  81499. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81500. /** mag = nearest and min = linear and mip = none */
  81501. static readonly TEXTURE_NEAREST_LINEAR: number;
  81502. /** nearest is mag = nearest and min = nearest and mip = linear */
  81503. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81504. /** mag = linear and min = nearest and mip = nearest */
  81505. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81506. /** mag = linear and min = nearest and mip = linear */
  81507. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81508. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81509. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81510. /** mag = linear and min = nearest and mip = none */
  81511. static readonly TEXTURE_LINEAR_NEAREST: number;
  81512. /** Explicit coordinates mode */
  81513. static readonly TEXTURE_EXPLICIT_MODE: number;
  81514. /** Spherical coordinates mode */
  81515. static readonly TEXTURE_SPHERICAL_MODE: number;
  81516. /** Planar coordinates mode */
  81517. static readonly TEXTURE_PLANAR_MODE: number;
  81518. /** Cubic coordinates mode */
  81519. static readonly TEXTURE_CUBIC_MODE: number;
  81520. /** Projection coordinates mode */
  81521. static readonly TEXTURE_PROJECTION_MODE: number;
  81522. /** Skybox coordinates mode */
  81523. static readonly TEXTURE_SKYBOX_MODE: number;
  81524. /** Inverse Cubic coordinates mode */
  81525. static readonly TEXTURE_INVCUBIC_MODE: number;
  81526. /** Equirectangular coordinates mode */
  81527. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81528. /** Equirectangular Fixed coordinates mode */
  81529. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81530. /** Equirectangular Fixed Mirrored coordinates mode */
  81531. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81532. /** Offline (baking) quality for texture filtering */
  81533. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81534. /** High quality for texture filtering */
  81535. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81536. /** Medium quality for texture filtering */
  81537. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81538. /** Low quality for texture filtering */
  81539. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81540. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81541. static readonly SCALEMODE_FLOOR: number;
  81542. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81543. static readonly SCALEMODE_NEAREST: number;
  81544. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81545. static readonly SCALEMODE_CEILING: number;
  81546. /**
  81547. * The dirty texture flag value
  81548. */
  81549. static readonly MATERIAL_TextureDirtyFlag: number;
  81550. /**
  81551. * The dirty light flag value
  81552. */
  81553. static readonly MATERIAL_LightDirtyFlag: number;
  81554. /**
  81555. * The dirty fresnel flag value
  81556. */
  81557. static readonly MATERIAL_FresnelDirtyFlag: number;
  81558. /**
  81559. * The dirty attribute flag value
  81560. */
  81561. static readonly MATERIAL_AttributesDirtyFlag: number;
  81562. /**
  81563. * The dirty misc flag value
  81564. */
  81565. static readonly MATERIAL_MiscDirtyFlag: number;
  81566. /**
  81567. * The dirty prepass flag value
  81568. */
  81569. static readonly MATERIAL_PrePassDirtyFlag: number;
  81570. /**
  81571. * The all dirty flag value
  81572. */
  81573. static readonly MATERIAL_AllDirtyFlag: number;
  81574. /**
  81575. * Returns the triangle fill mode
  81576. */
  81577. static readonly MATERIAL_TriangleFillMode: number;
  81578. /**
  81579. * Returns the wireframe mode
  81580. */
  81581. static readonly MATERIAL_WireFrameFillMode: number;
  81582. /**
  81583. * Returns the point fill mode
  81584. */
  81585. static readonly MATERIAL_PointFillMode: number;
  81586. /**
  81587. * Returns the point list draw mode
  81588. */
  81589. static readonly MATERIAL_PointListDrawMode: number;
  81590. /**
  81591. * Returns the line list draw mode
  81592. */
  81593. static readonly MATERIAL_LineListDrawMode: number;
  81594. /**
  81595. * Returns the line loop draw mode
  81596. */
  81597. static readonly MATERIAL_LineLoopDrawMode: number;
  81598. /**
  81599. * Returns the line strip draw mode
  81600. */
  81601. static readonly MATERIAL_LineStripDrawMode: number;
  81602. /**
  81603. * Returns the triangle strip draw mode
  81604. */
  81605. static readonly MATERIAL_TriangleStripDrawMode: number;
  81606. /**
  81607. * Returns the triangle fan draw mode
  81608. */
  81609. static readonly MATERIAL_TriangleFanDrawMode: number;
  81610. /**
  81611. * Stores the clock-wise side orientation
  81612. */
  81613. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81614. /**
  81615. * Stores the counter clock-wise side orientation
  81616. */
  81617. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81618. /**
  81619. * Nothing
  81620. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81621. */
  81622. static readonly ACTION_NothingTrigger: number;
  81623. /**
  81624. * On pick
  81625. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81626. */
  81627. static readonly ACTION_OnPickTrigger: number;
  81628. /**
  81629. * On left pick
  81630. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81631. */
  81632. static readonly ACTION_OnLeftPickTrigger: number;
  81633. /**
  81634. * On right pick
  81635. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81636. */
  81637. static readonly ACTION_OnRightPickTrigger: number;
  81638. /**
  81639. * On center pick
  81640. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81641. */
  81642. static readonly ACTION_OnCenterPickTrigger: number;
  81643. /**
  81644. * On pick down
  81645. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81646. */
  81647. static readonly ACTION_OnPickDownTrigger: number;
  81648. /**
  81649. * On double pick
  81650. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81651. */
  81652. static readonly ACTION_OnDoublePickTrigger: number;
  81653. /**
  81654. * On pick up
  81655. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81656. */
  81657. static readonly ACTION_OnPickUpTrigger: number;
  81658. /**
  81659. * On pick out.
  81660. * This trigger will only be raised if you also declared a OnPickDown
  81661. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81662. */
  81663. static readonly ACTION_OnPickOutTrigger: number;
  81664. /**
  81665. * On long press
  81666. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81667. */
  81668. static readonly ACTION_OnLongPressTrigger: number;
  81669. /**
  81670. * On pointer over
  81671. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81672. */
  81673. static readonly ACTION_OnPointerOverTrigger: number;
  81674. /**
  81675. * On pointer out
  81676. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81677. */
  81678. static readonly ACTION_OnPointerOutTrigger: number;
  81679. /**
  81680. * On every frame
  81681. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81682. */
  81683. static readonly ACTION_OnEveryFrameTrigger: number;
  81684. /**
  81685. * On intersection enter
  81686. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81687. */
  81688. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81689. /**
  81690. * On intersection exit
  81691. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81692. */
  81693. static readonly ACTION_OnIntersectionExitTrigger: number;
  81694. /**
  81695. * On key down
  81696. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81697. */
  81698. static readonly ACTION_OnKeyDownTrigger: number;
  81699. /**
  81700. * On key up
  81701. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81702. */
  81703. static readonly ACTION_OnKeyUpTrigger: number;
  81704. /**
  81705. * Billboard mode will only apply to Y axis
  81706. */
  81707. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81708. /**
  81709. * Billboard mode will apply to all axes
  81710. */
  81711. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81712. /**
  81713. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81714. */
  81715. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81716. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81717. * Test order :
  81718. * Is the bounding sphere outside the frustum ?
  81719. * If not, are the bounding box vertices outside the frustum ?
  81720. * It not, then the cullable object is in the frustum.
  81721. */
  81722. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81723. /** Culling strategy : Bounding Sphere Only.
  81724. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81725. * It's also less accurate than the standard because some not visible objects can still be selected.
  81726. * Test : is the bounding sphere outside the frustum ?
  81727. * If not, then the cullable object is in the frustum.
  81728. */
  81729. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81730. /** Culling strategy : Optimistic Inclusion.
  81731. * This in an inclusion test first, then the standard exclusion test.
  81732. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81733. * 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.
  81734. * Anyway, it's as accurate as the standard strategy.
  81735. * Test :
  81736. * Is the cullable object bounding sphere center in the frustum ?
  81737. * If not, apply the default culling strategy.
  81738. */
  81739. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81740. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81741. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81742. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81743. * 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.
  81744. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81745. * Test :
  81746. * Is the cullable object bounding sphere center in the frustum ?
  81747. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81748. */
  81749. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81750. /**
  81751. * No logging while loading
  81752. */
  81753. static readonly SCENELOADER_NO_LOGGING: number;
  81754. /**
  81755. * Minimal logging while loading
  81756. */
  81757. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81758. /**
  81759. * Summary logging while loading
  81760. */
  81761. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81762. /**
  81763. * Detailled logging while loading
  81764. */
  81765. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81766. /**
  81767. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81768. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81769. */
  81770. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81771. /**
  81772. * Constant used to retrieve the position texture index in the textures array in the prepass
  81773. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81774. */
  81775. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81776. /**
  81777. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81778. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81779. */
  81780. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81781. /**
  81782. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81783. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81784. */
  81785. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81786. /**
  81787. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81788. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81789. */
  81790. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81791. /**
  81792. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81793. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81794. */
  81795. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81796. /**
  81797. * Constant used to retrieve albedo index in the textures array in the prepass
  81798. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81799. */
  81800. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81801. }
  81802. }
  81803. declare module BABYLON {
  81804. /**
  81805. * This represents the required contract to create a new type of texture loader.
  81806. */
  81807. export interface IInternalTextureLoader {
  81808. /**
  81809. * Defines wether the loader supports cascade loading the different faces.
  81810. */
  81811. supportCascades: boolean;
  81812. /**
  81813. * This returns if the loader support the current file information.
  81814. * @param extension defines the file extension of the file being loaded
  81815. * @param mimeType defines the optional mime type of the file being loaded
  81816. * @returns true if the loader can load the specified file
  81817. */
  81818. canLoad(extension: string, mimeType?: string): boolean;
  81819. /**
  81820. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81821. * @param data contains the texture data
  81822. * @param texture defines the BabylonJS internal texture
  81823. * @param createPolynomials will be true if polynomials have been requested
  81824. * @param onLoad defines the callback to trigger once the texture is ready
  81825. * @param onError defines the callback to trigger in case of error
  81826. */
  81827. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81828. /**
  81829. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81830. * @param data contains the texture data
  81831. * @param texture defines the BabylonJS internal texture
  81832. * @param callback defines the method to call once ready to upload
  81833. */
  81834. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81835. }
  81836. }
  81837. declare module BABYLON {
  81838. /**
  81839. * Class used to store and describe the pipeline context associated with an effect
  81840. */
  81841. export interface IPipelineContext {
  81842. /**
  81843. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81844. */
  81845. isAsync: boolean;
  81846. /**
  81847. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81848. */
  81849. isReady: boolean;
  81850. /** @hidden */
  81851. _getVertexShaderCode(): string | null;
  81852. /** @hidden */
  81853. _getFragmentShaderCode(): string | null;
  81854. /** @hidden */
  81855. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81856. }
  81857. }
  81858. declare module BABYLON {
  81859. /**
  81860. * Class used to store gfx data (like WebGLBuffer)
  81861. */
  81862. export class DataBuffer {
  81863. /**
  81864. * Gets or sets the number of objects referencing this buffer
  81865. */
  81866. references: number;
  81867. /** Gets or sets the size of the underlying buffer */
  81868. capacity: number;
  81869. /**
  81870. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81871. */
  81872. is32Bits: boolean;
  81873. /**
  81874. * Gets the underlying buffer
  81875. */
  81876. get underlyingResource(): any;
  81877. }
  81878. }
  81879. declare module BABYLON {
  81880. /** @hidden */
  81881. export interface IShaderProcessor {
  81882. attributeProcessor?: (attribute: string) => string;
  81883. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81884. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81885. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81886. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81887. lineProcessor?: (line: string, isFragment: boolean) => string;
  81888. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81889. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81890. }
  81891. }
  81892. declare module BABYLON {
  81893. /** @hidden */
  81894. export interface ProcessingOptions {
  81895. defines: string[];
  81896. indexParameters: any;
  81897. isFragment: boolean;
  81898. shouldUseHighPrecisionShader: boolean;
  81899. supportsUniformBuffers: boolean;
  81900. shadersRepository: string;
  81901. includesShadersStore: {
  81902. [key: string]: string;
  81903. };
  81904. processor?: IShaderProcessor;
  81905. version: string;
  81906. platformName: string;
  81907. lookForClosingBracketForUniformBuffer?: boolean;
  81908. }
  81909. }
  81910. declare module BABYLON {
  81911. /** @hidden */
  81912. export class ShaderCodeNode {
  81913. line: string;
  81914. children: ShaderCodeNode[];
  81915. additionalDefineKey?: string;
  81916. additionalDefineValue?: string;
  81917. isValid(preprocessors: {
  81918. [key: string]: string;
  81919. }): boolean;
  81920. process(preprocessors: {
  81921. [key: string]: string;
  81922. }, options: ProcessingOptions): string;
  81923. }
  81924. }
  81925. declare module BABYLON {
  81926. /** @hidden */
  81927. export class ShaderCodeCursor {
  81928. private _lines;
  81929. lineIndex: number;
  81930. get currentLine(): string;
  81931. get canRead(): boolean;
  81932. set lines(value: string[]);
  81933. }
  81934. }
  81935. declare module BABYLON {
  81936. /** @hidden */
  81937. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81938. process(preprocessors: {
  81939. [key: string]: string;
  81940. }, options: ProcessingOptions): string;
  81941. }
  81942. }
  81943. declare module BABYLON {
  81944. /** @hidden */
  81945. export class ShaderDefineExpression {
  81946. isTrue(preprocessors: {
  81947. [key: string]: string;
  81948. }): boolean;
  81949. private static _OperatorPriority;
  81950. private static _Stack;
  81951. static postfixToInfix(postfix: string[]): string;
  81952. static infixToPostfix(infix: string): string[];
  81953. }
  81954. }
  81955. declare module BABYLON {
  81956. /** @hidden */
  81957. export class ShaderCodeTestNode extends ShaderCodeNode {
  81958. testExpression: ShaderDefineExpression;
  81959. isValid(preprocessors: {
  81960. [key: string]: string;
  81961. }): boolean;
  81962. }
  81963. }
  81964. declare module BABYLON {
  81965. /** @hidden */
  81966. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81967. define: string;
  81968. not: boolean;
  81969. constructor(define: string, not?: boolean);
  81970. isTrue(preprocessors: {
  81971. [key: string]: string;
  81972. }): boolean;
  81973. }
  81974. }
  81975. declare module BABYLON {
  81976. /** @hidden */
  81977. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81978. leftOperand: ShaderDefineExpression;
  81979. rightOperand: ShaderDefineExpression;
  81980. isTrue(preprocessors: {
  81981. [key: string]: string;
  81982. }): boolean;
  81983. }
  81984. }
  81985. declare module BABYLON {
  81986. /** @hidden */
  81987. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81988. leftOperand: ShaderDefineExpression;
  81989. rightOperand: ShaderDefineExpression;
  81990. isTrue(preprocessors: {
  81991. [key: string]: string;
  81992. }): boolean;
  81993. }
  81994. }
  81995. declare module BABYLON {
  81996. /** @hidden */
  81997. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81998. define: string;
  81999. operand: string;
  82000. testValue: string;
  82001. constructor(define: string, operand: string, testValue: string);
  82002. isTrue(preprocessors: {
  82003. [key: string]: string;
  82004. }): boolean;
  82005. }
  82006. }
  82007. declare module BABYLON {
  82008. /**
  82009. * Class used to enable access to offline support
  82010. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82011. */
  82012. export interface IOfflineProvider {
  82013. /**
  82014. * Gets a boolean indicating if scene must be saved in the database
  82015. */
  82016. enableSceneOffline: boolean;
  82017. /**
  82018. * Gets a boolean indicating if textures must be saved in the database
  82019. */
  82020. enableTexturesOffline: boolean;
  82021. /**
  82022. * Open the offline support and make it available
  82023. * @param successCallback defines the callback to call on success
  82024. * @param errorCallback defines the callback to call on error
  82025. */
  82026. open(successCallback: () => void, errorCallback: () => void): void;
  82027. /**
  82028. * Loads an image from the offline support
  82029. * @param url defines the url to load from
  82030. * @param image defines the target DOM image
  82031. */
  82032. loadImage(url: string, image: HTMLImageElement): void;
  82033. /**
  82034. * Loads a file from offline support
  82035. * @param url defines the URL to load from
  82036. * @param sceneLoaded defines a callback to call on success
  82037. * @param progressCallBack defines a callback to call when progress changed
  82038. * @param errorCallback defines a callback to call on error
  82039. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82040. */
  82041. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82042. }
  82043. }
  82044. declare module BABYLON {
  82045. /**
  82046. * Class used to help managing file picking and drag'n'drop
  82047. * File Storage
  82048. */
  82049. export class FilesInputStore {
  82050. /**
  82051. * List of files ready to be loaded
  82052. */
  82053. static FilesToLoad: {
  82054. [key: string]: File;
  82055. };
  82056. }
  82057. }
  82058. declare module BABYLON {
  82059. /**
  82060. * Class used to define a retry strategy when error happens while loading assets
  82061. */
  82062. export class RetryStrategy {
  82063. /**
  82064. * Function used to defines an exponential back off strategy
  82065. * @param maxRetries defines the maximum number of retries (3 by default)
  82066. * @param baseInterval defines the interval between retries
  82067. * @returns the strategy function to use
  82068. */
  82069. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82070. }
  82071. }
  82072. declare module BABYLON {
  82073. /**
  82074. * @ignore
  82075. * Application error to support additional information when loading a file
  82076. */
  82077. export abstract class BaseError extends Error {
  82078. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82079. }
  82080. }
  82081. declare module BABYLON {
  82082. /** @ignore */
  82083. export class LoadFileError extends BaseError {
  82084. request?: WebRequest;
  82085. file?: File;
  82086. /**
  82087. * Creates a new LoadFileError
  82088. * @param message defines the message of the error
  82089. * @param request defines the optional web request
  82090. * @param file defines the optional file
  82091. */
  82092. constructor(message: string, object?: WebRequest | File);
  82093. }
  82094. /** @ignore */
  82095. export class RequestFileError extends BaseError {
  82096. request: WebRequest;
  82097. /**
  82098. * Creates a new LoadFileError
  82099. * @param message defines the message of the error
  82100. * @param request defines the optional web request
  82101. */
  82102. constructor(message: string, request: WebRequest);
  82103. }
  82104. /** @ignore */
  82105. export class ReadFileError extends BaseError {
  82106. file: File;
  82107. /**
  82108. * Creates a new ReadFileError
  82109. * @param message defines the message of the error
  82110. * @param file defines the optional file
  82111. */
  82112. constructor(message: string, file: File);
  82113. }
  82114. /**
  82115. * @hidden
  82116. */
  82117. export class FileTools {
  82118. /**
  82119. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82120. */
  82121. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82122. /**
  82123. * Gets or sets the base URL to use to load assets
  82124. */
  82125. static BaseUrl: string;
  82126. /**
  82127. * Default behaviour for cors in the application.
  82128. * It can be a string if the expected behavior is identical in the entire app.
  82129. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82130. */
  82131. static CorsBehavior: string | ((url: string | string[]) => string);
  82132. /**
  82133. * Gets or sets a function used to pre-process url before using them to load assets
  82134. */
  82135. static PreprocessUrl: (url: string) => string;
  82136. /**
  82137. * Removes unwanted characters from an url
  82138. * @param url defines the url to clean
  82139. * @returns the cleaned url
  82140. */
  82141. private static _CleanUrl;
  82142. /**
  82143. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82144. * @param url define the url we are trying
  82145. * @param element define the dom element where to configure the cors policy
  82146. */
  82147. static SetCorsBehavior(url: string | string[], element: {
  82148. crossOrigin: string | null;
  82149. }): void;
  82150. /**
  82151. * Loads an image as an HTMLImageElement.
  82152. * @param input url string, ArrayBuffer, or Blob to load
  82153. * @param onLoad callback called when the image successfully loads
  82154. * @param onError callback called when the image fails to load
  82155. * @param offlineProvider offline provider for caching
  82156. * @param mimeType optional mime type
  82157. * @returns the HTMLImageElement of the loaded image
  82158. */
  82159. 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>;
  82160. /**
  82161. * Reads a file from a File object
  82162. * @param file defines the file to load
  82163. * @param onSuccess defines the callback to call when data is loaded
  82164. * @param onProgress defines the callback to call during loading process
  82165. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82166. * @param onError defines the callback to call when an error occurs
  82167. * @returns a file request object
  82168. */
  82169. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82170. /**
  82171. * Loads a file from a url
  82172. * @param url url to load
  82173. * @param onSuccess callback called when the file successfully loads
  82174. * @param onProgress callback called while file is loading (if the server supports this mode)
  82175. * @param offlineProvider defines the offline provider for caching
  82176. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82177. * @param onError callback called when the file fails to load
  82178. * @returns a file request object
  82179. */
  82180. 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;
  82181. /**
  82182. * Loads a file
  82183. * @param url url to load
  82184. * @param onSuccess callback called when the file successfully loads
  82185. * @param onProgress callback called while file is loading (if the server supports this mode)
  82186. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82187. * @param onError callback called when the file fails to load
  82188. * @param onOpened callback called when the web request is opened
  82189. * @returns a file request object
  82190. */
  82191. 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;
  82192. /**
  82193. * Checks if the loaded document was accessed via `file:`-Protocol.
  82194. * @returns boolean
  82195. */
  82196. static IsFileURL(): boolean;
  82197. }
  82198. }
  82199. declare module BABYLON {
  82200. /** @hidden */
  82201. export class ShaderProcessor {
  82202. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  82203. private static _ProcessPrecision;
  82204. private static _ExtractOperation;
  82205. private static _BuildSubExpression;
  82206. private static _BuildExpression;
  82207. private static _MoveCursorWithinIf;
  82208. private static _MoveCursor;
  82209. private static _EvaluatePreProcessors;
  82210. private static _PreparePreProcessors;
  82211. private static _ProcessShaderConversion;
  82212. private static _ProcessIncludes;
  82213. /**
  82214. * Loads a file from a url
  82215. * @param url url to load
  82216. * @param onSuccess callback called when the file successfully loads
  82217. * @param onProgress callback called while file is loading (if the server supports this mode)
  82218. * @param offlineProvider defines the offline provider for caching
  82219. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82220. * @param onError callback called when the file fails to load
  82221. * @returns a file request object
  82222. * @hidden
  82223. */
  82224. 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;
  82225. }
  82226. }
  82227. declare module BABYLON {
  82228. /**
  82229. * @hidden
  82230. */
  82231. export interface IColor4Like {
  82232. r: float;
  82233. g: float;
  82234. b: float;
  82235. a: float;
  82236. }
  82237. /**
  82238. * @hidden
  82239. */
  82240. export interface IColor3Like {
  82241. r: float;
  82242. g: float;
  82243. b: float;
  82244. }
  82245. /**
  82246. * @hidden
  82247. */
  82248. export interface IVector4Like {
  82249. x: float;
  82250. y: float;
  82251. z: float;
  82252. w: float;
  82253. }
  82254. /**
  82255. * @hidden
  82256. */
  82257. export interface IVector3Like {
  82258. x: float;
  82259. y: float;
  82260. z: float;
  82261. }
  82262. /**
  82263. * @hidden
  82264. */
  82265. export interface IVector2Like {
  82266. x: float;
  82267. y: float;
  82268. }
  82269. /**
  82270. * @hidden
  82271. */
  82272. export interface IMatrixLike {
  82273. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82274. updateFlag: int;
  82275. }
  82276. /**
  82277. * @hidden
  82278. */
  82279. export interface IViewportLike {
  82280. x: float;
  82281. y: float;
  82282. width: float;
  82283. height: float;
  82284. }
  82285. /**
  82286. * @hidden
  82287. */
  82288. export interface IPlaneLike {
  82289. normal: IVector3Like;
  82290. d: float;
  82291. normalize(): void;
  82292. }
  82293. }
  82294. declare module BABYLON {
  82295. /**
  82296. * Interface used to define common properties for effect fallbacks
  82297. */
  82298. export interface IEffectFallbacks {
  82299. /**
  82300. * Removes the defines that should be removed when falling back.
  82301. * @param currentDefines defines the current define statements for the shader.
  82302. * @param effect defines the current effect we try to compile
  82303. * @returns The resulting defines with defines of the current rank removed.
  82304. */
  82305. reduce(currentDefines: string, effect: Effect): string;
  82306. /**
  82307. * Removes the fallback from the bound mesh.
  82308. */
  82309. unBindMesh(): void;
  82310. /**
  82311. * Checks to see if more fallbacks are still availible.
  82312. */
  82313. hasMoreFallbacks: boolean;
  82314. }
  82315. }
  82316. declare module BABYLON {
  82317. /**
  82318. * Class used to evalaute queries containing `and` and `or` operators
  82319. */
  82320. export class AndOrNotEvaluator {
  82321. /**
  82322. * Evaluate a query
  82323. * @param query defines the query to evaluate
  82324. * @param evaluateCallback defines the callback used to filter result
  82325. * @returns true if the query matches
  82326. */
  82327. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82328. private static _HandleParenthesisContent;
  82329. private static _SimplifyNegation;
  82330. }
  82331. }
  82332. declare module BABYLON {
  82333. /**
  82334. * Class used to store custom tags
  82335. */
  82336. export class Tags {
  82337. /**
  82338. * Adds support for tags on the given object
  82339. * @param obj defines the object to use
  82340. */
  82341. static EnableFor(obj: any): void;
  82342. /**
  82343. * Removes tags support
  82344. * @param obj defines the object to use
  82345. */
  82346. static DisableFor(obj: any): void;
  82347. /**
  82348. * Gets a boolean indicating if the given object has tags
  82349. * @param obj defines the object to use
  82350. * @returns a boolean
  82351. */
  82352. static HasTags(obj: any): boolean;
  82353. /**
  82354. * Gets the tags available on a given object
  82355. * @param obj defines the object to use
  82356. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82357. * @returns the tags
  82358. */
  82359. static GetTags(obj: any, asString?: boolean): any;
  82360. /**
  82361. * Adds tags to an object
  82362. * @param obj defines the object to use
  82363. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82364. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82365. */
  82366. static AddTagsTo(obj: any, tagsString: string): void;
  82367. /**
  82368. * @hidden
  82369. */
  82370. static _AddTagTo(obj: any, tag: string): void;
  82371. /**
  82372. * Removes specific tags from a specific object
  82373. * @param obj defines the object to use
  82374. * @param tagsString defines the tags to remove
  82375. */
  82376. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82377. /**
  82378. * @hidden
  82379. */
  82380. static _RemoveTagFrom(obj: any, tag: string): void;
  82381. /**
  82382. * Defines if tags hosted on an object match a given query
  82383. * @param obj defines the object to use
  82384. * @param tagsQuery defines the tag query
  82385. * @returns a boolean
  82386. */
  82387. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82388. }
  82389. }
  82390. declare module BABYLON {
  82391. /**
  82392. * Scalar computation library
  82393. */
  82394. export class Scalar {
  82395. /**
  82396. * Two pi constants convenient for computation.
  82397. */
  82398. static TwoPi: number;
  82399. /**
  82400. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82401. * @param a number
  82402. * @param b number
  82403. * @param epsilon (default = 1.401298E-45)
  82404. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82405. */
  82406. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82407. /**
  82408. * Returns a string : the upper case translation of the number i to hexadecimal.
  82409. * @param i number
  82410. * @returns the upper case translation of the number i to hexadecimal.
  82411. */
  82412. static ToHex(i: number): string;
  82413. /**
  82414. * Returns -1 if value is negative and +1 is value is positive.
  82415. * @param value the value
  82416. * @returns the value itself if it's equal to zero.
  82417. */
  82418. static Sign(value: number): number;
  82419. /**
  82420. * Returns the value itself if it's between min and max.
  82421. * Returns min if the value is lower than min.
  82422. * Returns max if the value is greater than max.
  82423. * @param value the value to clmap
  82424. * @param min the min value to clamp to (default: 0)
  82425. * @param max the max value to clamp to (default: 1)
  82426. * @returns the clamped value
  82427. */
  82428. static Clamp(value: number, min?: number, max?: number): number;
  82429. /**
  82430. * the log2 of value.
  82431. * @param value the value to compute log2 of
  82432. * @returns the log2 of value.
  82433. */
  82434. static Log2(value: number): number;
  82435. /**
  82436. * Loops the value, so that it is never larger than length and never smaller than 0.
  82437. *
  82438. * This is similar to the modulo operator but it works with floating point numbers.
  82439. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82440. * With t = 5 and length = 2.5, the result would be 0.0.
  82441. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82442. * @param value the value
  82443. * @param length the length
  82444. * @returns the looped value
  82445. */
  82446. static Repeat(value: number, length: number): number;
  82447. /**
  82448. * Normalize the value between 0.0 and 1.0 using min and max values
  82449. * @param value value to normalize
  82450. * @param min max to normalize between
  82451. * @param max min to normalize between
  82452. * @returns the normalized value
  82453. */
  82454. static Normalize(value: number, min: number, max: number): number;
  82455. /**
  82456. * Denormalize the value from 0.0 and 1.0 using min and max values
  82457. * @param normalized value to denormalize
  82458. * @param min max to denormalize between
  82459. * @param max min to denormalize between
  82460. * @returns the denormalized value
  82461. */
  82462. static Denormalize(normalized: number, min: number, max: number): number;
  82463. /**
  82464. * Calculates the shortest difference between two given angles given in degrees.
  82465. * @param current current angle in degrees
  82466. * @param target target angle in degrees
  82467. * @returns the delta
  82468. */
  82469. static DeltaAngle(current: number, target: number): number;
  82470. /**
  82471. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82472. * @param tx value
  82473. * @param length length
  82474. * @returns The returned value will move back and forth between 0 and length
  82475. */
  82476. static PingPong(tx: number, length: number): number;
  82477. /**
  82478. * Interpolates between min and max with smoothing at the limits.
  82479. *
  82480. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82481. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82482. * @param from from
  82483. * @param to to
  82484. * @param tx value
  82485. * @returns the smooth stepped value
  82486. */
  82487. static SmoothStep(from: number, to: number, tx: number): number;
  82488. /**
  82489. * Moves a value current towards target.
  82490. *
  82491. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82492. * Negative values of maxDelta pushes the value away from target.
  82493. * @param current current value
  82494. * @param target target value
  82495. * @param maxDelta max distance to move
  82496. * @returns resulting value
  82497. */
  82498. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82499. /**
  82500. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82501. *
  82502. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82503. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82504. * @param current current value
  82505. * @param target target value
  82506. * @param maxDelta max distance to move
  82507. * @returns resulting angle
  82508. */
  82509. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82510. /**
  82511. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82512. * @param start start value
  82513. * @param end target value
  82514. * @param amount amount to lerp between
  82515. * @returns the lerped value
  82516. */
  82517. static Lerp(start: number, end: number, amount: number): number;
  82518. /**
  82519. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82520. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82521. * @param start start value
  82522. * @param end target value
  82523. * @param amount amount to lerp between
  82524. * @returns the lerped value
  82525. */
  82526. static LerpAngle(start: number, end: number, amount: number): number;
  82527. /**
  82528. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82529. * @param a start value
  82530. * @param b target value
  82531. * @param value value between a and b
  82532. * @returns the inverseLerp value
  82533. */
  82534. static InverseLerp(a: number, b: number, value: number): number;
  82535. /**
  82536. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82537. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82538. * @param value1 spline value
  82539. * @param tangent1 spline value
  82540. * @param value2 spline value
  82541. * @param tangent2 spline value
  82542. * @param amount input value
  82543. * @returns hermite result
  82544. */
  82545. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82546. /**
  82547. * Returns a random float number between and min and max values
  82548. * @param min min value of random
  82549. * @param max max value of random
  82550. * @returns random value
  82551. */
  82552. static RandomRange(min: number, max: number): number;
  82553. /**
  82554. * This function returns percentage of a number in a given range.
  82555. *
  82556. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82557. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82558. * @param number to convert to percentage
  82559. * @param min min range
  82560. * @param max max range
  82561. * @returns the percentage
  82562. */
  82563. static RangeToPercent(number: number, min: number, max: number): number;
  82564. /**
  82565. * This function returns number that corresponds to the percentage in a given range.
  82566. *
  82567. * PercentToRange(0.34,0,100) will return 34.
  82568. * @param percent to convert to number
  82569. * @param min min range
  82570. * @param max max range
  82571. * @returns the number
  82572. */
  82573. static PercentToRange(percent: number, min: number, max: number): number;
  82574. /**
  82575. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82576. * @param angle The angle to normalize in radian.
  82577. * @return The converted angle.
  82578. */
  82579. static NormalizeRadians(angle: number): number;
  82580. }
  82581. }
  82582. declare module BABYLON {
  82583. /**
  82584. * Constant used to convert a value to gamma space
  82585. * @ignorenaming
  82586. */
  82587. export const ToGammaSpace: number;
  82588. /**
  82589. * Constant used to convert a value to linear space
  82590. * @ignorenaming
  82591. */
  82592. export const ToLinearSpace = 2.2;
  82593. /**
  82594. * Constant used to define the minimal number value in Babylon.js
  82595. * @ignorenaming
  82596. */
  82597. let Epsilon: number;
  82598. }
  82599. declare module BABYLON {
  82600. /**
  82601. * Class used to represent a viewport on screen
  82602. */
  82603. export class Viewport {
  82604. /** viewport left coordinate */
  82605. x: number;
  82606. /** viewport top coordinate */
  82607. y: number;
  82608. /**viewport width */
  82609. width: number;
  82610. /** viewport height */
  82611. height: number;
  82612. /**
  82613. * Creates a Viewport object located at (x, y) and sized (width, height)
  82614. * @param x defines viewport left coordinate
  82615. * @param y defines viewport top coordinate
  82616. * @param width defines the viewport width
  82617. * @param height defines the viewport height
  82618. */
  82619. constructor(
  82620. /** viewport left coordinate */
  82621. x: number,
  82622. /** viewport top coordinate */
  82623. y: number,
  82624. /**viewport width */
  82625. width: number,
  82626. /** viewport height */
  82627. height: number);
  82628. /**
  82629. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82630. * @param renderWidth defines the rendering width
  82631. * @param renderHeight defines the rendering height
  82632. * @returns a new Viewport
  82633. */
  82634. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82635. /**
  82636. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82637. * @param renderWidth defines the rendering width
  82638. * @param renderHeight defines the rendering height
  82639. * @param ref defines the target viewport
  82640. * @returns the current viewport
  82641. */
  82642. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82643. /**
  82644. * Returns a new Viewport copied from the current one
  82645. * @returns a new Viewport
  82646. */
  82647. clone(): Viewport;
  82648. }
  82649. }
  82650. declare module BABYLON {
  82651. /**
  82652. * Class containing a set of static utilities functions for arrays.
  82653. */
  82654. export class ArrayTools {
  82655. /**
  82656. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82657. * @param size the number of element to construct and put in the array
  82658. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82659. * @returns a new array filled with new objects
  82660. */
  82661. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82662. }
  82663. }
  82664. declare module BABYLON {
  82665. /**
  82666. * Represents a plane by the equation ax + by + cz + d = 0
  82667. */
  82668. export class Plane {
  82669. private static _TmpMatrix;
  82670. /**
  82671. * Normal of the plane (a,b,c)
  82672. */
  82673. normal: Vector3;
  82674. /**
  82675. * d component of the plane
  82676. */
  82677. d: number;
  82678. /**
  82679. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82680. * @param a a component of the plane
  82681. * @param b b component of the plane
  82682. * @param c c component of the plane
  82683. * @param d d component of the plane
  82684. */
  82685. constructor(a: number, b: number, c: number, d: number);
  82686. /**
  82687. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82688. */
  82689. asArray(): number[];
  82690. /**
  82691. * @returns a new plane copied from the current Plane.
  82692. */
  82693. clone(): Plane;
  82694. /**
  82695. * @returns the string "Plane".
  82696. */
  82697. getClassName(): string;
  82698. /**
  82699. * @returns the Plane hash code.
  82700. */
  82701. getHashCode(): number;
  82702. /**
  82703. * Normalize the current Plane in place.
  82704. * @returns the updated Plane.
  82705. */
  82706. normalize(): Plane;
  82707. /**
  82708. * Applies a transformation the plane and returns the result
  82709. * @param transformation the transformation matrix to be applied to the plane
  82710. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82711. */
  82712. transform(transformation: DeepImmutable<Matrix>): Plane;
  82713. /**
  82714. * Compute the dot product between the point and the plane normal
  82715. * @param point point to calculate the dot product with
  82716. * @returns the dot product (float) of the point coordinates and the plane normal.
  82717. */
  82718. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82719. /**
  82720. * Updates the current Plane from the plane defined by the three given points.
  82721. * @param point1 one of the points used to contruct the plane
  82722. * @param point2 one of the points used to contruct the plane
  82723. * @param point3 one of the points used to contruct the plane
  82724. * @returns the updated Plane.
  82725. */
  82726. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82727. /**
  82728. * Checks if the plane is facing a given direction
  82729. * @param direction the direction to check if the plane is facing
  82730. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82731. * @returns True is the vector "direction" is the same side than the plane normal.
  82732. */
  82733. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82734. /**
  82735. * Calculates the distance to a point
  82736. * @param point point to calculate distance to
  82737. * @returns the signed distance (float) from the given point to the Plane.
  82738. */
  82739. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82740. /**
  82741. * Creates a plane from an array
  82742. * @param array the array to create a plane from
  82743. * @returns a new Plane from the given array.
  82744. */
  82745. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82746. /**
  82747. * Creates a plane from three points
  82748. * @param point1 point used to create the plane
  82749. * @param point2 point used to create the plane
  82750. * @param point3 point used to create the plane
  82751. * @returns a new Plane defined by the three given points.
  82752. */
  82753. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82754. /**
  82755. * Creates a plane from an origin point and a normal
  82756. * @param origin origin of the plane to be constructed
  82757. * @param normal normal of the plane to be constructed
  82758. * @returns a new Plane the normal vector to this plane at the given origin point.
  82759. * Note : the vector "normal" is updated because normalized.
  82760. */
  82761. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82762. /**
  82763. * Calculates the distance from a plane and a point
  82764. * @param origin origin of the plane to be constructed
  82765. * @param normal normal of the plane to be constructed
  82766. * @param point point to calculate distance to
  82767. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82768. */
  82769. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82770. }
  82771. }
  82772. declare module BABYLON {
  82773. /** @hidden */
  82774. export class PerformanceConfigurator {
  82775. /** @hidden */
  82776. static MatrixUse64Bits: boolean;
  82777. /** @hidden */
  82778. static MatrixTrackPrecisionChange: boolean;
  82779. /** @hidden */
  82780. static MatrixCurrentType: any;
  82781. /** @hidden */
  82782. static MatrixTrackedMatrices: Array<any> | null;
  82783. /** @hidden */
  82784. static SetMatrixPrecision(use64bits: boolean): void;
  82785. }
  82786. }
  82787. declare module BABYLON {
  82788. /**
  82789. * Class representing a vector containing 2 coordinates
  82790. */
  82791. export class Vector2 {
  82792. /** defines the first coordinate */
  82793. x: number;
  82794. /** defines the second coordinate */
  82795. y: number;
  82796. /**
  82797. * Creates a new Vector2 from the given x and y coordinates
  82798. * @param x defines the first coordinate
  82799. * @param y defines the second coordinate
  82800. */
  82801. constructor(
  82802. /** defines the first coordinate */
  82803. x?: number,
  82804. /** defines the second coordinate */
  82805. y?: number);
  82806. /**
  82807. * Gets a string with the Vector2 coordinates
  82808. * @returns a string with the Vector2 coordinates
  82809. */
  82810. toString(): string;
  82811. /**
  82812. * Gets class name
  82813. * @returns the string "Vector2"
  82814. */
  82815. getClassName(): string;
  82816. /**
  82817. * Gets current vector hash code
  82818. * @returns the Vector2 hash code as a number
  82819. */
  82820. getHashCode(): number;
  82821. /**
  82822. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82823. * @param array defines the source array
  82824. * @param index defines the offset in source array
  82825. * @returns the current Vector2
  82826. */
  82827. toArray(array: FloatArray, index?: number): Vector2;
  82828. /**
  82829. * Update the current vector from an array
  82830. * @param array defines the destination array
  82831. * @param index defines the offset in the destination array
  82832. * @returns the current Vector3
  82833. */
  82834. fromArray(array: FloatArray, index?: number): Vector2;
  82835. /**
  82836. * Copy the current vector to an array
  82837. * @returns a new array with 2 elements: the Vector2 coordinates.
  82838. */
  82839. asArray(): number[];
  82840. /**
  82841. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82842. * @param source defines the source Vector2
  82843. * @returns the current updated Vector2
  82844. */
  82845. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82846. /**
  82847. * Sets the Vector2 coordinates with the given floats
  82848. * @param x defines the first coordinate
  82849. * @param y defines the second coordinate
  82850. * @returns the current updated Vector2
  82851. */
  82852. copyFromFloats(x: number, y: number): Vector2;
  82853. /**
  82854. * Sets the Vector2 coordinates with the given floats
  82855. * @param x defines the first coordinate
  82856. * @param y defines the second coordinate
  82857. * @returns the current updated Vector2
  82858. */
  82859. set(x: number, y: number): Vector2;
  82860. /**
  82861. * Add another vector with the current one
  82862. * @param otherVector defines the other vector
  82863. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82864. */
  82865. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82866. /**
  82867. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82868. * @param otherVector defines the other vector
  82869. * @param result defines the target vector
  82870. * @returns the unmodified current Vector2
  82871. */
  82872. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82873. /**
  82874. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82875. * @param otherVector defines the other vector
  82876. * @returns the current updated Vector2
  82877. */
  82878. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82879. /**
  82880. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82881. * @param otherVector defines the other vector
  82882. * @returns a new Vector2
  82883. */
  82884. addVector3(otherVector: Vector3): Vector2;
  82885. /**
  82886. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82887. * @param otherVector defines the other vector
  82888. * @returns a new Vector2
  82889. */
  82890. subtract(otherVector: Vector2): Vector2;
  82891. /**
  82892. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82893. * @param otherVector defines the other vector
  82894. * @param result defines the target vector
  82895. * @returns the unmodified current Vector2
  82896. */
  82897. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82898. /**
  82899. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82900. * @param otherVector defines the other vector
  82901. * @returns the current updated Vector2
  82902. */
  82903. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82904. /**
  82905. * Multiplies in place the current Vector2 coordinates by the given ones
  82906. * @param otherVector defines the other vector
  82907. * @returns the current updated Vector2
  82908. */
  82909. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82910. /**
  82911. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82912. * @param otherVector defines the other vector
  82913. * @returns a new Vector2
  82914. */
  82915. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82916. /**
  82917. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82918. * @param otherVector defines the other vector
  82919. * @param result defines the target vector
  82920. * @returns the unmodified current Vector2
  82921. */
  82922. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82923. /**
  82924. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82925. * @param x defines the first coordinate
  82926. * @param y defines the second coordinate
  82927. * @returns a new Vector2
  82928. */
  82929. multiplyByFloats(x: number, y: number): Vector2;
  82930. /**
  82931. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82932. * @param otherVector defines the other vector
  82933. * @returns a new Vector2
  82934. */
  82935. divide(otherVector: Vector2): Vector2;
  82936. /**
  82937. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82938. * @param otherVector defines the other vector
  82939. * @param result defines the target vector
  82940. * @returns the unmodified current Vector2
  82941. */
  82942. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82943. /**
  82944. * Divides the current Vector2 coordinates by the given ones
  82945. * @param otherVector defines the other vector
  82946. * @returns the current updated Vector2
  82947. */
  82948. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82949. /**
  82950. * Gets a new Vector2 with current Vector2 negated coordinates
  82951. * @returns a new Vector2
  82952. */
  82953. negate(): Vector2;
  82954. /**
  82955. * Negate this vector in place
  82956. * @returns this
  82957. */
  82958. negateInPlace(): Vector2;
  82959. /**
  82960. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82961. * @param result defines the Vector3 object where to store the result
  82962. * @returns the current Vector2
  82963. */
  82964. negateToRef(result: Vector2): Vector2;
  82965. /**
  82966. * Multiply the Vector2 coordinates by scale
  82967. * @param scale defines the scaling factor
  82968. * @returns the current updated Vector2
  82969. */
  82970. scaleInPlace(scale: number): Vector2;
  82971. /**
  82972. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82973. * @param scale defines the scaling factor
  82974. * @returns a new Vector2
  82975. */
  82976. scale(scale: number): Vector2;
  82977. /**
  82978. * Scale the current Vector2 values by a factor to a given Vector2
  82979. * @param scale defines the scale factor
  82980. * @param result defines the Vector2 object where to store the result
  82981. * @returns the unmodified current Vector2
  82982. */
  82983. scaleToRef(scale: number, result: Vector2): Vector2;
  82984. /**
  82985. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82986. * @param scale defines the scale factor
  82987. * @param result defines the Vector2 object where to store the result
  82988. * @returns the unmodified current Vector2
  82989. */
  82990. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82991. /**
  82992. * Gets a boolean if two vectors are equals
  82993. * @param otherVector defines the other vector
  82994. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82995. */
  82996. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82997. /**
  82998. * Gets a boolean if two vectors are equals (using an epsilon value)
  82999. * @param otherVector defines the other vector
  83000. * @param epsilon defines the minimal distance to consider equality
  83001. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  83002. */
  83003. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  83004. /**
  83005. * Gets a new Vector2 from current Vector2 floored values
  83006. * @returns a new Vector2
  83007. */
  83008. floor(): Vector2;
  83009. /**
  83010. * Gets a new Vector2 from current Vector2 floored values
  83011. * @returns a new Vector2
  83012. */
  83013. fract(): Vector2;
  83014. /**
  83015. * Gets the length of the vector
  83016. * @returns the vector length (float)
  83017. */
  83018. length(): number;
  83019. /**
  83020. * Gets the vector squared length
  83021. * @returns the vector squared length (float)
  83022. */
  83023. lengthSquared(): number;
  83024. /**
  83025. * Normalize the vector
  83026. * @returns the current updated Vector2
  83027. */
  83028. normalize(): Vector2;
  83029. /**
  83030. * Gets a new Vector2 copied from the Vector2
  83031. * @returns a new Vector2
  83032. */
  83033. clone(): Vector2;
  83034. /**
  83035. * Gets a new Vector2(0, 0)
  83036. * @returns a new Vector2
  83037. */
  83038. static Zero(): Vector2;
  83039. /**
  83040. * Gets a new Vector2(1, 1)
  83041. * @returns a new Vector2
  83042. */
  83043. static One(): Vector2;
  83044. /**
  83045. * Gets a new Vector2 set from the given index element of the given array
  83046. * @param array defines the data source
  83047. * @param offset defines the offset in the data source
  83048. * @returns a new Vector2
  83049. */
  83050. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  83051. /**
  83052. * Sets "result" from the given index element of the given array
  83053. * @param array defines the data source
  83054. * @param offset defines the offset in the data source
  83055. * @param result defines the target vector
  83056. */
  83057. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  83058. /**
  83059. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  83060. * @param value1 defines 1st point of control
  83061. * @param value2 defines 2nd point of control
  83062. * @param value3 defines 3rd point of control
  83063. * @param value4 defines 4th point of control
  83064. * @param amount defines the interpolation factor
  83065. * @returns a new Vector2
  83066. */
  83067. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  83068. /**
  83069. * 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".
  83070. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  83071. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  83072. * @param value defines the value to clamp
  83073. * @param min defines the lower limit
  83074. * @param max defines the upper limit
  83075. * @returns a new Vector2
  83076. */
  83077. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  83078. /**
  83079. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  83080. * @param value1 defines the 1st control point
  83081. * @param tangent1 defines the outgoing tangent
  83082. * @param value2 defines the 2nd control point
  83083. * @param tangent2 defines the incoming tangent
  83084. * @param amount defines the interpolation factor
  83085. * @returns a new Vector2
  83086. */
  83087. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83088. /**
  83089. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83090. * @param start defines the start vector
  83091. * @param end defines the end vector
  83092. * @param amount defines the interpolation factor
  83093. * @returns a new Vector2
  83094. */
  83095. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83096. /**
  83097. * Gets the dot product of the vector "left" and the vector "right"
  83098. * @param left defines first vector
  83099. * @param right defines second vector
  83100. * @returns the dot product (float)
  83101. */
  83102. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83103. /**
  83104. * Returns a new Vector2 equal to the normalized given vector
  83105. * @param vector defines the vector to normalize
  83106. * @returns a new Vector2
  83107. */
  83108. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83109. /**
  83110. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83111. * @param left defines 1st vector
  83112. * @param right defines 2nd vector
  83113. * @returns a new Vector2
  83114. */
  83115. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83116. /**
  83117. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83118. * @param left defines 1st vector
  83119. * @param right defines 2nd vector
  83120. * @returns a new Vector2
  83121. */
  83122. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83123. /**
  83124. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83125. * @param vector defines the vector to transform
  83126. * @param transformation defines the matrix to apply
  83127. * @returns a new Vector2
  83128. */
  83129. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83130. /**
  83131. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83132. * @param vector defines the vector to transform
  83133. * @param transformation defines the matrix to apply
  83134. * @param result defines the target vector
  83135. */
  83136. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83137. /**
  83138. * Determines if a given vector is included in a triangle
  83139. * @param p defines the vector to test
  83140. * @param p0 defines 1st triangle point
  83141. * @param p1 defines 2nd triangle point
  83142. * @param p2 defines 3rd triangle point
  83143. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83144. */
  83145. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83146. /**
  83147. * Gets the distance between the vectors "value1" and "value2"
  83148. * @param value1 defines first vector
  83149. * @param value2 defines second vector
  83150. * @returns the distance between vectors
  83151. */
  83152. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83153. /**
  83154. * Returns the squared distance between the vectors "value1" and "value2"
  83155. * @param value1 defines first vector
  83156. * @param value2 defines second vector
  83157. * @returns the squared distance between vectors
  83158. */
  83159. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83160. /**
  83161. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83162. * @param value1 defines first vector
  83163. * @param value2 defines second vector
  83164. * @returns a new Vector2
  83165. */
  83166. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83167. /**
  83168. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83169. * @param p defines the middle point
  83170. * @param segA defines one point of the segment
  83171. * @param segB defines the other point of the segment
  83172. * @returns the shortest distance
  83173. */
  83174. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83175. }
  83176. /**
  83177. * Class used to store (x,y,z) vector representation
  83178. * A Vector3 is the main object used in 3D geometry
  83179. * It can represent etiher the coordinates of a point the space, either a direction
  83180. * Reminder: js uses a left handed forward facing system
  83181. */
  83182. export class Vector3 {
  83183. private static _UpReadOnly;
  83184. private static _ZeroReadOnly;
  83185. /** @hidden */
  83186. _x: number;
  83187. /** @hidden */
  83188. _y: number;
  83189. /** @hidden */
  83190. _z: number;
  83191. /** @hidden */
  83192. _isDirty: boolean;
  83193. /** Gets or sets the x coordinate */
  83194. get x(): number;
  83195. set x(value: number);
  83196. /** Gets or sets the y coordinate */
  83197. get y(): number;
  83198. set y(value: number);
  83199. /** Gets or sets the z coordinate */
  83200. get z(): number;
  83201. set z(value: number);
  83202. /**
  83203. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83204. * @param x defines the first coordinates (on X axis)
  83205. * @param y defines the second coordinates (on Y axis)
  83206. * @param z defines the third coordinates (on Z axis)
  83207. */
  83208. constructor(x?: number, y?: number, z?: number);
  83209. /**
  83210. * Creates a string representation of the Vector3
  83211. * @returns a string with the Vector3 coordinates.
  83212. */
  83213. toString(): string;
  83214. /**
  83215. * Gets the class name
  83216. * @returns the string "Vector3"
  83217. */
  83218. getClassName(): string;
  83219. /**
  83220. * Creates the Vector3 hash code
  83221. * @returns a number which tends to be unique between Vector3 instances
  83222. */
  83223. getHashCode(): number;
  83224. /**
  83225. * Creates an array containing three elements : the coordinates of the Vector3
  83226. * @returns a new array of numbers
  83227. */
  83228. asArray(): number[];
  83229. /**
  83230. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83231. * @param array defines the destination array
  83232. * @param index defines the offset in the destination array
  83233. * @returns the current Vector3
  83234. */
  83235. toArray(array: FloatArray, index?: number): Vector3;
  83236. /**
  83237. * Update the current vector from an array
  83238. * @param array defines the destination array
  83239. * @param index defines the offset in the destination array
  83240. * @returns the current Vector3
  83241. */
  83242. fromArray(array: FloatArray, index?: number): Vector3;
  83243. /**
  83244. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83245. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83246. */
  83247. toQuaternion(): Quaternion;
  83248. /**
  83249. * Adds the given vector to the current Vector3
  83250. * @param otherVector defines the second operand
  83251. * @returns the current updated Vector3
  83252. */
  83253. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83254. /**
  83255. * Adds the given coordinates to the current Vector3
  83256. * @param x defines the x coordinate of the operand
  83257. * @param y defines the y coordinate of the operand
  83258. * @param z defines the z coordinate of the operand
  83259. * @returns the current updated Vector3
  83260. */
  83261. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83262. /**
  83263. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83264. * @param otherVector defines the second operand
  83265. * @returns the resulting Vector3
  83266. */
  83267. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83268. /**
  83269. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83270. * @param otherVector defines the second operand
  83271. * @param result defines the Vector3 object where to store the result
  83272. * @returns the current Vector3
  83273. */
  83274. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83275. /**
  83276. * Subtract the given vector from the current Vector3
  83277. * @param otherVector defines the second operand
  83278. * @returns the current updated Vector3
  83279. */
  83280. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83281. /**
  83282. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83283. * @param otherVector defines the second operand
  83284. * @returns the resulting Vector3
  83285. */
  83286. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83287. /**
  83288. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83289. * @param otherVector defines the second operand
  83290. * @param result defines the Vector3 object where to store the result
  83291. * @returns the current Vector3
  83292. */
  83293. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83294. /**
  83295. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83296. * @param x defines the x coordinate of the operand
  83297. * @param y defines the y coordinate of the operand
  83298. * @param z defines the z coordinate of the operand
  83299. * @returns the resulting Vector3
  83300. */
  83301. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83302. /**
  83303. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83304. * @param x defines the x coordinate of the operand
  83305. * @param y defines the y coordinate of the operand
  83306. * @param z defines the z coordinate of the operand
  83307. * @param result defines the Vector3 object where to store the result
  83308. * @returns the current Vector3
  83309. */
  83310. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83311. /**
  83312. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83313. * @returns a new Vector3
  83314. */
  83315. negate(): Vector3;
  83316. /**
  83317. * Negate this vector in place
  83318. * @returns this
  83319. */
  83320. negateInPlace(): Vector3;
  83321. /**
  83322. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83323. * @param result defines the Vector3 object where to store the result
  83324. * @returns the current Vector3
  83325. */
  83326. negateToRef(result: Vector3): Vector3;
  83327. /**
  83328. * Multiplies the Vector3 coordinates by the float "scale"
  83329. * @param scale defines the multiplier factor
  83330. * @returns the current updated Vector3
  83331. */
  83332. scaleInPlace(scale: number): Vector3;
  83333. /**
  83334. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83335. * @param scale defines the multiplier factor
  83336. * @returns a new Vector3
  83337. */
  83338. scale(scale: number): Vector3;
  83339. /**
  83340. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83341. * @param scale defines the multiplier factor
  83342. * @param result defines the Vector3 object where to store the result
  83343. * @returns the current Vector3
  83344. */
  83345. scaleToRef(scale: number, result: Vector3): Vector3;
  83346. /**
  83347. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83348. * @param scale defines the scale factor
  83349. * @param result defines the Vector3 object where to store the result
  83350. * @returns the unmodified current Vector3
  83351. */
  83352. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83353. /**
  83354. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83355. * @param origin defines the origin of the projection ray
  83356. * @param plane defines the plane to project to
  83357. * @returns the projected vector3
  83358. */
  83359. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83360. /**
  83361. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83362. * @param origin defines the origin of the projection ray
  83363. * @param plane defines the plane to project to
  83364. * @param result defines the Vector3 where to store the result
  83365. */
  83366. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83367. /**
  83368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83369. * @param otherVector defines the second operand
  83370. * @returns true if both vectors are equals
  83371. */
  83372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83373. /**
  83374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83375. * @param otherVector defines the second operand
  83376. * @param epsilon defines the minimal distance to define values as equals
  83377. * @returns true if both vectors are distant less than epsilon
  83378. */
  83379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83380. /**
  83381. * Returns true if the current Vector3 coordinates equals the given floats
  83382. * @param x defines the x coordinate of the operand
  83383. * @param y defines the y coordinate of the operand
  83384. * @param z defines the z coordinate of the operand
  83385. * @returns true if both vectors are equals
  83386. */
  83387. equalsToFloats(x: number, y: number, z: number): boolean;
  83388. /**
  83389. * Multiplies the current Vector3 coordinates by the given ones
  83390. * @param otherVector defines the second operand
  83391. * @returns the current updated Vector3
  83392. */
  83393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83394. /**
  83395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83396. * @param otherVector defines the second operand
  83397. * @returns the new Vector3
  83398. */
  83399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83400. /**
  83401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83402. * @param otherVector defines the second operand
  83403. * @param result defines the Vector3 object where to store the result
  83404. * @returns the current Vector3
  83405. */
  83406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83407. /**
  83408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83409. * @param x defines the x coordinate of the operand
  83410. * @param y defines the y coordinate of the operand
  83411. * @param z defines the z coordinate of the operand
  83412. * @returns the new Vector3
  83413. */
  83414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83415. /**
  83416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83417. * @param otherVector defines the second operand
  83418. * @returns the new Vector3
  83419. */
  83420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83421. /**
  83422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83423. * @param otherVector defines the second operand
  83424. * @param result defines the Vector3 object where to store the result
  83425. * @returns the current Vector3
  83426. */
  83427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83428. /**
  83429. * Divides the current Vector3 coordinates by the given ones.
  83430. * @param otherVector defines the second operand
  83431. * @returns the current updated Vector3
  83432. */
  83433. divideInPlace(otherVector: Vector3): Vector3;
  83434. /**
  83435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83436. * @param other defines the second operand
  83437. * @returns the current updated Vector3
  83438. */
  83439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83440. /**
  83441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83442. * @param other defines the second operand
  83443. * @returns the current updated Vector3
  83444. */
  83445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83446. /**
  83447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83448. * @param x defines the x coordinate of the operand
  83449. * @param y defines the y coordinate of the operand
  83450. * @param z defines the z coordinate of the operand
  83451. * @returns the current updated Vector3
  83452. */
  83453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83454. /**
  83455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83456. * @param x defines the x coordinate of the operand
  83457. * @param y defines the y coordinate of the operand
  83458. * @param z defines the z coordinate of the operand
  83459. * @returns the current updated Vector3
  83460. */
  83461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83462. /**
  83463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83464. * Check if is non uniform within a certain amount of decimal places to account for this
  83465. * @param epsilon the amount the values can differ
  83466. * @returns if the the vector is non uniform to a certain number of decimal places
  83467. */
  83468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83469. /**
  83470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83471. */
  83472. get isNonUniform(): boolean;
  83473. /**
  83474. * Gets a new Vector3 from current Vector3 floored values
  83475. * @returns a new Vector3
  83476. */
  83477. floor(): Vector3;
  83478. /**
  83479. * Gets a new Vector3 from current Vector3 floored values
  83480. * @returns a new Vector3
  83481. */
  83482. fract(): Vector3;
  83483. /**
  83484. * Gets the length of the Vector3
  83485. * @returns the length of the Vector3
  83486. */
  83487. length(): number;
  83488. /**
  83489. * Gets the squared length of the Vector3
  83490. * @returns squared length of the Vector3
  83491. */
  83492. lengthSquared(): number;
  83493. /**
  83494. * Normalize the current Vector3.
  83495. * Please note that this is an in place operation.
  83496. * @returns the current updated Vector3
  83497. */
  83498. normalize(): Vector3;
  83499. /**
  83500. * Reorders the x y z properties of the vector in place
  83501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83502. * @returns the current updated vector
  83503. */
  83504. reorderInPlace(order: string): this;
  83505. /**
  83506. * Rotates the vector around 0,0,0 by a quaternion
  83507. * @param quaternion the rotation quaternion
  83508. * @param result vector to store the result
  83509. * @returns the resulting vector
  83510. */
  83511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83512. /**
  83513. * Rotates a vector around a given point
  83514. * @param quaternion the rotation quaternion
  83515. * @param point the point to rotate around
  83516. * @param result vector to store the result
  83517. * @returns the resulting vector
  83518. */
  83519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83520. /**
  83521. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83522. * The cross product is then orthogonal to both current and "other"
  83523. * @param other defines the right operand
  83524. * @returns the cross product
  83525. */
  83526. cross(other: Vector3): Vector3;
  83527. /**
  83528. * Normalize the current Vector3 with the given input length.
  83529. * Please note that this is an in place operation.
  83530. * @param len the length of the vector
  83531. * @returns the current updated Vector3
  83532. */
  83533. normalizeFromLength(len: number): Vector3;
  83534. /**
  83535. * Normalize the current Vector3 to a new vector
  83536. * @returns the new Vector3
  83537. */
  83538. normalizeToNew(): Vector3;
  83539. /**
  83540. * Normalize the current Vector3 to the reference
  83541. * @param reference define the Vector3 to update
  83542. * @returns the updated Vector3
  83543. */
  83544. normalizeToRef(reference: Vector3): Vector3;
  83545. /**
  83546. * Creates a new Vector3 copied from the current Vector3
  83547. * @returns the new Vector3
  83548. */
  83549. clone(): Vector3;
  83550. /**
  83551. * Copies the given vector coordinates to the current Vector3 ones
  83552. * @param source defines the source Vector3
  83553. * @returns the current updated Vector3
  83554. */
  83555. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83556. /**
  83557. * Copies the given floats to the current Vector3 coordinates
  83558. * @param x defines the x coordinate of the operand
  83559. * @param y defines the y coordinate of the operand
  83560. * @param z defines the z coordinate of the operand
  83561. * @returns the current updated Vector3
  83562. */
  83563. copyFromFloats(x: number, y: number, z: number): Vector3;
  83564. /**
  83565. * Copies the given floats to the current Vector3 coordinates
  83566. * @param x defines the x coordinate of the operand
  83567. * @param y defines the y coordinate of the operand
  83568. * @param z defines the z coordinate of the operand
  83569. * @returns the current updated Vector3
  83570. */
  83571. set(x: number, y: number, z: number): Vector3;
  83572. /**
  83573. * Copies the given float to the current Vector3 coordinates
  83574. * @param v defines the x, y and z coordinates of the operand
  83575. * @returns the current updated Vector3
  83576. */
  83577. setAll(v: number): Vector3;
  83578. /**
  83579. * Get the clip factor between two vectors
  83580. * @param vector0 defines the first operand
  83581. * @param vector1 defines the second operand
  83582. * @param axis defines the axis to use
  83583. * @param size defines the size along the axis
  83584. * @returns the clip factor
  83585. */
  83586. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83587. /**
  83588. * Get angle between two vectors
  83589. * @param vector0 angle between vector0 and vector1
  83590. * @param vector1 angle between vector0 and vector1
  83591. * @param normal direction of the normal
  83592. * @return the angle between vector0 and vector1
  83593. */
  83594. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83595. /**
  83596. * Returns a new Vector3 set from the index "offset" of the given array
  83597. * @param array defines the source array
  83598. * @param offset defines the offset in the source array
  83599. * @returns the new Vector3
  83600. */
  83601. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83602. /**
  83603. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83604. * @param array defines the source array
  83605. * @param offset defines the offset in the source array
  83606. * @returns the new Vector3
  83607. * @deprecated Please use FromArray instead.
  83608. */
  83609. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83610. /**
  83611. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83612. * @param array defines the source array
  83613. * @param offset defines the offset in the source array
  83614. * @param result defines the Vector3 where to store the result
  83615. */
  83616. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83617. /**
  83618. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83619. * @param array defines the source array
  83620. * @param offset defines the offset in the source array
  83621. * @param result defines the Vector3 where to store the result
  83622. * @deprecated Please use FromArrayToRef instead.
  83623. */
  83624. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83625. /**
  83626. * Sets the given vector "result" with the given floats.
  83627. * @param x defines the x coordinate of the source
  83628. * @param y defines the y coordinate of the source
  83629. * @param z defines the z coordinate of the source
  83630. * @param result defines the Vector3 where to store the result
  83631. */
  83632. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83633. /**
  83634. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83635. * @returns a new empty Vector3
  83636. */
  83637. static Zero(): Vector3;
  83638. /**
  83639. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83640. * @returns a new unit Vector3
  83641. */
  83642. static One(): Vector3;
  83643. /**
  83644. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83645. * @returns a new up Vector3
  83646. */
  83647. static Up(): Vector3;
  83648. /**
  83649. * Gets a up Vector3 that must not be updated
  83650. */
  83651. static get UpReadOnly(): DeepImmutable<Vector3>;
  83652. /**
  83653. * Gets a zero Vector3 that must not be updated
  83654. */
  83655. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83656. /**
  83657. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83658. * @returns a new down Vector3
  83659. */
  83660. static Down(): Vector3;
  83661. /**
  83662. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83663. * @param rightHandedSystem is the scene right-handed (negative z)
  83664. * @returns a new forward Vector3
  83665. */
  83666. static Forward(rightHandedSystem?: boolean): Vector3;
  83667. /**
  83668. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83669. * @param rightHandedSystem is the scene right-handed (negative-z)
  83670. * @returns a new forward Vector3
  83671. */
  83672. static Backward(rightHandedSystem?: boolean): Vector3;
  83673. /**
  83674. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83675. * @returns a new right Vector3
  83676. */
  83677. static Right(): Vector3;
  83678. /**
  83679. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83680. * @returns a new left Vector3
  83681. */
  83682. static Left(): Vector3;
  83683. /**
  83684. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83685. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83686. * @param vector defines the Vector3 to transform
  83687. * @param transformation defines the transformation matrix
  83688. * @returns the transformed Vector3
  83689. */
  83690. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83691. /**
  83692. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83693. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83694. * @param vector defines the Vector3 to transform
  83695. * @param transformation defines the transformation matrix
  83696. * @param result defines the Vector3 where to store the result
  83697. */
  83698. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83699. /**
  83700. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83701. * This method computes tranformed coordinates only, not transformed direction vectors
  83702. * @param x define the x coordinate of the source vector
  83703. * @param y define the y coordinate of the source vector
  83704. * @param z define the z coordinate of the source vector
  83705. * @param transformation defines the transformation matrix
  83706. * @param result defines the Vector3 where to store the result
  83707. */
  83708. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83709. /**
  83710. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83711. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83712. * @param vector defines the Vector3 to transform
  83713. * @param transformation defines the transformation matrix
  83714. * @returns the new Vector3
  83715. */
  83716. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83717. /**
  83718. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83720. * @param vector defines the Vector3 to transform
  83721. * @param transformation defines the transformation matrix
  83722. * @param result defines the Vector3 where to store the result
  83723. */
  83724. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83725. /**
  83726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83728. * @param x define the x coordinate of the source vector
  83729. * @param y define the y coordinate of the source vector
  83730. * @param z define the z coordinate of the source vector
  83731. * @param transformation defines the transformation matrix
  83732. * @param result defines the Vector3 where to store the result
  83733. */
  83734. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83735. /**
  83736. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83737. * @param value1 defines the first control point
  83738. * @param value2 defines the second control point
  83739. * @param value3 defines the third control point
  83740. * @param value4 defines the fourth control point
  83741. * @param amount defines the amount on the spline to use
  83742. * @returns the new Vector3
  83743. */
  83744. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83745. /**
  83746. * 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"
  83747. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83748. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83749. * @param value defines the current value
  83750. * @param min defines the lower range value
  83751. * @param max defines the upper range value
  83752. * @returns the new Vector3
  83753. */
  83754. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83755. /**
  83756. * 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"
  83757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83759. * @param value defines the current value
  83760. * @param min defines the lower range value
  83761. * @param max defines the upper range value
  83762. * @param result defines the Vector3 where to store the result
  83763. */
  83764. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83765. /**
  83766. * Checks if a given vector is inside a specific range
  83767. * @param v defines the vector to test
  83768. * @param min defines the minimum range
  83769. * @param max defines the maximum range
  83770. */
  83771. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83772. /**
  83773. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83774. * @param value1 defines the first control point
  83775. * @param tangent1 defines the first tangent vector
  83776. * @param value2 defines the second control point
  83777. * @param tangent2 defines the second tangent vector
  83778. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83779. * @returns the new Vector3
  83780. */
  83781. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83782. /**
  83783. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83784. * @param start defines the start value
  83785. * @param end defines the end value
  83786. * @param amount max defines amount between both (between 0 and 1)
  83787. * @returns the new Vector3
  83788. */
  83789. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83790. /**
  83791. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83792. * @param start defines the start value
  83793. * @param end defines the end value
  83794. * @param amount max defines amount between both (between 0 and 1)
  83795. * @param result defines the Vector3 where to store the result
  83796. */
  83797. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83798. /**
  83799. * Returns the dot product (float) between the vectors "left" and "right"
  83800. * @param left defines the left operand
  83801. * @param right defines the right operand
  83802. * @returns the dot product
  83803. */
  83804. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83805. /**
  83806. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83807. * The cross product is then orthogonal to both "left" and "right"
  83808. * @param left defines the left operand
  83809. * @param right defines the right operand
  83810. * @returns the cross product
  83811. */
  83812. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83813. /**
  83814. * Sets the given vector "result" with the cross product of "left" and "right"
  83815. * The cross product is then orthogonal to both "left" and "right"
  83816. * @param left defines the left operand
  83817. * @param right defines the right operand
  83818. * @param result defines the Vector3 where to store the result
  83819. */
  83820. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83821. /**
  83822. * Returns a new Vector3 as the normalization of the given vector
  83823. * @param vector defines the Vector3 to normalize
  83824. * @returns the new Vector3
  83825. */
  83826. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83827. /**
  83828. * Sets the given vector "result" with the normalization of the given first vector
  83829. * @param vector defines the Vector3 to normalize
  83830. * @param result defines the Vector3 where to store the result
  83831. */
  83832. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83833. /**
  83834. * Project a Vector3 onto screen space
  83835. * @param vector defines the Vector3 to project
  83836. * @param world defines the world matrix to use
  83837. * @param transform defines the transform (view x projection) matrix to use
  83838. * @param viewport defines the screen viewport to use
  83839. * @returns the new Vector3
  83840. */
  83841. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83842. /** @hidden */
  83843. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83844. /**
  83845. * Unproject from screen space to object space
  83846. * @param source defines the screen space Vector3 to use
  83847. * @param viewportWidth defines the current width of the viewport
  83848. * @param viewportHeight defines the current height of the viewport
  83849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83850. * @param transform defines the transform (view x projection) matrix to use
  83851. * @returns the new Vector3
  83852. */
  83853. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83854. /**
  83855. * Unproject from screen space to object space
  83856. * @param source defines the screen space Vector3 to use
  83857. * @param viewportWidth defines the current width of the viewport
  83858. * @param viewportHeight defines the current height of the viewport
  83859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83860. * @param view defines the view matrix to use
  83861. * @param projection defines the projection matrix to use
  83862. * @returns the new Vector3
  83863. */
  83864. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83865. /**
  83866. * Unproject from screen space to object space
  83867. * @param source defines the screen space Vector3 to use
  83868. * @param viewportWidth defines the current width of the viewport
  83869. * @param viewportHeight defines the current height of the viewport
  83870. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83871. * @param view defines the view matrix to use
  83872. * @param projection defines the projection matrix to use
  83873. * @param result defines the Vector3 where to store the result
  83874. */
  83875. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83876. /**
  83877. * Unproject from screen space to object space
  83878. * @param sourceX defines the screen space x coordinate to use
  83879. * @param sourceY defines the screen space y coordinate to use
  83880. * @param sourceZ defines the screen space z coordinate to use
  83881. * @param viewportWidth defines the current width of the viewport
  83882. * @param viewportHeight defines the current height of the viewport
  83883. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83884. * @param view defines the view matrix to use
  83885. * @param projection defines the projection matrix to use
  83886. * @param result defines the Vector3 where to store the result
  83887. */
  83888. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83889. /**
  83890. * Gets the minimal coordinate values between two Vector3
  83891. * @param left defines the first operand
  83892. * @param right defines the second operand
  83893. * @returns the new Vector3
  83894. */
  83895. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83896. /**
  83897. * Gets the maximal coordinate values between two Vector3
  83898. * @param left defines the first operand
  83899. * @param right defines the second operand
  83900. * @returns the new Vector3
  83901. */
  83902. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83903. /**
  83904. * Returns the distance between the vectors "value1" and "value2"
  83905. * @param value1 defines the first operand
  83906. * @param value2 defines the second operand
  83907. * @returns the distance
  83908. */
  83909. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83910. /**
  83911. * Returns the squared distance between the vectors "value1" and "value2"
  83912. * @param value1 defines the first operand
  83913. * @param value2 defines the second operand
  83914. * @returns the squared distance
  83915. */
  83916. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83917. /**
  83918. * Returns a new Vector3 located at the center between "value1" and "value2"
  83919. * @param value1 defines the first operand
  83920. * @param value2 defines the second operand
  83921. * @returns the new Vector3
  83922. */
  83923. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83924. /**
  83925. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83926. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83927. * to something in order to rotate it from its local system to the given target system
  83928. * Note: axis1, axis2 and axis3 are normalized during this operation
  83929. * @param axis1 defines the first axis
  83930. * @param axis2 defines the second axis
  83931. * @param axis3 defines the third axis
  83932. * @returns a new Vector3
  83933. */
  83934. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83935. /**
  83936. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83937. * @param axis1 defines the first axis
  83938. * @param axis2 defines the second axis
  83939. * @param axis3 defines the third axis
  83940. * @param ref defines the Vector3 where to store the result
  83941. */
  83942. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83943. }
  83944. /**
  83945. * Vector4 class created for EulerAngle class conversion to Quaternion
  83946. */
  83947. export class Vector4 {
  83948. /** x value of the vector */
  83949. x: number;
  83950. /** y value of the vector */
  83951. y: number;
  83952. /** z value of the vector */
  83953. z: number;
  83954. /** w value of the vector */
  83955. w: number;
  83956. /**
  83957. * Creates a Vector4 object from the given floats.
  83958. * @param x x value of the vector
  83959. * @param y y value of the vector
  83960. * @param z z value of the vector
  83961. * @param w w value of the vector
  83962. */
  83963. constructor(
  83964. /** x value of the vector */
  83965. x: number,
  83966. /** y value of the vector */
  83967. y: number,
  83968. /** z value of the vector */
  83969. z: number,
  83970. /** w value of the vector */
  83971. w: number);
  83972. /**
  83973. * Returns the string with the Vector4 coordinates.
  83974. * @returns a string containing all the vector values
  83975. */
  83976. toString(): string;
  83977. /**
  83978. * Returns the string "Vector4".
  83979. * @returns "Vector4"
  83980. */
  83981. getClassName(): string;
  83982. /**
  83983. * Returns the Vector4 hash code.
  83984. * @returns a unique hash code
  83985. */
  83986. getHashCode(): number;
  83987. /**
  83988. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83989. * @returns the resulting array
  83990. */
  83991. asArray(): number[];
  83992. /**
  83993. * Populates the given array from the given index with the Vector4 coordinates.
  83994. * @param array array to populate
  83995. * @param index index of the array to start at (default: 0)
  83996. * @returns the Vector4.
  83997. */
  83998. toArray(array: FloatArray, index?: number): Vector4;
  83999. /**
  84000. * Update the current vector from an array
  84001. * @param array defines the destination array
  84002. * @param index defines the offset in the destination array
  84003. * @returns the current Vector3
  84004. */
  84005. fromArray(array: FloatArray, index?: number): Vector4;
  84006. /**
  84007. * Adds the given vector to the current Vector4.
  84008. * @param otherVector the vector to add
  84009. * @returns the updated Vector4.
  84010. */
  84011. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84012. /**
  84013. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  84014. * @param otherVector the vector to add
  84015. * @returns the resulting vector
  84016. */
  84017. add(otherVector: DeepImmutable<Vector4>): Vector4;
  84018. /**
  84019. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  84020. * @param otherVector the vector to add
  84021. * @param result the vector to store the result
  84022. * @returns the current Vector4.
  84023. */
  84024. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84025. /**
  84026. * Subtract in place the given vector from the current Vector4.
  84027. * @param otherVector the vector to subtract
  84028. * @returns the updated Vector4.
  84029. */
  84030. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84031. /**
  84032. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  84033. * @param otherVector the vector to add
  84034. * @returns the new vector with the result
  84035. */
  84036. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  84037. /**
  84038. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  84039. * @param otherVector the vector to subtract
  84040. * @param result the vector to store the result
  84041. * @returns the current Vector4.
  84042. */
  84043. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84044. /**
  84045. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84046. */
  84047. /**
  84048. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84049. * @param x value to subtract
  84050. * @param y value to subtract
  84051. * @param z value to subtract
  84052. * @param w value to subtract
  84053. * @returns new vector containing the result
  84054. */
  84055. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84056. /**
  84057. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84058. * @param x value to subtract
  84059. * @param y value to subtract
  84060. * @param z value to subtract
  84061. * @param w value to subtract
  84062. * @param result the vector to store the result in
  84063. * @returns the current Vector4.
  84064. */
  84065. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  84066. /**
  84067. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  84068. * @returns a new vector with the negated values
  84069. */
  84070. negate(): Vector4;
  84071. /**
  84072. * Negate this vector in place
  84073. * @returns this
  84074. */
  84075. negateInPlace(): Vector4;
  84076. /**
  84077. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  84078. * @param result defines the Vector3 object where to store the result
  84079. * @returns the current Vector4
  84080. */
  84081. negateToRef(result: Vector4): Vector4;
  84082. /**
  84083. * Multiplies the current Vector4 coordinates by scale (float).
  84084. * @param scale the number to scale with
  84085. * @returns the updated Vector4.
  84086. */
  84087. scaleInPlace(scale: number): Vector4;
  84088. /**
  84089. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84090. * @param scale the number to scale with
  84091. * @returns a new vector with the result
  84092. */
  84093. scale(scale: number): Vector4;
  84094. /**
  84095. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84096. * @param scale the number to scale with
  84097. * @param result a vector to store the result in
  84098. * @returns the current Vector4.
  84099. */
  84100. scaleToRef(scale: number, result: Vector4): Vector4;
  84101. /**
  84102. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84103. * @param scale defines the scale factor
  84104. * @param result defines the Vector4 object where to store the result
  84105. * @returns the unmodified current Vector4
  84106. */
  84107. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84108. /**
  84109. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84110. * @param otherVector the vector to compare against
  84111. * @returns true if they are equal
  84112. */
  84113. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84114. /**
  84115. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84116. * @param otherVector vector to compare against
  84117. * @param epsilon (Default: very small number)
  84118. * @returns true if they are equal
  84119. */
  84120. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84121. /**
  84122. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84123. * @param x x value to compare against
  84124. * @param y y value to compare against
  84125. * @param z z value to compare against
  84126. * @param w w value to compare against
  84127. * @returns true if equal
  84128. */
  84129. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84130. /**
  84131. * Multiplies in place the current Vector4 by the given one.
  84132. * @param otherVector vector to multiple with
  84133. * @returns the updated Vector4.
  84134. */
  84135. multiplyInPlace(otherVector: Vector4): Vector4;
  84136. /**
  84137. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84138. * @param otherVector vector to multiple with
  84139. * @returns resulting new vector
  84140. */
  84141. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84142. /**
  84143. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84144. * @param otherVector vector to multiple with
  84145. * @param result vector to store the result
  84146. * @returns the current Vector4.
  84147. */
  84148. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84149. /**
  84150. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84151. * @param x x value multiply with
  84152. * @param y y value multiply with
  84153. * @param z z value multiply with
  84154. * @param w w value multiply with
  84155. * @returns resulting new vector
  84156. */
  84157. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84158. /**
  84159. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84160. * @param otherVector vector to devide with
  84161. * @returns resulting new vector
  84162. */
  84163. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84164. /**
  84165. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84166. * @param otherVector vector to devide with
  84167. * @param result vector to store the result
  84168. * @returns the current Vector4.
  84169. */
  84170. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84171. /**
  84172. * Divides the current Vector3 coordinates by the given ones.
  84173. * @param otherVector vector to devide with
  84174. * @returns the updated Vector3.
  84175. */
  84176. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84177. /**
  84178. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84179. * @param other defines the second operand
  84180. * @returns the current updated Vector4
  84181. */
  84182. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84183. /**
  84184. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84185. * @param other defines the second operand
  84186. * @returns the current updated Vector4
  84187. */
  84188. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84189. /**
  84190. * Gets a new Vector4 from current Vector4 floored values
  84191. * @returns a new Vector4
  84192. */
  84193. floor(): Vector4;
  84194. /**
  84195. * Gets a new Vector4 from current Vector3 floored values
  84196. * @returns a new Vector4
  84197. */
  84198. fract(): Vector4;
  84199. /**
  84200. * Returns the Vector4 length (float).
  84201. * @returns the length
  84202. */
  84203. length(): number;
  84204. /**
  84205. * Returns the Vector4 squared length (float).
  84206. * @returns the length squared
  84207. */
  84208. lengthSquared(): number;
  84209. /**
  84210. * Normalizes in place the Vector4.
  84211. * @returns the updated Vector4.
  84212. */
  84213. normalize(): Vector4;
  84214. /**
  84215. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84216. * @returns this converted to a new vector3
  84217. */
  84218. toVector3(): Vector3;
  84219. /**
  84220. * Returns a new Vector4 copied from the current one.
  84221. * @returns the new cloned vector
  84222. */
  84223. clone(): Vector4;
  84224. /**
  84225. * Updates the current Vector4 with the given one coordinates.
  84226. * @param source the source vector to copy from
  84227. * @returns the updated Vector4.
  84228. */
  84229. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84230. /**
  84231. * Updates the current Vector4 coordinates with the given floats.
  84232. * @param x float to copy from
  84233. * @param y float to copy from
  84234. * @param z float to copy from
  84235. * @param w float to copy from
  84236. * @returns the updated Vector4.
  84237. */
  84238. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84239. /**
  84240. * Updates the current Vector4 coordinates with the given floats.
  84241. * @param x float to set from
  84242. * @param y float to set from
  84243. * @param z float to set from
  84244. * @param w float to set from
  84245. * @returns the updated Vector4.
  84246. */
  84247. set(x: number, y: number, z: number, w: number): Vector4;
  84248. /**
  84249. * Copies the given float to the current Vector3 coordinates
  84250. * @param v defines the x, y, z and w coordinates of the operand
  84251. * @returns the current updated Vector3
  84252. */
  84253. setAll(v: number): Vector4;
  84254. /**
  84255. * Returns a new Vector4 set from the starting index of the given array.
  84256. * @param array the array to pull values from
  84257. * @param offset the offset into the array to start at
  84258. * @returns the new vector
  84259. */
  84260. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84261. /**
  84262. * Updates the given vector "result" from the starting index of the given array.
  84263. * @param array the array to pull values from
  84264. * @param offset the offset into the array to start at
  84265. * @param result the vector to store the result in
  84266. */
  84267. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84268. /**
  84269. * Updates the given vector "result" from the starting index of the given Float32Array.
  84270. * @param array the array to pull values from
  84271. * @param offset the offset into the array to start at
  84272. * @param result the vector to store the result in
  84273. */
  84274. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84275. /**
  84276. * Updates the given vector "result" coordinates from the given floats.
  84277. * @param x float to set from
  84278. * @param y float to set from
  84279. * @param z float to set from
  84280. * @param w float to set from
  84281. * @param result the vector to the floats in
  84282. */
  84283. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84284. /**
  84285. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84286. * @returns the new vector
  84287. */
  84288. static Zero(): Vector4;
  84289. /**
  84290. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84291. * @returns the new vector
  84292. */
  84293. static One(): Vector4;
  84294. /**
  84295. * Returns a new normalized Vector4 from the given one.
  84296. * @param vector the vector to normalize
  84297. * @returns the vector
  84298. */
  84299. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84300. /**
  84301. * Updates the given vector "result" from the normalization of the given one.
  84302. * @param vector the vector to normalize
  84303. * @param result the vector to store the result in
  84304. */
  84305. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84306. /**
  84307. * Returns a vector with the minimum values from the left and right vectors
  84308. * @param left left vector to minimize
  84309. * @param right right vector to minimize
  84310. * @returns a new vector with the minimum of the left and right vector values
  84311. */
  84312. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84313. /**
  84314. * Returns a vector with the maximum values from the left and right vectors
  84315. * @param left left vector to maximize
  84316. * @param right right vector to maximize
  84317. * @returns a new vector with the maximum of the left and right vector values
  84318. */
  84319. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84320. /**
  84321. * Returns the distance (float) between the vectors "value1" and "value2".
  84322. * @param value1 value to calulate the distance between
  84323. * @param value2 value to calulate the distance between
  84324. * @return the distance between the two vectors
  84325. */
  84326. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84327. /**
  84328. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84329. * @param value1 value to calulate the distance between
  84330. * @param value2 value to calulate the distance between
  84331. * @return the distance between the two vectors squared
  84332. */
  84333. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84334. /**
  84335. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84336. * @param value1 value to calulate the center between
  84337. * @param value2 value to calulate the center between
  84338. * @return the center between the two vectors
  84339. */
  84340. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84341. /**
  84342. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84343. * This methods computes transformed normalized direction vectors only.
  84344. * @param vector the vector to transform
  84345. * @param transformation the transformation matrix to apply
  84346. * @returns the new vector
  84347. */
  84348. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84349. /**
  84350. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84351. * This methods computes transformed normalized direction vectors only.
  84352. * @param vector the vector to transform
  84353. * @param transformation the transformation matrix to apply
  84354. * @param result the vector to store the result in
  84355. */
  84356. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84357. /**
  84358. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84359. * This methods computes transformed normalized direction vectors only.
  84360. * @param x value to transform
  84361. * @param y value to transform
  84362. * @param z value to transform
  84363. * @param w value to transform
  84364. * @param transformation the transformation matrix to apply
  84365. * @param result the vector to store the results in
  84366. */
  84367. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84368. /**
  84369. * Creates a new Vector4 from a Vector3
  84370. * @param source defines the source data
  84371. * @param w defines the 4th component (default is 0)
  84372. * @returns a new Vector4
  84373. */
  84374. static FromVector3(source: Vector3, w?: number): Vector4;
  84375. }
  84376. /**
  84377. * Class used to store quaternion data
  84378. * @see https://en.wikipedia.org/wiki/Quaternion
  84379. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84380. */
  84381. export class Quaternion {
  84382. /** @hidden */
  84383. _x: number;
  84384. /** @hidden */
  84385. _y: number;
  84386. /** @hidden */
  84387. _z: number;
  84388. /** @hidden */
  84389. _w: number;
  84390. /** @hidden */
  84391. _isDirty: boolean;
  84392. /** Gets or sets the x coordinate */
  84393. get x(): number;
  84394. set x(value: number);
  84395. /** Gets or sets the y coordinate */
  84396. get y(): number;
  84397. set y(value: number);
  84398. /** Gets or sets the z coordinate */
  84399. get z(): number;
  84400. set z(value: number);
  84401. /** Gets or sets the w coordinate */
  84402. get w(): number;
  84403. set w(value: number);
  84404. /**
  84405. * Creates a new Quaternion from the given floats
  84406. * @param x defines the first component (0 by default)
  84407. * @param y defines the second component (0 by default)
  84408. * @param z defines the third component (0 by default)
  84409. * @param w defines the fourth component (1.0 by default)
  84410. */
  84411. constructor(x?: number, y?: number, z?: number, w?: number);
  84412. /**
  84413. * Gets a string representation for the current quaternion
  84414. * @returns a string with the Quaternion coordinates
  84415. */
  84416. toString(): string;
  84417. /**
  84418. * Gets the class name of the quaternion
  84419. * @returns the string "Quaternion"
  84420. */
  84421. getClassName(): string;
  84422. /**
  84423. * Gets a hash code for this quaternion
  84424. * @returns the quaternion hash code
  84425. */
  84426. getHashCode(): number;
  84427. /**
  84428. * Copy the quaternion to an array
  84429. * @returns a new array populated with 4 elements from the quaternion coordinates
  84430. */
  84431. asArray(): number[];
  84432. /**
  84433. * Check if two quaternions are equals
  84434. * @param otherQuaternion defines the second operand
  84435. * @return true if the current quaternion and the given one coordinates are strictly equals
  84436. */
  84437. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84438. /**
  84439. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84440. * @param otherQuaternion defines the other quaternion
  84441. * @param epsilon defines the minimal distance to consider equality
  84442. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84443. */
  84444. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84445. /**
  84446. * Clone the current quaternion
  84447. * @returns a new quaternion copied from the current one
  84448. */
  84449. clone(): Quaternion;
  84450. /**
  84451. * Copy a quaternion to the current one
  84452. * @param other defines the other quaternion
  84453. * @returns the updated current quaternion
  84454. */
  84455. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84456. /**
  84457. * Updates the current quaternion with the given float coordinates
  84458. * @param x defines the x coordinate
  84459. * @param y defines the y coordinate
  84460. * @param z defines the z coordinate
  84461. * @param w defines the w coordinate
  84462. * @returns the updated current quaternion
  84463. */
  84464. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84465. /**
  84466. * Updates the current quaternion from the given float coordinates
  84467. * @param x defines the x coordinate
  84468. * @param y defines the y coordinate
  84469. * @param z defines the z coordinate
  84470. * @param w defines the w coordinate
  84471. * @returns the updated current quaternion
  84472. */
  84473. set(x: number, y: number, z: number, w: number): Quaternion;
  84474. /**
  84475. * Adds two quaternions
  84476. * @param other defines the second operand
  84477. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84478. */
  84479. add(other: DeepImmutable<Quaternion>): Quaternion;
  84480. /**
  84481. * Add a quaternion to the current one
  84482. * @param other defines the quaternion to add
  84483. * @returns the current quaternion
  84484. */
  84485. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84486. /**
  84487. * Subtract two quaternions
  84488. * @param other defines the second operand
  84489. * @returns a new quaternion as the subtraction result of the given one from the current one
  84490. */
  84491. subtract(other: Quaternion): Quaternion;
  84492. /**
  84493. * Multiplies the current quaternion by a scale factor
  84494. * @param value defines the scale factor
  84495. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84496. */
  84497. scale(value: number): Quaternion;
  84498. /**
  84499. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84500. * @param scale defines the scale factor
  84501. * @param result defines the Quaternion object where to store the result
  84502. * @returns the unmodified current quaternion
  84503. */
  84504. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84505. /**
  84506. * Multiplies in place the current quaternion by a scale factor
  84507. * @param value defines the scale factor
  84508. * @returns the current modified quaternion
  84509. */
  84510. scaleInPlace(value: number): Quaternion;
  84511. /**
  84512. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84513. * @param scale defines the scale factor
  84514. * @param result defines the Quaternion object where to store the result
  84515. * @returns the unmodified current quaternion
  84516. */
  84517. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84518. /**
  84519. * Multiplies two quaternions
  84520. * @param q1 defines the second operand
  84521. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84522. */
  84523. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84524. /**
  84525. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84526. * @param q1 defines the second operand
  84527. * @param result defines the target quaternion
  84528. * @returns the current quaternion
  84529. */
  84530. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84531. /**
  84532. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84533. * @param q1 defines the second operand
  84534. * @returns the currentupdated quaternion
  84535. */
  84536. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84537. /**
  84538. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84539. * @param ref defines the target quaternion
  84540. * @returns the current quaternion
  84541. */
  84542. conjugateToRef(ref: Quaternion): Quaternion;
  84543. /**
  84544. * Conjugates in place (1-q) the current quaternion
  84545. * @returns the current updated quaternion
  84546. */
  84547. conjugateInPlace(): Quaternion;
  84548. /**
  84549. * Conjugates in place (1-q) the current quaternion
  84550. * @returns a new quaternion
  84551. */
  84552. conjugate(): Quaternion;
  84553. /**
  84554. * Gets length of current quaternion
  84555. * @returns the quaternion length (float)
  84556. */
  84557. length(): number;
  84558. /**
  84559. * Normalize in place the current quaternion
  84560. * @returns the current updated quaternion
  84561. */
  84562. normalize(): Quaternion;
  84563. /**
  84564. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84565. * @param order is a reserved parameter and is ignored for now
  84566. * @returns a new Vector3 containing the Euler angles
  84567. */
  84568. toEulerAngles(order?: string): Vector3;
  84569. /**
  84570. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84571. * @param result defines the vector which will be filled with the Euler angles
  84572. * @returns the current unchanged quaternion
  84573. */
  84574. toEulerAnglesToRef(result: Vector3): Quaternion;
  84575. /**
  84576. * Updates the given rotation matrix with the current quaternion values
  84577. * @param result defines the target matrix
  84578. * @returns the current unchanged quaternion
  84579. */
  84580. toRotationMatrix(result: Matrix): Quaternion;
  84581. /**
  84582. * Updates the current quaternion from the given rotation matrix values
  84583. * @param matrix defines the source matrix
  84584. * @returns the current updated quaternion
  84585. */
  84586. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84587. /**
  84588. * Creates a new quaternion from a rotation matrix
  84589. * @param matrix defines the source matrix
  84590. * @returns a new quaternion created from the given rotation matrix values
  84591. */
  84592. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84593. /**
  84594. * Updates the given quaternion with the given rotation matrix values
  84595. * @param matrix defines the source matrix
  84596. * @param result defines the target quaternion
  84597. */
  84598. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84599. /**
  84600. * Returns the dot product (float) between the quaternions "left" and "right"
  84601. * @param left defines the left operand
  84602. * @param right defines the right operand
  84603. * @returns the dot product
  84604. */
  84605. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84606. /**
  84607. * Checks if the two quaternions are close to each other
  84608. * @param quat0 defines the first quaternion to check
  84609. * @param quat1 defines the second quaternion to check
  84610. * @returns true if the two quaternions are close to each other
  84611. */
  84612. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84613. /**
  84614. * Creates an empty quaternion
  84615. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84616. */
  84617. static Zero(): Quaternion;
  84618. /**
  84619. * Inverse a given quaternion
  84620. * @param q defines the source quaternion
  84621. * @returns a new quaternion as the inverted current quaternion
  84622. */
  84623. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84624. /**
  84625. * Inverse a given quaternion
  84626. * @param q defines the source quaternion
  84627. * @param result the quaternion the result will be stored in
  84628. * @returns the result quaternion
  84629. */
  84630. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84631. /**
  84632. * Creates an identity quaternion
  84633. * @returns the identity quaternion
  84634. */
  84635. static Identity(): Quaternion;
  84636. /**
  84637. * Gets a boolean indicating if the given quaternion is identity
  84638. * @param quaternion defines the quaternion to check
  84639. * @returns true if the quaternion is identity
  84640. */
  84641. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84642. /**
  84643. * Creates a quaternion from a rotation around an axis
  84644. * @param axis defines the axis to use
  84645. * @param angle defines the angle to use
  84646. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84647. */
  84648. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84649. /**
  84650. * Creates a rotation around an axis and stores it into the given quaternion
  84651. * @param axis defines the axis to use
  84652. * @param angle defines the angle to use
  84653. * @param result defines the target quaternion
  84654. * @returns the target quaternion
  84655. */
  84656. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84657. /**
  84658. * Creates a new quaternion from data stored into an array
  84659. * @param array defines the data source
  84660. * @param offset defines the offset in the source array where the data starts
  84661. * @returns a new quaternion
  84662. */
  84663. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84664. /**
  84665. * Updates the given quaternion "result" from the starting index of the given array.
  84666. * @param array the array to pull values from
  84667. * @param offset the offset into the array to start at
  84668. * @param result the quaternion to store the result in
  84669. */
  84670. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84671. /**
  84672. * Create a quaternion from Euler rotation angles
  84673. * @param x Pitch
  84674. * @param y Yaw
  84675. * @param z Roll
  84676. * @returns the new Quaternion
  84677. */
  84678. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84679. /**
  84680. * Updates a quaternion from Euler rotation angles
  84681. * @param x Pitch
  84682. * @param y Yaw
  84683. * @param z Roll
  84684. * @param result the quaternion to store the result
  84685. * @returns the updated quaternion
  84686. */
  84687. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84688. /**
  84689. * Create a quaternion from Euler rotation vector
  84690. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84691. * @returns the new Quaternion
  84692. */
  84693. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84694. /**
  84695. * Updates a quaternion from Euler rotation vector
  84696. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84697. * @param result the quaternion to store the result
  84698. * @returns the updated quaternion
  84699. */
  84700. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84701. /**
  84702. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84703. * @param yaw defines the rotation around Y axis
  84704. * @param pitch defines the rotation around X axis
  84705. * @param roll defines the rotation around Z axis
  84706. * @returns the new quaternion
  84707. */
  84708. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84709. /**
  84710. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84711. * @param yaw defines the rotation around Y axis
  84712. * @param pitch defines the rotation around X axis
  84713. * @param roll defines the rotation around Z axis
  84714. * @param result defines the target quaternion
  84715. */
  84716. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84717. /**
  84718. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84719. * @param alpha defines the rotation around first axis
  84720. * @param beta defines the rotation around second axis
  84721. * @param gamma defines the rotation around third axis
  84722. * @returns the new quaternion
  84723. */
  84724. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84725. /**
  84726. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84727. * @param alpha defines the rotation around first axis
  84728. * @param beta defines the rotation around second axis
  84729. * @param gamma defines the rotation around third axis
  84730. * @param result defines the target quaternion
  84731. */
  84732. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84733. /**
  84734. * 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)
  84735. * @param axis1 defines the first axis
  84736. * @param axis2 defines the second axis
  84737. * @param axis3 defines the third axis
  84738. * @returns the new quaternion
  84739. */
  84740. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84741. /**
  84742. * 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
  84743. * @param axis1 defines the first axis
  84744. * @param axis2 defines the second axis
  84745. * @param axis3 defines the third axis
  84746. * @param ref defines the target quaternion
  84747. */
  84748. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84749. /**
  84750. * Interpolates between two quaternions
  84751. * @param left defines first quaternion
  84752. * @param right defines second quaternion
  84753. * @param amount defines the gradient to use
  84754. * @returns the new interpolated quaternion
  84755. */
  84756. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84757. /**
  84758. * Interpolates between two quaternions and stores it into a target quaternion
  84759. * @param left defines first quaternion
  84760. * @param right defines second quaternion
  84761. * @param amount defines the gradient to use
  84762. * @param result defines the target quaternion
  84763. */
  84764. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84765. /**
  84766. * Interpolate between two quaternions using Hermite interpolation
  84767. * @param value1 defines first quaternion
  84768. * @param tangent1 defines the incoming tangent
  84769. * @param value2 defines second quaternion
  84770. * @param tangent2 defines the outgoing tangent
  84771. * @param amount defines the target quaternion
  84772. * @returns the new interpolated quaternion
  84773. */
  84774. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84775. }
  84776. /**
  84777. * Class used to store matrix data (4x4)
  84778. */
  84779. export class Matrix {
  84780. /**
  84781. * Gets the precision of matrix computations
  84782. */
  84783. static get Use64Bits(): boolean;
  84784. private static _updateFlagSeed;
  84785. private static _identityReadOnly;
  84786. private _isIdentity;
  84787. private _isIdentityDirty;
  84788. private _isIdentity3x2;
  84789. private _isIdentity3x2Dirty;
  84790. /**
  84791. * Gets the update flag of the matrix which is an unique number for the matrix.
  84792. * It will be incremented every time the matrix data change.
  84793. * You can use it to speed the comparison between two versions of the same matrix.
  84794. */
  84795. updateFlag: number;
  84796. private readonly _m;
  84797. /**
  84798. * Gets the internal data of the matrix
  84799. */
  84800. get m(): DeepImmutable<Float32Array | Array<number>>;
  84801. /** @hidden */
  84802. _markAsUpdated(): void;
  84803. /** @hidden */
  84804. private _updateIdentityStatus;
  84805. /**
  84806. * Creates an empty matrix (filled with zeros)
  84807. */
  84808. constructor();
  84809. /**
  84810. * Check if the current matrix is identity
  84811. * @returns true is the matrix is the identity matrix
  84812. */
  84813. isIdentity(): boolean;
  84814. /**
  84815. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84816. * @returns true is the matrix is the identity matrix
  84817. */
  84818. isIdentityAs3x2(): boolean;
  84819. /**
  84820. * Gets the determinant of the matrix
  84821. * @returns the matrix determinant
  84822. */
  84823. determinant(): number;
  84824. /**
  84825. * Returns the matrix as a Float32Array or Array<number>
  84826. * @returns the matrix underlying array
  84827. */
  84828. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84829. /**
  84830. * Returns the matrix as a Float32Array or Array<number>
  84831. * @returns the matrix underlying array.
  84832. */
  84833. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84834. /**
  84835. * Inverts the current matrix in place
  84836. * @returns the current inverted matrix
  84837. */
  84838. invert(): Matrix;
  84839. /**
  84840. * Sets all the matrix elements to zero
  84841. * @returns the current matrix
  84842. */
  84843. reset(): Matrix;
  84844. /**
  84845. * Adds the current matrix with a second one
  84846. * @param other defines the matrix to add
  84847. * @returns a new matrix as the addition of the current matrix and the given one
  84848. */
  84849. add(other: DeepImmutable<Matrix>): Matrix;
  84850. /**
  84851. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84852. * @param other defines the matrix to add
  84853. * @param result defines the target matrix
  84854. * @returns the current matrix
  84855. */
  84856. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84857. /**
  84858. * Adds in place the given matrix to the current matrix
  84859. * @param other defines the second operand
  84860. * @returns the current updated matrix
  84861. */
  84862. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84863. /**
  84864. * Sets the given matrix to the current inverted Matrix
  84865. * @param other defines the target matrix
  84866. * @returns the unmodified current matrix
  84867. */
  84868. invertToRef(other: Matrix): Matrix;
  84869. /**
  84870. * add a value at the specified position in the current Matrix
  84871. * @param index the index of the value within the matrix. between 0 and 15.
  84872. * @param value the value to be added
  84873. * @returns the current updated matrix
  84874. */
  84875. addAtIndex(index: number, value: number): Matrix;
  84876. /**
  84877. * mutiply the specified position in the current Matrix by a value
  84878. * @param index the index of the value within the matrix. between 0 and 15.
  84879. * @param value the value to be added
  84880. * @returns the current updated matrix
  84881. */
  84882. multiplyAtIndex(index: number, value: number): Matrix;
  84883. /**
  84884. * Inserts the translation vector (using 3 floats) in the current matrix
  84885. * @param x defines the 1st component of the translation
  84886. * @param y defines the 2nd component of the translation
  84887. * @param z defines the 3rd component of the translation
  84888. * @returns the current updated matrix
  84889. */
  84890. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84891. /**
  84892. * Adds the translation vector (using 3 floats) in the current matrix
  84893. * @param x defines the 1st component of the translation
  84894. * @param y defines the 2nd component of the translation
  84895. * @param z defines the 3rd component of the translation
  84896. * @returns the current updated matrix
  84897. */
  84898. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84899. /**
  84900. * Inserts the translation vector in the current matrix
  84901. * @param vector3 defines the translation to insert
  84902. * @returns the current updated matrix
  84903. */
  84904. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84905. /**
  84906. * Gets the translation value of the current matrix
  84907. * @returns a new Vector3 as the extracted translation from the matrix
  84908. */
  84909. getTranslation(): Vector3;
  84910. /**
  84911. * Fill a Vector3 with the extracted translation from the matrix
  84912. * @param result defines the Vector3 where to store the translation
  84913. * @returns the current matrix
  84914. */
  84915. getTranslationToRef(result: Vector3): Matrix;
  84916. /**
  84917. * Remove rotation and scaling part from the matrix
  84918. * @returns the updated matrix
  84919. */
  84920. removeRotationAndScaling(): Matrix;
  84921. /**
  84922. * Multiply two matrices
  84923. * @param other defines the second operand
  84924. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84925. */
  84926. multiply(other: DeepImmutable<Matrix>): Matrix;
  84927. /**
  84928. * Copy the current matrix from the given one
  84929. * @param other defines the source matrix
  84930. * @returns the current updated matrix
  84931. */
  84932. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84933. /**
  84934. * Populates the given array from the starting index with the current matrix values
  84935. * @param array defines the target array
  84936. * @param offset defines the offset in the target array where to start storing values
  84937. * @returns the current matrix
  84938. */
  84939. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84940. /**
  84941. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84942. * @param other defines the second operand
  84943. * @param result defines the matrix where to store the multiplication
  84944. * @returns the current matrix
  84945. */
  84946. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84947. /**
  84948. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84949. * @param other defines the second operand
  84950. * @param result defines the array where to store the multiplication
  84951. * @param offset defines the offset in the target array where to start storing values
  84952. * @returns the current matrix
  84953. */
  84954. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84955. /**
  84956. * Check equality between this matrix and a second one
  84957. * @param value defines the second matrix to compare
  84958. * @returns true is the current matrix and the given one values are strictly equal
  84959. */
  84960. equals(value: DeepImmutable<Matrix>): boolean;
  84961. /**
  84962. * Clone the current matrix
  84963. * @returns a new matrix from the current matrix
  84964. */
  84965. clone(): Matrix;
  84966. /**
  84967. * Returns the name of the current matrix class
  84968. * @returns the string "Matrix"
  84969. */
  84970. getClassName(): string;
  84971. /**
  84972. * Gets the hash code of the current matrix
  84973. * @returns the hash code
  84974. */
  84975. getHashCode(): number;
  84976. /**
  84977. * Decomposes the current Matrix into a translation, rotation and scaling components
  84978. * @param scale defines the scale vector3 given as a reference to update
  84979. * @param rotation defines the rotation quaternion given as a reference to update
  84980. * @param translation defines the translation vector3 given as a reference to update
  84981. * @returns true if operation was successful
  84982. */
  84983. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84984. /**
  84985. * Gets specific row of the matrix
  84986. * @param index defines the number of the row to get
  84987. * @returns the index-th row of the current matrix as a new Vector4
  84988. */
  84989. getRow(index: number): Nullable<Vector4>;
  84990. /**
  84991. * Sets the index-th row of the current matrix to the vector4 values
  84992. * @param index defines the number of the row to set
  84993. * @param row defines the target vector4
  84994. * @returns the updated current matrix
  84995. */
  84996. setRow(index: number, row: Vector4): Matrix;
  84997. /**
  84998. * Compute the transpose of the matrix
  84999. * @returns the new transposed matrix
  85000. */
  85001. transpose(): Matrix;
  85002. /**
  85003. * Compute the transpose of the matrix and store it in a given matrix
  85004. * @param result defines the target matrix
  85005. * @returns the current matrix
  85006. */
  85007. transposeToRef(result: Matrix): Matrix;
  85008. /**
  85009. * Sets the index-th row of the current matrix with the given 4 x float values
  85010. * @param index defines the row index
  85011. * @param x defines the x component to set
  85012. * @param y defines the y component to set
  85013. * @param z defines the z component to set
  85014. * @param w defines the w component to set
  85015. * @returns the updated current matrix
  85016. */
  85017. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  85018. /**
  85019. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  85020. * @param scale defines the scale factor
  85021. * @returns a new matrix
  85022. */
  85023. scale(scale: number): Matrix;
  85024. /**
  85025. * Scale the current matrix values by a factor to a given result matrix
  85026. * @param scale defines the scale factor
  85027. * @param result defines the matrix to store the result
  85028. * @returns the current matrix
  85029. */
  85030. scaleToRef(scale: number, result: Matrix): Matrix;
  85031. /**
  85032. * Scale the current matrix values by a factor and add the result to a given matrix
  85033. * @param scale defines the scale factor
  85034. * @param result defines the Matrix to store the result
  85035. * @returns the current matrix
  85036. */
  85037. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  85038. /**
  85039. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  85040. * @param ref matrix to store the result
  85041. */
  85042. toNormalMatrix(ref: Matrix): void;
  85043. /**
  85044. * Gets only rotation part of the current matrix
  85045. * @returns a new matrix sets to the extracted rotation matrix from the current one
  85046. */
  85047. getRotationMatrix(): Matrix;
  85048. /**
  85049. * Extracts the rotation matrix from the current one and sets it as the given "result"
  85050. * @param result defines the target matrix to store data to
  85051. * @returns the current matrix
  85052. */
  85053. getRotationMatrixToRef(result: Matrix): Matrix;
  85054. /**
  85055. * Toggles model matrix from being right handed to left handed in place and vice versa
  85056. */
  85057. toggleModelMatrixHandInPlace(): void;
  85058. /**
  85059. * Toggles projection matrix from being right handed to left handed in place and vice versa
  85060. */
  85061. toggleProjectionMatrixHandInPlace(): void;
  85062. /**
  85063. * Creates a matrix from an array
  85064. * @param array defines the source array
  85065. * @param offset defines an offset in the source array
  85066. * @returns a new Matrix set from the starting index of the given array
  85067. */
  85068. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  85069. /**
  85070. * Copy the content of an array into a given matrix
  85071. * @param array defines the source array
  85072. * @param offset defines an offset in the source array
  85073. * @param result defines the target matrix
  85074. */
  85075. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  85076. /**
  85077. * Stores an array into a matrix after having multiplied each component by a given factor
  85078. * @param array defines the source array
  85079. * @param offset defines the offset in the source array
  85080. * @param scale defines the scaling factor
  85081. * @param result defines the target matrix
  85082. */
  85083. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  85084. /**
  85085. * Gets an identity matrix that must not be updated
  85086. */
  85087. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85088. /**
  85089. * Stores a list of values (16) inside a given matrix
  85090. * @param initialM11 defines 1st value of 1st row
  85091. * @param initialM12 defines 2nd value of 1st row
  85092. * @param initialM13 defines 3rd value of 1st row
  85093. * @param initialM14 defines 4th value of 1st row
  85094. * @param initialM21 defines 1st value of 2nd row
  85095. * @param initialM22 defines 2nd value of 2nd row
  85096. * @param initialM23 defines 3rd value of 2nd row
  85097. * @param initialM24 defines 4th value of 2nd row
  85098. * @param initialM31 defines 1st value of 3rd row
  85099. * @param initialM32 defines 2nd value of 3rd row
  85100. * @param initialM33 defines 3rd value of 3rd row
  85101. * @param initialM34 defines 4th value of 3rd row
  85102. * @param initialM41 defines 1st value of 4th row
  85103. * @param initialM42 defines 2nd value of 4th row
  85104. * @param initialM43 defines 3rd value of 4th row
  85105. * @param initialM44 defines 4th value of 4th row
  85106. * @param result defines the target matrix
  85107. */
  85108. 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;
  85109. /**
  85110. * Creates new matrix from a list of values (16)
  85111. * @param initialM11 defines 1st value of 1st row
  85112. * @param initialM12 defines 2nd value of 1st row
  85113. * @param initialM13 defines 3rd value of 1st row
  85114. * @param initialM14 defines 4th value of 1st row
  85115. * @param initialM21 defines 1st value of 2nd row
  85116. * @param initialM22 defines 2nd value of 2nd row
  85117. * @param initialM23 defines 3rd value of 2nd row
  85118. * @param initialM24 defines 4th value of 2nd row
  85119. * @param initialM31 defines 1st value of 3rd row
  85120. * @param initialM32 defines 2nd value of 3rd row
  85121. * @param initialM33 defines 3rd value of 3rd row
  85122. * @param initialM34 defines 4th value of 3rd row
  85123. * @param initialM41 defines 1st value of 4th row
  85124. * @param initialM42 defines 2nd value of 4th row
  85125. * @param initialM43 defines 3rd value of 4th row
  85126. * @param initialM44 defines 4th value of 4th row
  85127. * @returns the new matrix
  85128. */
  85129. 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;
  85130. /**
  85131. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85132. * @param scale defines the scale vector3
  85133. * @param rotation defines the rotation quaternion
  85134. * @param translation defines the translation vector3
  85135. * @returns a new matrix
  85136. */
  85137. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85138. /**
  85139. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85140. * @param scale defines the scale vector3
  85141. * @param rotation defines the rotation quaternion
  85142. * @param translation defines the translation vector3
  85143. * @param result defines the target matrix
  85144. */
  85145. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85146. /**
  85147. * Creates a new identity matrix
  85148. * @returns a new identity matrix
  85149. */
  85150. static Identity(): Matrix;
  85151. /**
  85152. * Creates a new identity matrix and stores the result in a given matrix
  85153. * @param result defines the target matrix
  85154. */
  85155. static IdentityToRef(result: Matrix): void;
  85156. /**
  85157. * Creates a new zero matrix
  85158. * @returns a new zero matrix
  85159. */
  85160. static Zero(): Matrix;
  85161. /**
  85162. * Creates a new rotation matrix for "angle" radians around the X axis
  85163. * @param angle defines the angle (in radians) to use
  85164. * @return the new matrix
  85165. */
  85166. static RotationX(angle: number): Matrix;
  85167. /**
  85168. * Creates a new matrix as the invert of a given matrix
  85169. * @param source defines the source matrix
  85170. * @returns the new matrix
  85171. */
  85172. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85173. /**
  85174. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85175. * @param angle defines the angle (in radians) to use
  85176. * @param result defines the target matrix
  85177. */
  85178. static RotationXToRef(angle: number, result: Matrix): void;
  85179. /**
  85180. * Creates a new rotation matrix for "angle" radians around the Y axis
  85181. * @param angle defines the angle (in radians) to use
  85182. * @return the new matrix
  85183. */
  85184. static RotationY(angle: number): Matrix;
  85185. /**
  85186. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85187. * @param angle defines the angle (in radians) to use
  85188. * @param result defines the target matrix
  85189. */
  85190. static RotationYToRef(angle: number, result: Matrix): void;
  85191. /**
  85192. * Creates a new rotation matrix for "angle" radians around the Z axis
  85193. * @param angle defines the angle (in radians) to use
  85194. * @return the new matrix
  85195. */
  85196. static RotationZ(angle: number): Matrix;
  85197. /**
  85198. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85199. * @param angle defines the angle (in radians) to use
  85200. * @param result defines the target matrix
  85201. */
  85202. static RotationZToRef(angle: number, result: Matrix): void;
  85203. /**
  85204. * Creates a new rotation matrix for "angle" radians around the given axis
  85205. * @param axis defines the axis to use
  85206. * @param angle defines the angle (in radians) to use
  85207. * @return the new matrix
  85208. */
  85209. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85210. /**
  85211. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85212. * @param axis defines the axis to use
  85213. * @param angle defines the angle (in radians) to use
  85214. * @param result defines the target matrix
  85215. */
  85216. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85217. /**
  85218. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85219. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85220. * @param from defines the vector to align
  85221. * @param to defines the vector to align to
  85222. * @param result defines the target matrix
  85223. */
  85224. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85225. /**
  85226. * Creates a rotation matrix
  85227. * @param yaw defines the yaw angle in radians (Y axis)
  85228. * @param pitch defines the pitch angle in radians (X axis)
  85229. * @param roll defines the roll angle in radians (Z axis)
  85230. * @returns the new rotation matrix
  85231. */
  85232. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85233. /**
  85234. * Creates a rotation matrix and stores it in a given matrix
  85235. * @param yaw defines the yaw angle in radians (Y axis)
  85236. * @param pitch defines the pitch angle in radians (X axis)
  85237. * @param roll defines the roll angle in radians (Z axis)
  85238. * @param result defines the target matrix
  85239. */
  85240. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85241. /**
  85242. * Creates a scaling matrix
  85243. * @param x defines the scale factor on X axis
  85244. * @param y defines the scale factor on Y axis
  85245. * @param z defines the scale factor on Z axis
  85246. * @returns the new matrix
  85247. */
  85248. static Scaling(x: number, y: number, z: number): Matrix;
  85249. /**
  85250. * Creates a scaling matrix and stores it in a given matrix
  85251. * @param x defines the scale factor on X axis
  85252. * @param y defines the scale factor on Y axis
  85253. * @param z defines the scale factor on Z axis
  85254. * @param result defines the target matrix
  85255. */
  85256. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85257. /**
  85258. * Creates a translation matrix
  85259. * @param x defines the translation on X axis
  85260. * @param y defines the translation on Y axis
  85261. * @param z defines the translationon Z axis
  85262. * @returns the new matrix
  85263. */
  85264. static Translation(x: number, y: number, z: number): Matrix;
  85265. /**
  85266. * Creates a translation matrix and stores it in a given matrix
  85267. * @param x defines the translation on X axis
  85268. * @param y defines the translation on Y axis
  85269. * @param z defines the translationon Z axis
  85270. * @param result defines the target matrix
  85271. */
  85272. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85273. /**
  85274. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85275. * @param startValue defines the start value
  85276. * @param endValue defines the end value
  85277. * @param gradient defines the gradient factor
  85278. * @returns the new matrix
  85279. */
  85280. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85281. /**
  85282. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85283. * @param startValue defines the start value
  85284. * @param endValue defines the end value
  85285. * @param gradient defines the gradient factor
  85286. * @param result defines the Matrix object where to store data
  85287. */
  85288. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85289. /**
  85290. * Builds a new matrix whose values are computed by:
  85291. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85292. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85293. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85294. * @param startValue defines the first matrix
  85295. * @param endValue defines the second matrix
  85296. * @param gradient defines the gradient between the two matrices
  85297. * @returns the new matrix
  85298. */
  85299. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85300. /**
  85301. * Update a matrix to values which are computed by:
  85302. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85303. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85304. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85305. * @param startValue defines the first matrix
  85306. * @param endValue defines the second matrix
  85307. * @param gradient defines the gradient between the two matrices
  85308. * @param result defines the target matrix
  85309. */
  85310. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85311. /**
  85312. * 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"
  85313. * This function works in left handed mode
  85314. * @param eye defines the final position of the entity
  85315. * @param target defines where the entity should look at
  85316. * @param up defines the up vector for the entity
  85317. * @returns the new matrix
  85318. */
  85319. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85320. /**
  85321. * 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".
  85322. * This function works in left handed mode
  85323. * @param eye defines the final position of the entity
  85324. * @param target defines where the entity should look at
  85325. * @param up defines the up vector for the entity
  85326. * @param result defines the target matrix
  85327. */
  85328. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85329. /**
  85330. * 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"
  85331. * This function works in right handed mode
  85332. * @param eye defines the final position of the entity
  85333. * @param target defines where the entity should look at
  85334. * @param up defines the up vector for the entity
  85335. * @returns the new matrix
  85336. */
  85337. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85338. /**
  85339. * 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".
  85340. * This function works in right handed mode
  85341. * @param eye defines the final position of the entity
  85342. * @param target defines where the entity should look at
  85343. * @param up defines the up vector for the entity
  85344. * @param result defines the target matrix
  85345. */
  85346. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85347. /**
  85348. * Create a left-handed orthographic projection matrix
  85349. * @param width defines the viewport width
  85350. * @param height defines the viewport height
  85351. * @param znear defines the near clip plane
  85352. * @param zfar defines the far clip plane
  85353. * @returns a new matrix as a left-handed orthographic projection matrix
  85354. */
  85355. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85356. /**
  85357. * Store a left-handed orthographic projection to a given matrix
  85358. * @param width defines the viewport width
  85359. * @param height defines the viewport height
  85360. * @param znear defines the near clip plane
  85361. * @param zfar defines the far clip plane
  85362. * @param result defines the target matrix
  85363. */
  85364. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85365. /**
  85366. * Create a left-handed orthographic projection matrix
  85367. * @param left defines the viewport left coordinate
  85368. * @param right defines the viewport right coordinate
  85369. * @param bottom defines the viewport bottom coordinate
  85370. * @param top defines the viewport top coordinate
  85371. * @param znear defines the near clip plane
  85372. * @param zfar defines the far clip plane
  85373. * @returns a new matrix as a left-handed orthographic projection matrix
  85374. */
  85375. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85376. /**
  85377. * Stores a left-handed orthographic projection into a given matrix
  85378. * @param left defines the viewport left coordinate
  85379. * @param right defines the viewport right coordinate
  85380. * @param bottom defines the viewport bottom coordinate
  85381. * @param top defines the viewport top coordinate
  85382. * @param znear defines the near clip plane
  85383. * @param zfar defines the far clip plane
  85384. * @param result defines the target matrix
  85385. */
  85386. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85387. /**
  85388. * Creates a right-handed orthographic projection matrix
  85389. * @param left defines the viewport left coordinate
  85390. * @param right defines the viewport right coordinate
  85391. * @param bottom defines the viewport bottom coordinate
  85392. * @param top defines the viewport top coordinate
  85393. * @param znear defines the near clip plane
  85394. * @param zfar defines the far clip plane
  85395. * @returns a new matrix as a right-handed orthographic projection matrix
  85396. */
  85397. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85398. /**
  85399. * Stores a right-handed orthographic projection into a given matrix
  85400. * @param left defines the viewport left coordinate
  85401. * @param right defines the viewport right coordinate
  85402. * @param bottom defines the viewport bottom coordinate
  85403. * @param top defines the viewport top coordinate
  85404. * @param znear defines the near clip plane
  85405. * @param zfar defines the far clip plane
  85406. * @param result defines the target matrix
  85407. */
  85408. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85409. /**
  85410. * Creates a left-handed perspective projection matrix
  85411. * @param width defines the viewport width
  85412. * @param height defines the viewport height
  85413. * @param znear defines the near clip plane
  85414. * @param zfar defines the far clip plane
  85415. * @returns a new matrix as a left-handed perspective projection matrix
  85416. */
  85417. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85418. /**
  85419. * Creates a left-handed perspective projection matrix
  85420. * @param fov defines the horizontal field of view
  85421. * @param aspect defines the aspect ratio
  85422. * @param znear defines the near clip plane
  85423. * @param zfar defines the far clip plane
  85424. * @returns a new matrix as a left-handed perspective projection matrix
  85425. */
  85426. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85427. /**
  85428. * Stores a left-handed perspective projection into a given matrix
  85429. * @param fov defines the horizontal field of view
  85430. * @param aspect defines the aspect ratio
  85431. * @param znear defines the near clip plane
  85432. * @param zfar defines the far clip plane
  85433. * @param result defines the target matrix
  85434. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85435. */
  85436. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85437. /**
  85438. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85439. * @param fov defines the horizontal field of view
  85440. * @param aspect defines the aspect ratio
  85441. * @param znear defines the near clip plane
  85442. * @param zfar not used as infinity is used as far clip
  85443. * @param result defines the target matrix
  85444. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85445. */
  85446. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85447. /**
  85448. * Creates a right-handed perspective projection matrix
  85449. * @param fov defines the horizontal field of view
  85450. * @param aspect defines the aspect ratio
  85451. * @param znear defines the near clip plane
  85452. * @param zfar defines the far clip plane
  85453. * @returns a new matrix as a right-handed perspective projection matrix
  85454. */
  85455. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85456. /**
  85457. * Stores a right-handed perspective projection into a given matrix
  85458. * @param fov defines the horizontal field of view
  85459. * @param aspect defines the aspect ratio
  85460. * @param znear defines the near clip plane
  85461. * @param zfar defines the far clip plane
  85462. * @param result defines the target matrix
  85463. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85464. */
  85465. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85466. /**
  85467. * Stores a right-handed perspective projection into a given matrix
  85468. * @param fov defines the horizontal field of view
  85469. * @param aspect defines the aspect ratio
  85470. * @param znear defines the near clip plane
  85471. * @param zfar not used as infinity is used as far clip
  85472. * @param result defines the target matrix
  85473. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85474. */
  85475. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85476. /**
  85477. * Stores a perspective projection for WebVR info a given matrix
  85478. * @param fov defines the field of view
  85479. * @param znear defines the near clip plane
  85480. * @param zfar defines the far clip plane
  85481. * @param result defines the target matrix
  85482. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85483. */
  85484. static PerspectiveFovWebVRToRef(fov: {
  85485. upDegrees: number;
  85486. downDegrees: number;
  85487. leftDegrees: number;
  85488. rightDegrees: number;
  85489. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85490. /**
  85491. * Computes a complete transformation matrix
  85492. * @param viewport defines the viewport to use
  85493. * @param world defines the world matrix
  85494. * @param view defines the view matrix
  85495. * @param projection defines the projection matrix
  85496. * @param zmin defines the near clip plane
  85497. * @param zmax defines the far clip plane
  85498. * @returns the transformation matrix
  85499. */
  85500. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85501. /**
  85502. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85503. * @param matrix defines the matrix to use
  85504. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85505. */
  85506. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85507. /**
  85508. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85509. * @param matrix defines the matrix to use
  85510. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85511. */
  85512. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85513. /**
  85514. * Compute the transpose of a given matrix
  85515. * @param matrix defines the matrix to transpose
  85516. * @returns the new matrix
  85517. */
  85518. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85519. /**
  85520. * Compute the transpose of a matrix and store it in a target matrix
  85521. * @param matrix defines the matrix to transpose
  85522. * @param result defines the target matrix
  85523. */
  85524. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85525. /**
  85526. * Computes a reflection matrix from a plane
  85527. * @param plane defines the reflection plane
  85528. * @returns a new matrix
  85529. */
  85530. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85531. /**
  85532. * Computes a reflection matrix from a plane
  85533. * @param plane defines the reflection plane
  85534. * @param result defines the target matrix
  85535. */
  85536. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85537. /**
  85538. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85539. * @param xaxis defines the value of the 1st axis
  85540. * @param yaxis defines the value of the 2nd axis
  85541. * @param zaxis defines the value of the 3rd axis
  85542. * @param result defines the target matrix
  85543. */
  85544. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85545. /**
  85546. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85547. * @param quat defines the quaternion to use
  85548. * @param result defines the target matrix
  85549. */
  85550. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85551. }
  85552. /**
  85553. * @hidden
  85554. */
  85555. export class TmpVectors {
  85556. static Vector2: Vector2[];
  85557. static Vector3: Vector3[];
  85558. static Vector4: Vector4[];
  85559. static Quaternion: Quaternion[];
  85560. static Matrix: Matrix[];
  85561. }
  85562. }
  85563. declare module BABYLON {
  85564. /**
  85565. * Defines potential orientation for back face culling
  85566. */
  85567. export enum Orientation {
  85568. /**
  85569. * Clockwise
  85570. */
  85571. CW = 0,
  85572. /** Counter clockwise */
  85573. CCW = 1
  85574. }
  85575. /** Class used to represent a Bezier curve */
  85576. export class BezierCurve {
  85577. /**
  85578. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85579. * @param t defines the time
  85580. * @param x1 defines the left coordinate on X axis
  85581. * @param y1 defines the left coordinate on Y axis
  85582. * @param x2 defines the right coordinate on X axis
  85583. * @param y2 defines the right coordinate on Y axis
  85584. * @returns the interpolated value
  85585. */
  85586. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85587. }
  85588. /**
  85589. * Defines angle representation
  85590. */
  85591. export class Angle {
  85592. private _radians;
  85593. /**
  85594. * Creates an Angle object of "radians" radians (float).
  85595. * @param radians the angle in radians
  85596. */
  85597. constructor(radians: number);
  85598. /**
  85599. * Get value in degrees
  85600. * @returns the Angle value in degrees (float)
  85601. */
  85602. degrees(): number;
  85603. /**
  85604. * Get value in radians
  85605. * @returns the Angle value in radians (float)
  85606. */
  85607. radians(): number;
  85608. /**
  85609. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85610. * @param a defines first point as the origin
  85611. * @param b defines point
  85612. * @returns a new Angle
  85613. */
  85614. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85615. /**
  85616. * Gets a new Angle object from the given float in radians
  85617. * @param radians defines the angle value in radians
  85618. * @returns a new Angle
  85619. */
  85620. static FromRadians(radians: number): Angle;
  85621. /**
  85622. * Gets a new Angle object from the given float in degrees
  85623. * @param degrees defines the angle value in degrees
  85624. * @returns a new Angle
  85625. */
  85626. static FromDegrees(degrees: number): Angle;
  85627. }
  85628. /**
  85629. * This represents an arc in a 2d space.
  85630. */
  85631. export class Arc2 {
  85632. /** Defines the start point of the arc */
  85633. startPoint: Vector2;
  85634. /** Defines the mid point of the arc */
  85635. midPoint: Vector2;
  85636. /** Defines the end point of the arc */
  85637. endPoint: Vector2;
  85638. /**
  85639. * Defines the center point of the arc.
  85640. */
  85641. centerPoint: Vector2;
  85642. /**
  85643. * Defines the radius of the arc.
  85644. */
  85645. radius: number;
  85646. /**
  85647. * Defines the angle of the arc (from mid point to end point).
  85648. */
  85649. angle: Angle;
  85650. /**
  85651. * Defines the start angle of the arc (from start point to middle point).
  85652. */
  85653. startAngle: Angle;
  85654. /**
  85655. * Defines the orientation of the arc (clock wise/counter clock wise).
  85656. */
  85657. orientation: Orientation;
  85658. /**
  85659. * Creates an Arc object from the three given points : start, middle and end.
  85660. * @param startPoint Defines the start point of the arc
  85661. * @param midPoint Defines the midlle point of the arc
  85662. * @param endPoint Defines the end point of the arc
  85663. */
  85664. constructor(
  85665. /** Defines the start point of the arc */
  85666. startPoint: Vector2,
  85667. /** Defines the mid point of the arc */
  85668. midPoint: Vector2,
  85669. /** Defines the end point of the arc */
  85670. endPoint: Vector2);
  85671. }
  85672. /**
  85673. * Represents a 2D path made up of multiple 2D points
  85674. */
  85675. export class Path2 {
  85676. private _points;
  85677. private _length;
  85678. /**
  85679. * If the path start and end point are the same
  85680. */
  85681. closed: boolean;
  85682. /**
  85683. * Creates a Path2 object from the starting 2D coordinates x and y.
  85684. * @param x the starting points x value
  85685. * @param y the starting points y value
  85686. */
  85687. constructor(x: number, y: number);
  85688. /**
  85689. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85690. * @param x the added points x value
  85691. * @param y the added points y value
  85692. * @returns the updated Path2.
  85693. */
  85694. addLineTo(x: number, y: number): Path2;
  85695. /**
  85696. * 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.
  85697. * @param midX middle point x value
  85698. * @param midY middle point y value
  85699. * @param endX end point x value
  85700. * @param endY end point y value
  85701. * @param numberOfSegments (default: 36)
  85702. * @returns the updated Path2.
  85703. */
  85704. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85705. /**
  85706. * Closes the Path2.
  85707. * @returns the Path2.
  85708. */
  85709. close(): Path2;
  85710. /**
  85711. * Gets the sum of the distance between each sequential point in the path
  85712. * @returns the Path2 total length (float).
  85713. */
  85714. length(): number;
  85715. /**
  85716. * Gets the points which construct the path
  85717. * @returns the Path2 internal array of points.
  85718. */
  85719. getPoints(): Vector2[];
  85720. /**
  85721. * Retreives the point at the distance aways from the starting point
  85722. * @param normalizedLengthPosition the length along the path to retreive the point from
  85723. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85724. */
  85725. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85726. /**
  85727. * Creates a new path starting from an x and y position
  85728. * @param x starting x value
  85729. * @param y starting y value
  85730. * @returns a new Path2 starting at the coordinates (x, y).
  85731. */
  85732. static StartingAt(x: number, y: number): Path2;
  85733. }
  85734. /**
  85735. * Represents a 3D path made up of multiple 3D points
  85736. */
  85737. export class Path3D {
  85738. /**
  85739. * an array of Vector3, the curve axis of the Path3D
  85740. */
  85741. path: Vector3[];
  85742. private _curve;
  85743. private _distances;
  85744. private _tangents;
  85745. private _normals;
  85746. private _binormals;
  85747. private _raw;
  85748. private _alignTangentsWithPath;
  85749. private readonly _pointAtData;
  85750. /**
  85751. * new Path3D(path, normal, raw)
  85752. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85753. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85754. * @param path an array of Vector3, the curve axis of the Path3D
  85755. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85756. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85757. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85758. */
  85759. constructor(
  85760. /**
  85761. * an array of Vector3, the curve axis of the Path3D
  85762. */
  85763. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85764. /**
  85765. * Returns the Path3D array of successive Vector3 designing its curve.
  85766. * @returns the Path3D array of successive Vector3 designing its curve.
  85767. */
  85768. getCurve(): Vector3[];
  85769. /**
  85770. * Returns the Path3D array of successive Vector3 designing its curve.
  85771. * @returns the Path3D array of successive Vector3 designing its curve.
  85772. */
  85773. getPoints(): Vector3[];
  85774. /**
  85775. * @returns the computed length (float) of the path.
  85776. */
  85777. length(): number;
  85778. /**
  85779. * Returns an array populated with tangent vectors on each Path3D curve point.
  85780. * @returns an array populated with tangent vectors on each Path3D curve point.
  85781. */
  85782. getTangents(): Vector3[];
  85783. /**
  85784. * Returns an array populated with normal vectors on each Path3D curve point.
  85785. * @returns an array populated with normal vectors on each Path3D curve point.
  85786. */
  85787. getNormals(): Vector3[];
  85788. /**
  85789. * Returns an array populated with binormal vectors on each Path3D curve point.
  85790. * @returns an array populated with binormal vectors on each Path3D curve point.
  85791. */
  85792. getBinormals(): Vector3[];
  85793. /**
  85794. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85795. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85796. */
  85797. getDistances(): number[];
  85798. /**
  85799. * Returns an interpolated point along this path
  85800. * @param position the position of the point along this path, from 0.0 to 1.0
  85801. * @returns a new Vector3 as the point
  85802. */
  85803. getPointAt(position: number): Vector3;
  85804. /**
  85805. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85806. * @param position the position of the point along this path, from 0.0 to 1.0
  85807. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85808. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85809. */
  85810. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85811. /**
  85812. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85813. * @param position the position of the point along this path, from 0.0 to 1.0
  85814. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85815. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85816. */
  85817. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85818. /**
  85819. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85820. * @param position the position of the point along this path, from 0.0 to 1.0
  85821. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85822. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85823. */
  85824. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85825. /**
  85826. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85827. * @param position the position of the point along this path, from 0.0 to 1.0
  85828. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85829. */
  85830. getDistanceAt(position: number): number;
  85831. /**
  85832. * Returns the array index of the previous point of an interpolated point along this path
  85833. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85834. * @returns the array index
  85835. */
  85836. getPreviousPointIndexAt(position: number): number;
  85837. /**
  85838. * 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)
  85839. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85840. * @returns the sub position
  85841. */
  85842. getSubPositionAt(position: number): number;
  85843. /**
  85844. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85845. * @param target the vector of which to get the closest position to
  85846. * @returns the position of the closest virtual point on this path to the target vector
  85847. */
  85848. getClosestPositionTo(target: Vector3): number;
  85849. /**
  85850. * Returns a sub path (slice) of this path
  85851. * @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
  85852. * @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
  85853. * @returns a sub path (slice) of this path
  85854. */
  85855. slice(start?: number, end?: number): Path3D;
  85856. /**
  85857. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85858. * @param path path which all values are copied into the curves points
  85859. * @param firstNormal which should be projected onto the curve
  85860. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85861. * @returns the same object updated.
  85862. */
  85863. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85864. private _compute;
  85865. private _getFirstNonNullVector;
  85866. private _getLastNonNullVector;
  85867. private _normalVector;
  85868. /**
  85869. * Updates the point at data for an interpolated point along this curve
  85870. * @param position the position of the point along this curve, from 0.0 to 1.0
  85871. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85872. * @returns the (updated) point at data
  85873. */
  85874. private _updatePointAtData;
  85875. /**
  85876. * Updates the point at data from the specified parameters
  85877. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85878. * @param point the interpolated point
  85879. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85880. */
  85881. private _setPointAtData;
  85882. /**
  85883. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85884. */
  85885. private _updateInterpolationMatrix;
  85886. }
  85887. /**
  85888. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85889. * A Curve3 is designed from a series of successive Vector3.
  85890. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85891. */
  85892. export class Curve3 {
  85893. private _points;
  85894. private _length;
  85895. /**
  85896. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85897. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85898. * @param v1 (Vector3) the control point
  85899. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85900. * @param nbPoints (integer) the wanted number of points in the curve
  85901. * @returns the created Curve3
  85902. */
  85903. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85904. /**
  85905. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85906. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85907. * @param v1 (Vector3) the first control point
  85908. * @param v2 (Vector3) the second control point
  85909. * @param v3 (Vector3) the end point of the Cubic Bezier
  85910. * @param nbPoints (integer) the wanted number of points in the curve
  85911. * @returns the created Curve3
  85912. */
  85913. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85914. /**
  85915. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85916. * @param p1 (Vector3) the origin point of the Hermite Spline
  85917. * @param t1 (Vector3) the tangent vector at the origin point
  85918. * @param p2 (Vector3) the end point of the Hermite Spline
  85919. * @param t2 (Vector3) the tangent vector at the end point
  85920. * @param nbPoints (integer) the wanted number of points in the curve
  85921. * @returns the created Curve3
  85922. */
  85923. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85924. /**
  85925. * Returns a Curve3 object along a CatmullRom Spline curve :
  85926. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85927. * @param nbPoints (integer) the wanted number of points between each curve control points
  85928. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85929. * @returns the created Curve3
  85930. */
  85931. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85932. /**
  85933. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85934. * A Curve3 is designed from a series of successive Vector3.
  85935. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85936. * @param points points which make up the curve
  85937. */
  85938. constructor(points: Vector3[]);
  85939. /**
  85940. * @returns the Curve3 stored array of successive Vector3
  85941. */
  85942. getPoints(): Vector3[];
  85943. /**
  85944. * @returns the computed length (float) of the curve.
  85945. */
  85946. length(): number;
  85947. /**
  85948. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85949. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85950. * curveA and curveB keep unchanged.
  85951. * @param curve the curve to continue from this curve
  85952. * @returns the newly constructed curve
  85953. */
  85954. continue(curve: DeepImmutable<Curve3>): Curve3;
  85955. private _computeLength;
  85956. }
  85957. }
  85958. declare module BABYLON {
  85959. /**
  85960. * This represents the main contract an easing function should follow.
  85961. * Easing functions are used throughout the animation system.
  85962. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85963. */
  85964. export interface IEasingFunction {
  85965. /**
  85966. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85967. * of the easing function.
  85968. * The link below provides some of the most common examples of easing functions.
  85969. * @see https://easings.net/
  85970. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85971. * @returns the corresponding value on the curve defined by the easing function
  85972. */
  85973. ease(gradient: number): number;
  85974. }
  85975. /**
  85976. * Base class used for every default easing function.
  85977. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85978. */
  85979. export class EasingFunction implements IEasingFunction {
  85980. /**
  85981. * Interpolation follows the mathematical formula associated with the easing function.
  85982. */
  85983. static readonly EASINGMODE_EASEIN: number;
  85984. /**
  85985. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85986. */
  85987. static readonly EASINGMODE_EASEOUT: number;
  85988. /**
  85989. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85990. */
  85991. static readonly EASINGMODE_EASEINOUT: number;
  85992. private _easingMode;
  85993. /**
  85994. * Sets the easing mode of the current function.
  85995. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85996. */
  85997. setEasingMode(easingMode: number): void;
  85998. /**
  85999. * Gets the current easing mode.
  86000. * @returns the easing mode
  86001. */
  86002. getEasingMode(): number;
  86003. /**
  86004. * @hidden
  86005. */
  86006. easeInCore(gradient: number): number;
  86007. /**
  86008. * Given an input gradient between 0 and 1, this returns the corresponding value
  86009. * of the easing function.
  86010. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86011. * @returns the corresponding value on the curve defined by the easing function
  86012. */
  86013. ease(gradient: number): number;
  86014. }
  86015. /**
  86016. * Easing function with a circle shape (see link below).
  86017. * @see https://easings.net/#easeInCirc
  86018. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86019. */
  86020. export class CircleEase extends EasingFunction implements IEasingFunction {
  86021. /** @hidden */
  86022. easeInCore(gradient: number): number;
  86023. }
  86024. /**
  86025. * Easing function with a ease back shape (see link below).
  86026. * @see https://easings.net/#easeInBack
  86027. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86028. */
  86029. export class BackEase extends EasingFunction implements IEasingFunction {
  86030. /** Defines the amplitude of the function */
  86031. amplitude: number;
  86032. /**
  86033. * Instantiates a back ease easing
  86034. * @see https://easings.net/#easeInBack
  86035. * @param amplitude Defines the amplitude of the function
  86036. */
  86037. constructor(
  86038. /** Defines the amplitude of the function */
  86039. amplitude?: number);
  86040. /** @hidden */
  86041. easeInCore(gradient: number): number;
  86042. }
  86043. /**
  86044. * Easing function with a bouncing shape (see link below).
  86045. * @see https://easings.net/#easeInBounce
  86046. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86047. */
  86048. export class BounceEase extends EasingFunction implements IEasingFunction {
  86049. /** Defines the number of bounces */
  86050. bounces: number;
  86051. /** Defines the amplitude of the bounce */
  86052. bounciness: number;
  86053. /**
  86054. * Instantiates a bounce easing
  86055. * @see https://easings.net/#easeInBounce
  86056. * @param bounces Defines the number of bounces
  86057. * @param bounciness Defines the amplitude of the bounce
  86058. */
  86059. constructor(
  86060. /** Defines the number of bounces */
  86061. bounces?: number,
  86062. /** Defines the amplitude of the bounce */
  86063. bounciness?: number);
  86064. /** @hidden */
  86065. easeInCore(gradient: number): number;
  86066. }
  86067. /**
  86068. * Easing function with a power of 3 shape (see link below).
  86069. * @see https://easings.net/#easeInCubic
  86070. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86071. */
  86072. export class CubicEase extends EasingFunction implements IEasingFunction {
  86073. /** @hidden */
  86074. easeInCore(gradient: number): number;
  86075. }
  86076. /**
  86077. * Easing function with an elastic shape (see link below).
  86078. * @see https://easings.net/#easeInElastic
  86079. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86080. */
  86081. export class ElasticEase extends EasingFunction implements IEasingFunction {
  86082. /** Defines the number of oscillations*/
  86083. oscillations: number;
  86084. /** Defines the amplitude of the oscillations*/
  86085. springiness: number;
  86086. /**
  86087. * Instantiates an elastic easing function
  86088. * @see https://easings.net/#easeInElastic
  86089. * @param oscillations Defines the number of oscillations
  86090. * @param springiness Defines the amplitude of the oscillations
  86091. */
  86092. constructor(
  86093. /** Defines the number of oscillations*/
  86094. oscillations?: number,
  86095. /** Defines the amplitude of the oscillations*/
  86096. springiness?: number);
  86097. /** @hidden */
  86098. easeInCore(gradient: number): number;
  86099. }
  86100. /**
  86101. * Easing function with an exponential shape (see link below).
  86102. * @see https://easings.net/#easeInExpo
  86103. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86104. */
  86105. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86106. /** Defines the exponent of the function */
  86107. exponent: number;
  86108. /**
  86109. * Instantiates an exponential easing function
  86110. * @see https://easings.net/#easeInExpo
  86111. * @param exponent Defines the exponent of the function
  86112. */
  86113. constructor(
  86114. /** Defines the exponent of the function */
  86115. exponent?: number);
  86116. /** @hidden */
  86117. easeInCore(gradient: number): number;
  86118. }
  86119. /**
  86120. * Easing function with a power shape (see link below).
  86121. * @see https://easings.net/#easeInQuad
  86122. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86123. */
  86124. export class PowerEase extends EasingFunction implements IEasingFunction {
  86125. /** Defines the power of the function */
  86126. power: number;
  86127. /**
  86128. * Instantiates an power base easing function
  86129. * @see https://easings.net/#easeInQuad
  86130. * @param power Defines the power of the function
  86131. */
  86132. constructor(
  86133. /** Defines the power of the function */
  86134. power?: number);
  86135. /** @hidden */
  86136. easeInCore(gradient: number): number;
  86137. }
  86138. /**
  86139. * Easing function with a power of 2 shape (see link below).
  86140. * @see https://easings.net/#easeInQuad
  86141. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86142. */
  86143. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86144. /** @hidden */
  86145. easeInCore(gradient: number): number;
  86146. }
  86147. /**
  86148. * Easing function with a power of 4 shape (see link below).
  86149. * @see https://easings.net/#easeInQuart
  86150. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86151. */
  86152. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86153. /** @hidden */
  86154. easeInCore(gradient: number): number;
  86155. }
  86156. /**
  86157. * Easing function with a power of 5 shape (see link below).
  86158. * @see https://easings.net/#easeInQuint
  86159. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86160. */
  86161. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86162. /** @hidden */
  86163. easeInCore(gradient: number): number;
  86164. }
  86165. /**
  86166. * Easing function with a sin shape (see link below).
  86167. * @see https://easings.net/#easeInSine
  86168. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86169. */
  86170. export class SineEase extends EasingFunction implements IEasingFunction {
  86171. /** @hidden */
  86172. easeInCore(gradient: number): number;
  86173. }
  86174. /**
  86175. * Easing function with a bezier shape (see link below).
  86176. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86177. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86178. */
  86179. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86180. /** Defines the x component of the start tangent in the bezier curve */
  86181. x1: number;
  86182. /** Defines the y component of the start tangent in the bezier curve */
  86183. y1: number;
  86184. /** Defines the x component of the end tangent in the bezier curve */
  86185. x2: number;
  86186. /** Defines the y component of the end tangent in the bezier curve */
  86187. y2: number;
  86188. /**
  86189. * Instantiates a bezier function
  86190. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86191. * @param x1 Defines the x component of the start tangent in the bezier curve
  86192. * @param y1 Defines the y component of the start tangent in the bezier curve
  86193. * @param x2 Defines the x component of the end tangent in the bezier curve
  86194. * @param y2 Defines the y component of the end tangent in the bezier curve
  86195. */
  86196. constructor(
  86197. /** Defines the x component of the start tangent in the bezier curve */
  86198. x1?: number,
  86199. /** Defines the y component of the start tangent in the bezier curve */
  86200. y1?: number,
  86201. /** Defines the x component of the end tangent in the bezier curve */
  86202. x2?: number,
  86203. /** Defines the y component of the end tangent in the bezier curve */
  86204. y2?: number);
  86205. /** @hidden */
  86206. easeInCore(gradient: number): number;
  86207. }
  86208. }
  86209. declare module BABYLON {
  86210. /**
  86211. * Class used to hold a RBG color
  86212. */
  86213. export class Color3 {
  86214. /**
  86215. * Defines the red component (between 0 and 1, default is 0)
  86216. */
  86217. r: number;
  86218. /**
  86219. * Defines the green component (between 0 and 1, default is 0)
  86220. */
  86221. g: number;
  86222. /**
  86223. * Defines the blue component (between 0 and 1, default is 0)
  86224. */
  86225. b: number;
  86226. /**
  86227. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86228. * @param r defines the red component (between 0 and 1, default is 0)
  86229. * @param g defines the green component (between 0 and 1, default is 0)
  86230. * @param b defines the blue component (between 0 and 1, default is 0)
  86231. */
  86232. constructor(
  86233. /**
  86234. * Defines the red component (between 0 and 1, default is 0)
  86235. */
  86236. r?: number,
  86237. /**
  86238. * Defines the green component (between 0 and 1, default is 0)
  86239. */
  86240. g?: number,
  86241. /**
  86242. * Defines the blue component (between 0 and 1, default is 0)
  86243. */
  86244. b?: number);
  86245. /**
  86246. * Creates a string with the Color3 current values
  86247. * @returns the string representation of the Color3 object
  86248. */
  86249. toString(): string;
  86250. /**
  86251. * Returns the string "Color3"
  86252. * @returns "Color3"
  86253. */
  86254. getClassName(): string;
  86255. /**
  86256. * Compute the Color3 hash code
  86257. * @returns an unique number that can be used to hash Color3 objects
  86258. */
  86259. getHashCode(): number;
  86260. /**
  86261. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86262. * @param array defines the array where to store the r,g,b components
  86263. * @param index defines an optional index in the target array to define where to start storing values
  86264. * @returns the current Color3 object
  86265. */
  86266. toArray(array: FloatArray, index?: number): Color3;
  86267. /**
  86268. * Update the current color with values stored in an array from the starting index of the given array
  86269. * @param array defines the source array
  86270. * @param offset defines an offset in the source array
  86271. * @returns the current Color3 object
  86272. */
  86273. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86274. /**
  86275. * Returns a new Color4 object from the current Color3 and the given alpha
  86276. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86277. * @returns a new Color4 object
  86278. */
  86279. toColor4(alpha?: number): Color4;
  86280. /**
  86281. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86282. * @returns the new array
  86283. */
  86284. asArray(): number[];
  86285. /**
  86286. * Returns the luminance value
  86287. * @returns a float value
  86288. */
  86289. toLuminance(): number;
  86290. /**
  86291. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86292. * @param otherColor defines the second operand
  86293. * @returns the new Color3 object
  86294. */
  86295. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86296. /**
  86297. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86298. * @param otherColor defines the second operand
  86299. * @param result defines the Color3 object where to store the result
  86300. * @returns the current Color3
  86301. */
  86302. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86303. /**
  86304. * Determines equality between Color3 objects
  86305. * @param otherColor defines the second operand
  86306. * @returns true if the rgb values are equal to the given ones
  86307. */
  86308. equals(otherColor: DeepImmutable<Color3>): boolean;
  86309. /**
  86310. * Determines equality between the current Color3 object and a set of r,b,g values
  86311. * @param r defines the red component to check
  86312. * @param g defines the green component to check
  86313. * @param b defines the blue component to check
  86314. * @returns true if the rgb values are equal to the given ones
  86315. */
  86316. equalsFloats(r: number, g: number, b: number): boolean;
  86317. /**
  86318. * Multiplies in place each rgb value by scale
  86319. * @param scale defines the scaling factor
  86320. * @returns the updated Color3
  86321. */
  86322. scale(scale: number): Color3;
  86323. /**
  86324. * Multiplies the rgb values by scale and stores the result into "result"
  86325. * @param scale defines the scaling factor
  86326. * @param result defines the Color3 object where to store the result
  86327. * @returns the unmodified current Color3
  86328. */
  86329. scaleToRef(scale: number, result: Color3): Color3;
  86330. /**
  86331. * Scale the current Color3 values by a factor and add the result to a given Color3
  86332. * @param scale defines the scale factor
  86333. * @param result defines color to store the result into
  86334. * @returns the unmodified current Color3
  86335. */
  86336. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86337. /**
  86338. * Clamps the rgb values by the min and max values and stores the result into "result"
  86339. * @param min defines minimum clamping value (default is 0)
  86340. * @param max defines maximum clamping value (default is 1)
  86341. * @param result defines color to store the result into
  86342. * @returns the original Color3
  86343. */
  86344. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86345. /**
  86346. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86347. * @param otherColor defines the second operand
  86348. * @returns the new Color3
  86349. */
  86350. add(otherColor: DeepImmutable<Color3>): Color3;
  86351. /**
  86352. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86353. * @param otherColor defines the second operand
  86354. * @param result defines Color3 object to store the result into
  86355. * @returns the unmodified current Color3
  86356. */
  86357. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86358. /**
  86359. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86360. * @param otherColor defines the second operand
  86361. * @returns the new Color3
  86362. */
  86363. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86364. /**
  86365. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86366. * @param otherColor defines the second operand
  86367. * @param result defines Color3 object to store the result into
  86368. * @returns the unmodified current Color3
  86369. */
  86370. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86371. /**
  86372. * Copy the current object
  86373. * @returns a new Color3 copied the current one
  86374. */
  86375. clone(): Color3;
  86376. /**
  86377. * Copies the rgb values from the source in the current Color3
  86378. * @param source defines the source Color3 object
  86379. * @returns the updated Color3 object
  86380. */
  86381. copyFrom(source: DeepImmutable<Color3>): Color3;
  86382. /**
  86383. * Updates the Color3 rgb values from the given floats
  86384. * @param r defines the red component to read from
  86385. * @param g defines the green component to read from
  86386. * @param b defines the blue component to read from
  86387. * @returns the current Color3 object
  86388. */
  86389. copyFromFloats(r: number, g: number, b: number): Color3;
  86390. /**
  86391. * Updates the Color3 rgb values from the given floats
  86392. * @param r defines the red component to read from
  86393. * @param g defines the green component to read from
  86394. * @param b defines the blue component to read from
  86395. * @returns the current Color3 object
  86396. */
  86397. set(r: number, g: number, b: number): Color3;
  86398. /**
  86399. * Compute the Color3 hexadecimal code as a string
  86400. * @returns a string containing the hexadecimal representation of the Color3 object
  86401. */
  86402. toHexString(): string;
  86403. /**
  86404. * Computes a new Color3 converted from the current one to linear space
  86405. * @returns a new Color3 object
  86406. */
  86407. toLinearSpace(): Color3;
  86408. /**
  86409. * Converts current color in rgb space to HSV values
  86410. * @returns a new color3 representing the HSV values
  86411. */
  86412. toHSV(): Color3;
  86413. /**
  86414. * Converts current color in rgb space to HSV values
  86415. * @param result defines the Color3 where to store the HSV values
  86416. */
  86417. toHSVToRef(result: Color3): void;
  86418. /**
  86419. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86420. * @param convertedColor defines the Color3 object where to store the linear space version
  86421. * @returns the unmodified Color3
  86422. */
  86423. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86424. /**
  86425. * Computes a new Color3 converted from the current one to gamma space
  86426. * @returns a new Color3 object
  86427. */
  86428. toGammaSpace(): Color3;
  86429. /**
  86430. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86431. * @param convertedColor defines the Color3 object where to store the gamma space version
  86432. * @returns the unmodified Color3
  86433. */
  86434. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86435. private static _BlackReadOnly;
  86436. /**
  86437. * Convert Hue, saturation and value to a Color3 (RGB)
  86438. * @param hue defines the hue
  86439. * @param saturation defines the saturation
  86440. * @param value defines the value
  86441. * @param result defines the Color3 where to store the RGB values
  86442. */
  86443. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86444. /**
  86445. * Creates a new Color3 from the string containing valid hexadecimal values
  86446. * @param hex defines a string containing valid hexadecimal values
  86447. * @returns a new Color3 object
  86448. */
  86449. static FromHexString(hex: string): Color3;
  86450. /**
  86451. * Creates a new Color3 from the starting index of the given array
  86452. * @param array defines the source array
  86453. * @param offset defines an offset in the source array
  86454. * @returns a new Color3 object
  86455. */
  86456. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86457. /**
  86458. * Creates a new Color3 from the starting index element of the given array
  86459. * @param array defines the source array to read from
  86460. * @param offset defines the offset in the source array
  86461. * @param result defines the target Color3 object
  86462. */
  86463. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86464. /**
  86465. * Creates a new Color3 from integer values (< 256)
  86466. * @param r defines the red component to read from (value between 0 and 255)
  86467. * @param g defines the green component to read from (value between 0 and 255)
  86468. * @param b defines the blue component to read from (value between 0 and 255)
  86469. * @returns a new Color3 object
  86470. */
  86471. static FromInts(r: number, g: number, b: number): Color3;
  86472. /**
  86473. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86474. * @param start defines the start Color3 value
  86475. * @param end defines the end Color3 value
  86476. * @param amount defines the gradient value between start and end
  86477. * @returns a new Color3 object
  86478. */
  86479. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86480. /**
  86481. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86482. * @param left defines the start value
  86483. * @param right defines the end value
  86484. * @param amount defines the gradient factor
  86485. * @param result defines the Color3 object where to store the result
  86486. */
  86487. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86488. /**
  86489. * Returns a Color3 value containing a red color
  86490. * @returns a new Color3 object
  86491. */
  86492. static Red(): Color3;
  86493. /**
  86494. * Returns a Color3 value containing a green color
  86495. * @returns a new Color3 object
  86496. */
  86497. static Green(): Color3;
  86498. /**
  86499. * Returns a Color3 value containing a blue color
  86500. * @returns a new Color3 object
  86501. */
  86502. static Blue(): Color3;
  86503. /**
  86504. * Returns a Color3 value containing a black color
  86505. * @returns a new Color3 object
  86506. */
  86507. static Black(): Color3;
  86508. /**
  86509. * Gets a Color3 value containing a black color that must not be updated
  86510. */
  86511. static get BlackReadOnly(): DeepImmutable<Color3>;
  86512. /**
  86513. * Returns a Color3 value containing a white color
  86514. * @returns a new Color3 object
  86515. */
  86516. static White(): Color3;
  86517. /**
  86518. * Returns a Color3 value containing a purple color
  86519. * @returns a new Color3 object
  86520. */
  86521. static Purple(): Color3;
  86522. /**
  86523. * Returns a Color3 value containing a magenta color
  86524. * @returns a new Color3 object
  86525. */
  86526. static Magenta(): Color3;
  86527. /**
  86528. * Returns a Color3 value containing a yellow color
  86529. * @returns a new Color3 object
  86530. */
  86531. static Yellow(): Color3;
  86532. /**
  86533. * Returns a Color3 value containing a gray color
  86534. * @returns a new Color3 object
  86535. */
  86536. static Gray(): Color3;
  86537. /**
  86538. * Returns a Color3 value containing a teal color
  86539. * @returns a new Color3 object
  86540. */
  86541. static Teal(): Color3;
  86542. /**
  86543. * Returns a Color3 value containing a random color
  86544. * @returns a new Color3 object
  86545. */
  86546. static Random(): Color3;
  86547. }
  86548. /**
  86549. * Class used to hold a RBGA color
  86550. */
  86551. export class Color4 {
  86552. /**
  86553. * Defines the red component (between 0 and 1, default is 0)
  86554. */
  86555. r: number;
  86556. /**
  86557. * Defines the green component (between 0 and 1, default is 0)
  86558. */
  86559. g: number;
  86560. /**
  86561. * Defines the blue component (between 0 and 1, default is 0)
  86562. */
  86563. b: number;
  86564. /**
  86565. * Defines the alpha component (between 0 and 1, default is 1)
  86566. */
  86567. a: number;
  86568. /**
  86569. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86570. * @param r defines the red component (between 0 and 1, default is 0)
  86571. * @param g defines the green component (between 0 and 1, default is 0)
  86572. * @param b defines the blue component (between 0 and 1, default is 0)
  86573. * @param a defines the alpha component (between 0 and 1, default is 1)
  86574. */
  86575. constructor(
  86576. /**
  86577. * Defines the red component (between 0 and 1, default is 0)
  86578. */
  86579. r?: number,
  86580. /**
  86581. * Defines the green component (between 0 and 1, default is 0)
  86582. */
  86583. g?: number,
  86584. /**
  86585. * Defines the blue component (between 0 and 1, default is 0)
  86586. */
  86587. b?: number,
  86588. /**
  86589. * Defines the alpha component (between 0 and 1, default is 1)
  86590. */
  86591. a?: number);
  86592. /**
  86593. * Adds in place the given Color4 values to the current Color4 object
  86594. * @param right defines the second operand
  86595. * @returns the current updated Color4 object
  86596. */
  86597. addInPlace(right: DeepImmutable<Color4>): Color4;
  86598. /**
  86599. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86600. * @returns the new array
  86601. */
  86602. asArray(): number[];
  86603. /**
  86604. * Stores from the starting index in the given array the Color4 successive values
  86605. * @param array defines the array where to store the r,g,b components
  86606. * @param index defines an optional index in the target array to define where to start storing values
  86607. * @returns the current Color4 object
  86608. */
  86609. toArray(array: number[], index?: number): Color4;
  86610. /**
  86611. * Update the current color with values stored in an array from the starting index of the given array
  86612. * @param array defines the source array
  86613. * @param offset defines an offset in the source array
  86614. * @returns the current Color4 object
  86615. */
  86616. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86617. /**
  86618. * Determines equality between Color4 objects
  86619. * @param otherColor defines the second operand
  86620. * @returns true if the rgba values are equal to the given ones
  86621. */
  86622. equals(otherColor: DeepImmutable<Color4>): boolean;
  86623. /**
  86624. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86625. * @param right defines the second operand
  86626. * @returns a new Color4 object
  86627. */
  86628. add(right: DeepImmutable<Color4>): Color4;
  86629. /**
  86630. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86631. * @param right defines the second operand
  86632. * @returns a new Color4 object
  86633. */
  86634. subtract(right: DeepImmutable<Color4>): Color4;
  86635. /**
  86636. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86637. * @param right defines the second operand
  86638. * @param result defines the Color4 object where to store the result
  86639. * @returns the current Color4 object
  86640. */
  86641. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86642. /**
  86643. * Creates a new Color4 with the current Color4 values multiplied by scale
  86644. * @param scale defines the scaling factor to apply
  86645. * @returns a new Color4 object
  86646. */
  86647. scale(scale: number): Color4;
  86648. /**
  86649. * Multiplies the current Color4 values by scale and stores the result in "result"
  86650. * @param scale defines the scaling factor to apply
  86651. * @param result defines the Color4 object where to store the result
  86652. * @returns the current unmodified Color4
  86653. */
  86654. scaleToRef(scale: number, result: Color4): Color4;
  86655. /**
  86656. * Scale the current Color4 values by a factor and add the result to a given Color4
  86657. * @param scale defines the scale factor
  86658. * @param result defines the Color4 object where to store the result
  86659. * @returns the unmodified current Color4
  86660. */
  86661. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86662. /**
  86663. * Clamps the rgb values by the min and max values and stores the result into "result"
  86664. * @param min defines minimum clamping value (default is 0)
  86665. * @param max defines maximum clamping value (default is 1)
  86666. * @param result defines color to store the result into.
  86667. * @returns the cuurent Color4
  86668. */
  86669. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86670. /**
  86671. * Multipy an Color4 value by another and return a new Color4 object
  86672. * @param color defines the Color4 value to multiply by
  86673. * @returns a new Color4 object
  86674. */
  86675. multiply(color: Color4): Color4;
  86676. /**
  86677. * Multipy a Color4 value by another and push the result in a reference value
  86678. * @param color defines the Color4 value to multiply by
  86679. * @param result defines the Color4 to fill the result in
  86680. * @returns the result Color4
  86681. */
  86682. multiplyToRef(color: Color4, result: Color4): Color4;
  86683. /**
  86684. * Creates a string with the Color4 current values
  86685. * @returns the string representation of the Color4 object
  86686. */
  86687. toString(): string;
  86688. /**
  86689. * Returns the string "Color4"
  86690. * @returns "Color4"
  86691. */
  86692. getClassName(): string;
  86693. /**
  86694. * Compute the Color4 hash code
  86695. * @returns an unique number that can be used to hash Color4 objects
  86696. */
  86697. getHashCode(): number;
  86698. /**
  86699. * Creates a new Color4 copied from the current one
  86700. * @returns a new Color4 object
  86701. */
  86702. clone(): Color4;
  86703. /**
  86704. * Copies the given Color4 values into the current one
  86705. * @param source defines the source Color4 object
  86706. * @returns the current updated Color4 object
  86707. */
  86708. copyFrom(source: Color4): Color4;
  86709. /**
  86710. * Copies the given float values into the current one
  86711. * @param r defines the red component to read from
  86712. * @param g defines the green component to read from
  86713. * @param b defines the blue component to read from
  86714. * @param a defines the alpha component to read from
  86715. * @returns the current updated Color4 object
  86716. */
  86717. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86718. /**
  86719. * Copies the given float values into the current one
  86720. * @param r defines the red component to read from
  86721. * @param g defines the green component to read from
  86722. * @param b defines the blue component to read from
  86723. * @param a defines the alpha component to read from
  86724. * @returns the current updated Color4 object
  86725. */
  86726. set(r: number, g: number, b: number, a: number): Color4;
  86727. /**
  86728. * Compute the Color4 hexadecimal code as a string
  86729. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86730. * @returns a string containing the hexadecimal representation of the Color4 object
  86731. */
  86732. toHexString(returnAsColor3?: boolean): string;
  86733. /**
  86734. * Computes a new Color4 converted from the current one to linear space
  86735. * @returns a new Color4 object
  86736. */
  86737. toLinearSpace(): Color4;
  86738. /**
  86739. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86740. * @param convertedColor defines the Color4 object where to store the linear space version
  86741. * @returns the unmodified Color4
  86742. */
  86743. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86744. /**
  86745. * Computes a new Color4 converted from the current one to gamma space
  86746. * @returns a new Color4 object
  86747. */
  86748. toGammaSpace(): Color4;
  86749. /**
  86750. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86751. * @param convertedColor defines the Color4 object where to store the gamma space version
  86752. * @returns the unmodified Color4
  86753. */
  86754. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86755. /**
  86756. * Creates a new Color4 from the string containing valid hexadecimal values
  86757. * @param hex defines a string containing valid hexadecimal values
  86758. * @returns a new Color4 object
  86759. */
  86760. static FromHexString(hex: string): Color4;
  86761. /**
  86762. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86763. * @param left defines the start value
  86764. * @param right defines the end value
  86765. * @param amount defines the gradient factor
  86766. * @returns a new Color4 object
  86767. */
  86768. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86769. /**
  86770. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86771. * @param left defines the start value
  86772. * @param right defines the end value
  86773. * @param amount defines the gradient factor
  86774. * @param result defines the Color4 object where to store data
  86775. */
  86776. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86777. /**
  86778. * Creates a new Color4 from a Color3 and an alpha value
  86779. * @param color3 defines the source Color3 to read from
  86780. * @param alpha defines the alpha component (1.0 by default)
  86781. * @returns a new Color4 object
  86782. */
  86783. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86784. /**
  86785. * Creates a new Color4 from the starting index element of the given array
  86786. * @param array defines the source array to read from
  86787. * @param offset defines the offset in the source array
  86788. * @returns a new Color4 object
  86789. */
  86790. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86791. /**
  86792. * Creates a new Color4 from the starting index element of the given array
  86793. * @param array defines the source array to read from
  86794. * @param offset defines the offset in the source array
  86795. * @param result defines the target Color4 object
  86796. */
  86797. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86798. /**
  86799. * Creates a new Color3 from integer values (< 256)
  86800. * @param r defines the red component to read from (value between 0 and 255)
  86801. * @param g defines the green component to read from (value between 0 and 255)
  86802. * @param b defines the blue component to read from (value between 0 and 255)
  86803. * @param a defines the alpha component to read from (value between 0 and 255)
  86804. * @returns a new Color3 object
  86805. */
  86806. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86807. /**
  86808. * Check the content of a given array and convert it to an array containing RGBA data
  86809. * If the original array was already containing count * 4 values then it is returned directly
  86810. * @param colors defines the array to check
  86811. * @param count defines the number of RGBA data to expect
  86812. * @returns an array containing count * 4 values (RGBA)
  86813. */
  86814. static CheckColors4(colors: number[], count: number): number[];
  86815. }
  86816. /**
  86817. * @hidden
  86818. */
  86819. export class TmpColors {
  86820. static Color3: Color3[];
  86821. static Color4: Color4[];
  86822. }
  86823. }
  86824. declare module BABYLON {
  86825. /**
  86826. * Defines an interface which represents an animation key frame
  86827. */
  86828. export interface IAnimationKey {
  86829. /**
  86830. * Frame of the key frame
  86831. */
  86832. frame: number;
  86833. /**
  86834. * Value at the specifies key frame
  86835. */
  86836. value: any;
  86837. /**
  86838. * The input tangent for the cubic hermite spline
  86839. */
  86840. inTangent?: any;
  86841. /**
  86842. * The output tangent for the cubic hermite spline
  86843. */
  86844. outTangent?: any;
  86845. /**
  86846. * The animation interpolation type
  86847. */
  86848. interpolation?: AnimationKeyInterpolation;
  86849. }
  86850. /**
  86851. * Enum for the animation key frame interpolation type
  86852. */
  86853. export enum AnimationKeyInterpolation {
  86854. /**
  86855. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86856. */
  86857. STEP = 1
  86858. }
  86859. }
  86860. declare module BABYLON {
  86861. /**
  86862. * Represents the range of an animation
  86863. */
  86864. export class AnimationRange {
  86865. /**The name of the animation range**/
  86866. name: string;
  86867. /**The starting frame of the animation */
  86868. from: number;
  86869. /**The ending frame of the animation*/
  86870. to: number;
  86871. /**
  86872. * Initializes the range of an animation
  86873. * @param name The name of the animation range
  86874. * @param from The starting frame of the animation
  86875. * @param to The ending frame of the animation
  86876. */
  86877. constructor(
  86878. /**The name of the animation range**/
  86879. name: string,
  86880. /**The starting frame of the animation */
  86881. from: number,
  86882. /**The ending frame of the animation*/
  86883. to: number);
  86884. /**
  86885. * Makes a copy of the animation range
  86886. * @returns A copy of the animation range
  86887. */
  86888. clone(): AnimationRange;
  86889. }
  86890. }
  86891. declare module BABYLON {
  86892. /**
  86893. * Composed of a frame, and an action function
  86894. */
  86895. export class AnimationEvent {
  86896. /** The frame for which the event is triggered **/
  86897. frame: number;
  86898. /** The event to perform when triggered **/
  86899. action: (currentFrame: number) => void;
  86900. /** Specifies if the event should be triggered only once**/
  86901. onlyOnce?: boolean | undefined;
  86902. /**
  86903. * Specifies if the animation event is done
  86904. */
  86905. isDone: boolean;
  86906. /**
  86907. * Initializes the animation event
  86908. * @param frame The frame for which the event is triggered
  86909. * @param action The event to perform when triggered
  86910. * @param onlyOnce Specifies if the event should be triggered only once
  86911. */
  86912. constructor(
  86913. /** The frame for which the event is triggered **/
  86914. frame: number,
  86915. /** The event to perform when triggered **/
  86916. action: (currentFrame: number) => void,
  86917. /** Specifies if the event should be triggered only once**/
  86918. onlyOnce?: boolean | undefined);
  86919. /** @hidden */
  86920. _clone(): AnimationEvent;
  86921. }
  86922. }
  86923. declare module BABYLON {
  86924. /**
  86925. * Interface used to define a behavior
  86926. */
  86927. export interface Behavior<T> {
  86928. /** gets or sets behavior's name */
  86929. name: string;
  86930. /**
  86931. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86932. */
  86933. init(): void;
  86934. /**
  86935. * Called when the behavior is attached to a target
  86936. * @param target defines the target where the behavior is attached to
  86937. */
  86938. attach(target: T): void;
  86939. /**
  86940. * Called when the behavior is detached from its target
  86941. */
  86942. detach(): void;
  86943. }
  86944. /**
  86945. * Interface implemented by classes supporting behaviors
  86946. */
  86947. export interface IBehaviorAware<T> {
  86948. /**
  86949. * Attach a behavior
  86950. * @param behavior defines the behavior to attach
  86951. * @returns the current host
  86952. */
  86953. addBehavior(behavior: Behavior<T>): T;
  86954. /**
  86955. * Remove a behavior from the current object
  86956. * @param behavior defines the behavior to detach
  86957. * @returns the current host
  86958. */
  86959. removeBehavior(behavior: Behavior<T>): T;
  86960. /**
  86961. * Gets a behavior using its name to search
  86962. * @param name defines the name to search
  86963. * @returns the behavior or null if not found
  86964. */
  86965. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86966. }
  86967. }
  86968. declare module BABYLON {
  86969. /**
  86970. * Defines an array and its length.
  86971. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86972. */
  86973. export interface ISmartArrayLike<T> {
  86974. /**
  86975. * The data of the array.
  86976. */
  86977. data: Array<T>;
  86978. /**
  86979. * The active length of the array.
  86980. */
  86981. length: number;
  86982. }
  86983. /**
  86984. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86985. */
  86986. export class SmartArray<T> implements ISmartArrayLike<T> {
  86987. /**
  86988. * The full set of data from the array.
  86989. */
  86990. data: Array<T>;
  86991. /**
  86992. * The active length of the array.
  86993. */
  86994. length: number;
  86995. protected _id: number;
  86996. /**
  86997. * Instantiates a Smart Array.
  86998. * @param capacity defines the default capacity of the array.
  86999. */
  87000. constructor(capacity: number);
  87001. /**
  87002. * Pushes a value at the end of the active data.
  87003. * @param value defines the object to push in the array.
  87004. */
  87005. push(value: T): void;
  87006. /**
  87007. * Iterates over the active data and apply the lambda to them.
  87008. * @param func defines the action to apply on each value.
  87009. */
  87010. forEach(func: (content: T) => void): void;
  87011. /**
  87012. * Sorts the full sets of data.
  87013. * @param compareFn defines the comparison function to apply.
  87014. */
  87015. sort(compareFn: (a: T, b: T) => number): void;
  87016. /**
  87017. * Resets the active data to an empty array.
  87018. */
  87019. reset(): void;
  87020. /**
  87021. * Releases all the data from the array as well as the array.
  87022. */
  87023. dispose(): void;
  87024. /**
  87025. * Concats the active data with a given array.
  87026. * @param array defines the data to concatenate with.
  87027. */
  87028. concat(array: any): void;
  87029. /**
  87030. * Returns the position of a value in the active data.
  87031. * @param value defines the value to find the index for
  87032. * @returns the index if found in the active data otherwise -1
  87033. */
  87034. indexOf(value: T): number;
  87035. /**
  87036. * Returns whether an element is part of the active data.
  87037. * @param value defines the value to look for
  87038. * @returns true if found in the active data otherwise false
  87039. */
  87040. contains(value: T): boolean;
  87041. private static _GlobalId;
  87042. }
  87043. /**
  87044. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87045. * The data in this array can only be present once
  87046. */
  87047. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87048. private _duplicateId;
  87049. /**
  87050. * Pushes a value at the end of the active data.
  87051. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87052. * @param value defines the object to push in the array.
  87053. */
  87054. push(value: T): void;
  87055. /**
  87056. * Pushes a value at the end of the active data.
  87057. * If the data is already present, it won t be added again
  87058. * @param value defines the object to push in the array.
  87059. * @returns true if added false if it was already present
  87060. */
  87061. pushNoDuplicate(value: T): boolean;
  87062. /**
  87063. * Resets the active data to an empty array.
  87064. */
  87065. reset(): void;
  87066. /**
  87067. * Concats the active data with a given array.
  87068. * This ensures no dupplicate will be present in the result.
  87069. * @param array defines the data to concatenate with.
  87070. */
  87071. concatWithNoDuplicate(array: any): void;
  87072. }
  87073. }
  87074. declare module BABYLON {
  87075. /**
  87076. * @ignore
  87077. * This is a list of all the different input types that are available in the application.
  87078. * Fo instance: ArcRotateCameraGamepadInput...
  87079. */
  87080. export var CameraInputTypes: {};
  87081. /**
  87082. * This is the contract to implement in order to create a new input class.
  87083. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  87084. */
  87085. export interface ICameraInput<TCamera extends Camera> {
  87086. /**
  87087. * Defines the camera the input is attached to.
  87088. */
  87089. camera: Nullable<TCamera>;
  87090. /**
  87091. * Gets the class name of the current intput.
  87092. * @returns the class name
  87093. */
  87094. getClassName(): string;
  87095. /**
  87096. * Get the friendly name associated with the input class.
  87097. * @returns the input friendly name
  87098. */
  87099. getSimpleName(): string;
  87100. /**
  87101. * Attach the input controls to a specific dom element to get the input from.
  87102. * @param element Defines the element the controls should be listened from
  87103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87104. */
  87105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87106. /**
  87107. * Detach the current controls from the specified dom element.
  87108. * @param element Defines the element to stop listening the inputs from
  87109. */
  87110. detachControl(element: Nullable<HTMLElement>): void;
  87111. /**
  87112. * Update the current camera state depending on the inputs that have been used this frame.
  87113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87114. */
  87115. checkInputs?: () => void;
  87116. }
  87117. /**
  87118. * Represents a map of input types to input instance or input index to input instance.
  87119. */
  87120. export interface CameraInputsMap<TCamera extends Camera> {
  87121. /**
  87122. * Accessor to the input by input type.
  87123. */
  87124. [name: string]: ICameraInput<TCamera>;
  87125. /**
  87126. * Accessor to the input by input index.
  87127. */
  87128. [idx: number]: ICameraInput<TCamera>;
  87129. }
  87130. /**
  87131. * This represents the input manager used within a camera.
  87132. * It helps dealing with all the different kind of input attached to a camera.
  87133. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87134. */
  87135. export class CameraInputsManager<TCamera extends Camera> {
  87136. /**
  87137. * Defines the list of inputs attahed to the camera.
  87138. */
  87139. attached: CameraInputsMap<TCamera>;
  87140. /**
  87141. * Defines the dom element the camera is collecting inputs from.
  87142. * This is null if the controls have not been attached.
  87143. */
  87144. attachedElement: Nullable<HTMLElement>;
  87145. /**
  87146. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87147. */
  87148. noPreventDefault: boolean;
  87149. /**
  87150. * Defined the camera the input manager belongs to.
  87151. */
  87152. camera: TCamera;
  87153. /**
  87154. * Update the current camera state depending on the inputs that have been used this frame.
  87155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87156. */
  87157. checkInputs: () => void;
  87158. /**
  87159. * Instantiate a new Camera Input Manager.
  87160. * @param camera Defines the camera the input manager blongs to
  87161. */
  87162. constructor(camera: TCamera);
  87163. /**
  87164. * Add an input method to a camera
  87165. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87166. * @param input camera input method
  87167. */
  87168. add(input: ICameraInput<TCamera>): void;
  87169. /**
  87170. * Remove a specific input method from a camera
  87171. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87172. * @param inputToRemove camera input method
  87173. */
  87174. remove(inputToRemove: ICameraInput<TCamera>): void;
  87175. /**
  87176. * Remove a specific input type from a camera
  87177. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87178. * @param inputType the type of the input to remove
  87179. */
  87180. removeByType(inputType: string): void;
  87181. private _addCheckInputs;
  87182. /**
  87183. * Attach the input controls to the currently attached dom element to listen the events from.
  87184. * @param input Defines the input to attach
  87185. */
  87186. attachInput(input: ICameraInput<TCamera>): void;
  87187. /**
  87188. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87189. * @param element Defines the dom element to collect the events from
  87190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87191. */
  87192. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  87193. /**
  87194. * Detach the current manager inputs controls from a specific dom element.
  87195. * @param element Defines the dom element to collect the events from
  87196. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87197. */
  87198. detachElement(element: HTMLElement, disconnect?: boolean): void;
  87199. /**
  87200. * Rebuild the dynamic inputCheck function from the current list of
  87201. * defined inputs in the manager.
  87202. */
  87203. rebuildInputCheck(): void;
  87204. /**
  87205. * Remove all attached input methods from a camera
  87206. */
  87207. clear(): void;
  87208. /**
  87209. * Serialize the current input manager attached to a camera.
  87210. * This ensures than once parsed,
  87211. * the input associated to the camera will be identical to the current ones
  87212. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87213. */
  87214. serialize(serializedCamera: any): void;
  87215. /**
  87216. * Parses an input manager serialized JSON to restore the previous list of inputs
  87217. * and states associated to a camera.
  87218. * @param parsedCamera Defines the JSON to parse
  87219. */
  87220. parse(parsedCamera: any): void;
  87221. }
  87222. }
  87223. declare module BABYLON {
  87224. /**
  87225. * Class used to store data that will be store in GPU memory
  87226. */
  87227. export class Buffer {
  87228. private _engine;
  87229. private _buffer;
  87230. /** @hidden */
  87231. _data: Nullable<DataArray>;
  87232. private _updatable;
  87233. private _instanced;
  87234. private _divisor;
  87235. /**
  87236. * Gets the byte stride.
  87237. */
  87238. readonly byteStride: number;
  87239. /**
  87240. * Constructor
  87241. * @param engine the engine
  87242. * @param data the data to use for this buffer
  87243. * @param updatable whether the data is updatable
  87244. * @param stride the stride (optional)
  87245. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87246. * @param instanced whether the buffer is instanced (optional)
  87247. * @param useBytes set to true if the stride in in bytes (optional)
  87248. * @param divisor sets an optional divisor for instances (1 by default)
  87249. */
  87250. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87251. /**
  87252. * Create a new VertexBuffer based on the current buffer
  87253. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87254. * @param offset defines offset in the buffer (0 by default)
  87255. * @param size defines the size in floats of attributes (position is 3 for instance)
  87256. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87257. * @param instanced defines if the vertex buffer contains indexed data
  87258. * @param useBytes defines if the offset and stride are in bytes *
  87259. * @param divisor sets an optional divisor for instances (1 by default)
  87260. * @returns the new vertex buffer
  87261. */
  87262. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87263. /**
  87264. * Gets a boolean indicating if the Buffer is updatable?
  87265. * @returns true if the buffer is updatable
  87266. */
  87267. isUpdatable(): boolean;
  87268. /**
  87269. * Gets current buffer's data
  87270. * @returns a DataArray or null
  87271. */
  87272. getData(): Nullable<DataArray>;
  87273. /**
  87274. * Gets underlying native buffer
  87275. * @returns underlying native buffer
  87276. */
  87277. getBuffer(): Nullable<DataBuffer>;
  87278. /**
  87279. * Gets the stride in float32 units (i.e. byte stride / 4).
  87280. * May not be an integer if the byte stride is not divisible by 4.
  87281. * @returns the stride in float32 units
  87282. * @deprecated Please use byteStride instead.
  87283. */
  87284. getStrideSize(): number;
  87285. /**
  87286. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87287. * @param data defines the data to store
  87288. */
  87289. create(data?: Nullable<DataArray>): void;
  87290. /** @hidden */
  87291. _rebuild(): void;
  87292. /**
  87293. * Update current buffer data
  87294. * @param data defines the data to store
  87295. */
  87296. update(data: DataArray): void;
  87297. /**
  87298. * Updates the data directly.
  87299. * @param data the new data
  87300. * @param offset the new offset
  87301. * @param vertexCount the vertex count (optional)
  87302. * @param useBytes set to true if the offset is in bytes
  87303. */
  87304. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87305. /**
  87306. * Release all resources
  87307. */
  87308. dispose(): void;
  87309. }
  87310. /**
  87311. * Specialized buffer used to store vertex data
  87312. */
  87313. export class VertexBuffer {
  87314. /** @hidden */
  87315. _buffer: Buffer;
  87316. private _kind;
  87317. private _size;
  87318. private _ownsBuffer;
  87319. private _instanced;
  87320. private _instanceDivisor;
  87321. /**
  87322. * The byte type.
  87323. */
  87324. static readonly BYTE: number;
  87325. /**
  87326. * The unsigned byte type.
  87327. */
  87328. static readonly UNSIGNED_BYTE: number;
  87329. /**
  87330. * The short type.
  87331. */
  87332. static readonly SHORT: number;
  87333. /**
  87334. * The unsigned short type.
  87335. */
  87336. static readonly UNSIGNED_SHORT: number;
  87337. /**
  87338. * The integer type.
  87339. */
  87340. static readonly INT: number;
  87341. /**
  87342. * The unsigned integer type.
  87343. */
  87344. static readonly UNSIGNED_INT: number;
  87345. /**
  87346. * The float type.
  87347. */
  87348. static readonly FLOAT: number;
  87349. /**
  87350. * Gets or sets the instance divisor when in instanced mode
  87351. */
  87352. get instanceDivisor(): number;
  87353. set instanceDivisor(value: number);
  87354. /**
  87355. * Gets the byte stride.
  87356. */
  87357. readonly byteStride: number;
  87358. /**
  87359. * Gets the byte offset.
  87360. */
  87361. readonly byteOffset: number;
  87362. /**
  87363. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87364. */
  87365. readonly normalized: boolean;
  87366. /**
  87367. * Gets the data type of each component in the array.
  87368. */
  87369. readonly type: number;
  87370. /**
  87371. * Constructor
  87372. * @param engine the engine
  87373. * @param data the data to use for this vertex buffer
  87374. * @param kind the vertex buffer kind
  87375. * @param updatable whether the data is updatable
  87376. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87377. * @param stride the stride (optional)
  87378. * @param instanced whether the buffer is instanced (optional)
  87379. * @param offset the offset of the data (optional)
  87380. * @param size the number of components (optional)
  87381. * @param type the type of the component (optional)
  87382. * @param normalized whether the data contains normalized data (optional)
  87383. * @param useBytes set to true if stride and offset are in bytes (optional)
  87384. * @param divisor defines the instance divisor to use (1 by default)
  87385. */
  87386. 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);
  87387. /** @hidden */
  87388. _rebuild(): void;
  87389. /**
  87390. * Returns the kind of the VertexBuffer (string)
  87391. * @returns a string
  87392. */
  87393. getKind(): string;
  87394. /**
  87395. * Gets a boolean indicating if the VertexBuffer is updatable?
  87396. * @returns true if the buffer is updatable
  87397. */
  87398. isUpdatable(): boolean;
  87399. /**
  87400. * Gets current buffer's data
  87401. * @returns a DataArray or null
  87402. */
  87403. getData(): Nullable<DataArray>;
  87404. /**
  87405. * Gets underlying native buffer
  87406. * @returns underlying native buffer
  87407. */
  87408. getBuffer(): Nullable<DataBuffer>;
  87409. /**
  87410. * Gets the stride in float32 units (i.e. byte stride / 4).
  87411. * May not be an integer if the byte stride is not divisible by 4.
  87412. * @returns the stride in float32 units
  87413. * @deprecated Please use byteStride instead.
  87414. */
  87415. getStrideSize(): number;
  87416. /**
  87417. * Returns the offset as a multiple of the type byte length.
  87418. * @returns the offset in bytes
  87419. * @deprecated Please use byteOffset instead.
  87420. */
  87421. getOffset(): number;
  87422. /**
  87423. * Returns the number of components per vertex attribute (integer)
  87424. * @returns the size in float
  87425. */
  87426. getSize(): number;
  87427. /**
  87428. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87429. * @returns true if this buffer is instanced
  87430. */
  87431. getIsInstanced(): boolean;
  87432. /**
  87433. * Returns the instancing divisor, zero for non-instanced (integer).
  87434. * @returns a number
  87435. */
  87436. getInstanceDivisor(): number;
  87437. /**
  87438. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87439. * @param data defines the data to store
  87440. */
  87441. create(data?: DataArray): void;
  87442. /**
  87443. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87444. * This function will create a new buffer if the current one is not updatable
  87445. * @param data defines the data to store
  87446. */
  87447. update(data: DataArray): void;
  87448. /**
  87449. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87450. * Returns the directly updated WebGLBuffer.
  87451. * @param data the new data
  87452. * @param offset the new offset
  87453. * @param useBytes set to true if the offset is in bytes
  87454. */
  87455. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87456. /**
  87457. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87458. */
  87459. dispose(): void;
  87460. /**
  87461. * Enumerates each value of this vertex buffer as numbers.
  87462. * @param count the number of values to enumerate
  87463. * @param callback the callback function called for each value
  87464. */
  87465. forEach(count: number, callback: (value: number, index: number) => void): void;
  87466. /**
  87467. * Positions
  87468. */
  87469. static readonly PositionKind: string;
  87470. /**
  87471. * Normals
  87472. */
  87473. static readonly NormalKind: string;
  87474. /**
  87475. * Tangents
  87476. */
  87477. static readonly TangentKind: string;
  87478. /**
  87479. * Texture coordinates
  87480. */
  87481. static readonly UVKind: string;
  87482. /**
  87483. * Texture coordinates 2
  87484. */
  87485. static readonly UV2Kind: string;
  87486. /**
  87487. * Texture coordinates 3
  87488. */
  87489. static readonly UV3Kind: string;
  87490. /**
  87491. * Texture coordinates 4
  87492. */
  87493. static readonly UV4Kind: string;
  87494. /**
  87495. * Texture coordinates 5
  87496. */
  87497. static readonly UV5Kind: string;
  87498. /**
  87499. * Texture coordinates 6
  87500. */
  87501. static readonly UV6Kind: string;
  87502. /**
  87503. * Colors
  87504. */
  87505. static readonly ColorKind: string;
  87506. /**
  87507. * Matrix indices (for bones)
  87508. */
  87509. static readonly MatricesIndicesKind: string;
  87510. /**
  87511. * Matrix weights (for bones)
  87512. */
  87513. static readonly MatricesWeightsKind: string;
  87514. /**
  87515. * Additional matrix indices (for bones)
  87516. */
  87517. static readonly MatricesIndicesExtraKind: string;
  87518. /**
  87519. * Additional matrix weights (for bones)
  87520. */
  87521. static readonly MatricesWeightsExtraKind: string;
  87522. /**
  87523. * Deduces the stride given a kind.
  87524. * @param kind The kind string to deduce
  87525. * @returns The deduced stride
  87526. */
  87527. static DeduceStride(kind: string): number;
  87528. /**
  87529. * Gets the byte length of the given type.
  87530. * @param type the type
  87531. * @returns the number of bytes
  87532. */
  87533. static GetTypeByteLength(type: number): number;
  87534. /**
  87535. * Enumerates each value of the given parameters as numbers.
  87536. * @param data the data to enumerate
  87537. * @param byteOffset the byte offset of the data
  87538. * @param byteStride the byte stride of the data
  87539. * @param componentCount the number of components per element
  87540. * @param componentType the type of the component
  87541. * @param count the number of values to enumerate
  87542. * @param normalized whether the data is normalized
  87543. * @param callback the callback function called for each value
  87544. */
  87545. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87546. private static _GetFloatValue;
  87547. }
  87548. }
  87549. declare module BABYLON {
  87550. /**
  87551. * The options Interface for creating a Capsule Mesh
  87552. */
  87553. export interface ICreateCapsuleOptions {
  87554. /** The Orientation of the capsule. Default : Vector3.Up() */
  87555. orientation?: Vector3;
  87556. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87557. subdivisions: number;
  87558. /** Number of cylindrical segments on the capsule. */
  87559. tessellation: number;
  87560. /** Height or Length of the capsule. */
  87561. height: number;
  87562. /** Radius of the capsule. */
  87563. radius: number;
  87564. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87565. capSubdivisions: number;
  87566. /** Overwrite for the top radius. */
  87567. radiusTop?: number;
  87568. /** Overwrite for the bottom radius. */
  87569. radiusBottom?: number;
  87570. /** Overwrite for the top capSubdivisions. */
  87571. topCapSubdivisions?: number;
  87572. /** Overwrite for the bottom capSubdivisions. */
  87573. bottomCapSubdivisions?: number;
  87574. }
  87575. /**
  87576. * Class containing static functions to help procedurally build meshes
  87577. */
  87578. export class CapsuleBuilder {
  87579. /**
  87580. * Creates a capsule or a pill mesh
  87581. * @param name defines the name of the mesh
  87582. * @param options The constructors options.
  87583. * @param scene The scene the mesh is scoped to.
  87584. * @returns Capsule Mesh
  87585. */
  87586. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87587. }
  87588. }
  87589. declare module BABYLON {
  87590. /**
  87591. * @hidden
  87592. */
  87593. export class IntersectionInfo {
  87594. bu: Nullable<number>;
  87595. bv: Nullable<number>;
  87596. distance: number;
  87597. faceId: number;
  87598. subMeshId: number;
  87599. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87600. }
  87601. }
  87602. declare module BABYLON {
  87603. /**
  87604. * Class used to store bounding sphere information
  87605. */
  87606. export class BoundingSphere {
  87607. /**
  87608. * Gets the center of the bounding sphere in local space
  87609. */
  87610. readonly center: Vector3;
  87611. /**
  87612. * Radius of the bounding sphere in local space
  87613. */
  87614. radius: number;
  87615. /**
  87616. * Gets the center of the bounding sphere in world space
  87617. */
  87618. readonly centerWorld: Vector3;
  87619. /**
  87620. * Radius of the bounding sphere in world space
  87621. */
  87622. radiusWorld: number;
  87623. /**
  87624. * Gets the minimum vector in local space
  87625. */
  87626. readonly minimum: Vector3;
  87627. /**
  87628. * Gets the maximum vector in local space
  87629. */
  87630. readonly maximum: Vector3;
  87631. private _worldMatrix;
  87632. private static readonly TmpVector3;
  87633. /**
  87634. * Creates a new bounding sphere
  87635. * @param min defines the minimum vector (in local space)
  87636. * @param max defines the maximum vector (in local space)
  87637. * @param worldMatrix defines the new world matrix
  87638. */
  87639. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87640. /**
  87641. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87642. * @param min defines the new minimum vector (in local space)
  87643. * @param max defines the new maximum vector (in local space)
  87644. * @param worldMatrix defines the new world matrix
  87645. */
  87646. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87647. /**
  87648. * Scale the current bounding sphere by applying a scale factor
  87649. * @param factor defines the scale factor to apply
  87650. * @returns the current bounding box
  87651. */
  87652. scale(factor: number): BoundingSphere;
  87653. /**
  87654. * Gets the world matrix of the bounding box
  87655. * @returns a matrix
  87656. */
  87657. getWorldMatrix(): DeepImmutable<Matrix>;
  87658. /** @hidden */
  87659. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87660. /**
  87661. * Tests if the bounding sphere is intersecting the frustum planes
  87662. * @param frustumPlanes defines the frustum planes to test
  87663. * @returns true if there is an intersection
  87664. */
  87665. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87666. /**
  87667. * Tests if the bounding sphere center is in between the frustum planes.
  87668. * Used for optimistic fast inclusion.
  87669. * @param frustumPlanes defines the frustum planes to test
  87670. * @returns true if the sphere center is in between the frustum planes
  87671. */
  87672. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87673. /**
  87674. * Tests if a point is inside the bounding sphere
  87675. * @param point defines the point to test
  87676. * @returns true if the point is inside the bounding sphere
  87677. */
  87678. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87679. /**
  87680. * Checks if two sphere intersct
  87681. * @param sphere0 sphere 0
  87682. * @param sphere1 sphere 1
  87683. * @returns true if the speres intersect
  87684. */
  87685. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87686. }
  87687. }
  87688. declare module BABYLON {
  87689. /**
  87690. * Class used to store bounding box information
  87691. */
  87692. export class BoundingBox implements ICullable {
  87693. /**
  87694. * Gets the 8 vectors representing the bounding box in local space
  87695. */
  87696. readonly vectors: Vector3[];
  87697. /**
  87698. * Gets the center of the bounding box in local space
  87699. */
  87700. readonly center: Vector3;
  87701. /**
  87702. * Gets the center of the bounding box in world space
  87703. */
  87704. readonly centerWorld: Vector3;
  87705. /**
  87706. * Gets the extend size in local space
  87707. */
  87708. readonly extendSize: Vector3;
  87709. /**
  87710. * Gets the extend size in world space
  87711. */
  87712. readonly extendSizeWorld: Vector3;
  87713. /**
  87714. * Gets the OBB (object bounding box) directions
  87715. */
  87716. readonly directions: Vector3[];
  87717. /**
  87718. * Gets the 8 vectors representing the bounding box in world space
  87719. */
  87720. readonly vectorsWorld: Vector3[];
  87721. /**
  87722. * Gets the minimum vector in world space
  87723. */
  87724. readonly minimumWorld: Vector3;
  87725. /**
  87726. * Gets the maximum vector in world space
  87727. */
  87728. readonly maximumWorld: Vector3;
  87729. /**
  87730. * Gets the minimum vector in local space
  87731. */
  87732. readonly minimum: Vector3;
  87733. /**
  87734. * Gets the maximum vector in local space
  87735. */
  87736. readonly maximum: Vector3;
  87737. private _worldMatrix;
  87738. private static readonly TmpVector3;
  87739. /**
  87740. * @hidden
  87741. */
  87742. _tag: number;
  87743. /**
  87744. * Creates a new bounding box
  87745. * @param min defines the minimum vector (in local space)
  87746. * @param max defines the maximum vector (in local space)
  87747. * @param worldMatrix defines the new world matrix
  87748. */
  87749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87750. /**
  87751. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87752. * @param min defines the new minimum vector (in local space)
  87753. * @param max defines the new maximum vector (in local space)
  87754. * @param worldMatrix defines the new world matrix
  87755. */
  87756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87757. /**
  87758. * Scale the current bounding box by applying a scale factor
  87759. * @param factor defines the scale factor to apply
  87760. * @returns the current bounding box
  87761. */
  87762. scale(factor: number): BoundingBox;
  87763. /**
  87764. * Gets the world matrix of the bounding box
  87765. * @returns a matrix
  87766. */
  87767. getWorldMatrix(): DeepImmutable<Matrix>;
  87768. /** @hidden */
  87769. _update(world: DeepImmutable<Matrix>): void;
  87770. /**
  87771. * Tests if the bounding box is intersecting the frustum planes
  87772. * @param frustumPlanes defines the frustum planes to test
  87773. * @returns true if there is an intersection
  87774. */
  87775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87776. /**
  87777. * Tests if the bounding box is entirely inside the frustum planes
  87778. * @param frustumPlanes defines the frustum planes to test
  87779. * @returns true if there is an inclusion
  87780. */
  87781. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87782. /**
  87783. * Tests if a point is inside the bounding box
  87784. * @param point defines the point to test
  87785. * @returns true if the point is inside the bounding box
  87786. */
  87787. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87788. /**
  87789. * Tests if the bounding box intersects with a bounding sphere
  87790. * @param sphere defines the sphere to test
  87791. * @returns true if there is an intersection
  87792. */
  87793. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87794. /**
  87795. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87796. * @param min defines the min vector to use
  87797. * @param max defines the max vector to use
  87798. * @returns true if there is an intersection
  87799. */
  87800. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87801. /**
  87802. * Tests if two bounding boxes are intersections
  87803. * @param box0 defines the first box to test
  87804. * @param box1 defines the second box to test
  87805. * @returns true if there is an intersection
  87806. */
  87807. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87808. /**
  87809. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87810. * @param minPoint defines the minimum vector of the bounding box
  87811. * @param maxPoint defines the maximum vector of the bounding box
  87812. * @param sphereCenter defines the sphere center
  87813. * @param sphereRadius defines the sphere radius
  87814. * @returns true if there is an intersection
  87815. */
  87816. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87817. /**
  87818. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87819. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87820. * @param frustumPlanes defines the frustum planes to test
  87821. * @return true if there is an inclusion
  87822. */
  87823. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87824. /**
  87825. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87826. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87827. * @param frustumPlanes defines the frustum planes to test
  87828. * @return true if there is an intersection
  87829. */
  87830. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87831. }
  87832. }
  87833. declare module BABYLON {
  87834. /** @hidden */
  87835. export class Collider {
  87836. /** Define if a collision was found */
  87837. collisionFound: boolean;
  87838. /**
  87839. * Define last intersection point in local space
  87840. */
  87841. intersectionPoint: Vector3;
  87842. /**
  87843. * Define last collided mesh
  87844. */
  87845. collidedMesh: Nullable<AbstractMesh>;
  87846. private _collisionPoint;
  87847. private _planeIntersectionPoint;
  87848. private _tempVector;
  87849. private _tempVector2;
  87850. private _tempVector3;
  87851. private _tempVector4;
  87852. private _edge;
  87853. private _baseToVertex;
  87854. private _destinationPoint;
  87855. private _slidePlaneNormal;
  87856. private _displacementVector;
  87857. /** @hidden */
  87858. _radius: Vector3;
  87859. /** @hidden */
  87860. _retry: number;
  87861. private _velocity;
  87862. private _basePoint;
  87863. private _epsilon;
  87864. /** @hidden */
  87865. _velocityWorldLength: number;
  87866. /** @hidden */
  87867. _basePointWorld: Vector3;
  87868. private _velocityWorld;
  87869. private _normalizedVelocity;
  87870. /** @hidden */
  87871. _initialVelocity: Vector3;
  87872. /** @hidden */
  87873. _initialPosition: Vector3;
  87874. private _nearestDistance;
  87875. private _collisionMask;
  87876. get collisionMask(): number;
  87877. set collisionMask(mask: number);
  87878. /**
  87879. * Gets the plane normal used to compute the sliding response (in local space)
  87880. */
  87881. get slidePlaneNormal(): Vector3;
  87882. /** @hidden */
  87883. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87884. /** @hidden */
  87885. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87886. /** @hidden */
  87887. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87888. /** @hidden */
  87889. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87890. /** @hidden */
  87891. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87892. /** @hidden */
  87893. _getResponse(pos: Vector3, vel: Vector3): void;
  87894. }
  87895. }
  87896. declare module BABYLON {
  87897. /**
  87898. * Interface for cullable objects
  87899. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87900. */
  87901. export interface ICullable {
  87902. /**
  87903. * Checks if the object or part of the object is in the frustum
  87904. * @param frustumPlanes Camera near/planes
  87905. * @returns true if the object is in frustum otherwise false
  87906. */
  87907. isInFrustum(frustumPlanes: Plane[]): boolean;
  87908. /**
  87909. * Checks if a cullable object (mesh...) is in the camera frustum
  87910. * Unlike isInFrustum this cheks the full bounding box
  87911. * @param frustumPlanes Camera near/planes
  87912. * @returns true if the object is in frustum otherwise false
  87913. */
  87914. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87915. }
  87916. /**
  87917. * Info for a bounding data of a mesh
  87918. */
  87919. export class BoundingInfo implements ICullable {
  87920. /**
  87921. * Bounding box for the mesh
  87922. */
  87923. readonly boundingBox: BoundingBox;
  87924. /**
  87925. * Bounding sphere for the mesh
  87926. */
  87927. readonly boundingSphere: BoundingSphere;
  87928. private _isLocked;
  87929. private static readonly TmpVector3;
  87930. /**
  87931. * Constructs bounding info
  87932. * @param minimum min vector of the bounding box/sphere
  87933. * @param maximum max vector of the bounding box/sphere
  87934. * @param worldMatrix defines the new world matrix
  87935. */
  87936. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87937. /**
  87938. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87939. * @param min defines the new minimum vector (in local space)
  87940. * @param max defines the new maximum vector (in local space)
  87941. * @param worldMatrix defines the new world matrix
  87942. */
  87943. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87944. /**
  87945. * min vector of the bounding box/sphere
  87946. */
  87947. get minimum(): Vector3;
  87948. /**
  87949. * max vector of the bounding box/sphere
  87950. */
  87951. get maximum(): Vector3;
  87952. /**
  87953. * If the info is locked and won't be updated to avoid perf overhead
  87954. */
  87955. get isLocked(): boolean;
  87956. set isLocked(value: boolean);
  87957. /**
  87958. * Updates the bounding sphere and box
  87959. * @param world world matrix to be used to update
  87960. */
  87961. update(world: DeepImmutable<Matrix>): void;
  87962. /**
  87963. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87964. * @param center New center of the bounding info
  87965. * @param extend New extend of the bounding info
  87966. * @returns the current bounding info
  87967. */
  87968. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87969. /**
  87970. * Scale the current bounding info by applying a scale factor
  87971. * @param factor defines the scale factor to apply
  87972. * @returns the current bounding info
  87973. */
  87974. scale(factor: number): BoundingInfo;
  87975. /**
  87976. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87977. * @param frustumPlanes defines the frustum to test
  87978. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87979. * @returns true if the bounding info is in the frustum planes
  87980. */
  87981. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87982. /**
  87983. * Gets the world distance between the min and max points of the bounding box
  87984. */
  87985. get diagonalLength(): number;
  87986. /**
  87987. * Checks if a cullable object (mesh...) is in the camera frustum
  87988. * Unlike isInFrustum this cheks the full bounding box
  87989. * @param frustumPlanes Camera near/planes
  87990. * @returns true if the object is in frustum otherwise false
  87991. */
  87992. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87993. /** @hidden */
  87994. _checkCollision(collider: Collider): boolean;
  87995. /**
  87996. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87997. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87998. * @param point the point to check intersection with
  87999. * @returns if the point intersects
  88000. */
  88001. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88002. /**
  88003. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88004. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88005. * @param boundingInfo the bounding info to check intersection with
  88006. * @param precise if the intersection should be done using OBB
  88007. * @returns if the bounding info intersects
  88008. */
  88009. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88010. }
  88011. }
  88012. declare module BABYLON {
  88013. /**
  88014. * Extracts minimum and maximum values from a list of indexed positions
  88015. * @param positions defines the positions to use
  88016. * @param indices defines the indices to the positions
  88017. * @param indexStart defines the start index
  88018. * @param indexCount defines the end index
  88019. * @param bias defines bias value to add to the result
  88020. * @return minimum and maximum values
  88021. */
  88022. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88023. minimum: Vector3;
  88024. maximum: Vector3;
  88025. };
  88026. /**
  88027. * Extracts minimum and maximum values from a list of positions
  88028. * @param positions defines the positions to use
  88029. * @param start defines the start index in the positions array
  88030. * @param count defines the number of positions to handle
  88031. * @param bias defines bias value to add to the result
  88032. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88033. * @return minimum and maximum values
  88034. */
  88035. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88036. minimum: Vector3;
  88037. maximum: Vector3;
  88038. };
  88039. }
  88040. declare module BABYLON {
  88041. /** @hidden */
  88042. export class WebGLDataBuffer extends DataBuffer {
  88043. private _buffer;
  88044. constructor(resource: WebGLBuffer);
  88045. get underlyingResource(): any;
  88046. }
  88047. }
  88048. declare module BABYLON {
  88049. /** @hidden */
  88050. export class WebGLPipelineContext implements IPipelineContext {
  88051. engine: ThinEngine;
  88052. program: Nullable<WebGLProgram>;
  88053. context?: WebGLRenderingContext;
  88054. vertexShader?: WebGLShader;
  88055. fragmentShader?: WebGLShader;
  88056. isParallelCompiled: boolean;
  88057. onCompiled?: () => void;
  88058. transformFeedback?: WebGLTransformFeedback | null;
  88059. vertexCompilationError: Nullable<string>;
  88060. fragmentCompilationError: Nullable<string>;
  88061. programLinkError: Nullable<string>;
  88062. programValidationError: Nullable<string>;
  88063. get isAsync(): boolean;
  88064. get isReady(): boolean;
  88065. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  88066. _getVertexShaderCode(): string | null;
  88067. _getFragmentShaderCode(): string | null;
  88068. }
  88069. }
  88070. declare module BABYLON {
  88071. interface ThinEngine {
  88072. /**
  88073. * Create an uniform buffer
  88074. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88075. * @param elements defines the content of the uniform buffer
  88076. * @returns the webGL uniform buffer
  88077. */
  88078. createUniformBuffer(elements: FloatArray): DataBuffer;
  88079. /**
  88080. * Create a dynamic uniform buffer
  88081. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88082. * @param elements defines the content of the uniform buffer
  88083. * @returns the webGL uniform buffer
  88084. */
  88085. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88086. /**
  88087. * Update an existing uniform buffer
  88088. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88089. * @param uniformBuffer defines the target uniform buffer
  88090. * @param elements defines the content to update
  88091. * @param offset defines the offset in the uniform buffer where update should start
  88092. * @param count defines the size of the data to update
  88093. */
  88094. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88095. /**
  88096. * Bind an uniform buffer to the current webGL context
  88097. * @param buffer defines the buffer to bind
  88098. */
  88099. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88100. /**
  88101. * Bind a buffer to the current webGL context at a given location
  88102. * @param buffer defines the buffer to bind
  88103. * @param location defines the index where to bind the buffer
  88104. */
  88105. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88106. /**
  88107. * Bind a specific block at a given index in a specific shader program
  88108. * @param pipelineContext defines the pipeline context to use
  88109. * @param blockName defines the block name
  88110. * @param index defines the index where to bind the block
  88111. */
  88112. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88113. }
  88114. }
  88115. declare module BABYLON {
  88116. /**
  88117. * Uniform buffer objects.
  88118. *
  88119. * Handles blocks of uniform on the GPU.
  88120. *
  88121. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88122. *
  88123. * For more information, please refer to :
  88124. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88125. */
  88126. export class UniformBuffer {
  88127. private _engine;
  88128. private _buffer;
  88129. private _data;
  88130. private _bufferData;
  88131. private _dynamic?;
  88132. private _uniformLocations;
  88133. private _uniformSizes;
  88134. private _uniformLocationPointer;
  88135. private _needSync;
  88136. private _noUBO;
  88137. private _currentEffect;
  88138. /** @hidden */
  88139. _alreadyBound: boolean;
  88140. private static _MAX_UNIFORM_SIZE;
  88141. private static _tempBuffer;
  88142. /**
  88143. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88144. * This is dynamic to allow compat with webgl 1 and 2.
  88145. * You will need to pass the name of the uniform as well as the value.
  88146. */
  88147. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88148. /**
  88149. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88150. * This is dynamic to allow compat with webgl 1 and 2.
  88151. * You will need to pass the name of the uniform as well as the value.
  88152. */
  88153. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88154. /**
  88155. * Lambda to Update a single float in a uniform buffer.
  88156. * This is dynamic to allow compat with webgl 1 and 2.
  88157. * You will need to pass the name of the uniform as well as the value.
  88158. */
  88159. updateFloat: (name: string, x: number) => void;
  88160. /**
  88161. * Lambda to Update a vec2 of float in a uniform buffer.
  88162. * This is dynamic to allow compat with webgl 1 and 2.
  88163. * You will need to pass the name of the uniform as well as the value.
  88164. */
  88165. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88166. /**
  88167. * Lambda to Update a vec3 of float in a uniform buffer.
  88168. * This is dynamic to allow compat with webgl 1 and 2.
  88169. * You will need to pass the name of the uniform as well as the value.
  88170. */
  88171. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88172. /**
  88173. * Lambda to Update a vec4 of float in a uniform buffer.
  88174. * This is dynamic to allow compat with webgl 1 and 2.
  88175. * You will need to pass the name of the uniform as well as the value.
  88176. */
  88177. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88178. /**
  88179. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88180. * This is dynamic to allow compat with webgl 1 and 2.
  88181. * You will need to pass the name of the uniform as well as the value.
  88182. */
  88183. updateMatrix: (name: string, mat: Matrix) => void;
  88184. /**
  88185. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88186. * This is dynamic to allow compat with webgl 1 and 2.
  88187. * You will need to pass the name of the uniform as well as the value.
  88188. */
  88189. updateVector3: (name: string, vector: Vector3) => void;
  88190. /**
  88191. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88192. * This is dynamic to allow compat with webgl 1 and 2.
  88193. * You will need to pass the name of the uniform as well as the value.
  88194. */
  88195. updateVector4: (name: string, vector: Vector4) => void;
  88196. /**
  88197. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88198. * This is dynamic to allow compat with webgl 1 and 2.
  88199. * You will need to pass the name of the uniform as well as the value.
  88200. */
  88201. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88202. /**
  88203. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88204. * This is dynamic to allow compat with webgl 1 and 2.
  88205. * You will need to pass the name of the uniform as well as the value.
  88206. */
  88207. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88208. /**
  88209. * Instantiates a new Uniform buffer objects.
  88210. *
  88211. * Handles blocks of uniform on the GPU.
  88212. *
  88213. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88214. *
  88215. * For more information, please refer to :
  88216. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88217. * @param engine Define the engine the buffer is associated with
  88218. * @param data Define the data contained in the buffer
  88219. * @param dynamic Define if the buffer is updatable
  88220. */
  88221. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88222. /**
  88223. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88224. * or just falling back on setUniformXXX calls.
  88225. */
  88226. get useUbo(): boolean;
  88227. /**
  88228. * Indicates if the WebGL underlying uniform buffer is in sync
  88229. * with the javascript cache data.
  88230. */
  88231. get isSync(): boolean;
  88232. /**
  88233. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88234. * Also, a dynamic UniformBuffer will disable cache verification and always
  88235. * update the underlying WebGL uniform buffer to the GPU.
  88236. * @returns if Dynamic, otherwise false
  88237. */
  88238. isDynamic(): boolean;
  88239. /**
  88240. * The data cache on JS side.
  88241. * @returns the underlying data as a float array
  88242. */
  88243. getData(): Float32Array;
  88244. /**
  88245. * The underlying WebGL Uniform buffer.
  88246. * @returns the webgl buffer
  88247. */
  88248. getBuffer(): Nullable<DataBuffer>;
  88249. /**
  88250. * std140 layout specifies how to align data within an UBO structure.
  88251. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88252. * for specs.
  88253. */
  88254. private _fillAlignment;
  88255. /**
  88256. * Adds an uniform in the buffer.
  88257. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88258. * for the layout to be correct !
  88259. * @param name Name of the uniform, as used in the uniform block in the shader.
  88260. * @param size Data size, or data directly.
  88261. */
  88262. addUniform(name: string, size: number | number[]): void;
  88263. /**
  88264. * Adds a Matrix 4x4 to the uniform buffer.
  88265. * @param name Name of the uniform, as used in the uniform block in the shader.
  88266. * @param mat A 4x4 matrix.
  88267. */
  88268. addMatrix(name: string, mat: Matrix): void;
  88269. /**
  88270. * Adds a vec2 to the uniform buffer.
  88271. * @param name Name of the uniform, as used in the uniform block in the shader.
  88272. * @param x Define the x component value of the vec2
  88273. * @param y Define the y component value of the vec2
  88274. */
  88275. addFloat2(name: string, x: number, y: number): void;
  88276. /**
  88277. * Adds a vec3 to the uniform buffer.
  88278. * @param name Name of the uniform, as used in the uniform block in the shader.
  88279. * @param x Define the x component value of the vec3
  88280. * @param y Define the y component value of the vec3
  88281. * @param z Define the z component value of the vec3
  88282. */
  88283. addFloat3(name: string, x: number, y: number, z: number): void;
  88284. /**
  88285. * Adds a vec3 to the uniform buffer.
  88286. * @param name Name of the uniform, as used in the uniform block in the shader.
  88287. * @param color Define the vec3 from a Color
  88288. */
  88289. addColor3(name: string, color: Color3): void;
  88290. /**
  88291. * Adds a vec4 to the uniform buffer.
  88292. * @param name Name of the uniform, as used in the uniform block in the shader.
  88293. * @param color Define the rgb components from a Color
  88294. * @param alpha Define the a component of the vec4
  88295. */
  88296. addColor4(name: string, color: Color3, alpha: number): void;
  88297. /**
  88298. * Adds a vec3 to the uniform buffer.
  88299. * @param name Name of the uniform, as used in the uniform block in the shader.
  88300. * @param vector Define the vec3 components from a Vector
  88301. */
  88302. addVector3(name: string, vector: Vector3): void;
  88303. /**
  88304. * Adds a Matrix 3x3 to the uniform buffer.
  88305. * @param name Name of the uniform, as used in the uniform block in the shader.
  88306. */
  88307. addMatrix3x3(name: string): void;
  88308. /**
  88309. * Adds a Matrix 2x2 to the uniform buffer.
  88310. * @param name Name of the uniform, as used in the uniform block in the shader.
  88311. */
  88312. addMatrix2x2(name: string): void;
  88313. /**
  88314. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88315. */
  88316. create(): void;
  88317. /** @hidden */
  88318. _rebuild(): void;
  88319. /**
  88320. * Updates the WebGL Uniform Buffer on the GPU.
  88321. * If the `dynamic` flag is set to true, no cache comparison is done.
  88322. * Otherwise, the buffer will be updated only if the cache differs.
  88323. */
  88324. update(): void;
  88325. /**
  88326. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88327. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88328. * @param data Define the flattened data
  88329. * @param size Define the size of the data.
  88330. */
  88331. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88332. private _valueCache;
  88333. private _cacheMatrix;
  88334. private _updateMatrix3x3ForUniform;
  88335. private _updateMatrix3x3ForEffect;
  88336. private _updateMatrix2x2ForEffect;
  88337. private _updateMatrix2x2ForUniform;
  88338. private _updateFloatForEffect;
  88339. private _updateFloatForUniform;
  88340. private _updateFloat2ForEffect;
  88341. private _updateFloat2ForUniform;
  88342. private _updateFloat3ForEffect;
  88343. private _updateFloat3ForUniform;
  88344. private _updateFloat4ForEffect;
  88345. private _updateFloat4ForUniform;
  88346. private _updateMatrixForEffect;
  88347. private _updateMatrixForUniform;
  88348. private _updateVector3ForEffect;
  88349. private _updateVector3ForUniform;
  88350. private _updateVector4ForEffect;
  88351. private _updateVector4ForUniform;
  88352. private _updateColor3ForEffect;
  88353. private _updateColor3ForUniform;
  88354. private _updateColor4ForEffect;
  88355. private _updateColor4ForUniform;
  88356. /**
  88357. * Sets a sampler uniform on the effect.
  88358. * @param name Define the name of the sampler.
  88359. * @param texture Define the texture to set in the sampler
  88360. */
  88361. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88362. /**
  88363. * Directly updates the value of the uniform in the cache AND on the GPU.
  88364. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88365. * @param data Define the flattened data
  88366. */
  88367. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88368. /**
  88369. * Binds this uniform buffer to an effect.
  88370. * @param effect Define the effect to bind the buffer to
  88371. * @param name Name of the uniform block in the shader.
  88372. */
  88373. bindToEffect(effect: Effect, name: string): void;
  88374. /**
  88375. * Disposes the uniform buffer.
  88376. */
  88377. dispose(): void;
  88378. }
  88379. }
  88380. declare module BABYLON {
  88381. /**
  88382. * Enum that determines the text-wrapping mode to use.
  88383. */
  88384. export enum InspectableType {
  88385. /**
  88386. * Checkbox for booleans
  88387. */
  88388. Checkbox = 0,
  88389. /**
  88390. * Sliders for numbers
  88391. */
  88392. Slider = 1,
  88393. /**
  88394. * Vector3
  88395. */
  88396. Vector3 = 2,
  88397. /**
  88398. * Quaternions
  88399. */
  88400. Quaternion = 3,
  88401. /**
  88402. * Color3
  88403. */
  88404. Color3 = 4,
  88405. /**
  88406. * String
  88407. */
  88408. String = 5
  88409. }
  88410. /**
  88411. * Interface used to define custom inspectable properties.
  88412. * This interface is used by the inspector to display custom property grids
  88413. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88414. */
  88415. export interface IInspectable {
  88416. /**
  88417. * Gets the label to display
  88418. */
  88419. label: string;
  88420. /**
  88421. * Gets the name of the property to edit
  88422. */
  88423. propertyName: string;
  88424. /**
  88425. * Gets the type of the editor to use
  88426. */
  88427. type: InspectableType;
  88428. /**
  88429. * Gets the minimum value of the property when using in "slider" mode
  88430. */
  88431. min?: number;
  88432. /**
  88433. * Gets the maximum value of the property when using in "slider" mode
  88434. */
  88435. max?: number;
  88436. /**
  88437. * Gets the setp to use when using in "slider" mode
  88438. */
  88439. step?: number;
  88440. }
  88441. }
  88442. declare module BABYLON {
  88443. /**
  88444. * Class used to provide helper for timing
  88445. */
  88446. export class TimingTools {
  88447. /**
  88448. * Polyfill for setImmediate
  88449. * @param action defines the action to execute after the current execution block
  88450. */
  88451. static SetImmediate(action: () => void): void;
  88452. }
  88453. }
  88454. declare module BABYLON {
  88455. /**
  88456. * Class used to enable instatition of objects by class name
  88457. */
  88458. export class InstantiationTools {
  88459. /**
  88460. * Use this object to register external classes like custom textures or material
  88461. * to allow the laoders to instantiate them
  88462. */
  88463. static RegisteredExternalClasses: {
  88464. [key: string]: Object;
  88465. };
  88466. /**
  88467. * Tries to instantiate a new object from a given class name
  88468. * @param className defines the class name to instantiate
  88469. * @returns the new object or null if the system was not able to do the instantiation
  88470. */
  88471. static Instantiate(className: string): any;
  88472. }
  88473. }
  88474. declare module BABYLON {
  88475. /**
  88476. * Define options used to create a depth texture
  88477. */
  88478. export class DepthTextureCreationOptions {
  88479. /** Specifies whether or not a stencil should be allocated in the texture */
  88480. generateStencil?: boolean;
  88481. /** Specifies whether or not bilinear filtering is enable on the texture */
  88482. bilinearFiltering?: boolean;
  88483. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88484. comparisonFunction?: number;
  88485. /** Specifies if the created texture is a cube texture */
  88486. isCube?: boolean;
  88487. }
  88488. }
  88489. declare module BABYLON {
  88490. interface ThinEngine {
  88491. /**
  88492. * Creates a depth stencil cube texture.
  88493. * This is only available in WebGL 2.
  88494. * @param size The size of face edge in the cube texture.
  88495. * @param options The options defining the cube texture.
  88496. * @returns The cube texture
  88497. */
  88498. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88499. /**
  88500. * Creates a cube texture
  88501. * @param rootUrl defines the url where the files to load is located
  88502. * @param scene defines the current scene
  88503. * @param files defines the list of files to load (1 per face)
  88504. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88505. * @param onLoad defines an optional callback raised when the texture is loaded
  88506. * @param onError defines an optional callback raised if there is an issue to load the texture
  88507. * @param format defines the format of the data
  88508. * @param forcedExtension defines the extension to use to pick the right loader
  88509. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88510. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88511. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88512. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88513. * @returns the cube texture as an InternalTexture
  88514. */
  88515. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  88516. /**
  88517. * Creates a cube texture
  88518. * @param rootUrl defines the url where the files to load is located
  88519. * @param scene defines the current scene
  88520. * @param files defines the list of files to load (1 per face)
  88521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88522. * @param onLoad defines an optional callback raised when the texture is loaded
  88523. * @param onError defines an optional callback raised if there is an issue to load the texture
  88524. * @param format defines the format of the data
  88525. * @param forcedExtension defines the extension to use to pick the right loader
  88526. * @returns the cube texture as an InternalTexture
  88527. */
  88528. 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;
  88529. /**
  88530. * Creates a cube texture
  88531. * @param rootUrl defines the url where the files to load is located
  88532. * @param scene defines the current scene
  88533. * @param files defines the list of files to load (1 per face)
  88534. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88535. * @param onLoad defines an optional callback raised when the texture is loaded
  88536. * @param onError defines an optional callback raised if there is an issue to load the texture
  88537. * @param format defines the format of the data
  88538. * @param forcedExtension defines the extension to use to pick the right loader
  88539. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88540. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88541. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88542. * @returns the cube texture as an InternalTexture
  88543. */
  88544. 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;
  88545. /** @hidden */
  88546. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88547. /** @hidden */
  88548. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88549. /** @hidden */
  88550. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88551. /** @hidden */
  88552. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88553. /**
  88554. * @hidden
  88555. */
  88556. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88557. }
  88558. }
  88559. declare module BABYLON {
  88560. /**
  88561. * Class for creating a cube texture
  88562. */
  88563. export class CubeTexture extends BaseTexture {
  88564. private _delayedOnLoad;
  88565. /**
  88566. * Observable triggered once the texture has been loaded.
  88567. */
  88568. onLoadObservable: Observable<CubeTexture>;
  88569. /**
  88570. * The url of the texture
  88571. */
  88572. url: string;
  88573. /**
  88574. * Gets or sets the center of the bounding box associated with the cube texture.
  88575. * It must define where the camera used to render the texture was set
  88576. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88577. */
  88578. boundingBoxPosition: Vector3;
  88579. private _boundingBoxSize;
  88580. /**
  88581. * Gets or sets the size of the bounding box associated with the cube texture
  88582. * When defined, the cubemap will switch to local mode
  88583. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88584. * @example https://www.babylonjs-playground.com/#RNASML
  88585. */
  88586. set boundingBoxSize(value: Vector3);
  88587. /**
  88588. * Returns the bounding box size
  88589. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88590. */
  88591. get boundingBoxSize(): Vector3;
  88592. protected _rotationY: number;
  88593. /**
  88594. * Sets texture matrix rotation angle around Y axis in radians.
  88595. */
  88596. set rotationY(value: number);
  88597. /**
  88598. * Gets texture matrix rotation angle around Y axis radians.
  88599. */
  88600. get rotationY(): number;
  88601. /**
  88602. * Are mip maps generated for this texture or not.
  88603. */
  88604. get noMipmap(): boolean;
  88605. private _noMipmap;
  88606. private _files;
  88607. protected _forcedExtension: Nullable<string>;
  88608. private _extensions;
  88609. private _textureMatrix;
  88610. private _format;
  88611. private _createPolynomials;
  88612. /**
  88613. * Creates a cube texture from an array of image urls
  88614. * @param files defines an array of image urls
  88615. * @param scene defines the hosting scene
  88616. * @param noMipmap specifies if mip maps are not used
  88617. * @returns a cube texture
  88618. */
  88619. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88620. /**
  88621. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88622. * @param url defines the url of the prefiltered texture
  88623. * @param scene defines the scene the texture is attached to
  88624. * @param forcedExtension defines the extension of the file if different from the url
  88625. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88626. * @return the prefiltered texture
  88627. */
  88628. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88629. /**
  88630. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88631. * as prefiltered data.
  88632. * @param rootUrl defines the url of the texture or the root name of the six images
  88633. * @param null defines the scene or engine the texture is attached to
  88634. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88635. * @param noMipmap defines if mipmaps should be created or not
  88636. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88637. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88638. * @param onError defines a callback triggered in case of error during load
  88639. * @param format defines the internal format to use for the texture once loaded
  88640. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88641. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88642. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88643. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88644. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88645. * @return the cube texture
  88646. */
  88647. 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);
  88648. /**
  88649. * Get the current class name of the texture useful for serialization or dynamic coding.
  88650. * @returns "CubeTexture"
  88651. */
  88652. getClassName(): string;
  88653. /**
  88654. * Update the url (and optional buffer) of this texture if url was null during construction.
  88655. * @param url the url of the texture
  88656. * @param forcedExtension defines the extension to use
  88657. * @param onLoad callback called when the texture is loaded (defaults to null)
  88658. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88659. */
  88660. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88661. /**
  88662. * Delays loading of the cube texture
  88663. * @param forcedExtension defines the extension to use
  88664. */
  88665. delayLoad(forcedExtension?: string): void;
  88666. /**
  88667. * Returns the reflection texture matrix
  88668. * @returns the reflection texture matrix
  88669. */
  88670. getReflectionTextureMatrix(): Matrix;
  88671. /**
  88672. * Sets the reflection texture matrix
  88673. * @param value Reflection texture matrix
  88674. */
  88675. setReflectionTextureMatrix(value: Matrix): void;
  88676. /**
  88677. * Parses text to create a cube texture
  88678. * @param parsedTexture define the serialized text to read from
  88679. * @param scene defines the hosting scene
  88680. * @param rootUrl defines the root url of the cube texture
  88681. * @returns a cube texture
  88682. */
  88683. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88684. /**
  88685. * Makes a clone, or deep copy, of the cube texture
  88686. * @returns a new cube texture
  88687. */
  88688. clone(): CubeTexture;
  88689. }
  88690. }
  88691. declare module BABYLON {
  88692. /**
  88693. * Manages the defines for the Material
  88694. */
  88695. export class MaterialDefines {
  88696. /** @hidden */
  88697. protected _keys: string[];
  88698. private _isDirty;
  88699. /** @hidden */
  88700. _renderId: number;
  88701. /** @hidden */
  88702. _areLightsDirty: boolean;
  88703. /** @hidden */
  88704. _areLightsDisposed: boolean;
  88705. /** @hidden */
  88706. _areAttributesDirty: boolean;
  88707. /** @hidden */
  88708. _areTexturesDirty: boolean;
  88709. /** @hidden */
  88710. _areFresnelDirty: boolean;
  88711. /** @hidden */
  88712. _areMiscDirty: boolean;
  88713. /** @hidden */
  88714. _arePrePassDirty: boolean;
  88715. /** @hidden */
  88716. _areImageProcessingDirty: boolean;
  88717. /** @hidden */
  88718. _normals: boolean;
  88719. /** @hidden */
  88720. _uvs: boolean;
  88721. /** @hidden */
  88722. _needNormals: boolean;
  88723. /** @hidden */
  88724. _needUVs: boolean;
  88725. [id: string]: any;
  88726. /**
  88727. * Specifies if the material needs to be re-calculated
  88728. */
  88729. get isDirty(): boolean;
  88730. /**
  88731. * Marks the material to indicate that it has been re-calculated
  88732. */
  88733. markAsProcessed(): void;
  88734. /**
  88735. * Marks the material to indicate that it needs to be re-calculated
  88736. */
  88737. markAsUnprocessed(): void;
  88738. /**
  88739. * Marks the material to indicate all of its defines need to be re-calculated
  88740. */
  88741. markAllAsDirty(): void;
  88742. /**
  88743. * Marks the material to indicate that image processing needs to be re-calculated
  88744. */
  88745. markAsImageProcessingDirty(): void;
  88746. /**
  88747. * Marks the material to indicate the lights need to be re-calculated
  88748. * @param disposed Defines whether the light is dirty due to dispose or not
  88749. */
  88750. markAsLightDirty(disposed?: boolean): void;
  88751. /**
  88752. * Marks the attribute state as changed
  88753. */
  88754. markAsAttributesDirty(): void;
  88755. /**
  88756. * Marks the texture state as changed
  88757. */
  88758. markAsTexturesDirty(): void;
  88759. /**
  88760. * Marks the fresnel state as changed
  88761. */
  88762. markAsFresnelDirty(): void;
  88763. /**
  88764. * Marks the misc state as changed
  88765. */
  88766. markAsMiscDirty(): void;
  88767. /**
  88768. * Marks the prepass state as changed
  88769. */
  88770. markAsPrePassDirty(): void;
  88771. /**
  88772. * Rebuilds the material defines
  88773. */
  88774. rebuild(): void;
  88775. /**
  88776. * Specifies if two material defines are equal
  88777. * @param other - A material define instance to compare to
  88778. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88779. */
  88780. isEqual(other: MaterialDefines): boolean;
  88781. /**
  88782. * Clones this instance's defines to another instance
  88783. * @param other - material defines to clone values to
  88784. */
  88785. cloneTo(other: MaterialDefines): void;
  88786. /**
  88787. * Resets the material define values
  88788. */
  88789. reset(): void;
  88790. /**
  88791. * Converts the material define values to a string
  88792. * @returns - String of material define information
  88793. */
  88794. toString(): string;
  88795. }
  88796. }
  88797. declare module BABYLON {
  88798. /**
  88799. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88800. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88801. * 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;
  88802. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88803. */
  88804. export class ColorCurves {
  88805. private _dirty;
  88806. private _tempColor;
  88807. private _globalCurve;
  88808. private _highlightsCurve;
  88809. private _midtonesCurve;
  88810. private _shadowsCurve;
  88811. private _positiveCurve;
  88812. private _negativeCurve;
  88813. private _globalHue;
  88814. private _globalDensity;
  88815. private _globalSaturation;
  88816. private _globalExposure;
  88817. /**
  88818. * Gets the global Hue value.
  88819. * 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).
  88820. */
  88821. get globalHue(): number;
  88822. /**
  88823. * Sets the global Hue value.
  88824. * 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).
  88825. */
  88826. set globalHue(value: number);
  88827. /**
  88828. * Gets the global Density value.
  88829. * 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.
  88830. * Values less than zero provide a filter of opposite hue.
  88831. */
  88832. get globalDensity(): number;
  88833. /**
  88834. * Sets the global Density value.
  88835. * 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.
  88836. * Values less than zero provide a filter of opposite hue.
  88837. */
  88838. set globalDensity(value: number);
  88839. /**
  88840. * Gets the global Saturation value.
  88841. * 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.
  88842. */
  88843. get globalSaturation(): number;
  88844. /**
  88845. * Sets the global Saturation value.
  88846. * 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.
  88847. */
  88848. set globalSaturation(value: number);
  88849. /**
  88850. * Gets the global Exposure value.
  88851. * 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.
  88852. */
  88853. get globalExposure(): number;
  88854. /**
  88855. * Sets the global Exposure value.
  88856. * 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.
  88857. */
  88858. set globalExposure(value: number);
  88859. private _highlightsHue;
  88860. private _highlightsDensity;
  88861. private _highlightsSaturation;
  88862. private _highlightsExposure;
  88863. /**
  88864. * Gets the highlights Hue value.
  88865. * 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).
  88866. */
  88867. get highlightsHue(): number;
  88868. /**
  88869. * Sets the highlights Hue value.
  88870. * 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).
  88871. */
  88872. set highlightsHue(value: number);
  88873. /**
  88874. * Gets the highlights Density value.
  88875. * 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.
  88876. * Values less than zero provide a filter of opposite hue.
  88877. */
  88878. get highlightsDensity(): number;
  88879. /**
  88880. * Sets the highlights Density value.
  88881. * 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.
  88882. * Values less than zero provide a filter of opposite hue.
  88883. */
  88884. set highlightsDensity(value: number);
  88885. /**
  88886. * Gets the highlights Saturation value.
  88887. * 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.
  88888. */
  88889. get highlightsSaturation(): number;
  88890. /**
  88891. * Sets the highlights Saturation value.
  88892. * 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.
  88893. */
  88894. set highlightsSaturation(value: number);
  88895. /**
  88896. * Gets the highlights Exposure value.
  88897. * 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.
  88898. */
  88899. get highlightsExposure(): number;
  88900. /**
  88901. * Sets the highlights Exposure value.
  88902. * 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.
  88903. */
  88904. set highlightsExposure(value: number);
  88905. private _midtonesHue;
  88906. private _midtonesDensity;
  88907. private _midtonesSaturation;
  88908. private _midtonesExposure;
  88909. /**
  88910. * Gets the midtones Hue value.
  88911. * 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).
  88912. */
  88913. get midtonesHue(): number;
  88914. /**
  88915. * Sets the midtones Hue value.
  88916. * 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).
  88917. */
  88918. set midtonesHue(value: number);
  88919. /**
  88920. * Gets the midtones Density value.
  88921. * 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.
  88922. * Values less than zero provide a filter of opposite hue.
  88923. */
  88924. get midtonesDensity(): number;
  88925. /**
  88926. * Sets the midtones Density value.
  88927. * 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.
  88928. * Values less than zero provide a filter of opposite hue.
  88929. */
  88930. set midtonesDensity(value: number);
  88931. /**
  88932. * Gets the midtones Saturation value.
  88933. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  88934. */
  88935. get midtonesSaturation(): number;
  88936. /**
  88937. * Sets the midtones Saturation value.
  88938. * 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.
  88939. */
  88940. set midtonesSaturation(value: number);
  88941. /**
  88942. * Gets the midtones Exposure value.
  88943. * 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.
  88944. */
  88945. get midtonesExposure(): number;
  88946. /**
  88947. * Sets the midtones Exposure value.
  88948. * 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.
  88949. */
  88950. set midtonesExposure(value: number);
  88951. private _shadowsHue;
  88952. private _shadowsDensity;
  88953. private _shadowsSaturation;
  88954. private _shadowsExposure;
  88955. /**
  88956. * Gets the shadows Hue value.
  88957. * 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).
  88958. */
  88959. get shadowsHue(): number;
  88960. /**
  88961. * Sets the shadows Hue value.
  88962. * 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).
  88963. */
  88964. set shadowsHue(value: number);
  88965. /**
  88966. * Gets the shadows Density value.
  88967. * 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.
  88968. * Values less than zero provide a filter of opposite hue.
  88969. */
  88970. get shadowsDensity(): number;
  88971. /**
  88972. * Sets the shadows Density value.
  88973. * 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.
  88974. * Values less than zero provide a filter of opposite hue.
  88975. */
  88976. set shadowsDensity(value: number);
  88977. /**
  88978. * Gets the shadows Saturation value.
  88979. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  88980. */
  88981. get shadowsSaturation(): number;
  88982. /**
  88983. * Sets the shadows Saturation value.
  88984. * 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.
  88985. */
  88986. set shadowsSaturation(value: number);
  88987. /**
  88988. * Gets the shadows Exposure value.
  88989. * 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.
  88990. */
  88991. get shadowsExposure(): number;
  88992. /**
  88993. * Sets the shadows Exposure value.
  88994. * 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.
  88995. */
  88996. set shadowsExposure(value: number);
  88997. /**
  88998. * Returns the class name
  88999. * @returns The class name
  89000. */
  89001. getClassName(): string;
  89002. /**
  89003. * Binds the color curves to the shader.
  89004. * @param colorCurves The color curve to bind
  89005. * @param effect The effect to bind to
  89006. * @param positiveUniform The positive uniform shader parameter
  89007. * @param neutralUniform The neutral uniform shader parameter
  89008. * @param negativeUniform The negative uniform shader parameter
  89009. */
  89010. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89011. /**
  89012. * Prepare the list of uniforms associated with the ColorCurves effects.
  89013. * @param uniformsList The list of uniforms used in the effect
  89014. */
  89015. static PrepareUniforms(uniformsList: string[]): void;
  89016. /**
  89017. * Returns color grading data based on a hue, density, saturation and exposure value.
  89018. * @param filterHue The hue of the color filter.
  89019. * @param filterDensity The density of the color filter.
  89020. * @param saturation The saturation.
  89021. * @param exposure The exposure.
  89022. * @param result The result data container.
  89023. */
  89024. private getColorGradingDataToRef;
  89025. /**
  89026. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89027. * @param value The input slider value in range [-100,100].
  89028. * @returns Adjusted value.
  89029. */
  89030. private static applyColorGradingSliderNonlinear;
  89031. /**
  89032. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89033. * @param hue The hue (H) input.
  89034. * @param saturation The saturation (S) input.
  89035. * @param brightness The brightness (B) input.
  89036. * @result An RGBA color represented as Vector4.
  89037. */
  89038. private static fromHSBToRef;
  89039. /**
  89040. * Returns a value clamped between min and max
  89041. * @param value The value to clamp
  89042. * @param min The minimum of value
  89043. * @param max The maximum of value
  89044. * @returns The clamped value.
  89045. */
  89046. private static clamp;
  89047. /**
  89048. * Clones the current color curve instance.
  89049. * @return The cloned curves
  89050. */
  89051. clone(): ColorCurves;
  89052. /**
  89053. * Serializes the current color curve instance to a json representation.
  89054. * @return a JSON representation
  89055. */
  89056. serialize(): any;
  89057. /**
  89058. * Parses the color curve from a json representation.
  89059. * @param source the JSON source to parse
  89060. * @return The parsed curves
  89061. */
  89062. static Parse(source: any): ColorCurves;
  89063. }
  89064. }
  89065. declare module BABYLON {
  89066. /**
  89067. * Interface to follow in your material defines to integrate easily the
  89068. * Image proccessing functions.
  89069. * @hidden
  89070. */
  89071. export interface IImageProcessingConfigurationDefines {
  89072. IMAGEPROCESSING: boolean;
  89073. VIGNETTE: boolean;
  89074. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89075. VIGNETTEBLENDMODEOPAQUE: boolean;
  89076. TONEMAPPING: boolean;
  89077. TONEMAPPING_ACES: boolean;
  89078. CONTRAST: boolean;
  89079. EXPOSURE: boolean;
  89080. COLORCURVES: boolean;
  89081. COLORGRADING: boolean;
  89082. COLORGRADING3D: boolean;
  89083. SAMPLER3DGREENDEPTH: boolean;
  89084. SAMPLER3DBGRMAP: boolean;
  89085. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89086. }
  89087. /**
  89088. * @hidden
  89089. */
  89090. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89091. IMAGEPROCESSING: boolean;
  89092. VIGNETTE: boolean;
  89093. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89094. VIGNETTEBLENDMODEOPAQUE: boolean;
  89095. TONEMAPPING: boolean;
  89096. TONEMAPPING_ACES: boolean;
  89097. CONTRAST: boolean;
  89098. COLORCURVES: boolean;
  89099. COLORGRADING: boolean;
  89100. COLORGRADING3D: boolean;
  89101. SAMPLER3DGREENDEPTH: boolean;
  89102. SAMPLER3DBGRMAP: boolean;
  89103. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89104. EXPOSURE: boolean;
  89105. constructor();
  89106. }
  89107. /**
  89108. * This groups together the common properties used for image processing either in direct forward pass
  89109. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89110. * or not.
  89111. */
  89112. export class ImageProcessingConfiguration {
  89113. /**
  89114. * Default tone mapping applied in BabylonJS.
  89115. */
  89116. static readonly TONEMAPPING_STANDARD: number;
  89117. /**
  89118. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89119. * to other engines rendering to increase portability.
  89120. */
  89121. static readonly TONEMAPPING_ACES: number;
  89122. /**
  89123. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89124. */
  89125. colorCurves: Nullable<ColorCurves>;
  89126. private _colorCurvesEnabled;
  89127. /**
  89128. * Gets wether the color curves effect is enabled.
  89129. */
  89130. get colorCurvesEnabled(): boolean;
  89131. /**
  89132. * Sets wether the color curves effect is enabled.
  89133. */
  89134. set colorCurvesEnabled(value: boolean);
  89135. private _colorGradingTexture;
  89136. /**
  89137. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89138. */
  89139. get colorGradingTexture(): Nullable<BaseTexture>;
  89140. /**
  89141. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89142. */
  89143. set colorGradingTexture(value: Nullable<BaseTexture>);
  89144. private _colorGradingEnabled;
  89145. /**
  89146. * Gets wether the color grading effect is enabled.
  89147. */
  89148. get colorGradingEnabled(): boolean;
  89149. /**
  89150. * Sets wether the color grading effect is enabled.
  89151. */
  89152. set colorGradingEnabled(value: boolean);
  89153. private _colorGradingWithGreenDepth;
  89154. /**
  89155. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89156. */
  89157. get colorGradingWithGreenDepth(): boolean;
  89158. /**
  89159. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89160. */
  89161. set colorGradingWithGreenDepth(value: boolean);
  89162. private _colorGradingBGR;
  89163. /**
  89164. * Gets wether the color grading texture contains BGR values.
  89165. */
  89166. get colorGradingBGR(): boolean;
  89167. /**
  89168. * Sets wether the color grading texture contains BGR values.
  89169. */
  89170. set colorGradingBGR(value: boolean);
  89171. /** @hidden */
  89172. _exposure: number;
  89173. /**
  89174. * Gets the Exposure used in the effect.
  89175. */
  89176. get exposure(): number;
  89177. /**
  89178. * Sets the Exposure used in the effect.
  89179. */
  89180. set exposure(value: number);
  89181. private _toneMappingEnabled;
  89182. /**
  89183. * Gets wether the tone mapping effect is enabled.
  89184. */
  89185. get toneMappingEnabled(): boolean;
  89186. /**
  89187. * Sets wether the tone mapping effect is enabled.
  89188. */
  89189. set toneMappingEnabled(value: boolean);
  89190. private _toneMappingType;
  89191. /**
  89192. * Gets the type of tone mapping effect.
  89193. */
  89194. get toneMappingType(): number;
  89195. /**
  89196. * Sets the type of tone mapping effect used in BabylonJS.
  89197. */
  89198. set toneMappingType(value: number);
  89199. protected _contrast: number;
  89200. /**
  89201. * Gets the contrast used in the effect.
  89202. */
  89203. get contrast(): number;
  89204. /**
  89205. * Sets the contrast used in the effect.
  89206. */
  89207. set contrast(value: number);
  89208. /**
  89209. * Vignette stretch size.
  89210. */
  89211. vignetteStretch: number;
  89212. /**
  89213. * Vignette centre X Offset.
  89214. */
  89215. vignetteCentreX: number;
  89216. /**
  89217. * Vignette centre Y Offset.
  89218. */
  89219. vignetteCentreY: number;
  89220. /**
  89221. * Vignette weight or intensity of the vignette effect.
  89222. */
  89223. vignetteWeight: number;
  89224. /**
  89225. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89226. * if vignetteEnabled is set to true.
  89227. */
  89228. vignetteColor: Color4;
  89229. /**
  89230. * Camera field of view used by the Vignette effect.
  89231. */
  89232. vignetteCameraFov: number;
  89233. private _vignetteBlendMode;
  89234. /**
  89235. * Gets the vignette blend mode allowing different kind of effect.
  89236. */
  89237. get vignetteBlendMode(): number;
  89238. /**
  89239. * Sets the vignette blend mode allowing different kind of effect.
  89240. */
  89241. set vignetteBlendMode(value: number);
  89242. private _vignetteEnabled;
  89243. /**
  89244. * Gets wether the vignette effect is enabled.
  89245. */
  89246. get vignetteEnabled(): boolean;
  89247. /**
  89248. * Sets wether the vignette effect is enabled.
  89249. */
  89250. set vignetteEnabled(value: boolean);
  89251. private _applyByPostProcess;
  89252. /**
  89253. * Gets wether the image processing is applied through a post process or not.
  89254. */
  89255. get applyByPostProcess(): boolean;
  89256. /**
  89257. * Sets wether the image processing is applied through a post process or not.
  89258. */
  89259. set applyByPostProcess(value: boolean);
  89260. private _isEnabled;
  89261. /**
  89262. * Gets wether the image processing is enabled or not.
  89263. */
  89264. get isEnabled(): boolean;
  89265. /**
  89266. * Sets wether the image processing is enabled or not.
  89267. */
  89268. set isEnabled(value: boolean);
  89269. /**
  89270. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89271. */
  89272. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89273. /**
  89274. * Method called each time the image processing information changes requires to recompile the effect.
  89275. */
  89276. protected _updateParameters(): void;
  89277. /**
  89278. * Gets the current class name.
  89279. * @return "ImageProcessingConfiguration"
  89280. */
  89281. getClassName(): string;
  89282. /**
  89283. * Prepare the list of uniforms associated with the Image Processing effects.
  89284. * @param uniforms The list of uniforms used in the effect
  89285. * @param defines the list of defines currently in use
  89286. */
  89287. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89288. /**
  89289. * Prepare the list of samplers associated with the Image Processing effects.
  89290. * @param samplersList The list of uniforms used in the effect
  89291. * @param defines the list of defines currently in use
  89292. */
  89293. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89294. /**
  89295. * Prepare the list of defines associated to the shader.
  89296. * @param defines the list of defines to complete
  89297. * @param forPostProcess Define if we are currently in post process mode or not
  89298. */
  89299. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89300. /**
  89301. * Returns true if all the image processing information are ready.
  89302. * @returns True if ready, otherwise, false
  89303. */
  89304. isReady(): boolean;
  89305. /**
  89306. * Binds the image processing to the shader.
  89307. * @param effect The effect to bind to
  89308. * @param overrideAspectRatio Override the aspect ratio of the effect
  89309. */
  89310. bind(effect: Effect, overrideAspectRatio?: number): void;
  89311. /**
  89312. * Clones the current image processing instance.
  89313. * @return The cloned image processing
  89314. */
  89315. clone(): ImageProcessingConfiguration;
  89316. /**
  89317. * Serializes the current image processing instance to a json representation.
  89318. * @return a JSON representation
  89319. */
  89320. serialize(): any;
  89321. /**
  89322. * Parses the image processing from a json representation.
  89323. * @param source the JSON source to parse
  89324. * @return The parsed image processing
  89325. */
  89326. static Parse(source: any): ImageProcessingConfiguration;
  89327. private static _VIGNETTEMODE_MULTIPLY;
  89328. private static _VIGNETTEMODE_OPAQUE;
  89329. /**
  89330. * Used to apply the vignette as a mix with the pixel color.
  89331. */
  89332. static get VIGNETTEMODE_MULTIPLY(): number;
  89333. /**
  89334. * Used to apply the vignette as a replacement of the pixel color.
  89335. */
  89336. static get VIGNETTEMODE_OPAQUE(): number;
  89337. }
  89338. }
  89339. declare module BABYLON {
  89340. /** @hidden */
  89341. export var postprocessVertexShader: {
  89342. name: string;
  89343. shader: string;
  89344. };
  89345. }
  89346. declare module BABYLON {
  89347. /**
  89348. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89349. */
  89350. export type RenderTargetTextureSize = number | {
  89351. width: number;
  89352. height: number;
  89353. layers?: number;
  89354. };
  89355. interface ThinEngine {
  89356. /**
  89357. * Creates a new render target texture
  89358. * @param size defines the size of the texture
  89359. * @param options defines the options used to create the texture
  89360. * @returns a new render target texture stored in an InternalTexture
  89361. */
  89362. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89363. /**
  89364. * Creates a depth stencil texture.
  89365. * This is only available in WebGL 2 or with the depth texture extension available.
  89366. * @param size The size of face edge in the texture.
  89367. * @param options The options defining the texture.
  89368. * @returns The texture
  89369. */
  89370. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89371. /** @hidden */
  89372. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89373. }
  89374. }
  89375. declare module BABYLON {
  89376. /**
  89377. * Defines the kind of connection point for node based material
  89378. */
  89379. export enum NodeMaterialBlockConnectionPointTypes {
  89380. /** Float */
  89381. Float = 1,
  89382. /** Int */
  89383. Int = 2,
  89384. /** Vector2 */
  89385. Vector2 = 4,
  89386. /** Vector3 */
  89387. Vector3 = 8,
  89388. /** Vector4 */
  89389. Vector4 = 16,
  89390. /** Color3 */
  89391. Color3 = 32,
  89392. /** Color4 */
  89393. Color4 = 64,
  89394. /** Matrix */
  89395. Matrix = 128,
  89396. /** Custom object */
  89397. Object = 256,
  89398. /** Detect type based on connection */
  89399. AutoDetect = 1024,
  89400. /** Output type that will be defined by input type */
  89401. BasedOnInput = 2048
  89402. }
  89403. }
  89404. declare module BABYLON {
  89405. /**
  89406. * Enum used to define the target of a block
  89407. */
  89408. export enum NodeMaterialBlockTargets {
  89409. /** Vertex shader */
  89410. Vertex = 1,
  89411. /** Fragment shader */
  89412. Fragment = 2,
  89413. /** Neutral */
  89414. Neutral = 4,
  89415. /** Vertex and Fragment */
  89416. VertexAndFragment = 3
  89417. }
  89418. }
  89419. declare module BABYLON {
  89420. /**
  89421. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89422. */
  89423. export enum NodeMaterialBlockConnectionPointMode {
  89424. /** Value is an uniform */
  89425. Uniform = 0,
  89426. /** Value is a mesh attribute */
  89427. Attribute = 1,
  89428. /** Value is a varying between vertex and fragment shaders */
  89429. Varying = 2,
  89430. /** Mode is undefined */
  89431. Undefined = 3
  89432. }
  89433. }
  89434. declare module BABYLON {
  89435. /**
  89436. * Enum used to define system values e.g. values automatically provided by the system
  89437. */
  89438. export enum NodeMaterialSystemValues {
  89439. /** World */
  89440. World = 1,
  89441. /** View */
  89442. View = 2,
  89443. /** Projection */
  89444. Projection = 3,
  89445. /** ViewProjection */
  89446. ViewProjection = 4,
  89447. /** WorldView */
  89448. WorldView = 5,
  89449. /** WorldViewProjection */
  89450. WorldViewProjection = 6,
  89451. /** CameraPosition */
  89452. CameraPosition = 7,
  89453. /** Fog Color */
  89454. FogColor = 8,
  89455. /** Delta time */
  89456. DeltaTime = 9
  89457. }
  89458. }
  89459. declare module BABYLON {
  89460. /** Defines supported spaces */
  89461. export enum Space {
  89462. /** Local (object) space */
  89463. LOCAL = 0,
  89464. /** World space */
  89465. WORLD = 1,
  89466. /** Bone space */
  89467. BONE = 2
  89468. }
  89469. /** Defines the 3 main axes */
  89470. export class Axis {
  89471. /** X axis */
  89472. static X: Vector3;
  89473. /** Y axis */
  89474. static Y: Vector3;
  89475. /** Z axis */
  89476. static Z: Vector3;
  89477. }
  89478. }
  89479. declare module BABYLON {
  89480. /**
  89481. * Represents a camera frustum
  89482. */
  89483. export class Frustum {
  89484. /**
  89485. * Gets the planes representing the frustum
  89486. * @param transform matrix to be applied to the returned planes
  89487. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89488. */
  89489. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89490. /**
  89491. * Gets the near frustum plane transformed by the transform matrix
  89492. * @param transform transformation matrix to be applied to the resulting frustum plane
  89493. * @param frustumPlane the resuling frustum plane
  89494. */
  89495. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89496. /**
  89497. * Gets the far frustum plane transformed by the transform matrix
  89498. * @param transform transformation matrix to be applied to the resulting frustum plane
  89499. * @param frustumPlane the resuling frustum plane
  89500. */
  89501. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89502. /**
  89503. * Gets the left frustum plane transformed by the transform matrix
  89504. * @param transform transformation matrix to be applied to the resulting frustum plane
  89505. * @param frustumPlane the resuling frustum plane
  89506. */
  89507. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89508. /**
  89509. * Gets the right frustum plane transformed by the transform matrix
  89510. * @param transform transformation matrix to be applied to the resulting frustum plane
  89511. * @param frustumPlane the resuling frustum plane
  89512. */
  89513. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89514. /**
  89515. * Gets the top frustum plane transformed by the transform matrix
  89516. * @param transform transformation matrix to be applied to the resulting frustum plane
  89517. * @param frustumPlane the resuling frustum plane
  89518. */
  89519. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89520. /**
  89521. * Gets the bottom frustum plane transformed by the transform matrix
  89522. * @param transform transformation matrix to be applied to the resulting frustum plane
  89523. * @param frustumPlane the resuling frustum plane
  89524. */
  89525. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89526. /**
  89527. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89528. * @param transform transformation matrix to be applied to the resulting frustum planes
  89529. * @param frustumPlanes the resuling frustum planes
  89530. */
  89531. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89532. }
  89533. }
  89534. declare module BABYLON {
  89535. /**
  89536. * Interface for the size containing width and height
  89537. */
  89538. export interface ISize {
  89539. /**
  89540. * Width
  89541. */
  89542. width: number;
  89543. /**
  89544. * Heighht
  89545. */
  89546. height: number;
  89547. }
  89548. /**
  89549. * Size containing widht and height
  89550. */
  89551. export class Size implements ISize {
  89552. /**
  89553. * Width
  89554. */
  89555. width: number;
  89556. /**
  89557. * Height
  89558. */
  89559. height: number;
  89560. /**
  89561. * Creates a Size object from the given width and height (floats).
  89562. * @param width width of the new size
  89563. * @param height height of the new size
  89564. */
  89565. constructor(width: number, height: number);
  89566. /**
  89567. * Returns a string with the Size width and height
  89568. * @returns a string with the Size width and height
  89569. */
  89570. toString(): string;
  89571. /**
  89572. * "Size"
  89573. * @returns the string "Size"
  89574. */
  89575. getClassName(): string;
  89576. /**
  89577. * Returns the Size hash code.
  89578. * @returns a hash code for a unique width and height
  89579. */
  89580. getHashCode(): number;
  89581. /**
  89582. * Updates the current size from the given one.
  89583. * @param src the given size
  89584. */
  89585. copyFrom(src: Size): void;
  89586. /**
  89587. * Updates in place the current Size from the given floats.
  89588. * @param width width of the new size
  89589. * @param height height of the new size
  89590. * @returns the updated Size.
  89591. */
  89592. copyFromFloats(width: number, height: number): Size;
  89593. /**
  89594. * Updates in place the current Size from the given floats.
  89595. * @param width width to set
  89596. * @param height height to set
  89597. * @returns the updated Size.
  89598. */
  89599. set(width: number, height: number): Size;
  89600. /**
  89601. * Multiplies the width and height by numbers
  89602. * @param w factor to multiple the width by
  89603. * @param h factor to multiple the height by
  89604. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89605. */
  89606. multiplyByFloats(w: number, h: number): Size;
  89607. /**
  89608. * Clones the size
  89609. * @returns a new Size copied from the given one.
  89610. */
  89611. clone(): Size;
  89612. /**
  89613. * True if the current Size and the given one width and height are strictly equal.
  89614. * @param other the other size to compare against
  89615. * @returns True if the current Size and the given one width and height are strictly equal.
  89616. */
  89617. equals(other: Size): boolean;
  89618. /**
  89619. * The surface of the Size : width * height (float).
  89620. */
  89621. get surface(): number;
  89622. /**
  89623. * Create a new size of zero
  89624. * @returns a new Size set to (0.0, 0.0)
  89625. */
  89626. static Zero(): Size;
  89627. /**
  89628. * Sums the width and height of two sizes
  89629. * @param otherSize size to add to this size
  89630. * @returns a new Size set as the addition result of the current Size and the given one.
  89631. */
  89632. add(otherSize: Size): Size;
  89633. /**
  89634. * Subtracts the width and height of two
  89635. * @param otherSize size to subtract to this size
  89636. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89637. */
  89638. subtract(otherSize: Size): Size;
  89639. /**
  89640. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89641. * @param start starting size to lerp between
  89642. * @param end end size to lerp between
  89643. * @param amount amount to lerp between the start and end values
  89644. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89645. */
  89646. static Lerp(start: Size, end: Size, amount: number): Size;
  89647. }
  89648. }
  89649. declare module BABYLON {
  89650. /**
  89651. * Contains position and normal vectors for a vertex
  89652. */
  89653. export class PositionNormalVertex {
  89654. /** the position of the vertex (defaut: 0,0,0) */
  89655. position: Vector3;
  89656. /** the normal of the vertex (defaut: 0,1,0) */
  89657. normal: Vector3;
  89658. /**
  89659. * Creates a PositionNormalVertex
  89660. * @param position the position of the vertex (defaut: 0,0,0)
  89661. * @param normal the normal of the vertex (defaut: 0,1,0)
  89662. */
  89663. constructor(
  89664. /** the position of the vertex (defaut: 0,0,0) */
  89665. position?: Vector3,
  89666. /** the normal of the vertex (defaut: 0,1,0) */
  89667. normal?: Vector3);
  89668. /**
  89669. * Clones the PositionNormalVertex
  89670. * @returns the cloned PositionNormalVertex
  89671. */
  89672. clone(): PositionNormalVertex;
  89673. }
  89674. /**
  89675. * Contains position, normal and uv vectors for a vertex
  89676. */
  89677. export class PositionNormalTextureVertex {
  89678. /** the position of the vertex (defaut: 0,0,0) */
  89679. position: Vector3;
  89680. /** the normal of the vertex (defaut: 0,1,0) */
  89681. normal: Vector3;
  89682. /** the uv of the vertex (default: 0,0) */
  89683. uv: Vector2;
  89684. /**
  89685. * Creates a PositionNormalTextureVertex
  89686. * @param position the position of the vertex (defaut: 0,0,0)
  89687. * @param normal the normal of the vertex (defaut: 0,1,0)
  89688. * @param uv the uv of the vertex (default: 0,0)
  89689. */
  89690. constructor(
  89691. /** the position of the vertex (defaut: 0,0,0) */
  89692. position?: Vector3,
  89693. /** the normal of the vertex (defaut: 0,1,0) */
  89694. normal?: Vector3,
  89695. /** the uv of the vertex (default: 0,0) */
  89696. uv?: Vector2);
  89697. /**
  89698. * Clones the PositionNormalTextureVertex
  89699. * @returns the cloned PositionNormalTextureVertex
  89700. */
  89701. clone(): PositionNormalTextureVertex;
  89702. }
  89703. }
  89704. declare module BABYLON {
  89705. /**
  89706. * Enum defining the type of animations supported by InputBlock
  89707. */
  89708. export enum AnimatedInputBlockTypes {
  89709. /** No animation */
  89710. None = 0,
  89711. /** Time based animation. Will only work for floats */
  89712. Time = 1
  89713. }
  89714. }
  89715. declare module BABYLON {
  89716. /**
  89717. * Interface describing all the common properties and methods a shadow light needs to implement.
  89718. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89719. * as well as binding the different shadow properties to the effects.
  89720. */
  89721. export interface IShadowLight extends Light {
  89722. /**
  89723. * The light id in the scene (used in scene.findLighById for instance)
  89724. */
  89725. id: string;
  89726. /**
  89727. * The position the shdow will be casted from.
  89728. */
  89729. position: Vector3;
  89730. /**
  89731. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89732. */
  89733. direction: Vector3;
  89734. /**
  89735. * The transformed position. Position of the light in world space taking parenting in account.
  89736. */
  89737. transformedPosition: Vector3;
  89738. /**
  89739. * The transformed direction. Direction of the light in world space taking parenting in account.
  89740. */
  89741. transformedDirection: Vector3;
  89742. /**
  89743. * The friendly name of the light in the scene.
  89744. */
  89745. name: string;
  89746. /**
  89747. * Defines the shadow projection clipping minimum z value.
  89748. */
  89749. shadowMinZ: number;
  89750. /**
  89751. * Defines the shadow projection clipping maximum z value.
  89752. */
  89753. shadowMaxZ: number;
  89754. /**
  89755. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89756. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89757. */
  89758. computeTransformedInformation(): boolean;
  89759. /**
  89760. * Gets the scene the light belongs to.
  89761. * @returns The scene
  89762. */
  89763. getScene(): Scene;
  89764. /**
  89765. * Callback defining a custom Projection Matrix Builder.
  89766. * This can be used to override the default projection matrix computation.
  89767. */
  89768. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89769. /**
  89770. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89771. * @param matrix The materix to updated with the projection information
  89772. * @param viewMatrix The transform matrix of the light
  89773. * @param renderList The list of mesh to render in the map
  89774. * @returns The current light
  89775. */
  89776. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89777. /**
  89778. * Gets the current depth scale used in ESM.
  89779. * @returns The scale
  89780. */
  89781. getDepthScale(): number;
  89782. /**
  89783. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89784. * @returns true if a cube texture needs to be use
  89785. */
  89786. needCube(): boolean;
  89787. /**
  89788. * Detects if the projection matrix requires to be recomputed this frame.
  89789. * @returns true if it requires to be recomputed otherwise, false.
  89790. */
  89791. needProjectionMatrixCompute(): boolean;
  89792. /**
  89793. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89794. */
  89795. forceProjectionMatrixCompute(): void;
  89796. /**
  89797. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89798. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89799. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89800. */
  89801. getShadowDirection(faceIndex?: number): Vector3;
  89802. /**
  89803. * Gets the minZ used for shadow according to both the scene and the light.
  89804. * @param activeCamera The camera we are returning the min for
  89805. * @returns the depth min z
  89806. */
  89807. getDepthMinZ(activeCamera: Camera): number;
  89808. /**
  89809. * Gets the maxZ used for shadow according to both the scene and the light.
  89810. * @param activeCamera The camera we are returning the max for
  89811. * @returns the depth max z
  89812. */
  89813. getDepthMaxZ(activeCamera: Camera): number;
  89814. }
  89815. /**
  89816. * Base implementation IShadowLight
  89817. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89818. */
  89819. export abstract class ShadowLight extends Light implements IShadowLight {
  89820. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89821. protected _position: Vector3;
  89822. protected _setPosition(value: Vector3): void;
  89823. /**
  89824. * Sets the position the shadow will be casted from. Also use as the light position for both
  89825. * point and spot lights.
  89826. */
  89827. get position(): Vector3;
  89828. /**
  89829. * Sets the position the shadow will be casted from. Also use as the light position for both
  89830. * point and spot lights.
  89831. */
  89832. set position(value: Vector3);
  89833. protected _direction: Vector3;
  89834. protected _setDirection(value: Vector3): void;
  89835. /**
  89836. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89837. * Also use as the light direction on spot and directional lights.
  89838. */
  89839. get direction(): Vector3;
  89840. /**
  89841. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89842. * Also use as the light direction on spot and directional lights.
  89843. */
  89844. set direction(value: Vector3);
  89845. protected _shadowMinZ: number;
  89846. /**
  89847. * Gets the shadow projection clipping minimum z value.
  89848. */
  89849. get shadowMinZ(): number;
  89850. /**
  89851. * Sets the shadow projection clipping minimum z value.
  89852. */
  89853. set shadowMinZ(value: number);
  89854. protected _shadowMaxZ: number;
  89855. /**
  89856. * Sets the shadow projection clipping maximum z value.
  89857. */
  89858. get shadowMaxZ(): number;
  89859. /**
  89860. * Gets the shadow projection clipping maximum z value.
  89861. */
  89862. set shadowMaxZ(value: number);
  89863. /**
  89864. * Callback defining a custom Projection Matrix Builder.
  89865. * This can be used to override the default projection matrix computation.
  89866. */
  89867. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89868. /**
  89869. * The transformed position. Position of the light in world space taking parenting in account.
  89870. */
  89871. transformedPosition: Vector3;
  89872. /**
  89873. * The transformed direction. Direction of the light in world space taking parenting in account.
  89874. */
  89875. transformedDirection: Vector3;
  89876. private _needProjectionMatrixCompute;
  89877. /**
  89878. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89879. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89880. */
  89881. computeTransformedInformation(): boolean;
  89882. /**
  89883. * Return the depth scale used for the shadow map.
  89884. * @returns the depth scale.
  89885. */
  89886. getDepthScale(): number;
  89887. /**
  89888. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89889. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89890. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89891. */
  89892. getShadowDirection(faceIndex?: number): Vector3;
  89893. /**
  89894. * Returns the ShadowLight absolute position in the World.
  89895. * @returns the position vector in world space
  89896. */
  89897. getAbsolutePosition(): Vector3;
  89898. /**
  89899. * Sets the ShadowLight direction toward the passed target.
  89900. * @param target The point to target in local space
  89901. * @returns the updated ShadowLight direction
  89902. */
  89903. setDirectionToTarget(target: Vector3): Vector3;
  89904. /**
  89905. * Returns the light rotation in euler definition.
  89906. * @returns the x y z rotation in local space.
  89907. */
  89908. getRotation(): Vector3;
  89909. /**
  89910. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89911. * @returns true if a cube texture needs to be use
  89912. */
  89913. needCube(): boolean;
  89914. /**
  89915. * Detects if the projection matrix requires to be recomputed this frame.
  89916. * @returns true if it requires to be recomputed otherwise, false.
  89917. */
  89918. needProjectionMatrixCompute(): boolean;
  89919. /**
  89920. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89921. */
  89922. forceProjectionMatrixCompute(): void;
  89923. /** @hidden */
  89924. _initCache(): void;
  89925. /** @hidden */
  89926. _isSynchronized(): boolean;
  89927. /**
  89928. * Computes the world matrix of the node
  89929. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89930. * @returns the world matrix
  89931. */
  89932. computeWorldMatrix(force?: boolean): Matrix;
  89933. /**
  89934. * Gets the minZ used for shadow according to both the scene and the light.
  89935. * @param activeCamera The camera we are returning the min for
  89936. * @returns the depth min z
  89937. */
  89938. getDepthMinZ(activeCamera: Camera): number;
  89939. /**
  89940. * Gets the maxZ used for shadow according to both the scene and the light.
  89941. * @param activeCamera The camera we are returning the max for
  89942. * @returns the depth max z
  89943. */
  89944. getDepthMaxZ(activeCamera: Camera): number;
  89945. /**
  89946. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89947. * @param matrix The materix to updated with the projection information
  89948. * @param viewMatrix The transform matrix of the light
  89949. * @param renderList The list of mesh to render in the map
  89950. * @returns The current light
  89951. */
  89952. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89953. }
  89954. }
  89955. declare module BABYLON {
  89956. /** @hidden */
  89957. export var packingFunctions: {
  89958. name: string;
  89959. shader: string;
  89960. };
  89961. }
  89962. declare module BABYLON {
  89963. /** @hidden */
  89964. export var bayerDitherFunctions: {
  89965. name: string;
  89966. shader: string;
  89967. };
  89968. }
  89969. declare module BABYLON {
  89970. /** @hidden */
  89971. export var shadowMapFragmentDeclaration: {
  89972. name: string;
  89973. shader: string;
  89974. };
  89975. }
  89976. declare module BABYLON {
  89977. /** @hidden */
  89978. export var clipPlaneFragmentDeclaration: {
  89979. name: string;
  89980. shader: string;
  89981. };
  89982. }
  89983. declare module BABYLON {
  89984. /** @hidden */
  89985. export var clipPlaneFragment: {
  89986. name: string;
  89987. shader: string;
  89988. };
  89989. }
  89990. declare module BABYLON {
  89991. /** @hidden */
  89992. export var shadowMapFragment: {
  89993. name: string;
  89994. shader: string;
  89995. };
  89996. }
  89997. declare module BABYLON {
  89998. /** @hidden */
  89999. export var shadowMapPixelShader: {
  90000. name: string;
  90001. shader: string;
  90002. };
  90003. }
  90004. declare module BABYLON {
  90005. /** @hidden */
  90006. export var bonesDeclaration: {
  90007. name: string;
  90008. shader: string;
  90009. };
  90010. }
  90011. declare module BABYLON {
  90012. /** @hidden */
  90013. export var morphTargetsVertexGlobalDeclaration: {
  90014. name: string;
  90015. shader: string;
  90016. };
  90017. }
  90018. declare module BABYLON {
  90019. /** @hidden */
  90020. export var morphTargetsVertexDeclaration: {
  90021. name: string;
  90022. shader: string;
  90023. };
  90024. }
  90025. declare module BABYLON {
  90026. /** @hidden */
  90027. export var instancesDeclaration: {
  90028. name: string;
  90029. shader: string;
  90030. };
  90031. }
  90032. declare module BABYLON {
  90033. /** @hidden */
  90034. export var helperFunctions: {
  90035. name: string;
  90036. shader: string;
  90037. };
  90038. }
  90039. declare module BABYLON {
  90040. /** @hidden */
  90041. export var shadowMapVertexDeclaration: {
  90042. name: string;
  90043. shader: string;
  90044. };
  90045. }
  90046. declare module BABYLON {
  90047. /** @hidden */
  90048. export var clipPlaneVertexDeclaration: {
  90049. name: string;
  90050. shader: string;
  90051. };
  90052. }
  90053. declare module BABYLON {
  90054. /** @hidden */
  90055. export var morphTargetsVertex: {
  90056. name: string;
  90057. shader: string;
  90058. };
  90059. }
  90060. declare module BABYLON {
  90061. /** @hidden */
  90062. export var instancesVertex: {
  90063. name: string;
  90064. shader: string;
  90065. };
  90066. }
  90067. declare module BABYLON {
  90068. /** @hidden */
  90069. export var bonesVertex: {
  90070. name: string;
  90071. shader: string;
  90072. };
  90073. }
  90074. declare module BABYLON {
  90075. /** @hidden */
  90076. export var shadowMapVertexNormalBias: {
  90077. name: string;
  90078. shader: string;
  90079. };
  90080. }
  90081. declare module BABYLON {
  90082. /** @hidden */
  90083. export var shadowMapVertexMetric: {
  90084. name: string;
  90085. shader: string;
  90086. };
  90087. }
  90088. declare module BABYLON {
  90089. /** @hidden */
  90090. export var clipPlaneVertex: {
  90091. name: string;
  90092. shader: string;
  90093. };
  90094. }
  90095. declare module BABYLON {
  90096. /** @hidden */
  90097. export var shadowMapVertexShader: {
  90098. name: string;
  90099. shader: string;
  90100. };
  90101. }
  90102. declare module BABYLON {
  90103. /** @hidden */
  90104. export var depthBoxBlurPixelShader: {
  90105. name: string;
  90106. shader: string;
  90107. };
  90108. }
  90109. declare module BABYLON {
  90110. /** @hidden */
  90111. export var shadowMapFragmentSoftTransparentShadow: {
  90112. name: string;
  90113. shader: string;
  90114. };
  90115. }
  90116. declare module BABYLON {
  90117. /**
  90118. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90119. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90120. */
  90121. export class EffectFallbacks implements IEffectFallbacks {
  90122. private _defines;
  90123. private _currentRank;
  90124. private _maxRank;
  90125. private _mesh;
  90126. /**
  90127. * Removes the fallback from the bound mesh.
  90128. */
  90129. unBindMesh(): void;
  90130. /**
  90131. * Adds a fallback on the specified property.
  90132. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90133. * @param define The name of the define in the shader
  90134. */
  90135. addFallback(rank: number, define: string): void;
  90136. /**
  90137. * Sets the mesh to use CPU skinning when needing to fallback.
  90138. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90139. * @param mesh The mesh to use the fallbacks.
  90140. */
  90141. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90142. /**
  90143. * Checks to see if more fallbacks are still availible.
  90144. */
  90145. get hasMoreFallbacks(): boolean;
  90146. /**
  90147. * Removes the defines that should be removed when falling back.
  90148. * @param currentDefines defines the current define statements for the shader.
  90149. * @param effect defines the current effect we try to compile
  90150. * @returns The resulting defines with defines of the current rank removed.
  90151. */
  90152. reduce(currentDefines: string, effect: Effect): string;
  90153. }
  90154. }
  90155. declare module BABYLON {
  90156. /**
  90157. * Interface used to define Action
  90158. */
  90159. export interface IAction {
  90160. /**
  90161. * Trigger for the action
  90162. */
  90163. trigger: number;
  90164. /** Options of the trigger */
  90165. triggerOptions: any;
  90166. /**
  90167. * Gets the trigger parameters
  90168. * @returns the trigger parameters
  90169. */
  90170. getTriggerParameter(): any;
  90171. /**
  90172. * Internal only - executes current action event
  90173. * @hidden
  90174. */
  90175. _executeCurrent(evt?: ActionEvent): void;
  90176. /**
  90177. * Serialize placeholder for child classes
  90178. * @param parent of child
  90179. * @returns the serialized object
  90180. */
  90181. serialize(parent: any): any;
  90182. /**
  90183. * Internal only
  90184. * @hidden
  90185. */
  90186. _prepare(): void;
  90187. /**
  90188. * Internal only - manager for action
  90189. * @hidden
  90190. */
  90191. _actionManager: Nullable<AbstractActionManager>;
  90192. /**
  90193. * Adds action to chain of actions, may be a DoNothingAction
  90194. * @param action defines the next action to execute
  90195. * @returns The action passed in
  90196. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90197. */
  90198. then(action: IAction): IAction;
  90199. }
  90200. /**
  90201. * The action to be carried out following a trigger
  90202. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90203. */
  90204. export class Action implements IAction {
  90205. /** the trigger, with or without parameters, for the action */
  90206. triggerOptions: any;
  90207. /**
  90208. * Trigger for the action
  90209. */
  90210. trigger: number;
  90211. /**
  90212. * Internal only - manager for action
  90213. * @hidden
  90214. */
  90215. _actionManager: ActionManager;
  90216. private _nextActiveAction;
  90217. private _child;
  90218. private _condition?;
  90219. private _triggerParameter;
  90220. /**
  90221. * An event triggered prior to action being executed.
  90222. */
  90223. onBeforeExecuteObservable: Observable<Action>;
  90224. /**
  90225. * Creates a new Action
  90226. * @param triggerOptions the trigger, with or without parameters, for the action
  90227. * @param condition an optional determinant of action
  90228. */
  90229. constructor(
  90230. /** the trigger, with or without parameters, for the action */
  90231. triggerOptions: any, condition?: Condition);
  90232. /**
  90233. * Internal only
  90234. * @hidden
  90235. */
  90236. _prepare(): void;
  90237. /**
  90238. * Gets the trigger parameters
  90239. * @returns the trigger parameters
  90240. */
  90241. getTriggerParameter(): any;
  90242. /**
  90243. * Internal only - executes current action event
  90244. * @hidden
  90245. */
  90246. _executeCurrent(evt?: ActionEvent): void;
  90247. /**
  90248. * Execute placeholder for child classes
  90249. * @param evt optional action event
  90250. */
  90251. execute(evt?: ActionEvent): void;
  90252. /**
  90253. * Skips to next active action
  90254. */
  90255. skipToNextActiveAction(): void;
  90256. /**
  90257. * Adds action to chain of actions, may be a DoNothingAction
  90258. * @param action defines the next action to execute
  90259. * @returns The action passed in
  90260. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90261. */
  90262. then(action: Action): Action;
  90263. /**
  90264. * Internal only
  90265. * @hidden
  90266. */
  90267. _getProperty(propertyPath: string): string;
  90268. /**
  90269. * Internal only
  90270. * @hidden
  90271. */
  90272. _getEffectiveTarget(target: any, propertyPath: string): any;
  90273. /**
  90274. * Serialize placeholder for child classes
  90275. * @param parent of child
  90276. * @returns the serialized object
  90277. */
  90278. serialize(parent: any): any;
  90279. /**
  90280. * Internal only called by serialize
  90281. * @hidden
  90282. */
  90283. protected _serialize(serializedAction: any, parent?: any): any;
  90284. /**
  90285. * Internal only
  90286. * @hidden
  90287. */
  90288. static _SerializeValueAsString: (value: any) => string;
  90289. /**
  90290. * Internal only
  90291. * @hidden
  90292. */
  90293. static _GetTargetProperty: (target: Scene | Node) => {
  90294. name: string;
  90295. targetType: string;
  90296. value: string;
  90297. };
  90298. }
  90299. }
  90300. declare module BABYLON {
  90301. /**
  90302. * A Condition applied to an Action
  90303. */
  90304. export class Condition {
  90305. /**
  90306. * Internal only - manager for action
  90307. * @hidden
  90308. */
  90309. _actionManager: ActionManager;
  90310. /**
  90311. * Internal only
  90312. * @hidden
  90313. */
  90314. _evaluationId: number;
  90315. /**
  90316. * Internal only
  90317. * @hidden
  90318. */
  90319. _currentResult: boolean;
  90320. /**
  90321. * Creates a new Condition
  90322. * @param actionManager the manager of the action the condition is applied to
  90323. */
  90324. constructor(actionManager: ActionManager);
  90325. /**
  90326. * Check if the current condition is valid
  90327. * @returns a boolean
  90328. */
  90329. isValid(): boolean;
  90330. /**
  90331. * Internal only
  90332. * @hidden
  90333. */
  90334. _getProperty(propertyPath: string): string;
  90335. /**
  90336. * Internal only
  90337. * @hidden
  90338. */
  90339. _getEffectiveTarget(target: any, propertyPath: string): any;
  90340. /**
  90341. * Serialize placeholder for child classes
  90342. * @returns the serialized object
  90343. */
  90344. serialize(): any;
  90345. /**
  90346. * Internal only
  90347. * @hidden
  90348. */
  90349. protected _serialize(serializedCondition: any): any;
  90350. }
  90351. /**
  90352. * Defines specific conditional operators as extensions of Condition
  90353. */
  90354. export class ValueCondition extends Condition {
  90355. /** path to specify the property of the target the conditional operator uses */
  90356. propertyPath: string;
  90357. /** the value compared by the conditional operator against the current value of the property */
  90358. value: any;
  90359. /** the conditional operator, default ValueCondition.IsEqual */
  90360. operator: number;
  90361. /**
  90362. * Internal only
  90363. * @hidden
  90364. */
  90365. private static _IsEqual;
  90366. /**
  90367. * Internal only
  90368. * @hidden
  90369. */
  90370. private static _IsDifferent;
  90371. /**
  90372. * Internal only
  90373. * @hidden
  90374. */
  90375. private static _IsGreater;
  90376. /**
  90377. * Internal only
  90378. * @hidden
  90379. */
  90380. private static _IsLesser;
  90381. /**
  90382. * returns the number for IsEqual
  90383. */
  90384. static get IsEqual(): number;
  90385. /**
  90386. * Returns the number for IsDifferent
  90387. */
  90388. static get IsDifferent(): number;
  90389. /**
  90390. * Returns the number for IsGreater
  90391. */
  90392. static get IsGreater(): number;
  90393. /**
  90394. * Returns the number for IsLesser
  90395. */
  90396. static get IsLesser(): number;
  90397. /**
  90398. * Internal only The action manager for the condition
  90399. * @hidden
  90400. */
  90401. _actionManager: ActionManager;
  90402. /**
  90403. * Internal only
  90404. * @hidden
  90405. */
  90406. private _target;
  90407. /**
  90408. * Internal only
  90409. * @hidden
  90410. */
  90411. private _effectiveTarget;
  90412. /**
  90413. * Internal only
  90414. * @hidden
  90415. */
  90416. private _property;
  90417. /**
  90418. * Creates a new ValueCondition
  90419. * @param actionManager manager for the action the condition applies to
  90420. * @param target for the action
  90421. * @param propertyPath path to specify the property of the target the conditional operator uses
  90422. * @param value the value compared by the conditional operator against the current value of the property
  90423. * @param operator the conditional operator, default ValueCondition.IsEqual
  90424. */
  90425. constructor(actionManager: ActionManager, target: any,
  90426. /** path to specify the property of the target the conditional operator uses */
  90427. propertyPath: string,
  90428. /** the value compared by the conditional operator against the current value of the property */
  90429. value: any,
  90430. /** the conditional operator, default ValueCondition.IsEqual */
  90431. operator?: number);
  90432. /**
  90433. * Compares the given value with the property value for the specified conditional operator
  90434. * @returns the result of the comparison
  90435. */
  90436. isValid(): boolean;
  90437. /**
  90438. * Serialize the ValueCondition into a JSON compatible object
  90439. * @returns serialization object
  90440. */
  90441. serialize(): any;
  90442. /**
  90443. * Gets the name of the conditional operator for the ValueCondition
  90444. * @param operator the conditional operator
  90445. * @returns the name
  90446. */
  90447. static GetOperatorName(operator: number): string;
  90448. }
  90449. /**
  90450. * Defines a predicate condition as an extension of Condition
  90451. */
  90452. export class PredicateCondition extends Condition {
  90453. /** defines the predicate function used to validate the condition */
  90454. predicate: () => boolean;
  90455. /**
  90456. * Internal only - manager for action
  90457. * @hidden
  90458. */
  90459. _actionManager: ActionManager;
  90460. /**
  90461. * Creates a new PredicateCondition
  90462. * @param actionManager manager for the action the condition applies to
  90463. * @param predicate defines the predicate function used to validate the condition
  90464. */
  90465. constructor(actionManager: ActionManager,
  90466. /** defines the predicate function used to validate the condition */
  90467. predicate: () => boolean);
  90468. /**
  90469. * @returns the validity of the predicate condition
  90470. */
  90471. isValid(): boolean;
  90472. }
  90473. /**
  90474. * Defines a state condition as an extension of Condition
  90475. */
  90476. export class StateCondition extends Condition {
  90477. /** Value to compare with target state */
  90478. value: string;
  90479. /**
  90480. * Internal only - manager for action
  90481. * @hidden
  90482. */
  90483. _actionManager: ActionManager;
  90484. /**
  90485. * Internal only
  90486. * @hidden
  90487. */
  90488. private _target;
  90489. /**
  90490. * Creates a new StateCondition
  90491. * @param actionManager manager for the action the condition applies to
  90492. * @param target of the condition
  90493. * @param value to compare with target state
  90494. */
  90495. constructor(actionManager: ActionManager, target: any,
  90496. /** Value to compare with target state */
  90497. value: string);
  90498. /**
  90499. * Gets a boolean indicating if the current condition is met
  90500. * @returns the validity of the state
  90501. */
  90502. isValid(): boolean;
  90503. /**
  90504. * Serialize the StateCondition into a JSON compatible object
  90505. * @returns serialization object
  90506. */
  90507. serialize(): any;
  90508. }
  90509. }
  90510. declare module BABYLON {
  90511. /**
  90512. * This defines an action responsible to toggle a boolean once triggered.
  90513. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90514. */
  90515. export class SwitchBooleanAction extends Action {
  90516. /**
  90517. * The path to the boolean property in the target object
  90518. */
  90519. propertyPath: string;
  90520. private _target;
  90521. private _effectiveTarget;
  90522. private _property;
  90523. /**
  90524. * Instantiate the action
  90525. * @param triggerOptions defines the trigger options
  90526. * @param target defines the object containing the boolean
  90527. * @param propertyPath defines the path to the boolean property in the target object
  90528. * @param condition defines the trigger related conditions
  90529. */
  90530. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90531. /** @hidden */
  90532. _prepare(): void;
  90533. /**
  90534. * Execute the action toggle the boolean value.
  90535. */
  90536. execute(): void;
  90537. /**
  90538. * Serializes the actions and its related information.
  90539. * @param parent defines the object to serialize in
  90540. * @returns the serialized object
  90541. */
  90542. serialize(parent: any): any;
  90543. }
  90544. /**
  90545. * This defines an action responsible to set a the state field of the target
  90546. * to a desired value once triggered.
  90547. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90548. */
  90549. export class SetStateAction extends Action {
  90550. /**
  90551. * The value to store in the state field.
  90552. */
  90553. value: string;
  90554. private _target;
  90555. /**
  90556. * Instantiate the action
  90557. * @param triggerOptions defines the trigger options
  90558. * @param target defines the object containing the state property
  90559. * @param value defines the value to store in the state field
  90560. * @param condition defines the trigger related conditions
  90561. */
  90562. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90563. /**
  90564. * Execute the action and store the value on the target state property.
  90565. */
  90566. execute(): void;
  90567. /**
  90568. * Serializes the actions and its related information.
  90569. * @param parent defines the object to serialize in
  90570. * @returns the serialized object
  90571. */
  90572. serialize(parent: any): any;
  90573. }
  90574. /**
  90575. * This defines an action responsible to set a property of the target
  90576. * to a desired value once triggered.
  90577. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90578. */
  90579. export class SetValueAction extends Action {
  90580. /**
  90581. * The path of the property to set in the target.
  90582. */
  90583. propertyPath: string;
  90584. /**
  90585. * The value to set in the property
  90586. */
  90587. value: any;
  90588. private _target;
  90589. private _effectiveTarget;
  90590. private _property;
  90591. /**
  90592. * Instantiate the action
  90593. * @param triggerOptions defines the trigger options
  90594. * @param target defines the object containing the property
  90595. * @param propertyPath defines the path of the property to set in the target
  90596. * @param value defines the value to set in the property
  90597. * @param condition defines the trigger related conditions
  90598. */
  90599. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90600. /** @hidden */
  90601. _prepare(): void;
  90602. /**
  90603. * Execute the action and set the targetted property to the desired value.
  90604. */
  90605. execute(): void;
  90606. /**
  90607. * Serializes the actions and its related information.
  90608. * @param parent defines the object to serialize in
  90609. * @returns the serialized object
  90610. */
  90611. serialize(parent: any): any;
  90612. }
  90613. /**
  90614. * This defines an action responsible to increment the target value
  90615. * to a desired value once triggered.
  90616. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90617. */
  90618. export class IncrementValueAction extends Action {
  90619. /**
  90620. * The path of the property to increment in the target.
  90621. */
  90622. propertyPath: string;
  90623. /**
  90624. * The value we should increment the property by.
  90625. */
  90626. value: any;
  90627. private _target;
  90628. private _effectiveTarget;
  90629. private _property;
  90630. /**
  90631. * Instantiate the action
  90632. * @param triggerOptions defines the trigger options
  90633. * @param target defines the object containing the property
  90634. * @param propertyPath defines the path of the property to increment in the target
  90635. * @param value defines the value value we should increment the property by
  90636. * @param condition defines the trigger related conditions
  90637. */
  90638. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90639. /** @hidden */
  90640. _prepare(): void;
  90641. /**
  90642. * Execute the action and increment the target of the value amount.
  90643. */
  90644. execute(): void;
  90645. /**
  90646. * Serializes the actions and its related information.
  90647. * @param parent defines the object to serialize in
  90648. * @returns the serialized object
  90649. */
  90650. serialize(parent: any): any;
  90651. }
  90652. /**
  90653. * This defines an action responsible to start an animation once triggered.
  90654. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90655. */
  90656. export class PlayAnimationAction extends Action {
  90657. /**
  90658. * Where the animation should start (animation frame)
  90659. */
  90660. from: number;
  90661. /**
  90662. * Where the animation should stop (animation frame)
  90663. */
  90664. to: number;
  90665. /**
  90666. * Define if the animation should loop or stop after the first play.
  90667. */
  90668. loop?: boolean;
  90669. private _target;
  90670. /**
  90671. * Instantiate the action
  90672. * @param triggerOptions defines the trigger options
  90673. * @param target defines the target animation or animation name
  90674. * @param from defines from where the animation should start (animation frame)
  90675. * @param end defines where the animation should stop (animation frame)
  90676. * @param loop defines if the animation should loop or stop after the first play
  90677. * @param condition defines the trigger related conditions
  90678. */
  90679. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90680. /** @hidden */
  90681. _prepare(): void;
  90682. /**
  90683. * Execute the action and play the animation.
  90684. */
  90685. execute(): void;
  90686. /**
  90687. * Serializes the actions and its related information.
  90688. * @param parent defines the object to serialize in
  90689. * @returns the serialized object
  90690. */
  90691. serialize(parent: any): any;
  90692. }
  90693. /**
  90694. * This defines an action responsible to stop an animation once triggered.
  90695. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90696. */
  90697. export class StopAnimationAction extends Action {
  90698. private _target;
  90699. /**
  90700. * Instantiate the action
  90701. * @param triggerOptions defines the trigger options
  90702. * @param target defines the target animation or animation name
  90703. * @param condition defines the trigger related conditions
  90704. */
  90705. constructor(triggerOptions: any, target: any, condition?: Condition);
  90706. /** @hidden */
  90707. _prepare(): void;
  90708. /**
  90709. * Execute the action and stop the animation.
  90710. */
  90711. execute(): void;
  90712. /**
  90713. * Serializes the actions and its related information.
  90714. * @param parent defines the object to serialize in
  90715. * @returns the serialized object
  90716. */
  90717. serialize(parent: any): any;
  90718. }
  90719. /**
  90720. * This defines an action responsible that does nothing once triggered.
  90721. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90722. */
  90723. export class DoNothingAction extends Action {
  90724. /**
  90725. * Instantiate the action
  90726. * @param triggerOptions defines the trigger options
  90727. * @param condition defines the trigger related conditions
  90728. */
  90729. constructor(triggerOptions?: any, condition?: Condition);
  90730. /**
  90731. * Execute the action and do nothing.
  90732. */
  90733. execute(): void;
  90734. /**
  90735. * Serializes the actions and its related information.
  90736. * @param parent defines the object to serialize in
  90737. * @returns the serialized object
  90738. */
  90739. serialize(parent: any): any;
  90740. }
  90741. /**
  90742. * This defines an action responsible to trigger several actions once triggered.
  90743. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90744. */
  90745. export class CombineAction extends Action {
  90746. /**
  90747. * The list of aggregated animations to run.
  90748. */
  90749. children: Action[];
  90750. /**
  90751. * Instantiate the action
  90752. * @param triggerOptions defines the trigger options
  90753. * @param children defines the list of aggregated animations to run
  90754. * @param condition defines the trigger related conditions
  90755. */
  90756. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90757. /** @hidden */
  90758. _prepare(): void;
  90759. /**
  90760. * Execute the action and executes all the aggregated actions.
  90761. */
  90762. execute(evt: ActionEvent): void;
  90763. /**
  90764. * Serializes the actions and its related information.
  90765. * @param parent defines the object to serialize in
  90766. * @returns the serialized object
  90767. */
  90768. serialize(parent: any): any;
  90769. }
  90770. /**
  90771. * This defines an action responsible to run code (external event) once triggered.
  90772. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90773. */
  90774. export class ExecuteCodeAction extends Action {
  90775. /**
  90776. * The callback function to run.
  90777. */
  90778. func: (evt: ActionEvent) => void;
  90779. /**
  90780. * Instantiate the action
  90781. * @param triggerOptions defines the trigger options
  90782. * @param func defines the callback function to run
  90783. * @param condition defines the trigger related conditions
  90784. */
  90785. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90786. /**
  90787. * Execute the action and run the attached code.
  90788. */
  90789. execute(evt: ActionEvent): void;
  90790. }
  90791. /**
  90792. * This defines an action responsible to set the parent property of the target once triggered.
  90793. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90794. */
  90795. export class SetParentAction extends Action {
  90796. private _parent;
  90797. private _target;
  90798. /**
  90799. * Instantiate the action
  90800. * @param triggerOptions defines the trigger options
  90801. * @param target defines the target containing the parent property
  90802. * @param parent defines from where the animation should start (animation frame)
  90803. * @param condition defines the trigger related conditions
  90804. */
  90805. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90806. /** @hidden */
  90807. _prepare(): void;
  90808. /**
  90809. * Execute the action and set the parent property.
  90810. */
  90811. execute(): void;
  90812. /**
  90813. * Serializes the actions and its related information.
  90814. * @param parent defines the object to serialize in
  90815. * @returns the serialized object
  90816. */
  90817. serialize(parent: any): any;
  90818. }
  90819. }
  90820. declare module BABYLON {
  90821. /**
  90822. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90823. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90824. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90825. */
  90826. export class ActionManager extends AbstractActionManager {
  90827. /**
  90828. * Nothing
  90829. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90830. */
  90831. static readonly NothingTrigger: number;
  90832. /**
  90833. * On pick
  90834. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90835. */
  90836. static readonly OnPickTrigger: number;
  90837. /**
  90838. * On left pick
  90839. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90840. */
  90841. static readonly OnLeftPickTrigger: number;
  90842. /**
  90843. * On right pick
  90844. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90845. */
  90846. static readonly OnRightPickTrigger: number;
  90847. /**
  90848. * On center pick
  90849. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90850. */
  90851. static readonly OnCenterPickTrigger: number;
  90852. /**
  90853. * On pick down
  90854. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90855. */
  90856. static readonly OnPickDownTrigger: number;
  90857. /**
  90858. * On double pick
  90859. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90860. */
  90861. static readonly OnDoublePickTrigger: number;
  90862. /**
  90863. * On pick up
  90864. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90865. */
  90866. static readonly OnPickUpTrigger: number;
  90867. /**
  90868. * On pick out.
  90869. * This trigger will only be raised if you also declared a OnPickDown
  90870. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90871. */
  90872. static readonly OnPickOutTrigger: number;
  90873. /**
  90874. * On long press
  90875. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90876. */
  90877. static readonly OnLongPressTrigger: number;
  90878. /**
  90879. * On pointer over
  90880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90881. */
  90882. static readonly OnPointerOverTrigger: number;
  90883. /**
  90884. * On pointer out
  90885. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90886. */
  90887. static readonly OnPointerOutTrigger: number;
  90888. /**
  90889. * On every frame
  90890. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90891. */
  90892. static readonly OnEveryFrameTrigger: number;
  90893. /**
  90894. * On intersection enter
  90895. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90896. */
  90897. static readonly OnIntersectionEnterTrigger: number;
  90898. /**
  90899. * On intersection exit
  90900. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90901. */
  90902. static readonly OnIntersectionExitTrigger: number;
  90903. /**
  90904. * On key down
  90905. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90906. */
  90907. static readonly OnKeyDownTrigger: number;
  90908. /**
  90909. * On key up
  90910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90911. */
  90912. static readonly OnKeyUpTrigger: number;
  90913. private _scene;
  90914. /**
  90915. * Creates a new action manager
  90916. * @param scene defines the hosting scene
  90917. */
  90918. constructor(scene: Scene);
  90919. /**
  90920. * Releases all associated resources
  90921. */
  90922. dispose(): void;
  90923. /**
  90924. * Gets hosting scene
  90925. * @returns the hosting scene
  90926. */
  90927. getScene(): Scene;
  90928. /**
  90929. * Does this action manager handles actions of any of the given triggers
  90930. * @param triggers defines the triggers to be tested
  90931. * @return a boolean indicating whether one (or more) of the triggers is handled
  90932. */
  90933. hasSpecificTriggers(triggers: number[]): boolean;
  90934. /**
  90935. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90936. * speed.
  90937. * @param triggerA defines the trigger to be tested
  90938. * @param triggerB defines the trigger to be tested
  90939. * @return a boolean indicating whether one (or more) of the triggers is handled
  90940. */
  90941. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90942. /**
  90943. * Does this action manager handles actions of a given trigger
  90944. * @param trigger defines the trigger to be tested
  90945. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90946. * @return whether the trigger is handled
  90947. */
  90948. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90949. /**
  90950. * Does this action manager has pointer triggers
  90951. */
  90952. get hasPointerTriggers(): boolean;
  90953. /**
  90954. * Does this action manager has pick triggers
  90955. */
  90956. get hasPickTriggers(): boolean;
  90957. /**
  90958. * Registers an action to this action manager
  90959. * @param action defines the action to be registered
  90960. * @return the action amended (prepared) after registration
  90961. */
  90962. registerAction(action: IAction): Nullable<IAction>;
  90963. /**
  90964. * Unregisters an action to this action manager
  90965. * @param action defines the action to be unregistered
  90966. * @return a boolean indicating whether the action has been unregistered
  90967. */
  90968. unregisterAction(action: IAction): Boolean;
  90969. /**
  90970. * Process a specific trigger
  90971. * @param trigger defines the trigger to process
  90972. * @param evt defines the event details to be processed
  90973. */
  90974. processTrigger(trigger: number, evt?: IActionEvent): void;
  90975. /** @hidden */
  90976. _getEffectiveTarget(target: any, propertyPath: string): any;
  90977. /** @hidden */
  90978. _getProperty(propertyPath: string): string;
  90979. /**
  90980. * Serialize this manager to a JSON object
  90981. * @param name defines the property name to store this manager
  90982. * @returns a JSON representation of this manager
  90983. */
  90984. serialize(name: string): any;
  90985. /**
  90986. * Creates a new ActionManager from a JSON data
  90987. * @param parsedActions defines the JSON data to read from
  90988. * @param object defines the hosting mesh
  90989. * @param scene defines the hosting scene
  90990. */
  90991. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90992. /**
  90993. * Get a trigger name by index
  90994. * @param trigger defines the trigger index
  90995. * @returns a trigger name
  90996. */
  90997. static GetTriggerName(trigger: number): string;
  90998. }
  90999. }
  91000. declare module BABYLON {
  91001. /**
  91002. * Class used to represent a sprite
  91003. * @see https://doc.babylonjs.com/babylon101/sprites
  91004. */
  91005. export class Sprite implements IAnimatable {
  91006. /** defines the name */
  91007. name: string;
  91008. /** Gets or sets the current world position */
  91009. position: Vector3;
  91010. /** Gets or sets the main color */
  91011. color: Color4;
  91012. /** Gets or sets the width */
  91013. width: number;
  91014. /** Gets or sets the height */
  91015. height: number;
  91016. /** Gets or sets rotation angle */
  91017. angle: number;
  91018. /** Gets or sets the cell index in the sprite sheet */
  91019. cellIndex: number;
  91020. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91021. cellRef: string;
  91022. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91023. invertU: boolean;
  91024. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91025. invertV: boolean;
  91026. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91027. disposeWhenFinishedAnimating: boolean;
  91028. /** Gets the list of attached animations */
  91029. animations: Nullable<Array<Animation>>;
  91030. /** Gets or sets a boolean indicating if the sprite can be picked */
  91031. isPickable: boolean;
  91032. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  91033. useAlphaForPicking: boolean;
  91034. /** @hidden */
  91035. _xOffset: number;
  91036. /** @hidden */
  91037. _yOffset: number;
  91038. /** @hidden */
  91039. _xSize: number;
  91040. /** @hidden */
  91041. _ySize: number;
  91042. /**
  91043. * Gets or sets the associated action manager
  91044. */
  91045. actionManager: Nullable<ActionManager>;
  91046. /**
  91047. * An event triggered when the control has been disposed
  91048. */
  91049. onDisposeObservable: Observable<Sprite>;
  91050. private _animationStarted;
  91051. private _loopAnimation;
  91052. private _fromIndex;
  91053. private _toIndex;
  91054. private _delay;
  91055. private _direction;
  91056. private _manager;
  91057. private _time;
  91058. private _onAnimationEnd;
  91059. /**
  91060. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91061. */
  91062. isVisible: boolean;
  91063. /**
  91064. * Gets or sets the sprite size
  91065. */
  91066. get size(): number;
  91067. set size(value: number);
  91068. /**
  91069. * Returns a boolean indicating if the animation is started
  91070. */
  91071. get animationStarted(): boolean;
  91072. /**
  91073. * Gets or sets the unique id of the sprite
  91074. */
  91075. uniqueId: number;
  91076. /**
  91077. * Gets the manager of this sprite
  91078. */
  91079. get manager(): ISpriteManager;
  91080. /**
  91081. * Creates a new Sprite
  91082. * @param name defines the name
  91083. * @param manager defines the manager
  91084. */
  91085. constructor(
  91086. /** defines the name */
  91087. name: string, manager: ISpriteManager);
  91088. /**
  91089. * Returns the string "Sprite"
  91090. * @returns "Sprite"
  91091. */
  91092. getClassName(): string;
  91093. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91094. get fromIndex(): number;
  91095. set fromIndex(value: number);
  91096. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91097. get toIndex(): number;
  91098. set toIndex(value: number);
  91099. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91100. get loopAnimation(): boolean;
  91101. set loopAnimation(value: boolean);
  91102. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91103. get delay(): number;
  91104. set delay(value: number);
  91105. /**
  91106. * Starts an animation
  91107. * @param from defines the initial key
  91108. * @param to defines the end key
  91109. * @param loop defines if the animation must loop
  91110. * @param delay defines the start delay (in ms)
  91111. * @param onAnimationEnd defines a callback to call when animation ends
  91112. */
  91113. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91114. /** Stops current animation (if any) */
  91115. stopAnimation(): void;
  91116. /** @hidden */
  91117. _animate(deltaTime: number): void;
  91118. /** Release associated resources */
  91119. dispose(): void;
  91120. /**
  91121. * Serializes the sprite to a JSON object
  91122. * @returns the JSON object
  91123. */
  91124. serialize(): any;
  91125. /**
  91126. * Parses a JSON object to create a new sprite
  91127. * @param parsedSprite The JSON object to parse
  91128. * @param manager defines the hosting manager
  91129. * @returns the new sprite
  91130. */
  91131. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91132. }
  91133. }
  91134. declare module BABYLON {
  91135. /**
  91136. * Information about the result of picking within a scene
  91137. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91138. */
  91139. export class PickingInfo {
  91140. /** @hidden */
  91141. _pickingUnavailable: boolean;
  91142. /**
  91143. * If the pick collided with an object
  91144. */
  91145. hit: boolean;
  91146. /**
  91147. * Distance away where the pick collided
  91148. */
  91149. distance: number;
  91150. /**
  91151. * The location of pick collision
  91152. */
  91153. pickedPoint: Nullable<Vector3>;
  91154. /**
  91155. * The mesh corresponding the the pick collision
  91156. */
  91157. pickedMesh: Nullable<AbstractMesh>;
  91158. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91159. bu: number;
  91160. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91161. bv: number;
  91162. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91163. faceId: number;
  91164. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91165. subMeshFaceId: number;
  91166. /** Id of the the submesh that was picked */
  91167. subMeshId: number;
  91168. /** If a sprite was picked, this will be the sprite the pick collided with */
  91169. pickedSprite: Nullable<Sprite>;
  91170. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91171. thinInstanceIndex: number;
  91172. /**
  91173. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91174. */
  91175. originMesh: Nullable<AbstractMesh>;
  91176. /**
  91177. * The ray that was used to perform the picking.
  91178. */
  91179. ray: Nullable<Ray>;
  91180. /**
  91181. * Gets the normal correspodning to the face the pick collided with
  91182. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91183. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91184. * @returns The normal correspodning to the face the pick collided with
  91185. */
  91186. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91187. /**
  91188. * Gets the texture coordinates of where the pick occured
  91189. * @returns the vector containing the coordnates of the texture
  91190. */
  91191. getTextureCoordinates(): Nullable<Vector2>;
  91192. }
  91193. }
  91194. declare module BABYLON {
  91195. /**
  91196. * Class representing a ray with position and direction
  91197. */
  91198. export class Ray {
  91199. /** origin point */
  91200. origin: Vector3;
  91201. /** direction */
  91202. direction: Vector3;
  91203. /** length of the ray */
  91204. length: number;
  91205. private static readonly _TmpVector3;
  91206. private _tmpRay;
  91207. /**
  91208. * Creates a new ray
  91209. * @param origin origin point
  91210. * @param direction direction
  91211. * @param length length of the ray
  91212. */
  91213. constructor(
  91214. /** origin point */
  91215. origin: Vector3,
  91216. /** direction */
  91217. direction: Vector3,
  91218. /** length of the ray */
  91219. length?: number);
  91220. /**
  91221. * Checks if the ray intersects a box
  91222. * This does not account for the ray lenght by design to improve perfs.
  91223. * @param minimum bound of the box
  91224. * @param maximum bound of the box
  91225. * @param intersectionTreshold extra extend to be added to the box in all direction
  91226. * @returns if the box was hit
  91227. */
  91228. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91229. /**
  91230. * Checks if the ray intersects a box
  91231. * This does not account for the ray lenght by design to improve perfs.
  91232. * @param box the bounding box to check
  91233. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91234. * @returns if the box was hit
  91235. */
  91236. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91237. /**
  91238. * If the ray hits a sphere
  91239. * @param sphere the bounding sphere to check
  91240. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91241. * @returns true if it hits the sphere
  91242. */
  91243. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91244. /**
  91245. * If the ray hits a triange
  91246. * @param vertex0 triangle vertex
  91247. * @param vertex1 triangle vertex
  91248. * @param vertex2 triangle vertex
  91249. * @returns intersection information if hit
  91250. */
  91251. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91252. /**
  91253. * Checks if ray intersects a plane
  91254. * @param plane the plane to check
  91255. * @returns the distance away it was hit
  91256. */
  91257. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91258. /**
  91259. * Calculate the intercept of a ray on a given axis
  91260. * @param axis to check 'x' | 'y' | 'z'
  91261. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91262. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91263. */
  91264. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91265. /**
  91266. * Checks if ray intersects a mesh
  91267. * @param mesh the mesh to check
  91268. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91269. * @returns picking info of the intersecton
  91270. */
  91271. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91272. /**
  91273. * Checks if ray intersects a mesh
  91274. * @param meshes the meshes to check
  91275. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91276. * @param results array to store result in
  91277. * @returns Array of picking infos
  91278. */
  91279. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91280. private _comparePickingInfo;
  91281. private static smallnum;
  91282. private static rayl;
  91283. /**
  91284. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91285. * @param sega the first point of the segment to test the intersection against
  91286. * @param segb the second point of the segment to test the intersection against
  91287. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91288. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91289. */
  91290. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91291. /**
  91292. * Update the ray from viewport position
  91293. * @param x position
  91294. * @param y y position
  91295. * @param viewportWidth viewport width
  91296. * @param viewportHeight viewport height
  91297. * @param world world matrix
  91298. * @param view view matrix
  91299. * @param projection projection matrix
  91300. * @returns this ray updated
  91301. */
  91302. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91303. /**
  91304. * Creates a ray with origin and direction of 0,0,0
  91305. * @returns the new ray
  91306. */
  91307. static Zero(): Ray;
  91308. /**
  91309. * Creates a new ray from screen space and viewport
  91310. * @param x position
  91311. * @param y y position
  91312. * @param viewportWidth viewport width
  91313. * @param viewportHeight viewport height
  91314. * @param world world matrix
  91315. * @param view view matrix
  91316. * @param projection projection matrix
  91317. * @returns new ray
  91318. */
  91319. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91320. /**
  91321. * 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
  91322. * transformed to the given world matrix.
  91323. * @param origin The origin point
  91324. * @param end The end point
  91325. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91326. * @returns the new ray
  91327. */
  91328. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91329. /**
  91330. * Transforms a ray by a matrix
  91331. * @param ray ray to transform
  91332. * @param matrix matrix to apply
  91333. * @returns the resulting new ray
  91334. */
  91335. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91336. /**
  91337. * Transforms a ray by a matrix
  91338. * @param ray ray to transform
  91339. * @param matrix matrix to apply
  91340. * @param result ray to store result in
  91341. */
  91342. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91343. /**
  91344. * Unproject a ray from screen space to object space
  91345. * @param sourceX defines the screen space x coordinate to use
  91346. * @param sourceY defines the screen space y coordinate to use
  91347. * @param viewportWidth defines the current width of the viewport
  91348. * @param viewportHeight defines the current height of the viewport
  91349. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91350. * @param view defines the view matrix to use
  91351. * @param projection defines the projection matrix to use
  91352. */
  91353. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91354. }
  91355. /**
  91356. * Type used to define predicate used to select faces when a mesh intersection is detected
  91357. */
  91358. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91359. interface Scene {
  91360. /** @hidden */
  91361. _tempPickingRay: Nullable<Ray>;
  91362. /** @hidden */
  91363. _cachedRayForTransform: Ray;
  91364. /** @hidden */
  91365. _pickWithRayInverseMatrix: Matrix;
  91366. /** @hidden */
  91367. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91368. /** @hidden */
  91369. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91370. /** @hidden */
  91371. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91372. }
  91373. }
  91374. declare module BABYLON {
  91375. /**
  91376. * Groups all the scene component constants in one place to ease maintenance.
  91377. * @hidden
  91378. */
  91379. export class SceneComponentConstants {
  91380. static readonly NAME_EFFECTLAYER: string;
  91381. static readonly NAME_LAYER: string;
  91382. static readonly NAME_LENSFLARESYSTEM: string;
  91383. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91384. static readonly NAME_PARTICLESYSTEM: string;
  91385. static readonly NAME_GAMEPAD: string;
  91386. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91387. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91388. static readonly NAME_PREPASSRENDERER: string;
  91389. static readonly NAME_DEPTHRENDERER: string;
  91390. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91391. static readonly NAME_SPRITE: string;
  91392. static readonly NAME_SUBSURFACE: string;
  91393. static readonly NAME_OUTLINERENDERER: string;
  91394. static readonly NAME_PROCEDURALTEXTURE: string;
  91395. static readonly NAME_SHADOWGENERATOR: string;
  91396. static readonly NAME_OCTREE: string;
  91397. static readonly NAME_PHYSICSENGINE: string;
  91398. static readonly NAME_AUDIO: string;
  91399. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91400. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91401. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91402. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91403. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91404. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91405. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91406. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91407. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91408. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91409. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91410. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91411. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91412. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91413. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91414. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91415. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91416. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91417. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91418. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91419. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91420. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91421. static readonly STEP_AFTERRENDER_AUDIO: number;
  91422. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91423. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91424. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91425. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91426. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91427. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91428. static readonly STEP_POINTERMOVE_SPRITE: number;
  91429. static readonly STEP_POINTERDOWN_SPRITE: number;
  91430. static readonly STEP_POINTERUP_SPRITE: number;
  91431. }
  91432. /**
  91433. * This represents a scene component.
  91434. *
  91435. * This is used to decouple the dependency the scene is having on the different workloads like
  91436. * layers, post processes...
  91437. */
  91438. export interface ISceneComponent {
  91439. /**
  91440. * The name of the component. Each component must have a unique name.
  91441. */
  91442. name: string;
  91443. /**
  91444. * The scene the component belongs to.
  91445. */
  91446. scene: Scene;
  91447. /**
  91448. * Register the component to one instance of a scene.
  91449. */
  91450. register(): void;
  91451. /**
  91452. * Rebuilds the elements related to this component in case of
  91453. * context lost for instance.
  91454. */
  91455. rebuild(): void;
  91456. /**
  91457. * Disposes the component and the associated ressources.
  91458. */
  91459. dispose(): void;
  91460. }
  91461. /**
  91462. * This represents a SERIALIZABLE scene component.
  91463. *
  91464. * This extends Scene Component to add Serialization methods on top.
  91465. */
  91466. export interface ISceneSerializableComponent extends ISceneComponent {
  91467. /**
  91468. * Adds all the elements from the container to the scene
  91469. * @param container the container holding the elements
  91470. */
  91471. addFromContainer(container: AbstractScene): void;
  91472. /**
  91473. * Removes all the elements in the container from the scene
  91474. * @param container contains the elements to remove
  91475. * @param dispose if the removed element should be disposed (default: false)
  91476. */
  91477. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91478. /**
  91479. * Serializes the component data to the specified json object
  91480. * @param serializationObject The object to serialize to
  91481. */
  91482. serialize(serializationObject: any): void;
  91483. }
  91484. /**
  91485. * Strong typing of a Mesh related stage step action
  91486. */
  91487. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91488. /**
  91489. * Strong typing of a Evaluate Sub Mesh related stage step action
  91490. */
  91491. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91492. /**
  91493. * Strong typing of a Active Mesh related stage step action
  91494. */
  91495. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91496. /**
  91497. * Strong typing of a Camera related stage step action
  91498. */
  91499. export type CameraStageAction = (camera: Camera) => void;
  91500. /**
  91501. * Strong typing of a Camera Frame buffer related stage step action
  91502. */
  91503. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91504. /**
  91505. * Strong typing of a Render Target related stage step action
  91506. */
  91507. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91508. /**
  91509. * Strong typing of a RenderingGroup related stage step action
  91510. */
  91511. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91512. /**
  91513. * Strong typing of a Mesh Render related stage step action
  91514. */
  91515. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91516. /**
  91517. * Strong typing of a simple stage step action
  91518. */
  91519. export type SimpleStageAction = () => void;
  91520. /**
  91521. * Strong typing of a render target action.
  91522. */
  91523. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91524. /**
  91525. * Strong typing of a pointer move action.
  91526. */
  91527. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91528. /**
  91529. * Strong typing of a pointer up/down action.
  91530. */
  91531. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91532. /**
  91533. * Representation of a stage in the scene (Basically a list of ordered steps)
  91534. * @hidden
  91535. */
  91536. export class Stage<T extends Function> extends Array<{
  91537. index: number;
  91538. component: ISceneComponent;
  91539. action: T;
  91540. }> {
  91541. /**
  91542. * Hide ctor from the rest of the world.
  91543. * @param items The items to add.
  91544. */
  91545. private constructor();
  91546. /**
  91547. * Creates a new Stage.
  91548. * @returns A new instance of a Stage
  91549. */
  91550. static Create<T extends Function>(): Stage<T>;
  91551. /**
  91552. * Registers a step in an ordered way in the targeted stage.
  91553. * @param index Defines the position to register the step in
  91554. * @param component Defines the component attached to the step
  91555. * @param action Defines the action to launch during the step
  91556. */
  91557. registerStep(index: number, component: ISceneComponent, action: T): void;
  91558. /**
  91559. * Clears all the steps from the stage.
  91560. */
  91561. clear(): void;
  91562. }
  91563. }
  91564. declare module BABYLON {
  91565. interface Scene {
  91566. /** @hidden */
  91567. _pointerOverSprite: Nullable<Sprite>;
  91568. /** @hidden */
  91569. _pickedDownSprite: Nullable<Sprite>;
  91570. /** @hidden */
  91571. _tempSpritePickingRay: Nullable<Ray>;
  91572. /**
  91573. * All of the sprite managers added to this scene
  91574. * @see https://doc.babylonjs.com/babylon101/sprites
  91575. */
  91576. spriteManagers: Array<ISpriteManager>;
  91577. /**
  91578. * An event triggered when sprites rendering is about to start
  91579. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91580. */
  91581. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91582. /**
  91583. * An event triggered when sprites rendering is done
  91584. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91585. */
  91586. onAfterSpritesRenderingObservable: Observable<Scene>;
  91587. /** @hidden */
  91588. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91589. /** Launch a ray to try to pick a sprite in the scene
  91590. * @param x position on screen
  91591. * @param y position on screen
  91592. * @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
  91593. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91594. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91595. * @returns a PickingInfo
  91596. */
  91597. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91598. /** Use the given ray to pick a sprite in the scene
  91599. * @param ray The ray (in world space) to use to pick meshes
  91600. * @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
  91601. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91602. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91603. * @returns a PickingInfo
  91604. */
  91605. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91606. /** @hidden */
  91607. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91608. /** Launch a ray to try to pick sprites in the scene
  91609. * @param x position on screen
  91610. * @param y position on screen
  91611. * @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
  91612. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91613. * @returns a PickingInfo array
  91614. */
  91615. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91616. /** Use the given ray to pick sprites in the scene
  91617. * @param ray The ray (in world space) to use to pick meshes
  91618. * @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
  91619. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91620. * @returns a PickingInfo array
  91621. */
  91622. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91623. /**
  91624. * Force the sprite under the pointer
  91625. * @param sprite defines the sprite to use
  91626. */
  91627. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91628. /**
  91629. * Gets the sprite under the pointer
  91630. * @returns a Sprite or null if no sprite is under the pointer
  91631. */
  91632. getPointerOverSprite(): Nullable<Sprite>;
  91633. }
  91634. /**
  91635. * Defines the sprite scene component responsible to manage sprites
  91636. * in a given scene.
  91637. */
  91638. export class SpriteSceneComponent implements ISceneComponent {
  91639. /**
  91640. * The component name helpfull to identify the component in the list of scene components.
  91641. */
  91642. readonly name: string;
  91643. /**
  91644. * The scene the component belongs to.
  91645. */
  91646. scene: Scene;
  91647. /** @hidden */
  91648. private _spritePredicate;
  91649. /**
  91650. * Creates a new instance of the component for the given scene
  91651. * @param scene Defines the scene to register the component in
  91652. */
  91653. constructor(scene: Scene);
  91654. /**
  91655. * Registers the component in a given scene
  91656. */
  91657. register(): void;
  91658. /**
  91659. * Rebuilds the elements related to this component in case of
  91660. * context lost for instance.
  91661. */
  91662. rebuild(): void;
  91663. /**
  91664. * Disposes the component and the associated ressources.
  91665. */
  91666. dispose(): void;
  91667. private _pickSpriteButKeepRay;
  91668. private _pointerMove;
  91669. private _pointerDown;
  91670. private _pointerUp;
  91671. }
  91672. }
  91673. declare module BABYLON {
  91674. /** @hidden */
  91675. export var fogFragmentDeclaration: {
  91676. name: string;
  91677. shader: string;
  91678. };
  91679. }
  91680. declare module BABYLON {
  91681. /** @hidden */
  91682. export var fogFragment: {
  91683. name: string;
  91684. shader: string;
  91685. };
  91686. }
  91687. declare module BABYLON {
  91688. /** @hidden */
  91689. export var imageProcessingCompatibility: {
  91690. name: string;
  91691. shader: string;
  91692. };
  91693. }
  91694. declare module BABYLON {
  91695. /** @hidden */
  91696. export var spritesPixelShader: {
  91697. name: string;
  91698. shader: string;
  91699. };
  91700. }
  91701. declare module BABYLON {
  91702. /** @hidden */
  91703. export var fogVertexDeclaration: {
  91704. name: string;
  91705. shader: string;
  91706. };
  91707. }
  91708. declare module BABYLON {
  91709. /** @hidden */
  91710. export var spritesVertexShader: {
  91711. name: string;
  91712. shader: string;
  91713. };
  91714. }
  91715. declare module BABYLON {
  91716. /**
  91717. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91718. */
  91719. export interface ISpriteManager extends IDisposable {
  91720. /**
  91721. * Gets manager's name
  91722. */
  91723. name: string;
  91724. /**
  91725. * Restricts the camera to viewing objects with the same layerMask.
  91726. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91727. */
  91728. layerMask: number;
  91729. /**
  91730. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91731. */
  91732. isPickable: boolean;
  91733. /**
  91734. * Gets the hosting scene
  91735. */
  91736. scene: Scene;
  91737. /**
  91738. * Specifies the rendering group id for this mesh (0 by default)
  91739. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91740. */
  91741. renderingGroupId: number;
  91742. /**
  91743. * Defines the list of sprites managed by the manager.
  91744. */
  91745. sprites: Array<Sprite>;
  91746. /**
  91747. * Gets or sets the spritesheet texture
  91748. */
  91749. texture: Texture;
  91750. /** Defines the default width of a cell in the spritesheet */
  91751. cellWidth: number;
  91752. /** Defines the default height of a cell in the spritesheet */
  91753. cellHeight: number;
  91754. /**
  91755. * Tests the intersection of a sprite with a specific ray.
  91756. * @param ray The ray we are sending to test the collision
  91757. * @param camera The camera space we are sending rays in
  91758. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91759. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91760. * @returns picking info or null.
  91761. */
  91762. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91763. /**
  91764. * Intersects the sprites with a ray
  91765. * @param ray defines the ray to intersect with
  91766. * @param camera defines the current active camera
  91767. * @param predicate defines a predicate used to select candidate sprites
  91768. * @returns null if no hit or a PickingInfo array
  91769. */
  91770. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91771. /**
  91772. * Renders the list of sprites on screen.
  91773. */
  91774. render(): void;
  91775. }
  91776. /**
  91777. * Class used to manage multiple sprites on the same spritesheet
  91778. * @see https://doc.babylonjs.com/babylon101/sprites
  91779. */
  91780. export class SpriteManager implements ISpriteManager {
  91781. /** defines the manager's name */
  91782. name: string;
  91783. /** Define the Url to load snippets */
  91784. static SnippetUrl: string;
  91785. /** Snippet ID if the manager was created from the snippet server */
  91786. snippetId: string;
  91787. /** Gets the list of sprites */
  91788. sprites: Sprite[];
  91789. /** Gets or sets the rendering group id (0 by default) */
  91790. renderingGroupId: number;
  91791. /** Gets or sets camera layer mask */
  91792. layerMask: number;
  91793. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91794. fogEnabled: boolean;
  91795. /** Gets or sets a boolean indicating if the sprites are pickable */
  91796. isPickable: boolean;
  91797. /** Defines the default width of a cell in the spritesheet */
  91798. cellWidth: number;
  91799. /** Defines the default height of a cell in the spritesheet */
  91800. cellHeight: number;
  91801. /** Associative array from JSON sprite data file */
  91802. private _cellData;
  91803. /** Array of sprite names from JSON sprite data file */
  91804. private _spriteMap;
  91805. /** True when packed cell data from JSON file is ready*/
  91806. private _packedAndReady;
  91807. private _textureContent;
  91808. private _useInstancing;
  91809. /**
  91810. * An event triggered when the manager is disposed.
  91811. */
  91812. onDisposeObservable: Observable<SpriteManager>;
  91813. private _onDisposeObserver;
  91814. /**
  91815. * Callback called when the manager is disposed
  91816. */
  91817. set onDispose(callback: () => void);
  91818. private _capacity;
  91819. private _fromPacked;
  91820. private _spriteTexture;
  91821. private _epsilon;
  91822. private _scene;
  91823. private _vertexData;
  91824. private _buffer;
  91825. private _vertexBuffers;
  91826. private _spriteBuffer;
  91827. private _indexBuffer;
  91828. private _effectBase;
  91829. private _effectFog;
  91830. private _vertexBufferSize;
  91831. /**
  91832. * Gets or sets the unique id of the sprite
  91833. */
  91834. uniqueId: number;
  91835. /**
  91836. * Gets the array of sprites
  91837. */
  91838. get children(): Sprite[];
  91839. /**
  91840. * Gets the hosting scene
  91841. */
  91842. get scene(): Scene;
  91843. /**
  91844. * Gets the capacity of the manager
  91845. */
  91846. get capacity(): number;
  91847. /**
  91848. * Gets or sets the spritesheet texture
  91849. */
  91850. get texture(): Texture;
  91851. set texture(value: Texture);
  91852. private _blendMode;
  91853. /**
  91854. * Blend mode use to render the particle, it can be any of
  91855. * the static Constants.ALPHA_x properties provided in this class.
  91856. * Default value is Constants.ALPHA_COMBINE
  91857. */
  91858. get blendMode(): number;
  91859. set blendMode(blendMode: number);
  91860. /** Disables writing to the depth buffer when rendering the sprites.
  91861. * It can be handy to disable depth writing when using textures without alpha channel
  91862. * and setting some specific blend modes.
  91863. */
  91864. disableDepthWrite: boolean;
  91865. /**
  91866. * Creates a new sprite manager
  91867. * @param name defines the manager's name
  91868. * @param imgUrl defines the sprite sheet url
  91869. * @param capacity defines the maximum allowed number of sprites
  91870. * @param cellSize defines the size of a sprite cell
  91871. * @param scene defines the hosting scene
  91872. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91873. * @param samplingMode defines the smapling mode to use with spritesheet
  91874. * @param fromPacked set to false; do not alter
  91875. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91876. */
  91877. constructor(
  91878. /** defines the manager's name */
  91879. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91880. /**
  91881. * Returns the string "SpriteManager"
  91882. * @returns "SpriteManager"
  91883. */
  91884. getClassName(): string;
  91885. private _makePacked;
  91886. private _appendSpriteVertex;
  91887. private _checkTextureAlpha;
  91888. /**
  91889. * Intersects the sprites with a ray
  91890. * @param ray defines the ray to intersect with
  91891. * @param camera defines the current active camera
  91892. * @param predicate defines a predicate used to select candidate sprites
  91893. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91894. * @returns null if no hit or a PickingInfo
  91895. */
  91896. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91897. /**
  91898. * Intersects the sprites with a ray
  91899. * @param ray defines the ray to intersect with
  91900. * @param camera defines the current active camera
  91901. * @param predicate defines a predicate used to select candidate sprites
  91902. * @returns null if no hit or a PickingInfo array
  91903. */
  91904. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91905. /**
  91906. * Render all child sprites
  91907. */
  91908. render(): void;
  91909. /**
  91910. * Release associated resources
  91911. */
  91912. dispose(): void;
  91913. /**
  91914. * Serializes the sprite manager to a JSON object
  91915. * @param serializeTexture defines if the texture must be serialized as well
  91916. * @returns the JSON object
  91917. */
  91918. serialize(serializeTexture?: boolean): any;
  91919. /**
  91920. * Parses a JSON object to create a new sprite manager.
  91921. * @param parsedManager The JSON object to parse
  91922. * @param scene The scene to create the sprite managerin
  91923. * @param rootUrl The root url to use to load external dependencies like texture
  91924. * @returns the new sprite manager
  91925. */
  91926. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91927. /**
  91928. * Creates a sprite manager from a snippet saved in a remote file
  91929. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91930. * @param url defines the url to load from
  91931. * @param scene defines the hosting scene
  91932. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91933. * @returns a promise that will resolve to the new sprite manager
  91934. */
  91935. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91936. /**
  91937. * Creates a sprite manager from a snippet saved by the sprite editor
  91938. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91939. * @param scene defines the hosting scene
  91940. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91941. * @returns a promise that will resolve to the new sprite manager
  91942. */
  91943. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91944. }
  91945. }
  91946. declare module BABYLON {
  91947. /** Interface used by value gradients (color, factor, ...) */
  91948. export interface IValueGradient {
  91949. /**
  91950. * Gets or sets the gradient value (between 0 and 1)
  91951. */
  91952. gradient: number;
  91953. }
  91954. /** Class used to store color4 gradient */
  91955. export class ColorGradient implements IValueGradient {
  91956. /**
  91957. * Gets or sets the gradient value (between 0 and 1)
  91958. */
  91959. gradient: number;
  91960. /**
  91961. * Gets or sets first associated color
  91962. */
  91963. color1: Color4;
  91964. /**
  91965. * Gets or sets second associated color
  91966. */
  91967. color2?: Color4 | undefined;
  91968. /**
  91969. * Creates a new color4 gradient
  91970. * @param gradient gets or sets the gradient value (between 0 and 1)
  91971. * @param color1 gets or sets first associated color
  91972. * @param color2 gets or sets first second color
  91973. */
  91974. constructor(
  91975. /**
  91976. * Gets or sets the gradient value (between 0 and 1)
  91977. */
  91978. gradient: number,
  91979. /**
  91980. * Gets or sets first associated color
  91981. */
  91982. color1: Color4,
  91983. /**
  91984. * Gets or sets second associated color
  91985. */
  91986. color2?: Color4 | undefined);
  91987. /**
  91988. * Will get a color picked randomly between color1 and color2.
  91989. * If color2 is undefined then color1 will be used
  91990. * @param result defines the target Color4 to store the result in
  91991. */
  91992. getColorToRef(result: Color4): void;
  91993. }
  91994. /** Class used to store color 3 gradient */
  91995. export class Color3Gradient implements IValueGradient {
  91996. /**
  91997. * Gets or sets the gradient value (between 0 and 1)
  91998. */
  91999. gradient: number;
  92000. /**
  92001. * Gets or sets the associated color
  92002. */
  92003. color: Color3;
  92004. /**
  92005. * Creates a new color3 gradient
  92006. * @param gradient gets or sets the gradient value (between 0 and 1)
  92007. * @param color gets or sets associated color
  92008. */
  92009. constructor(
  92010. /**
  92011. * Gets or sets the gradient value (between 0 and 1)
  92012. */
  92013. gradient: number,
  92014. /**
  92015. * Gets or sets the associated color
  92016. */
  92017. color: Color3);
  92018. }
  92019. /** Class used to store factor gradient */
  92020. export class FactorGradient implements IValueGradient {
  92021. /**
  92022. * Gets or sets the gradient value (between 0 and 1)
  92023. */
  92024. gradient: number;
  92025. /**
  92026. * Gets or sets first associated factor
  92027. */
  92028. factor1: number;
  92029. /**
  92030. * Gets or sets second associated factor
  92031. */
  92032. factor2?: number | undefined;
  92033. /**
  92034. * Creates a new factor gradient
  92035. * @param gradient gets or sets the gradient value (between 0 and 1)
  92036. * @param factor1 gets or sets first associated factor
  92037. * @param factor2 gets or sets second associated factor
  92038. */
  92039. constructor(
  92040. /**
  92041. * Gets or sets the gradient value (between 0 and 1)
  92042. */
  92043. gradient: number,
  92044. /**
  92045. * Gets or sets first associated factor
  92046. */
  92047. factor1: number,
  92048. /**
  92049. * Gets or sets second associated factor
  92050. */
  92051. factor2?: number | undefined);
  92052. /**
  92053. * Will get a number picked randomly between factor1 and factor2.
  92054. * If factor2 is undefined then factor1 will be used
  92055. * @returns the picked number
  92056. */
  92057. getFactor(): number;
  92058. }
  92059. /**
  92060. * Helper used to simplify some generic gradient tasks
  92061. */
  92062. export class GradientHelper {
  92063. /**
  92064. * Gets the current gradient from an array of IValueGradient
  92065. * @param ratio defines the current ratio to get
  92066. * @param gradients defines the array of IValueGradient
  92067. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  92068. */
  92069. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  92070. }
  92071. }
  92072. declare module BABYLON {
  92073. interface ThinEngine {
  92074. /**
  92075. * Creates a raw texture
  92076. * @param data defines the data to store in the texture
  92077. * @param width defines the width of the texture
  92078. * @param height defines the height of the texture
  92079. * @param format defines the format of the data
  92080. * @param generateMipMaps defines if the engine should generate the mip levels
  92081. * @param invertY defines if data must be stored with Y axis inverted
  92082. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92083. * @param compression defines the compression used (null by default)
  92084. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92085. * @returns the raw texture inside an InternalTexture
  92086. */
  92087. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92088. /**
  92089. * Update a raw texture
  92090. * @param texture defines the texture to update
  92091. * @param data defines the data to store in the texture
  92092. * @param format defines the format of the data
  92093. * @param invertY defines if data must be stored with Y axis inverted
  92094. */
  92095. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92096. /**
  92097. * Update a raw texture
  92098. * @param texture defines the texture to update
  92099. * @param data defines the data to store in the texture
  92100. * @param format defines the format of the data
  92101. * @param invertY defines if data must be stored with Y axis inverted
  92102. * @param compression defines the compression used (null by default)
  92103. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92104. */
  92105. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92106. /**
  92107. * Creates a new raw cube texture
  92108. * @param data defines the array of data to use to create each face
  92109. * @param size defines the size of the textures
  92110. * @param format defines the format of the data
  92111. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92112. * @param generateMipMaps defines if the engine should generate the mip levels
  92113. * @param invertY defines if data must be stored with Y axis inverted
  92114. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92115. * @param compression defines the compression used (null by default)
  92116. * @returns the cube texture as an InternalTexture
  92117. */
  92118. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92119. /**
  92120. * Update a raw cube texture
  92121. * @param texture defines the texture to udpdate
  92122. * @param data defines the data to store
  92123. * @param format defines the data format
  92124. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92125. * @param invertY defines if data must be stored with Y axis inverted
  92126. */
  92127. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92128. /**
  92129. * Update a raw cube texture
  92130. * @param texture defines the texture to udpdate
  92131. * @param data defines the data to store
  92132. * @param format defines the data format
  92133. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92134. * @param invertY defines if data must be stored with Y axis inverted
  92135. * @param compression defines the compression used (null by default)
  92136. */
  92137. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92138. /**
  92139. * Update a raw cube texture
  92140. * @param texture defines the texture to udpdate
  92141. * @param data defines the data to store
  92142. * @param format defines the data format
  92143. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92144. * @param invertY defines if data must be stored with Y axis inverted
  92145. * @param compression defines the compression used (null by default)
  92146. * @param level defines which level of the texture to update
  92147. */
  92148. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92149. /**
  92150. * Creates a new raw cube texture from a specified url
  92151. * @param url defines the url where the data is located
  92152. * @param scene defines the current scene
  92153. * @param size defines the size of the textures
  92154. * @param format defines the format of the data
  92155. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92156. * @param noMipmap defines if the engine should avoid generating the mip levels
  92157. * @param callback defines a callback used to extract texture data from loaded data
  92158. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92159. * @param onLoad defines a callback called when texture is loaded
  92160. * @param onError defines a callback called if there is an error
  92161. * @returns the cube texture as an InternalTexture
  92162. */
  92163. 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;
  92164. /**
  92165. * Creates a new raw cube texture from a specified url
  92166. * @param url defines the url where the data is located
  92167. * @param scene defines the current scene
  92168. * @param size defines the size of the textures
  92169. * @param format defines the format of the data
  92170. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92171. * @param noMipmap defines if the engine should avoid generating the mip levels
  92172. * @param callback defines a callback used to extract texture data from loaded data
  92173. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92174. * @param onLoad defines a callback called when texture is loaded
  92175. * @param onError defines a callback called if there is an error
  92176. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92177. * @param invertY defines if data must be stored with Y axis inverted
  92178. * @returns the cube texture as an InternalTexture
  92179. */
  92180. 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;
  92181. /**
  92182. * Creates a new raw 3D texture
  92183. * @param data defines the data used to create the texture
  92184. * @param width defines the width of the texture
  92185. * @param height defines the height of the texture
  92186. * @param depth defines the depth of the texture
  92187. * @param format defines the format of the texture
  92188. * @param generateMipMaps defines if the engine must generate mip levels
  92189. * @param invertY defines if data must be stored with Y axis inverted
  92190. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92191. * @param compression defines the compressed used (can be null)
  92192. * @param textureType defines the compressed used (can be null)
  92193. * @returns a new raw 3D texture (stored in an InternalTexture)
  92194. */
  92195. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92196. /**
  92197. * Update a raw 3D texture
  92198. * @param texture defines the texture to update
  92199. * @param data defines the data to store
  92200. * @param format defines the data format
  92201. * @param invertY defines if data must be stored with Y axis inverted
  92202. */
  92203. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92204. /**
  92205. * Update a raw 3D texture
  92206. * @param texture defines the texture to update
  92207. * @param data defines the data to store
  92208. * @param format defines the data format
  92209. * @param invertY defines if data must be stored with Y axis inverted
  92210. * @param compression defines the used compression (can be null)
  92211. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92212. */
  92213. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92214. /**
  92215. * Creates a new raw 2D array texture
  92216. * @param data defines the data used to create the texture
  92217. * @param width defines the width of the texture
  92218. * @param height defines the height of the texture
  92219. * @param depth defines the number of layers of the texture
  92220. * @param format defines the format of the texture
  92221. * @param generateMipMaps defines if the engine must generate mip levels
  92222. * @param invertY defines if data must be stored with Y axis inverted
  92223. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92224. * @param compression defines the compressed used (can be null)
  92225. * @param textureType defines the compressed used (can be null)
  92226. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92227. */
  92228. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92229. /**
  92230. * Update a raw 2D array texture
  92231. * @param texture defines the texture to update
  92232. * @param data defines the data to store
  92233. * @param format defines the data format
  92234. * @param invertY defines if data must be stored with Y axis inverted
  92235. */
  92236. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92237. /**
  92238. * Update a raw 2D array texture
  92239. * @param texture defines the texture to update
  92240. * @param data defines the data to store
  92241. * @param format defines the data format
  92242. * @param invertY defines if data must be stored with Y axis inverted
  92243. * @param compression defines the used compression (can be null)
  92244. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92245. */
  92246. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92247. }
  92248. }
  92249. declare module BABYLON {
  92250. /**
  92251. * Raw texture can help creating a texture directly from an array of data.
  92252. * This can be super useful if you either get the data from an uncompressed source or
  92253. * if you wish to create your texture pixel by pixel.
  92254. */
  92255. export class RawTexture extends Texture {
  92256. /**
  92257. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92258. */
  92259. format: number;
  92260. /**
  92261. * Instantiates a new RawTexture.
  92262. * Raw texture can help creating a texture directly from an array of data.
  92263. * This can be super useful if you either get the data from an uncompressed source or
  92264. * if you wish to create your texture pixel by pixel.
  92265. * @param data define the array of data to use to create the texture
  92266. * @param width define the width of the texture
  92267. * @param height define the height of the texture
  92268. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92269. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92270. * @param generateMipMaps define whether mip maps should be generated or not
  92271. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92272. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92273. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92274. */
  92275. constructor(data: ArrayBufferView, width: number, height: number,
  92276. /**
  92277. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92278. */
  92279. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92280. /**
  92281. * Updates the texture underlying data.
  92282. * @param data Define the new data of the texture
  92283. */
  92284. update(data: ArrayBufferView): void;
  92285. /**
  92286. * Creates a luminance texture from some data.
  92287. * @param data Define the texture data
  92288. * @param width Define the width of the texture
  92289. * @param height Define the height of the texture
  92290. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92291. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92292. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92293. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92294. * @returns the luminance texture
  92295. */
  92296. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92297. /**
  92298. * Creates a luminance alpha texture from some data.
  92299. * @param data Define the texture data
  92300. * @param width Define the width of the texture
  92301. * @param height Define the height of the texture
  92302. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92303. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92304. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92305. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92306. * @returns the luminance alpha texture
  92307. */
  92308. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92309. /**
  92310. * Creates an alpha texture from some data.
  92311. * @param data Define the texture data
  92312. * @param width Define the width of the texture
  92313. * @param height Define the height of the texture
  92314. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92315. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92316. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92317. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92318. * @returns the alpha texture
  92319. */
  92320. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92321. /**
  92322. * Creates a RGB texture from some data.
  92323. * @param data Define the texture data
  92324. * @param width Define the width of the texture
  92325. * @param height Define the height of the texture
  92326. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92327. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92328. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92329. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92330. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92331. * @returns the RGB alpha texture
  92332. */
  92333. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92334. /**
  92335. * Creates a RGBA texture from some data.
  92336. * @param data Define the texture data
  92337. * @param width Define the width of the texture
  92338. * @param height Define the height of the texture
  92339. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92340. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92341. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92342. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92343. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92344. * @returns the RGBA texture
  92345. */
  92346. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92347. /**
  92348. * Creates a R texture from some data.
  92349. * @param data Define the texture data
  92350. * @param width Define the width of the texture
  92351. * @param height Define the height of the texture
  92352. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92353. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92354. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92355. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92356. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92357. * @returns the R texture
  92358. */
  92359. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92360. }
  92361. }
  92362. declare module BABYLON {
  92363. interface ThinEngine {
  92364. /**
  92365. * Update a dynamic index buffer
  92366. * @param indexBuffer defines the target index buffer
  92367. * @param indices defines the data to update
  92368. * @param offset defines the offset in the target index buffer where update should start
  92369. */
  92370. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92371. /**
  92372. * Updates a dynamic vertex buffer.
  92373. * @param vertexBuffer the vertex buffer to update
  92374. * @param data the data used to update the vertex buffer
  92375. * @param byteOffset the byte offset of the data
  92376. * @param byteLength the byte length of the data
  92377. */
  92378. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92379. }
  92380. }
  92381. declare module BABYLON {
  92382. interface AbstractScene {
  92383. /**
  92384. * The list of procedural textures added to the scene
  92385. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92386. */
  92387. proceduralTextures: Array<ProceduralTexture>;
  92388. }
  92389. /**
  92390. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92391. * in a given scene.
  92392. */
  92393. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92394. /**
  92395. * The component name helpfull to identify the component in the list of scene components.
  92396. */
  92397. readonly name: string;
  92398. /**
  92399. * The scene the component belongs to.
  92400. */
  92401. scene: Scene;
  92402. /**
  92403. * Creates a new instance of the component for the given scene
  92404. * @param scene Defines the scene to register the component in
  92405. */
  92406. constructor(scene: Scene);
  92407. /**
  92408. * Registers the component in a given scene
  92409. */
  92410. register(): void;
  92411. /**
  92412. * Rebuilds the elements related to this component in case of
  92413. * context lost for instance.
  92414. */
  92415. rebuild(): void;
  92416. /**
  92417. * Disposes the component and the associated ressources.
  92418. */
  92419. dispose(): void;
  92420. private _beforeClear;
  92421. }
  92422. }
  92423. declare module BABYLON {
  92424. interface ThinEngine {
  92425. /**
  92426. * Creates a new render target cube texture
  92427. * @param size defines the size of the texture
  92428. * @param options defines the options used to create the texture
  92429. * @returns a new render target cube texture stored in an InternalTexture
  92430. */
  92431. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92432. }
  92433. }
  92434. declare module BABYLON {
  92435. /** @hidden */
  92436. export var proceduralVertexShader: {
  92437. name: string;
  92438. shader: string;
  92439. };
  92440. }
  92441. declare module BABYLON {
  92442. /**
  92443. * 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.
  92444. * This is the base class of any Procedural texture and contains most of the shareable code.
  92445. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92446. */
  92447. export class ProceduralTexture extends Texture {
  92448. /**
  92449. * Define if the texture is enabled or not (disabled texture will not render)
  92450. */
  92451. isEnabled: boolean;
  92452. /**
  92453. * Define if the texture must be cleared before rendering (default is true)
  92454. */
  92455. autoClear: boolean;
  92456. /**
  92457. * Callback called when the texture is generated
  92458. */
  92459. onGenerated: () => void;
  92460. /**
  92461. * Event raised when the texture is generated
  92462. */
  92463. onGeneratedObservable: Observable<ProceduralTexture>;
  92464. /**
  92465. * Event raised before the texture is generated
  92466. */
  92467. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92468. /**
  92469. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92470. */
  92471. nodeMaterialSource: Nullable<NodeMaterial>;
  92472. /** @hidden */
  92473. _generateMipMaps: boolean;
  92474. /** @hidden **/
  92475. _effect: Effect;
  92476. /** @hidden */
  92477. _textures: {
  92478. [key: string]: Texture;
  92479. };
  92480. /** @hidden */
  92481. protected _fallbackTexture: Nullable<Texture>;
  92482. private _size;
  92483. private _currentRefreshId;
  92484. private _frameId;
  92485. private _refreshRate;
  92486. private _vertexBuffers;
  92487. private _indexBuffer;
  92488. private _uniforms;
  92489. private _samplers;
  92490. private _fragment;
  92491. private _floats;
  92492. private _ints;
  92493. private _floatsArrays;
  92494. private _colors3;
  92495. private _colors4;
  92496. private _vectors2;
  92497. private _vectors3;
  92498. private _matrices;
  92499. private _fallbackTextureUsed;
  92500. private _fullEngine;
  92501. private _cachedDefines;
  92502. private _contentUpdateId;
  92503. private _contentData;
  92504. /**
  92505. * Instantiates a new procedural texture.
  92506. * 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.
  92507. * This is the base class of any Procedural texture and contains most of the shareable code.
  92508. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92509. * @param name Define the name of the texture
  92510. * @param size Define the size of the texture to create
  92511. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92512. * @param scene Define the scene the texture belongs to
  92513. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92514. * @param generateMipMaps Define if the texture should creates mip maps or not
  92515. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92516. * @param textureType The FBO internal texture type
  92517. */
  92518. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92519. /**
  92520. * The effect that is created when initializing the post process.
  92521. * @returns The created effect corresponding the the postprocess.
  92522. */
  92523. getEffect(): Effect;
  92524. /**
  92525. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92526. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92527. */
  92528. getContent(): Nullable<ArrayBufferView>;
  92529. private _createIndexBuffer;
  92530. /** @hidden */
  92531. _rebuild(): void;
  92532. /**
  92533. * Resets the texture in order to recreate its associated resources.
  92534. * This can be called in case of context loss
  92535. */
  92536. reset(): void;
  92537. protected _getDefines(): string;
  92538. /**
  92539. * Is the texture ready to be used ? (rendered at least once)
  92540. * @returns true if ready, otherwise, false.
  92541. */
  92542. isReady(): boolean;
  92543. /**
  92544. * Resets the refresh counter of the texture and start bak from scratch.
  92545. * Could be useful to regenerate the texture if it is setup to render only once.
  92546. */
  92547. resetRefreshCounter(): void;
  92548. /**
  92549. * Set the fragment shader to use in order to render the texture.
  92550. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92551. */
  92552. setFragment(fragment: any): void;
  92553. /**
  92554. * Define the refresh rate of the texture or the rendering frequency.
  92555. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92556. */
  92557. get refreshRate(): number;
  92558. set refreshRate(value: number);
  92559. /** @hidden */
  92560. _shouldRender(): boolean;
  92561. /**
  92562. * Get the size the texture is rendering at.
  92563. * @returns the size (on cube texture it is always squared)
  92564. */
  92565. getRenderSize(): RenderTargetTextureSize;
  92566. /**
  92567. * Resize the texture to new value.
  92568. * @param size Define the new size the texture should have
  92569. * @param generateMipMaps Define whether the new texture should create mip maps
  92570. */
  92571. resize(size: number, generateMipMaps: boolean): void;
  92572. private _checkUniform;
  92573. /**
  92574. * Set a texture in the shader program used to render.
  92575. * @param name Define the name of the uniform samplers as defined in the shader
  92576. * @param texture Define the texture to bind to this sampler
  92577. * @return the texture itself allowing "fluent" like uniform updates
  92578. */
  92579. setTexture(name: string, texture: Texture): ProceduralTexture;
  92580. /**
  92581. * Set a float in the shader.
  92582. * @param name Define the name of the uniform as defined in the shader
  92583. * @param value Define the value to give to the uniform
  92584. * @return the texture itself allowing "fluent" like uniform updates
  92585. */
  92586. setFloat(name: string, value: number): ProceduralTexture;
  92587. /**
  92588. * Set a int in the shader.
  92589. * @param name Define the name of the uniform as defined in the shader
  92590. * @param value Define the value to give to the uniform
  92591. * @return the texture itself allowing "fluent" like uniform updates
  92592. */
  92593. setInt(name: string, value: number): ProceduralTexture;
  92594. /**
  92595. * Set an array of floats in the shader.
  92596. * @param name Define the name of the uniform as defined in the shader
  92597. * @param value Define the value to give to the uniform
  92598. * @return the texture itself allowing "fluent" like uniform updates
  92599. */
  92600. setFloats(name: string, value: number[]): ProceduralTexture;
  92601. /**
  92602. * Set a vec3 in the shader from a Color3.
  92603. * @param name Define the name of the uniform as defined in the shader
  92604. * @param value Define the value to give to the uniform
  92605. * @return the texture itself allowing "fluent" like uniform updates
  92606. */
  92607. setColor3(name: string, value: Color3): ProceduralTexture;
  92608. /**
  92609. * Set a vec4 in the shader from a Color4.
  92610. * @param name Define the name of the uniform as defined in the shader
  92611. * @param value Define the value to give to the uniform
  92612. * @return the texture itself allowing "fluent" like uniform updates
  92613. */
  92614. setColor4(name: string, value: Color4): ProceduralTexture;
  92615. /**
  92616. * Set a vec2 in the shader from a Vector2.
  92617. * @param name Define the name of the uniform as defined in the shader
  92618. * @param value Define the value to give to the uniform
  92619. * @return the texture itself allowing "fluent" like uniform updates
  92620. */
  92621. setVector2(name: string, value: Vector2): ProceduralTexture;
  92622. /**
  92623. * Set a vec3 in the shader from a Vector3.
  92624. * @param name Define the name of the uniform as defined in the shader
  92625. * @param value Define the value to give to the uniform
  92626. * @return the texture itself allowing "fluent" like uniform updates
  92627. */
  92628. setVector3(name: string, value: Vector3): ProceduralTexture;
  92629. /**
  92630. * Set a mat4 in the shader from a MAtrix.
  92631. * @param name Define the name of the uniform as defined in the shader
  92632. * @param value Define the value to give to the uniform
  92633. * @return the texture itself allowing "fluent" like uniform updates
  92634. */
  92635. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92636. /**
  92637. * Render the texture to its associated render target.
  92638. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92639. */
  92640. render(useCameraPostProcess?: boolean): void;
  92641. /**
  92642. * Clone the texture.
  92643. * @returns the cloned texture
  92644. */
  92645. clone(): ProceduralTexture;
  92646. /**
  92647. * Dispose the texture and release its asoociated resources.
  92648. */
  92649. dispose(): void;
  92650. }
  92651. }
  92652. declare module BABYLON {
  92653. /**
  92654. * This represents the base class for particle system in Babylon.
  92655. * 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.
  92656. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92657. * @example https://doc.babylonjs.com/babylon101/particles
  92658. */
  92659. export class BaseParticleSystem {
  92660. /**
  92661. * Source color is added to the destination color without alpha affecting the result
  92662. */
  92663. static BLENDMODE_ONEONE: number;
  92664. /**
  92665. * Blend current color and particle color using particle’s alpha
  92666. */
  92667. static BLENDMODE_STANDARD: number;
  92668. /**
  92669. * Add current color and particle color multiplied by particle’s alpha
  92670. */
  92671. static BLENDMODE_ADD: number;
  92672. /**
  92673. * Multiply current color with particle color
  92674. */
  92675. static BLENDMODE_MULTIPLY: number;
  92676. /**
  92677. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92678. */
  92679. static BLENDMODE_MULTIPLYADD: number;
  92680. /**
  92681. * List of animations used by the particle system.
  92682. */
  92683. animations: Animation[];
  92684. /**
  92685. * Gets or sets the unique id of the particle system
  92686. */
  92687. uniqueId: number;
  92688. /**
  92689. * The id of the Particle system.
  92690. */
  92691. id: string;
  92692. /**
  92693. * The friendly name of the Particle system.
  92694. */
  92695. name: string;
  92696. /**
  92697. * Snippet ID if the particle system was created from the snippet server
  92698. */
  92699. snippetId: string;
  92700. /**
  92701. * The rendering group used by the Particle system to chose when to render.
  92702. */
  92703. renderingGroupId: number;
  92704. /**
  92705. * The emitter represents the Mesh or position we are attaching the particle system to.
  92706. */
  92707. emitter: Nullable<AbstractMesh | Vector3>;
  92708. /**
  92709. * The maximum number of particles to emit per frame
  92710. */
  92711. emitRate: number;
  92712. /**
  92713. * If you want to launch only a few particles at once, that can be done, as well.
  92714. */
  92715. manualEmitCount: number;
  92716. /**
  92717. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92718. */
  92719. updateSpeed: number;
  92720. /**
  92721. * The amount of time the particle system is running (depends of the overall update speed).
  92722. */
  92723. targetStopDuration: number;
  92724. /**
  92725. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92726. */
  92727. disposeOnStop: boolean;
  92728. /**
  92729. * Minimum power of emitting particles.
  92730. */
  92731. minEmitPower: number;
  92732. /**
  92733. * Maximum power of emitting particles.
  92734. */
  92735. maxEmitPower: number;
  92736. /**
  92737. * Minimum life time of emitting particles.
  92738. */
  92739. minLifeTime: number;
  92740. /**
  92741. * Maximum life time of emitting particles.
  92742. */
  92743. maxLifeTime: number;
  92744. /**
  92745. * Minimum Size of emitting particles.
  92746. */
  92747. minSize: number;
  92748. /**
  92749. * Maximum Size of emitting particles.
  92750. */
  92751. maxSize: number;
  92752. /**
  92753. * Minimum scale of emitting particles on X axis.
  92754. */
  92755. minScaleX: number;
  92756. /**
  92757. * Maximum scale of emitting particles on X axis.
  92758. */
  92759. maxScaleX: number;
  92760. /**
  92761. * Minimum scale of emitting particles on Y axis.
  92762. */
  92763. minScaleY: number;
  92764. /**
  92765. * Maximum scale of emitting particles on Y axis.
  92766. */
  92767. maxScaleY: number;
  92768. /**
  92769. * Gets or sets the minimal initial rotation in radians.
  92770. */
  92771. minInitialRotation: number;
  92772. /**
  92773. * Gets or sets the maximal initial rotation in radians.
  92774. */
  92775. maxInitialRotation: number;
  92776. /**
  92777. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92778. */
  92779. minAngularSpeed: number;
  92780. /**
  92781. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92782. */
  92783. maxAngularSpeed: number;
  92784. /**
  92785. * The texture used to render each particle. (this can be a spritesheet)
  92786. */
  92787. particleTexture: Nullable<BaseTexture>;
  92788. /**
  92789. * The layer mask we are rendering the particles through.
  92790. */
  92791. layerMask: number;
  92792. /**
  92793. * This can help using your own shader to render the particle system.
  92794. * The according effect will be created
  92795. */
  92796. customShader: any;
  92797. /**
  92798. * By default particle system starts as soon as they are created. This prevents the
  92799. * automatic start to happen and let you decide when to start emitting particles.
  92800. */
  92801. preventAutoStart: boolean;
  92802. private _noiseTexture;
  92803. /**
  92804. * Gets or sets a texture used to add random noise to particle positions
  92805. */
  92806. get noiseTexture(): Nullable<ProceduralTexture>;
  92807. set noiseTexture(value: Nullable<ProceduralTexture>);
  92808. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92809. noiseStrength: Vector3;
  92810. /**
  92811. * Callback triggered when the particle animation is ending.
  92812. */
  92813. onAnimationEnd: Nullable<() => void>;
  92814. /**
  92815. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92816. */
  92817. blendMode: number;
  92818. /**
  92819. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92820. * to override the particles.
  92821. */
  92822. forceDepthWrite: boolean;
  92823. /** 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 */
  92824. preWarmCycles: number;
  92825. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92826. preWarmStepOffset: number;
  92827. /**
  92828. * 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)
  92829. */
  92830. spriteCellChangeSpeed: number;
  92831. /**
  92832. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92833. */
  92834. startSpriteCellID: number;
  92835. /**
  92836. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92837. */
  92838. endSpriteCellID: number;
  92839. /**
  92840. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92841. */
  92842. spriteCellWidth: number;
  92843. /**
  92844. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92845. */
  92846. spriteCellHeight: number;
  92847. /**
  92848. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92849. */
  92850. spriteRandomStartCell: boolean;
  92851. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92852. translationPivot: Vector2;
  92853. /** @hidden */
  92854. protected _isAnimationSheetEnabled: boolean;
  92855. /**
  92856. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92857. */
  92858. beginAnimationOnStart: boolean;
  92859. /**
  92860. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92861. */
  92862. beginAnimationFrom: number;
  92863. /**
  92864. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92865. */
  92866. beginAnimationTo: number;
  92867. /**
  92868. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92869. */
  92870. beginAnimationLoop: boolean;
  92871. /**
  92872. * Gets or sets a world offset applied to all particles
  92873. */
  92874. worldOffset: Vector3;
  92875. /**
  92876. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92877. */
  92878. get isAnimationSheetEnabled(): boolean;
  92879. set isAnimationSheetEnabled(value: boolean);
  92880. /**
  92881. * Get hosting scene
  92882. * @returns the scene
  92883. */
  92884. getScene(): Nullable<Scene>;
  92885. /**
  92886. * You can use gravity if you want to give an orientation to your particles.
  92887. */
  92888. gravity: Vector3;
  92889. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92890. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92891. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92892. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92893. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92894. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92895. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92896. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92897. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92898. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92899. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92900. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92901. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92902. /**
  92903. * Defines the delay in milliseconds before starting the system (0 by default)
  92904. */
  92905. startDelay: number;
  92906. /**
  92907. * Gets the current list of drag gradients.
  92908. * You must use addDragGradient and removeDragGradient to udpate this list
  92909. * @returns the list of drag gradients
  92910. */
  92911. getDragGradients(): Nullable<Array<FactorGradient>>;
  92912. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92913. limitVelocityDamping: number;
  92914. /**
  92915. * Gets the current list of limit velocity gradients.
  92916. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92917. * @returns the list of limit velocity gradients
  92918. */
  92919. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92920. /**
  92921. * Gets the current list of color gradients.
  92922. * You must use addColorGradient and removeColorGradient to udpate this list
  92923. * @returns the list of color gradients
  92924. */
  92925. getColorGradients(): Nullable<Array<ColorGradient>>;
  92926. /**
  92927. * Gets the current list of size gradients.
  92928. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92929. * @returns the list of size gradients
  92930. */
  92931. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92932. /**
  92933. * Gets the current list of color remap gradients.
  92934. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92935. * @returns the list of color remap gradients
  92936. */
  92937. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92938. /**
  92939. * Gets the current list of alpha remap gradients.
  92940. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92941. * @returns the list of alpha remap gradients
  92942. */
  92943. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92944. /**
  92945. * Gets the current list of life time gradients.
  92946. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92947. * @returns the list of life time gradients
  92948. */
  92949. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92950. /**
  92951. * Gets the current list of angular speed gradients.
  92952. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92953. * @returns the list of angular speed gradients
  92954. */
  92955. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92956. /**
  92957. * Gets the current list of velocity gradients.
  92958. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92959. * @returns the list of velocity gradients
  92960. */
  92961. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92962. /**
  92963. * Gets the current list of start size gradients.
  92964. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92965. * @returns the list of start size gradients
  92966. */
  92967. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92968. /**
  92969. * Gets the current list of emit rate gradients.
  92970. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92971. * @returns the list of emit rate gradients
  92972. */
  92973. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92974. /**
  92975. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92976. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92977. */
  92978. get direction1(): Vector3;
  92979. set direction1(value: Vector3);
  92980. /**
  92981. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92982. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92983. */
  92984. get direction2(): Vector3;
  92985. set direction2(value: Vector3);
  92986. /**
  92987. * 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.
  92988. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92989. */
  92990. get minEmitBox(): Vector3;
  92991. set minEmitBox(value: Vector3);
  92992. /**
  92993. * 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.
  92994. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92995. */
  92996. get maxEmitBox(): Vector3;
  92997. set maxEmitBox(value: Vector3);
  92998. /**
  92999. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93000. */
  93001. color1: Color4;
  93002. /**
  93003. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93004. */
  93005. color2: Color4;
  93006. /**
  93007. * Color the particle will have at the end of its lifetime
  93008. */
  93009. colorDead: Color4;
  93010. /**
  93011. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  93012. */
  93013. textureMask: Color4;
  93014. /**
  93015. * The particle emitter type defines the emitter used by the particle system.
  93016. * It can be for example box, sphere, or cone...
  93017. */
  93018. particleEmitterType: IParticleEmitterType;
  93019. /** @hidden */
  93020. _isSubEmitter: boolean;
  93021. /**
  93022. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93023. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93024. */
  93025. billboardMode: number;
  93026. protected _isBillboardBased: boolean;
  93027. /**
  93028. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93029. */
  93030. get isBillboardBased(): boolean;
  93031. set isBillboardBased(value: boolean);
  93032. /**
  93033. * The scene the particle system belongs to.
  93034. */
  93035. protected _scene: Nullable<Scene>;
  93036. /**
  93037. * The engine the particle system belongs to.
  93038. */
  93039. protected _engine: ThinEngine;
  93040. /**
  93041. * Local cache of defines for image processing.
  93042. */
  93043. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  93044. /**
  93045. * Default configuration related to image processing available in the standard Material.
  93046. */
  93047. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  93048. /**
  93049. * Gets the image processing configuration used either in this material.
  93050. */
  93051. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  93052. /**
  93053. * Sets the Default image processing configuration used either in the this material.
  93054. *
  93055. * If sets to null, the scene one is in use.
  93056. */
  93057. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  93058. /**
  93059. * Attaches a new image processing configuration to the Standard Material.
  93060. * @param configuration
  93061. */
  93062. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93063. /** @hidden */
  93064. protected _reset(): void;
  93065. /** @hidden */
  93066. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  93067. /**
  93068. * Instantiates a particle system.
  93069. * 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.
  93070. * @param name The name of the particle system
  93071. */
  93072. constructor(name: string);
  93073. /**
  93074. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93075. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93076. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93077. * @returns the emitter
  93078. */
  93079. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93080. /**
  93081. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93082. * @param radius The radius of the hemisphere to emit from
  93083. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93084. * @returns the emitter
  93085. */
  93086. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  93087. /**
  93088. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93089. * @param radius The radius of the sphere to emit from
  93090. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93091. * @returns the emitter
  93092. */
  93093. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93094. /**
  93095. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93096. * @param radius The radius of the sphere to emit from
  93097. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93098. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93099. * @returns the emitter
  93100. */
  93101. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93102. /**
  93103. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93104. * @param radius The radius of the emission cylinder
  93105. * @param height The height of the emission cylinder
  93106. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93107. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93108. * @returns the emitter
  93109. */
  93110. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93111. /**
  93112. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93113. * @param radius The radius of the cylinder to emit from
  93114. * @param height The height of the emission cylinder
  93115. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93116. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93117. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93118. * @returns the emitter
  93119. */
  93120. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93121. /**
  93122. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93123. * @param radius The radius of the cone to emit from
  93124. * @param angle The base angle of the cone
  93125. * @returns the emitter
  93126. */
  93127. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93128. /**
  93129. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93130. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93131. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93132. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93133. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93134. * @returns the emitter
  93135. */
  93136. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93137. }
  93138. }
  93139. declare module BABYLON {
  93140. /**
  93141. * Type of sub emitter
  93142. */
  93143. export enum SubEmitterType {
  93144. /**
  93145. * Attached to the particle over it's lifetime
  93146. */
  93147. ATTACHED = 0,
  93148. /**
  93149. * Created when the particle dies
  93150. */
  93151. END = 1
  93152. }
  93153. /**
  93154. * Sub emitter class used to emit particles from an existing particle
  93155. */
  93156. export class SubEmitter {
  93157. /**
  93158. * the particle system to be used by the sub emitter
  93159. */
  93160. particleSystem: ParticleSystem;
  93161. /**
  93162. * Type of the submitter (Default: END)
  93163. */
  93164. type: SubEmitterType;
  93165. /**
  93166. * 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)
  93167. * Note: This only is supported when using an emitter of type Mesh
  93168. */
  93169. inheritDirection: boolean;
  93170. /**
  93171. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93172. */
  93173. inheritedVelocityAmount: number;
  93174. /**
  93175. * Creates a sub emitter
  93176. * @param particleSystem the particle system to be used by the sub emitter
  93177. */
  93178. constructor(
  93179. /**
  93180. * the particle system to be used by the sub emitter
  93181. */
  93182. particleSystem: ParticleSystem);
  93183. /**
  93184. * Clones the sub emitter
  93185. * @returns the cloned sub emitter
  93186. */
  93187. clone(): SubEmitter;
  93188. /**
  93189. * Serialize current object to a JSON object
  93190. * @returns the serialized object
  93191. */
  93192. serialize(): any;
  93193. /** @hidden */
  93194. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93195. /**
  93196. * Creates a new SubEmitter from a serialized JSON version
  93197. * @param serializationObject defines the JSON object to read from
  93198. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93199. * @param rootUrl defines the rootUrl for data loading
  93200. * @returns a new SubEmitter
  93201. */
  93202. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93203. /** Release associated resources */
  93204. dispose(): void;
  93205. }
  93206. }
  93207. declare module BABYLON {
  93208. /** @hidden */
  93209. export var imageProcessingDeclaration: {
  93210. name: string;
  93211. shader: string;
  93212. };
  93213. }
  93214. declare module BABYLON {
  93215. /** @hidden */
  93216. export var imageProcessingFunctions: {
  93217. name: string;
  93218. shader: string;
  93219. };
  93220. }
  93221. declare module BABYLON {
  93222. /** @hidden */
  93223. export var particlesPixelShader: {
  93224. name: string;
  93225. shader: string;
  93226. };
  93227. }
  93228. declare module BABYLON {
  93229. /** @hidden */
  93230. export var particlesVertexShader: {
  93231. name: string;
  93232. shader: string;
  93233. };
  93234. }
  93235. declare module BABYLON {
  93236. /**
  93237. * Interface used to define entities containing multiple clip planes
  93238. */
  93239. export interface IClipPlanesHolder {
  93240. /**
  93241. * Gets or sets the active clipplane 1
  93242. */
  93243. clipPlane: Nullable<Plane>;
  93244. /**
  93245. * Gets or sets the active clipplane 2
  93246. */
  93247. clipPlane2: Nullable<Plane>;
  93248. /**
  93249. * Gets or sets the active clipplane 3
  93250. */
  93251. clipPlane3: Nullable<Plane>;
  93252. /**
  93253. * Gets or sets the active clipplane 4
  93254. */
  93255. clipPlane4: Nullable<Plane>;
  93256. /**
  93257. * Gets or sets the active clipplane 5
  93258. */
  93259. clipPlane5: Nullable<Plane>;
  93260. /**
  93261. * Gets or sets the active clipplane 6
  93262. */
  93263. clipPlane6: Nullable<Plane>;
  93264. }
  93265. }
  93266. declare module BABYLON {
  93267. /**
  93268. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93269. *
  93270. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93271. *
  93272. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93273. */
  93274. export class ThinMaterialHelper {
  93275. /**
  93276. * Binds the clip plane information from the holder to the effect.
  93277. * @param effect The effect we are binding the data to
  93278. * @param holder The entity containing the clip plane information
  93279. */
  93280. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93281. }
  93282. }
  93283. declare module BABYLON {
  93284. interface ThinEngine {
  93285. /**
  93286. * Sets alpha constants used by some alpha blending modes
  93287. * @param r defines the red component
  93288. * @param g defines the green component
  93289. * @param b defines the blue component
  93290. * @param a defines the alpha component
  93291. */
  93292. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93293. /**
  93294. * Sets the current alpha mode
  93295. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93296. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93297. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93298. */
  93299. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93300. /**
  93301. * Gets the current alpha mode
  93302. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93303. * @returns the current alpha mode
  93304. */
  93305. getAlphaMode(): number;
  93306. /**
  93307. * Sets the current alpha equation
  93308. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93309. */
  93310. setAlphaEquation(equation: number): void;
  93311. /**
  93312. * Gets the current alpha equation.
  93313. * @returns the current alpha equation
  93314. */
  93315. getAlphaEquation(): number;
  93316. }
  93317. }
  93318. declare module BABYLON {
  93319. /**
  93320. * This represents a particle system in Babylon.
  93321. * 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.
  93322. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93323. * @example https://doc.babylonjs.com/babylon101/particles
  93324. */
  93325. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93326. /**
  93327. * Billboard mode will only apply to Y axis
  93328. */
  93329. static readonly BILLBOARDMODE_Y: number;
  93330. /**
  93331. * Billboard mode will apply to all axes
  93332. */
  93333. static readonly BILLBOARDMODE_ALL: number;
  93334. /**
  93335. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93336. */
  93337. static readonly BILLBOARDMODE_STRETCHED: number;
  93338. /**
  93339. * This function can be defined to provide custom update for active particles.
  93340. * This function will be called instead of regular update (age, position, color, etc.).
  93341. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93342. */
  93343. updateFunction: (particles: Particle[]) => void;
  93344. private _emitterWorldMatrix;
  93345. /**
  93346. * This function can be defined to specify initial direction for every new particle.
  93347. * It by default use the emitterType defined function
  93348. */
  93349. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93350. /**
  93351. * This function can be defined to specify initial position for every new particle.
  93352. * It by default use the emitterType defined function
  93353. */
  93354. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93355. /**
  93356. * @hidden
  93357. */
  93358. _inheritedVelocityOffset: Vector3;
  93359. /**
  93360. * An event triggered when the system is disposed
  93361. */
  93362. onDisposeObservable: Observable<IParticleSystem>;
  93363. /**
  93364. * An event triggered when the system is stopped
  93365. */
  93366. onStoppedObservable: Observable<IParticleSystem>;
  93367. private _onDisposeObserver;
  93368. /**
  93369. * Sets a callback that will be triggered when the system is disposed
  93370. */
  93371. set onDispose(callback: () => void);
  93372. private _particles;
  93373. private _epsilon;
  93374. private _capacity;
  93375. private _stockParticles;
  93376. private _newPartsExcess;
  93377. private _vertexData;
  93378. private _vertexBuffer;
  93379. private _vertexBuffers;
  93380. private _spriteBuffer;
  93381. private _indexBuffer;
  93382. private _effect;
  93383. private _customEffect;
  93384. private _cachedDefines;
  93385. private _scaledColorStep;
  93386. private _colorDiff;
  93387. private _scaledDirection;
  93388. private _scaledGravity;
  93389. private _currentRenderId;
  93390. private _alive;
  93391. private _useInstancing;
  93392. private _started;
  93393. private _stopped;
  93394. private _actualFrame;
  93395. private _scaledUpdateSpeed;
  93396. private _vertexBufferSize;
  93397. /** @hidden */
  93398. _currentEmitRateGradient: Nullable<FactorGradient>;
  93399. /** @hidden */
  93400. _currentEmitRate1: number;
  93401. /** @hidden */
  93402. _currentEmitRate2: number;
  93403. /** @hidden */
  93404. _currentStartSizeGradient: Nullable<FactorGradient>;
  93405. /** @hidden */
  93406. _currentStartSize1: number;
  93407. /** @hidden */
  93408. _currentStartSize2: number;
  93409. private readonly _rawTextureWidth;
  93410. private _rampGradientsTexture;
  93411. private _useRampGradients;
  93412. /** Gets or sets a matrix to use to compute projection */
  93413. defaultProjectionMatrix: Matrix;
  93414. /** Gets or sets a matrix to use to compute view */
  93415. defaultViewMatrix: Matrix;
  93416. /** Gets or sets a boolean indicating that ramp gradients must be used
  93417. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93418. */
  93419. get useRampGradients(): boolean;
  93420. set useRampGradients(value: boolean);
  93421. /**
  93422. * 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.
  93423. * 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: [])
  93424. */
  93425. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93426. private _subEmitters;
  93427. /**
  93428. * @hidden
  93429. * If the particle systems emitter should be disposed when the particle system is disposed
  93430. */
  93431. _disposeEmitterOnDispose: boolean;
  93432. /**
  93433. * The current active Sub-systems, this property is used by the root particle system only.
  93434. */
  93435. activeSubSystems: Array<ParticleSystem>;
  93436. /**
  93437. * Specifies if the particles are updated in emitter local space or world space
  93438. */
  93439. isLocal: boolean;
  93440. private _rootParticleSystem;
  93441. /**
  93442. * Gets the current list of active particles
  93443. */
  93444. get particles(): Particle[];
  93445. /**
  93446. * Gets the number of particles active at the same time.
  93447. * @returns The number of active particles.
  93448. */
  93449. getActiveCount(): number;
  93450. /**
  93451. * Returns the string "ParticleSystem"
  93452. * @returns a string containing the class name
  93453. */
  93454. getClassName(): string;
  93455. /**
  93456. * Gets a boolean indicating that the system is stopping
  93457. * @returns true if the system is currently stopping
  93458. */
  93459. isStopping(): boolean;
  93460. /**
  93461. * Gets the custom effect used to render the particles
  93462. * @param blendMode Blend mode for which the effect should be retrieved
  93463. * @returns The effect
  93464. */
  93465. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93466. /**
  93467. * Sets the custom effect used to render the particles
  93468. * @param effect The effect to set
  93469. * @param blendMode Blend mode for which the effect should be set
  93470. */
  93471. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93472. /** @hidden */
  93473. private _onBeforeDrawParticlesObservable;
  93474. /**
  93475. * Observable that will be called just before the particles are drawn
  93476. */
  93477. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93478. /**
  93479. * Gets the name of the particle vertex shader
  93480. */
  93481. get vertexShaderName(): string;
  93482. /**
  93483. * Instantiates a particle system.
  93484. * 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.
  93485. * @param name The name of the particle system
  93486. * @param capacity The max number of particles alive at the same time
  93487. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93488. * @param customEffect a custom effect used to change the way particles are rendered by default
  93489. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93490. * @param epsilon Offset used to render the particles
  93491. */
  93492. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93493. private _addFactorGradient;
  93494. private _removeFactorGradient;
  93495. /**
  93496. * Adds a new life time gradient
  93497. * @param gradient defines the gradient to use (between 0 and 1)
  93498. * @param factor defines the life time factor to affect to the specified gradient
  93499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93500. * @returns the current particle system
  93501. */
  93502. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93503. /**
  93504. * Remove a specific life time gradient
  93505. * @param gradient defines the gradient to remove
  93506. * @returns the current particle system
  93507. */
  93508. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93509. /**
  93510. * Adds a new size gradient
  93511. * @param gradient defines the gradient to use (between 0 and 1)
  93512. * @param factor defines the size factor to affect to the specified gradient
  93513. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93514. * @returns the current particle system
  93515. */
  93516. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93517. /**
  93518. * Remove a specific size gradient
  93519. * @param gradient defines the gradient to remove
  93520. * @returns the current particle system
  93521. */
  93522. removeSizeGradient(gradient: number): IParticleSystem;
  93523. /**
  93524. * Adds a new color remap gradient
  93525. * @param gradient defines the gradient to use (between 0 and 1)
  93526. * @param min defines the color remap minimal range
  93527. * @param max defines the color remap maximal range
  93528. * @returns the current particle system
  93529. */
  93530. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93531. /**
  93532. * Remove a specific color remap gradient
  93533. * @param gradient defines the gradient to remove
  93534. * @returns the current particle system
  93535. */
  93536. removeColorRemapGradient(gradient: number): IParticleSystem;
  93537. /**
  93538. * Adds a new alpha remap gradient
  93539. * @param gradient defines the gradient to use (between 0 and 1)
  93540. * @param min defines the alpha remap minimal range
  93541. * @param max defines the alpha remap maximal range
  93542. * @returns the current particle system
  93543. */
  93544. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93545. /**
  93546. * Remove a specific alpha remap gradient
  93547. * @param gradient defines the gradient to remove
  93548. * @returns the current particle system
  93549. */
  93550. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93551. /**
  93552. * Adds a new angular speed gradient
  93553. * @param gradient defines the gradient to use (between 0 and 1)
  93554. * @param factor defines the angular speed to affect to the specified gradient
  93555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93556. * @returns the current particle system
  93557. */
  93558. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93559. /**
  93560. * Remove a specific angular speed gradient
  93561. * @param gradient defines the gradient to remove
  93562. * @returns the current particle system
  93563. */
  93564. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93565. /**
  93566. * Adds a new velocity gradient
  93567. * @param gradient defines the gradient to use (between 0 and 1)
  93568. * @param factor defines the velocity to affect to the specified gradient
  93569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93570. * @returns the current particle system
  93571. */
  93572. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93573. /**
  93574. * Remove a specific velocity gradient
  93575. * @param gradient defines the gradient to remove
  93576. * @returns the current particle system
  93577. */
  93578. removeVelocityGradient(gradient: number): IParticleSystem;
  93579. /**
  93580. * Adds a new limit velocity gradient
  93581. * @param gradient defines the gradient to use (between 0 and 1)
  93582. * @param factor defines the limit velocity value to affect to the specified gradient
  93583. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93584. * @returns the current particle system
  93585. */
  93586. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93587. /**
  93588. * Remove a specific limit velocity gradient
  93589. * @param gradient defines the gradient to remove
  93590. * @returns the current particle system
  93591. */
  93592. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93593. /**
  93594. * Adds a new drag gradient
  93595. * @param gradient defines the gradient to use (between 0 and 1)
  93596. * @param factor defines the drag value to affect to the specified gradient
  93597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93598. * @returns the current particle system
  93599. */
  93600. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93601. /**
  93602. * Remove a specific drag gradient
  93603. * @param gradient defines the gradient to remove
  93604. * @returns the current particle system
  93605. */
  93606. removeDragGradient(gradient: number): IParticleSystem;
  93607. /**
  93608. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93609. * @param gradient defines the gradient to use (between 0 and 1)
  93610. * @param factor defines the emit rate value to affect to the specified gradient
  93611. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93612. * @returns the current particle system
  93613. */
  93614. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93615. /**
  93616. * Remove a specific emit rate gradient
  93617. * @param gradient defines the gradient to remove
  93618. * @returns the current particle system
  93619. */
  93620. removeEmitRateGradient(gradient: number): IParticleSystem;
  93621. /**
  93622. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93623. * @param gradient defines the gradient to use (between 0 and 1)
  93624. * @param factor defines the start size value to affect to the specified gradient
  93625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93626. * @returns the current particle system
  93627. */
  93628. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93629. /**
  93630. * Remove a specific start size gradient
  93631. * @param gradient defines the gradient to remove
  93632. * @returns the current particle system
  93633. */
  93634. removeStartSizeGradient(gradient: number): IParticleSystem;
  93635. private _createRampGradientTexture;
  93636. /**
  93637. * Gets the current list of ramp gradients.
  93638. * You must use addRampGradient and removeRampGradient to udpate this list
  93639. * @returns the list of ramp gradients
  93640. */
  93641. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93642. /** Force the system to rebuild all gradients that need to be resync */
  93643. forceRefreshGradients(): void;
  93644. private _syncRampGradientTexture;
  93645. /**
  93646. * Adds a new ramp gradient used to remap particle colors
  93647. * @param gradient defines the gradient to use (between 0 and 1)
  93648. * @param color defines the color to affect to the specified gradient
  93649. * @returns the current particle system
  93650. */
  93651. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93652. /**
  93653. * Remove a specific ramp gradient
  93654. * @param gradient defines the gradient to remove
  93655. * @returns the current particle system
  93656. */
  93657. removeRampGradient(gradient: number): ParticleSystem;
  93658. /**
  93659. * Adds a new color gradient
  93660. * @param gradient defines the gradient to use (between 0 and 1)
  93661. * @param color1 defines the color to affect to the specified gradient
  93662. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93663. * @returns this particle system
  93664. */
  93665. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93666. /**
  93667. * Remove a specific color gradient
  93668. * @param gradient defines the gradient to remove
  93669. * @returns this particle system
  93670. */
  93671. removeColorGradient(gradient: number): IParticleSystem;
  93672. private _fetchR;
  93673. protected _reset(): void;
  93674. private _resetEffect;
  93675. private _createVertexBuffers;
  93676. private _createIndexBuffer;
  93677. /**
  93678. * Gets the maximum number of particles active at the same time.
  93679. * @returns The max number of active particles.
  93680. */
  93681. getCapacity(): number;
  93682. /**
  93683. * Gets whether there are still active particles in the system.
  93684. * @returns True if it is alive, otherwise false.
  93685. */
  93686. isAlive(): boolean;
  93687. /**
  93688. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93689. * @returns True if it has been started, otherwise false.
  93690. */
  93691. isStarted(): boolean;
  93692. private _prepareSubEmitterInternalArray;
  93693. /**
  93694. * Starts the particle system and begins to emit
  93695. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93696. */
  93697. start(delay?: number): void;
  93698. /**
  93699. * Stops the particle system.
  93700. * @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.
  93701. */
  93702. stop(stopSubEmitters?: boolean): void;
  93703. /**
  93704. * Remove all active particles
  93705. */
  93706. reset(): void;
  93707. /**
  93708. * @hidden (for internal use only)
  93709. */
  93710. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93711. /**
  93712. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93713. * Its lifetime will start back at 0.
  93714. */
  93715. recycleParticle: (particle: Particle) => void;
  93716. private _stopSubEmitters;
  93717. private _createParticle;
  93718. private _removeFromRoot;
  93719. private _emitFromParticle;
  93720. private _update;
  93721. /** @hidden */
  93722. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93723. /** @hidden */
  93724. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93725. /**
  93726. * Fill the defines array according to the current settings of the particle system
  93727. * @param defines Array to be updated
  93728. * @param blendMode blend mode to take into account when updating the array
  93729. */
  93730. fillDefines(defines: Array<string>, blendMode: number): void;
  93731. /**
  93732. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93733. * @param uniforms Uniforms array to fill
  93734. * @param attributes Attributes array to fill
  93735. * @param samplers Samplers array to fill
  93736. */
  93737. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93738. /** @hidden */
  93739. private _getEffect;
  93740. /**
  93741. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93742. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93743. */
  93744. animate(preWarmOnly?: boolean): void;
  93745. private _appendParticleVertices;
  93746. /**
  93747. * Rebuilds the particle system.
  93748. */
  93749. rebuild(): void;
  93750. /**
  93751. * Is this system ready to be used/rendered
  93752. * @return true if the system is ready
  93753. */
  93754. isReady(): boolean;
  93755. private _render;
  93756. /**
  93757. * Renders the particle system in its current state.
  93758. * @returns the current number of particles
  93759. */
  93760. render(): number;
  93761. /**
  93762. * Disposes the particle system and free the associated resources
  93763. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93764. */
  93765. dispose(disposeTexture?: boolean): void;
  93766. /**
  93767. * Clones the particle system.
  93768. * @param name The name of the cloned object
  93769. * @param newEmitter The new emitter to use
  93770. * @returns the cloned particle system
  93771. */
  93772. clone(name: string, newEmitter: any): ParticleSystem;
  93773. /**
  93774. * Serializes the particle system to a JSON object
  93775. * @param serializeTexture defines if the texture must be serialized as well
  93776. * @returns the JSON object
  93777. */
  93778. serialize(serializeTexture?: boolean): any;
  93779. /** @hidden */
  93780. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93781. /** @hidden */
  93782. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93783. /**
  93784. * Parses a JSON object to create a particle system.
  93785. * @param parsedParticleSystem The JSON object to parse
  93786. * @param sceneOrEngine The scene or the engine to create the particle system in
  93787. * @param rootUrl The root url to use to load external dependencies like texture
  93788. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93789. * @returns the Parsed particle system
  93790. */
  93791. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93792. }
  93793. }
  93794. declare module BABYLON {
  93795. /**
  93796. * A particle represents one of the element emitted by a particle system.
  93797. * This is mainly define by its coordinates, direction, velocity and age.
  93798. */
  93799. export class Particle {
  93800. /**
  93801. * The particle system the particle belongs to.
  93802. */
  93803. particleSystem: ParticleSystem;
  93804. private static _Count;
  93805. /**
  93806. * Unique ID of the particle
  93807. */
  93808. id: number;
  93809. /**
  93810. * The world position of the particle in the scene.
  93811. */
  93812. position: Vector3;
  93813. /**
  93814. * The world direction of the particle in the scene.
  93815. */
  93816. direction: Vector3;
  93817. /**
  93818. * The color of the particle.
  93819. */
  93820. color: Color4;
  93821. /**
  93822. * The color change of the particle per step.
  93823. */
  93824. colorStep: Color4;
  93825. /**
  93826. * Defines how long will the life of the particle be.
  93827. */
  93828. lifeTime: number;
  93829. /**
  93830. * The current age of the particle.
  93831. */
  93832. age: number;
  93833. /**
  93834. * The current size of the particle.
  93835. */
  93836. size: number;
  93837. /**
  93838. * The current scale of the particle.
  93839. */
  93840. scale: Vector2;
  93841. /**
  93842. * The current angle of the particle.
  93843. */
  93844. angle: number;
  93845. /**
  93846. * Defines how fast is the angle changing.
  93847. */
  93848. angularSpeed: number;
  93849. /**
  93850. * Defines the cell index used by the particle to be rendered from a sprite.
  93851. */
  93852. cellIndex: number;
  93853. /**
  93854. * The information required to support color remapping
  93855. */
  93856. remapData: Vector4;
  93857. /** @hidden */
  93858. _randomCellOffset?: number;
  93859. /** @hidden */
  93860. _initialDirection: Nullable<Vector3>;
  93861. /** @hidden */
  93862. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93863. /** @hidden */
  93864. _initialStartSpriteCellID: number;
  93865. /** @hidden */
  93866. _initialEndSpriteCellID: number;
  93867. /** @hidden */
  93868. _currentColorGradient: Nullable<ColorGradient>;
  93869. /** @hidden */
  93870. _currentColor1: Color4;
  93871. /** @hidden */
  93872. _currentColor2: Color4;
  93873. /** @hidden */
  93874. _currentSizeGradient: Nullable<FactorGradient>;
  93875. /** @hidden */
  93876. _currentSize1: number;
  93877. /** @hidden */
  93878. _currentSize2: number;
  93879. /** @hidden */
  93880. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93881. /** @hidden */
  93882. _currentAngularSpeed1: number;
  93883. /** @hidden */
  93884. _currentAngularSpeed2: number;
  93885. /** @hidden */
  93886. _currentVelocityGradient: Nullable<FactorGradient>;
  93887. /** @hidden */
  93888. _currentVelocity1: number;
  93889. /** @hidden */
  93890. _currentVelocity2: number;
  93891. /** @hidden */
  93892. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93893. /** @hidden */
  93894. _currentLimitVelocity1: number;
  93895. /** @hidden */
  93896. _currentLimitVelocity2: number;
  93897. /** @hidden */
  93898. _currentDragGradient: Nullable<FactorGradient>;
  93899. /** @hidden */
  93900. _currentDrag1: number;
  93901. /** @hidden */
  93902. _currentDrag2: number;
  93903. /** @hidden */
  93904. _randomNoiseCoordinates1: Vector3;
  93905. /** @hidden */
  93906. _randomNoiseCoordinates2: Vector3;
  93907. /** @hidden */
  93908. _localPosition?: Vector3;
  93909. /**
  93910. * Creates a new instance Particle
  93911. * @param particleSystem the particle system the particle belongs to
  93912. */
  93913. constructor(
  93914. /**
  93915. * The particle system the particle belongs to.
  93916. */
  93917. particleSystem: ParticleSystem);
  93918. private updateCellInfoFromSystem;
  93919. /**
  93920. * Defines how the sprite cell index is updated for the particle
  93921. */
  93922. updateCellIndex(): void;
  93923. /** @hidden */
  93924. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93925. /** @hidden */
  93926. _inheritParticleInfoToSubEmitters(): void;
  93927. /** @hidden */
  93928. _reset(): void;
  93929. /**
  93930. * Copy the properties of particle to another one.
  93931. * @param other the particle to copy the information to.
  93932. */
  93933. copyTo(other: Particle): void;
  93934. }
  93935. }
  93936. declare module BABYLON {
  93937. /**
  93938. * Particle emitter represents a volume emitting particles.
  93939. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93940. */
  93941. export interface IParticleEmitterType {
  93942. /**
  93943. * Called by the particle System when the direction is computed for the created particle.
  93944. * @param worldMatrix is the world matrix of the particle system
  93945. * @param directionToUpdate is the direction vector to update with the result
  93946. * @param particle is the particle we are computed the direction for
  93947. * @param isLocal defines if the direction should be set in local space
  93948. */
  93949. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93950. /**
  93951. * Called by the particle System when the position is computed for the created particle.
  93952. * @param worldMatrix is the world matrix of the particle system
  93953. * @param positionToUpdate is the position vector to update with the result
  93954. * @param particle is the particle we are computed the position for
  93955. * @param isLocal defines if the position should be set in local space
  93956. */
  93957. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93958. /**
  93959. * Clones the current emitter and returns a copy of it
  93960. * @returns the new emitter
  93961. */
  93962. clone(): IParticleEmitterType;
  93963. /**
  93964. * Called by the GPUParticleSystem to setup the update shader
  93965. * @param effect defines the update shader
  93966. */
  93967. applyToShader(effect: Effect): void;
  93968. /**
  93969. * Returns a string to use to update the GPU particles update shader
  93970. * @returns the effect defines string
  93971. */
  93972. getEffectDefines(): string;
  93973. /**
  93974. * Returns a string representing the class name
  93975. * @returns a string containing the class name
  93976. */
  93977. getClassName(): string;
  93978. /**
  93979. * Serializes the particle system to a JSON object.
  93980. * @returns the JSON object
  93981. */
  93982. serialize(): any;
  93983. /**
  93984. * Parse properties from a JSON object
  93985. * @param serializationObject defines the JSON object
  93986. * @param scene defines the hosting scene
  93987. */
  93988. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93989. }
  93990. }
  93991. declare module BABYLON {
  93992. /**
  93993. * Particle emitter emitting particles from the inside of a box.
  93994. * It emits the particles randomly between 2 given directions.
  93995. */
  93996. export class BoxParticleEmitter implements IParticleEmitterType {
  93997. /**
  93998. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93999. */
  94000. direction1: Vector3;
  94001. /**
  94002. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94003. */
  94004. direction2: Vector3;
  94005. /**
  94006. * 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.
  94007. */
  94008. minEmitBox: Vector3;
  94009. /**
  94010. * 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.
  94011. */
  94012. maxEmitBox: Vector3;
  94013. /**
  94014. * Creates a new instance BoxParticleEmitter
  94015. */
  94016. constructor();
  94017. /**
  94018. * Called by the particle System when the direction is computed for the created particle.
  94019. * @param worldMatrix is the world matrix of the particle system
  94020. * @param directionToUpdate is the direction vector to update with the result
  94021. * @param particle is the particle we are computed the direction for
  94022. * @param isLocal defines if the direction should be set in local space
  94023. */
  94024. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94025. /**
  94026. * Called by the particle System when the position is computed for the created particle.
  94027. * @param worldMatrix is the world matrix of the particle system
  94028. * @param positionToUpdate is the position vector to update with the result
  94029. * @param particle is the particle we are computed the position for
  94030. * @param isLocal defines if the position should be set in local space
  94031. */
  94032. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94033. /**
  94034. * Clones the current emitter and returns a copy of it
  94035. * @returns the new emitter
  94036. */
  94037. clone(): BoxParticleEmitter;
  94038. /**
  94039. * Called by the GPUParticleSystem to setup the update shader
  94040. * @param effect defines the update shader
  94041. */
  94042. applyToShader(effect: Effect): void;
  94043. /**
  94044. * Returns a string to use to update the GPU particles update shader
  94045. * @returns a string containng the defines string
  94046. */
  94047. getEffectDefines(): string;
  94048. /**
  94049. * Returns the string "BoxParticleEmitter"
  94050. * @returns a string containing the class name
  94051. */
  94052. getClassName(): string;
  94053. /**
  94054. * Serializes the particle system to a JSON object.
  94055. * @returns the JSON object
  94056. */
  94057. serialize(): any;
  94058. /**
  94059. * Parse properties from a JSON object
  94060. * @param serializationObject defines the JSON object
  94061. */
  94062. parse(serializationObject: any): void;
  94063. }
  94064. }
  94065. declare module BABYLON {
  94066. /**
  94067. * Particle emitter emitting particles from the inside of a cone.
  94068. * It emits the particles alongside the cone volume from the base to the particle.
  94069. * The emission direction might be randomized.
  94070. */
  94071. export class ConeParticleEmitter implements IParticleEmitterType {
  94072. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94073. directionRandomizer: number;
  94074. private _radius;
  94075. private _angle;
  94076. private _height;
  94077. /**
  94078. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  94079. */
  94080. radiusRange: number;
  94081. /**
  94082. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  94083. */
  94084. heightRange: number;
  94085. /**
  94086. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  94087. */
  94088. emitFromSpawnPointOnly: boolean;
  94089. /**
  94090. * Gets or sets the radius of the emission cone
  94091. */
  94092. get radius(): number;
  94093. set radius(value: number);
  94094. /**
  94095. * Gets or sets the angle of the emission cone
  94096. */
  94097. get angle(): number;
  94098. set angle(value: number);
  94099. private _buildHeight;
  94100. /**
  94101. * Creates a new instance ConeParticleEmitter
  94102. * @param radius the radius of the emission cone (1 by default)
  94103. * @param angle the cone base angle (PI by default)
  94104. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94105. */
  94106. constructor(radius?: number, angle?: number,
  94107. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94108. directionRandomizer?: number);
  94109. /**
  94110. * Called by the particle System when the direction is computed for the created particle.
  94111. * @param worldMatrix is the world matrix of the particle system
  94112. * @param directionToUpdate is the direction vector to update with the result
  94113. * @param particle is the particle we are computed the direction for
  94114. * @param isLocal defines if the direction should be set in local space
  94115. */
  94116. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94117. /**
  94118. * Called by the particle System when the position is computed for the created particle.
  94119. * @param worldMatrix is the world matrix of the particle system
  94120. * @param positionToUpdate is the position vector to update with the result
  94121. * @param particle is the particle we are computed the position for
  94122. * @param isLocal defines if the position should be set in local space
  94123. */
  94124. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94125. /**
  94126. * Clones the current emitter and returns a copy of it
  94127. * @returns the new emitter
  94128. */
  94129. clone(): ConeParticleEmitter;
  94130. /**
  94131. * Called by the GPUParticleSystem to setup the update shader
  94132. * @param effect defines the update shader
  94133. */
  94134. applyToShader(effect: Effect): void;
  94135. /**
  94136. * Returns a string to use to update the GPU particles update shader
  94137. * @returns a string containng the defines string
  94138. */
  94139. getEffectDefines(): string;
  94140. /**
  94141. * Returns the string "ConeParticleEmitter"
  94142. * @returns a string containing the class name
  94143. */
  94144. getClassName(): string;
  94145. /**
  94146. * Serializes the particle system to a JSON object.
  94147. * @returns the JSON object
  94148. */
  94149. serialize(): any;
  94150. /**
  94151. * Parse properties from a JSON object
  94152. * @param serializationObject defines the JSON object
  94153. */
  94154. parse(serializationObject: any): void;
  94155. }
  94156. }
  94157. declare module BABYLON {
  94158. /**
  94159. * Particle emitter emitting particles from the inside of a cylinder.
  94160. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94161. */
  94162. export class CylinderParticleEmitter implements IParticleEmitterType {
  94163. /**
  94164. * The radius of the emission cylinder.
  94165. */
  94166. radius: number;
  94167. /**
  94168. * The height of the emission cylinder.
  94169. */
  94170. height: number;
  94171. /**
  94172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94173. */
  94174. radiusRange: number;
  94175. /**
  94176. * How much to randomize the particle direction [0-1].
  94177. */
  94178. directionRandomizer: number;
  94179. /**
  94180. * Creates a new instance CylinderParticleEmitter
  94181. * @param radius the radius of the emission cylinder (1 by default)
  94182. * @param height the height of the emission cylinder (1 by default)
  94183. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94184. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94185. */
  94186. constructor(
  94187. /**
  94188. * The radius of the emission cylinder.
  94189. */
  94190. radius?: number,
  94191. /**
  94192. * The height of the emission cylinder.
  94193. */
  94194. height?: number,
  94195. /**
  94196. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94197. */
  94198. radiusRange?: number,
  94199. /**
  94200. * How much to randomize the particle direction [0-1].
  94201. */
  94202. directionRandomizer?: number);
  94203. /**
  94204. * Called by the particle System when the direction is computed for the created particle.
  94205. * @param worldMatrix is the world matrix of the particle system
  94206. * @param directionToUpdate is the direction vector to update with the result
  94207. * @param particle is the particle we are computed the direction for
  94208. * @param isLocal defines if the direction should be set in local space
  94209. */
  94210. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94211. /**
  94212. * Called by the particle System when the position is computed for the created particle.
  94213. * @param worldMatrix is the world matrix of the particle system
  94214. * @param positionToUpdate is the position vector to update with the result
  94215. * @param particle is the particle we are computed the position for
  94216. * @param isLocal defines if the position should be set in local space
  94217. */
  94218. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94219. /**
  94220. * Clones the current emitter and returns a copy of it
  94221. * @returns the new emitter
  94222. */
  94223. clone(): CylinderParticleEmitter;
  94224. /**
  94225. * Called by the GPUParticleSystem to setup the update shader
  94226. * @param effect defines the update shader
  94227. */
  94228. applyToShader(effect: Effect): void;
  94229. /**
  94230. * Returns a string to use to update the GPU particles update shader
  94231. * @returns a string containng the defines string
  94232. */
  94233. getEffectDefines(): string;
  94234. /**
  94235. * Returns the string "CylinderParticleEmitter"
  94236. * @returns a string containing the class name
  94237. */
  94238. getClassName(): string;
  94239. /**
  94240. * Serializes the particle system to a JSON object.
  94241. * @returns the JSON object
  94242. */
  94243. serialize(): any;
  94244. /**
  94245. * Parse properties from a JSON object
  94246. * @param serializationObject defines the JSON object
  94247. */
  94248. parse(serializationObject: any): void;
  94249. }
  94250. /**
  94251. * Particle emitter emitting particles from the inside of a cylinder.
  94252. * It emits the particles randomly between two vectors.
  94253. */
  94254. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94255. /**
  94256. * The min limit of the emission direction.
  94257. */
  94258. direction1: Vector3;
  94259. /**
  94260. * The max limit of the emission direction.
  94261. */
  94262. direction2: Vector3;
  94263. /**
  94264. * Creates a new instance CylinderDirectedParticleEmitter
  94265. * @param radius the radius of the emission cylinder (1 by default)
  94266. * @param height the height of the emission cylinder (1 by default)
  94267. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94268. * @param direction1 the min limit of the emission direction (up vector by default)
  94269. * @param direction2 the max limit of the emission direction (up vector by default)
  94270. */
  94271. constructor(radius?: number, height?: number, radiusRange?: number,
  94272. /**
  94273. * The min limit of the emission direction.
  94274. */
  94275. direction1?: Vector3,
  94276. /**
  94277. * The max limit of the emission direction.
  94278. */
  94279. direction2?: Vector3);
  94280. /**
  94281. * Called by the particle System when the direction is computed for the created particle.
  94282. * @param worldMatrix is the world matrix of the particle system
  94283. * @param directionToUpdate is the direction vector to update with the result
  94284. * @param particle is the particle we are computed the direction for
  94285. */
  94286. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94287. /**
  94288. * Clones the current emitter and returns a copy of it
  94289. * @returns the new emitter
  94290. */
  94291. clone(): CylinderDirectedParticleEmitter;
  94292. /**
  94293. * Called by the GPUParticleSystem to setup the update shader
  94294. * @param effect defines the update shader
  94295. */
  94296. applyToShader(effect: Effect): void;
  94297. /**
  94298. * Returns a string to use to update the GPU particles update shader
  94299. * @returns a string containng the defines string
  94300. */
  94301. getEffectDefines(): string;
  94302. /**
  94303. * Returns the string "CylinderDirectedParticleEmitter"
  94304. * @returns a string containing the class name
  94305. */
  94306. getClassName(): string;
  94307. /**
  94308. * Serializes the particle system to a JSON object.
  94309. * @returns the JSON object
  94310. */
  94311. serialize(): any;
  94312. /**
  94313. * Parse properties from a JSON object
  94314. * @param serializationObject defines the JSON object
  94315. */
  94316. parse(serializationObject: any): void;
  94317. }
  94318. }
  94319. declare module BABYLON {
  94320. /**
  94321. * Particle emitter emitting particles from the inside of a hemisphere.
  94322. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94323. */
  94324. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94325. /**
  94326. * The radius of the emission hemisphere.
  94327. */
  94328. radius: number;
  94329. /**
  94330. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94331. */
  94332. radiusRange: number;
  94333. /**
  94334. * How much to randomize the particle direction [0-1].
  94335. */
  94336. directionRandomizer: number;
  94337. /**
  94338. * Creates a new instance HemisphericParticleEmitter
  94339. * @param radius the radius of the emission hemisphere (1 by default)
  94340. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94341. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94342. */
  94343. constructor(
  94344. /**
  94345. * The radius of the emission hemisphere.
  94346. */
  94347. radius?: number,
  94348. /**
  94349. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94350. */
  94351. radiusRange?: number,
  94352. /**
  94353. * How much to randomize the particle direction [0-1].
  94354. */
  94355. directionRandomizer?: number);
  94356. /**
  94357. * Called by the particle System when the direction is computed for the created particle.
  94358. * @param worldMatrix is the world matrix of the particle system
  94359. * @param directionToUpdate is the direction vector to update with the result
  94360. * @param particle is the particle we are computed the direction for
  94361. * @param isLocal defines if the direction should be set in local space
  94362. */
  94363. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94364. /**
  94365. * Called by the particle System when the position is computed for the created particle.
  94366. * @param worldMatrix is the world matrix of the particle system
  94367. * @param positionToUpdate is the position vector to update with the result
  94368. * @param particle is the particle we are computed the position for
  94369. * @param isLocal defines if the position should be set in local space
  94370. */
  94371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94372. /**
  94373. * Clones the current emitter and returns a copy of it
  94374. * @returns the new emitter
  94375. */
  94376. clone(): HemisphericParticleEmitter;
  94377. /**
  94378. * Called by the GPUParticleSystem to setup the update shader
  94379. * @param effect defines the update shader
  94380. */
  94381. applyToShader(effect: Effect): void;
  94382. /**
  94383. * Returns a string to use to update the GPU particles update shader
  94384. * @returns a string containng the defines string
  94385. */
  94386. getEffectDefines(): string;
  94387. /**
  94388. * Returns the string "HemisphericParticleEmitter"
  94389. * @returns a string containing the class name
  94390. */
  94391. getClassName(): string;
  94392. /**
  94393. * Serializes the particle system to a JSON object.
  94394. * @returns the JSON object
  94395. */
  94396. serialize(): any;
  94397. /**
  94398. * Parse properties from a JSON object
  94399. * @param serializationObject defines the JSON object
  94400. */
  94401. parse(serializationObject: any): void;
  94402. }
  94403. }
  94404. declare module BABYLON {
  94405. /**
  94406. * Particle emitter emitting particles from a point.
  94407. * It emits the particles randomly between 2 given directions.
  94408. */
  94409. export class PointParticleEmitter implements IParticleEmitterType {
  94410. /**
  94411. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94412. */
  94413. direction1: Vector3;
  94414. /**
  94415. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94416. */
  94417. direction2: Vector3;
  94418. /**
  94419. * Creates a new instance PointParticleEmitter
  94420. */
  94421. constructor();
  94422. /**
  94423. * Called by the particle System when the direction is computed for the created particle.
  94424. * @param worldMatrix is the world matrix of the particle system
  94425. * @param directionToUpdate is the direction vector to update with the result
  94426. * @param particle is the particle we are computed the direction for
  94427. * @param isLocal defines if the direction should be set in local space
  94428. */
  94429. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94430. /**
  94431. * Called by the particle System when the position is computed for the created particle.
  94432. * @param worldMatrix is the world matrix of the particle system
  94433. * @param positionToUpdate is the position vector to update with the result
  94434. * @param particle is the particle we are computed the position for
  94435. * @param isLocal defines if the position should be set in local space
  94436. */
  94437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94438. /**
  94439. * Clones the current emitter and returns a copy of it
  94440. * @returns the new emitter
  94441. */
  94442. clone(): PointParticleEmitter;
  94443. /**
  94444. * Called by the GPUParticleSystem to setup the update shader
  94445. * @param effect defines the update shader
  94446. */
  94447. applyToShader(effect: Effect): void;
  94448. /**
  94449. * Returns a string to use to update the GPU particles update shader
  94450. * @returns a string containng the defines string
  94451. */
  94452. getEffectDefines(): string;
  94453. /**
  94454. * Returns the string "PointParticleEmitter"
  94455. * @returns a string containing the class name
  94456. */
  94457. getClassName(): string;
  94458. /**
  94459. * Serializes the particle system to a JSON object.
  94460. * @returns the JSON object
  94461. */
  94462. serialize(): any;
  94463. /**
  94464. * Parse properties from a JSON object
  94465. * @param serializationObject defines the JSON object
  94466. */
  94467. parse(serializationObject: any): void;
  94468. }
  94469. }
  94470. declare module BABYLON {
  94471. /**
  94472. * Particle emitter emitting particles from the inside of a sphere.
  94473. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94474. */
  94475. export class SphereParticleEmitter implements IParticleEmitterType {
  94476. /**
  94477. * The radius of the emission sphere.
  94478. */
  94479. radius: number;
  94480. /**
  94481. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94482. */
  94483. radiusRange: number;
  94484. /**
  94485. * How much to randomize the particle direction [0-1].
  94486. */
  94487. directionRandomizer: number;
  94488. /**
  94489. * Creates a new instance SphereParticleEmitter
  94490. * @param radius the radius of the emission sphere (1 by default)
  94491. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94492. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94493. */
  94494. constructor(
  94495. /**
  94496. * The radius of the emission sphere.
  94497. */
  94498. radius?: number,
  94499. /**
  94500. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94501. */
  94502. radiusRange?: number,
  94503. /**
  94504. * How much to randomize the particle direction [0-1].
  94505. */
  94506. directionRandomizer?: number);
  94507. /**
  94508. * Called by the particle System when the direction is computed for the created particle.
  94509. * @param worldMatrix is the world matrix of the particle system
  94510. * @param directionToUpdate is the direction vector to update with the result
  94511. * @param particle is the particle we are computed the direction for
  94512. * @param isLocal defines if the direction should be set in local space
  94513. */
  94514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94515. /**
  94516. * Called by the particle System when the position is computed for the created particle.
  94517. * @param worldMatrix is the world matrix of the particle system
  94518. * @param positionToUpdate is the position vector to update with the result
  94519. * @param particle is the particle we are computed the position for
  94520. * @param isLocal defines if the position should be set in local space
  94521. */
  94522. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94523. /**
  94524. * Clones the current emitter and returns a copy of it
  94525. * @returns the new emitter
  94526. */
  94527. clone(): SphereParticleEmitter;
  94528. /**
  94529. * Called by the GPUParticleSystem to setup the update shader
  94530. * @param effect defines the update shader
  94531. */
  94532. applyToShader(effect: Effect): void;
  94533. /**
  94534. * Returns a string to use to update the GPU particles update shader
  94535. * @returns a string containng the defines string
  94536. */
  94537. getEffectDefines(): string;
  94538. /**
  94539. * Returns the string "SphereParticleEmitter"
  94540. * @returns a string containing the class name
  94541. */
  94542. getClassName(): string;
  94543. /**
  94544. * Serializes the particle system to a JSON object.
  94545. * @returns the JSON object
  94546. */
  94547. serialize(): any;
  94548. /**
  94549. * Parse properties from a JSON object
  94550. * @param serializationObject defines the JSON object
  94551. */
  94552. parse(serializationObject: any): void;
  94553. }
  94554. /**
  94555. * Particle emitter emitting particles from the inside of a sphere.
  94556. * It emits the particles randomly between two vectors.
  94557. */
  94558. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94559. /**
  94560. * The min limit of the emission direction.
  94561. */
  94562. direction1: Vector3;
  94563. /**
  94564. * The max limit of the emission direction.
  94565. */
  94566. direction2: Vector3;
  94567. /**
  94568. * Creates a new instance SphereDirectedParticleEmitter
  94569. * @param radius the radius of the emission sphere (1 by default)
  94570. * @param direction1 the min limit of the emission direction (up vector by default)
  94571. * @param direction2 the max limit of the emission direction (up vector by default)
  94572. */
  94573. constructor(radius?: number,
  94574. /**
  94575. * The min limit of the emission direction.
  94576. */
  94577. direction1?: Vector3,
  94578. /**
  94579. * The max limit of the emission direction.
  94580. */
  94581. direction2?: Vector3);
  94582. /**
  94583. * Called by the particle System when the direction is computed for the created particle.
  94584. * @param worldMatrix is the world matrix of the particle system
  94585. * @param directionToUpdate is the direction vector to update with the result
  94586. * @param particle is the particle we are computed the direction for
  94587. */
  94588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94589. /**
  94590. * Clones the current emitter and returns a copy of it
  94591. * @returns the new emitter
  94592. */
  94593. clone(): SphereDirectedParticleEmitter;
  94594. /**
  94595. * Called by the GPUParticleSystem to setup the update shader
  94596. * @param effect defines the update shader
  94597. */
  94598. applyToShader(effect: Effect): void;
  94599. /**
  94600. * Returns a string to use to update the GPU particles update shader
  94601. * @returns a string containng the defines string
  94602. */
  94603. getEffectDefines(): string;
  94604. /**
  94605. * Returns the string "SphereDirectedParticleEmitter"
  94606. * @returns a string containing the class name
  94607. */
  94608. getClassName(): string;
  94609. /**
  94610. * Serializes the particle system to a JSON object.
  94611. * @returns the JSON object
  94612. */
  94613. serialize(): any;
  94614. /**
  94615. * Parse properties from a JSON object
  94616. * @param serializationObject defines the JSON object
  94617. */
  94618. parse(serializationObject: any): void;
  94619. }
  94620. }
  94621. declare module BABYLON {
  94622. /**
  94623. * Particle emitter emitting particles from a custom list of positions.
  94624. */
  94625. export class CustomParticleEmitter implements IParticleEmitterType {
  94626. /**
  94627. * Gets or sets the position generator that will create the inital position of each particle.
  94628. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94629. */
  94630. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94631. /**
  94632. * Gets or sets the destination generator that will create the final destination of each particle.
  94633. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94634. */
  94635. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94636. /**
  94637. * Creates a new instance CustomParticleEmitter
  94638. */
  94639. constructor();
  94640. /**
  94641. * Called by the particle System when the direction is computed for the created particle.
  94642. * @param worldMatrix is the world matrix of the particle system
  94643. * @param directionToUpdate is the direction vector to update with the result
  94644. * @param particle is the particle we are computed the direction for
  94645. * @param isLocal defines if the direction should be set in local space
  94646. */
  94647. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94648. /**
  94649. * Called by the particle System when the position is computed for the created particle.
  94650. * @param worldMatrix is the world matrix of the particle system
  94651. * @param positionToUpdate is the position vector to update with the result
  94652. * @param particle is the particle we are computed the position for
  94653. * @param isLocal defines if the position should be set in local space
  94654. */
  94655. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94656. /**
  94657. * Clones the current emitter and returns a copy of it
  94658. * @returns the new emitter
  94659. */
  94660. clone(): CustomParticleEmitter;
  94661. /**
  94662. * Called by the GPUParticleSystem to setup the update shader
  94663. * @param effect defines the update shader
  94664. */
  94665. applyToShader(effect: Effect): void;
  94666. /**
  94667. * Returns a string to use to update the GPU particles update shader
  94668. * @returns a string containng the defines string
  94669. */
  94670. getEffectDefines(): string;
  94671. /**
  94672. * Returns the string "PointParticleEmitter"
  94673. * @returns a string containing the class name
  94674. */
  94675. getClassName(): string;
  94676. /**
  94677. * Serializes the particle system to a JSON object.
  94678. * @returns the JSON object
  94679. */
  94680. serialize(): any;
  94681. /**
  94682. * Parse properties from a JSON object
  94683. * @param serializationObject defines the JSON object
  94684. */
  94685. parse(serializationObject: any): void;
  94686. }
  94687. }
  94688. declare module BABYLON {
  94689. /**
  94690. * Particle emitter emitting particles from the inside of a box.
  94691. * It emits the particles randomly between 2 given directions.
  94692. */
  94693. export class MeshParticleEmitter implements IParticleEmitterType {
  94694. private _indices;
  94695. private _positions;
  94696. private _normals;
  94697. private _storedNormal;
  94698. private _mesh;
  94699. /**
  94700. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94701. */
  94702. direction1: Vector3;
  94703. /**
  94704. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94705. */
  94706. direction2: Vector3;
  94707. /**
  94708. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94709. */
  94710. useMeshNormalsForDirection: boolean;
  94711. /** Defines the mesh to use as source */
  94712. get mesh(): Nullable<AbstractMesh>;
  94713. set mesh(value: Nullable<AbstractMesh>);
  94714. /**
  94715. * Creates a new instance MeshParticleEmitter
  94716. * @param mesh defines the mesh to use as source
  94717. */
  94718. constructor(mesh?: Nullable<AbstractMesh>);
  94719. /**
  94720. * Called by the particle System when the direction is computed for the created particle.
  94721. * @param worldMatrix is the world matrix of the particle system
  94722. * @param directionToUpdate is the direction vector to update with the result
  94723. * @param particle is the particle we are computed the direction for
  94724. * @param isLocal defines if the direction should be set in local space
  94725. */
  94726. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94727. /**
  94728. * Called by the particle System when the position is computed for the created particle.
  94729. * @param worldMatrix is the world matrix of the particle system
  94730. * @param positionToUpdate is the position vector to update with the result
  94731. * @param particle is the particle we are computed the position for
  94732. * @param isLocal defines if the position should be set in local space
  94733. */
  94734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94735. /**
  94736. * Clones the current emitter and returns a copy of it
  94737. * @returns the new emitter
  94738. */
  94739. clone(): MeshParticleEmitter;
  94740. /**
  94741. * Called by the GPUParticleSystem to setup the update shader
  94742. * @param effect defines the update shader
  94743. */
  94744. applyToShader(effect: Effect): void;
  94745. /**
  94746. * Returns a string to use to update the GPU particles update shader
  94747. * @returns a string containng the defines string
  94748. */
  94749. getEffectDefines(): string;
  94750. /**
  94751. * Returns the string "BoxParticleEmitter"
  94752. * @returns a string containing the class name
  94753. */
  94754. getClassName(): string;
  94755. /**
  94756. * Serializes the particle system to a JSON object.
  94757. * @returns the JSON object
  94758. */
  94759. serialize(): any;
  94760. /**
  94761. * Parse properties from a JSON object
  94762. * @param serializationObject defines the JSON object
  94763. * @param scene defines the hosting scene
  94764. */
  94765. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94766. }
  94767. }
  94768. declare module BABYLON {
  94769. /**
  94770. * Interface representing a particle system in Babylon.js.
  94771. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94772. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94773. */
  94774. export interface IParticleSystem {
  94775. /**
  94776. * List of animations used by the particle system.
  94777. */
  94778. animations: Animation[];
  94779. /**
  94780. * The id of the Particle system.
  94781. */
  94782. id: string;
  94783. /**
  94784. * The name of the Particle system.
  94785. */
  94786. name: string;
  94787. /**
  94788. * The emitter represents the Mesh or position we are attaching the particle system to.
  94789. */
  94790. emitter: Nullable<AbstractMesh | Vector3>;
  94791. /**
  94792. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94793. */
  94794. isBillboardBased: boolean;
  94795. /**
  94796. * The rendering group used by the Particle system to chose when to render.
  94797. */
  94798. renderingGroupId: number;
  94799. /**
  94800. * The layer mask we are rendering the particles through.
  94801. */
  94802. layerMask: number;
  94803. /**
  94804. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94805. */
  94806. updateSpeed: number;
  94807. /**
  94808. * The amount of time the particle system is running (depends of the overall update speed).
  94809. */
  94810. targetStopDuration: number;
  94811. /**
  94812. * The texture used to render each particle. (this can be a spritesheet)
  94813. */
  94814. particleTexture: Nullable<BaseTexture>;
  94815. /**
  94816. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94817. */
  94818. blendMode: number;
  94819. /**
  94820. * Minimum life time of emitting particles.
  94821. */
  94822. minLifeTime: number;
  94823. /**
  94824. * Maximum life time of emitting particles.
  94825. */
  94826. maxLifeTime: number;
  94827. /**
  94828. * Minimum Size of emitting particles.
  94829. */
  94830. minSize: number;
  94831. /**
  94832. * Maximum Size of emitting particles.
  94833. */
  94834. maxSize: number;
  94835. /**
  94836. * Minimum scale of emitting particles on X axis.
  94837. */
  94838. minScaleX: number;
  94839. /**
  94840. * Maximum scale of emitting particles on X axis.
  94841. */
  94842. maxScaleX: number;
  94843. /**
  94844. * Minimum scale of emitting particles on Y axis.
  94845. */
  94846. minScaleY: number;
  94847. /**
  94848. * Maximum scale of emitting particles on Y axis.
  94849. */
  94850. maxScaleY: number;
  94851. /**
  94852. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94853. */
  94854. color1: Color4;
  94855. /**
  94856. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94857. */
  94858. color2: Color4;
  94859. /**
  94860. * Color the particle will have at the end of its lifetime.
  94861. */
  94862. colorDead: Color4;
  94863. /**
  94864. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94865. */
  94866. emitRate: number;
  94867. /**
  94868. * You can use gravity if you want to give an orientation to your particles.
  94869. */
  94870. gravity: Vector3;
  94871. /**
  94872. * Minimum power of emitting particles.
  94873. */
  94874. minEmitPower: number;
  94875. /**
  94876. * Maximum power of emitting particles.
  94877. */
  94878. maxEmitPower: number;
  94879. /**
  94880. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94881. */
  94882. minAngularSpeed: number;
  94883. /**
  94884. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94885. */
  94886. maxAngularSpeed: number;
  94887. /**
  94888. * Gets or sets the minimal initial rotation in radians.
  94889. */
  94890. minInitialRotation: number;
  94891. /**
  94892. * Gets or sets the maximal initial rotation in radians.
  94893. */
  94894. maxInitialRotation: number;
  94895. /**
  94896. * The particle emitter type defines the emitter used by the particle system.
  94897. * It can be for example box, sphere, or cone...
  94898. */
  94899. particleEmitterType: Nullable<IParticleEmitterType>;
  94900. /**
  94901. * Defines the delay in milliseconds before starting the system (0 by default)
  94902. */
  94903. startDelay: number;
  94904. /**
  94905. * 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
  94906. */
  94907. preWarmCycles: number;
  94908. /**
  94909. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94910. */
  94911. preWarmStepOffset: number;
  94912. /**
  94913. * 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)
  94914. */
  94915. spriteCellChangeSpeed: number;
  94916. /**
  94917. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94918. */
  94919. startSpriteCellID: number;
  94920. /**
  94921. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94922. */
  94923. endSpriteCellID: number;
  94924. /**
  94925. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94926. */
  94927. spriteCellWidth: number;
  94928. /**
  94929. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94930. */
  94931. spriteCellHeight: number;
  94932. /**
  94933. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94934. */
  94935. spriteRandomStartCell: boolean;
  94936. /**
  94937. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94938. */
  94939. isAnimationSheetEnabled: boolean;
  94940. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94941. translationPivot: Vector2;
  94942. /**
  94943. * Gets or sets a texture used to add random noise to particle positions
  94944. */
  94945. noiseTexture: Nullable<BaseTexture>;
  94946. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94947. noiseStrength: Vector3;
  94948. /**
  94949. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94950. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94951. */
  94952. billboardMode: number;
  94953. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94954. limitVelocityDamping: number;
  94955. /**
  94956. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94957. */
  94958. beginAnimationOnStart: boolean;
  94959. /**
  94960. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94961. */
  94962. beginAnimationFrom: number;
  94963. /**
  94964. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94965. */
  94966. beginAnimationTo: number;
  94967. /**
  94968. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94969. */
  94970. beginAnimationLoop: boolean;
  94971. /**
  94972. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94973. */
  94974. disposeOnStop: boolean;
  94975. /**
  94976. * Specifies if the particles are updated in emitter local space or world space
  94977. */
  94978. isLocal: boolean;
  94979. /** Snippet ID if the particle system was created from the snippet server */
  94980. snippetId: string;
  94981. /** Gets or sets a matrix to use to compute projection */
  94982. defaultProjectionMatrix: Matrix;
  94983. /**
  94984. * Gets the maximum number of particles active at the same time.
  94985. * @returns The max number of active particles.
  94986. */
  94987. getCapacity(): number;
  94988. /**
  94989. * Gets the number of particles active at the same time.
  94990. * @returns The number of active particles.
  94991. */
  94992. getActiveCount(): number;
  94993. /**
  94994. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94995. * @returns True if it has been started, otherwise false.
  94996. */
  94997. isStarted(): boolean;
  94998. /**
  94999. * Animates the particle system for this frame.
  95000. */
  95001. animate(): void;
  95002. /**
  95003. * Renders the particle system in its current state.
  95004. * @returns the current number of particles
  95005. */
  95006. render(): number;
  95007. /**
  95008. * Dispose the particle system and frees its associated resources.
  95009. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  95010. */
  95011. dispose(disposeTexture?: boolean): void;
  95012. /**
  95013. * An event triggered when the system is disposed
  95014. */
  95015. onDisposeObservable: Observable<IParticleSystem>;
  95016. /**
  95017. * An event triggered when the system is stopped
  95018. */
  95019. onStoppedObservable: Observable<IParticleSystem>;
  95020. /**
  95021. * Clones the particle system.
  95022. * @param name The name of the cloned object
  95023. * @param newEmitter The new emitter to use
  95024. * @returns the cloned particle system
  95025. */
  95026. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  95027. /**
  95028. * Serializes the particle system to a JSON object
  95029. * @param serializeTexture defines if the texture must be serialized as well
  95030. * @returns the JSON object
  95031. */
  95032. serialize(serializeTexture: boolean): any;
  95033. /**
  95034. * Rebuild the particle system
  95035. */
  95036. rebuild(): void;
  95037. /** Force the system to rebuild all gradients that need to be resync */
  95038. forceRefreshGradients(): void;
  95039. /**
  95040. * Starts the particle system and begins to emit
  95041. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  95042. */
  95043. start(delay?: number): void;
  95044. /**
  95045. * Stops the particle system.
  95046. */
  95047. stop(): void;
  95048. /**
  95049. * Remove all active particles
  95050. */
  95051. reset(): void;
  95052. /**
  95053. * Gets a boolean indicating that the system is stopping
  95054. * @returns true if the system is currently stopping
  95055. */
  95056. isStopping(): boolean;
  95057. /**
  95058. * Is this system ready to be used/rendered
  95059. * @return true if the system is ready
  95060. */
  95061. isReady(): boolean;
  95062. /**
  95063. * Returns the string "ParticleSystem"
  95064. * @returns a string containing the class name
  95065. */
  95066. getClassName(): string;
  95067. /**
  95068. * Gets the custom effect used to render the particles
  95069. * @param blendMode Blend mode for which the effect should be retrieved
  95070. * @returns The effect
  95071. */
  95072. getCustomEffect(blendMode: number): Nullable<Effect>;
  95073. /**
  95074. * Sets the custom effect used to render the particles
  95075. * @param effect The effect to set
  95076. * @param blendMode Blend mode for which the effect should be set
  95077. */
  95078. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  95079. /**
  95080. * Fill the defines array according to the current settings of the particle system
  95081. * @param defines Array to be updated
  95082. * @param blendMode blend mode to take into account when updating the array
  95083. */
  95084. fillDefines(defines: Array<string>, blendMode: number): void;
  95085. /**
  95086. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  95087. * @param uniforms Uniforms array to fill
  95088. * @param attributes Attributes array to fill
  95089. * @param samplers Samplers array to fill
  95090. */
  95091. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95092. /**
  95093. * Observable that will be called just before the particles are drawn
  95094. */
  95095. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95096. /**
  95097. * Gets the name of the particle vertex shader
  95098. */
  95099. vertexShaderName: string;
  95100. /**
  95101. * Adds a new color gradient
  95102. * @param gradient defines the gradient to use (between 0 and 1)
  95103. * @param color1 defines the color to affect to the specified gradient
  95104. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95105. * @returns the current particle system
  95106. */
  95107. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95108. /**
  95109. * Remove a specific color gradient
  95110. * @param gradient defines the gradient to remove
  95111. * @returns the current particle system
  95112. */
  95113. removeColorGradient(gradient: number): IParticleSystem;
  95114. /**
  95115. * Adds a new size gradient
  95116. * @param gradient defines the gradient to use (between 0 and 1)
  95117. * @param factor defines the size factor to affect to the specified gradient
  95118. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95119. * @returns the current particle system
  95120. */
  95121. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95122. /**
  95123. * Remove a specific size gradient
  95124. * @param gradient defines the gradient to remove
  95125. * @returns the current particle system
  95126. */
  95127. removeSizeGradient(gradient: number): IParticleSystem;
  95128. /**
  95129. * Gets the current list of color gradients.
  95130. * You must use addColorGradient and removeColorGradient to udpate this list
  95131. * @returns the list of color gradients
  95132. */
  95133. getColorGradients(): Nullable<Array<ColorGradient>>;
  95134. /**
  95135. * Gets the current list of size gradients.
  95136. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95137. * @returns the list of size gradients
  95138. */
  95139. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95140. /**
  95141. * Gets the current list of angular speed gradients.
  95142. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95143. * @returns the list of angular speed gradients
  95144. */
  95145. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95146. /**
  95147. * Adds a new angular speed gradient
  95148. * @param gradient defines the gradient to use (between 0 and 1)
  95149. * @param factor defines the angular speed to affect to the specified gradient
  95150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95151. * @returns the current particle system
  95152. */
  95153. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95154. /**
  95155. * Remove a specific angular speed gradient
  95156. * @param gradient defines the gradient to remove
  95157. * @returns the current particle system
  95158. */
  95159. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95160. /**
  95161. * Gets the current list of velocity gradients.
  95162. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95163. * @returns the list of velocity gradients
  95164. */
  95165. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95166. /**
  95167. * Adds a new velocity gradient
  95168. * @param gradient defines the gradient to use (between 0 and 1)
  95169. * @param factor defines the velocity to affect to the specified gradient
  95170. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95171. * @returns the current particle system
  95172. */
  95173. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95174. /**
  95175. * Remove a specific velocity gradient
  95176. * @param gradient defines the gradient to remove
  95177. * @returns the current particle system
  95178. */
  95179. removeVelocityGradient(gradient: number): IParticleSystem;
  95180. /**
  95181. * Gets the current list of limit velocity gradients.
  95182. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95183. * @returns the list of limit velocity gradients
  95184. */
  95185. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95186. /**
  95187. * Adds a new limit velocity gradient
  95188. * @param gradient defines the gradient to use (between 0 and 1)
  95189. * @param factor defines the limit velocity to affect to the specified gradient
  95190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95191. * @returns the current particle system
  95192. */
  95193. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95194. /**
  95195. * Remove a specific limit velocity gradient
  95196. * @param gradient defines the gradient to remove
  95197. * @returns the current particle system
  95198. */
  95199. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95200. /**
  95201. * Adds a new drag gradient
  95202. * @param gradient defines the gradient to use (between 0 and 1)
  95203. * @param factor defines the drag to affect to the specified gradient
  95204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95205. * @returns the current particle system
  95206. */
  95207. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95208. /**
  95209. * Remove a specific drag gradient
  95210. * @param gradient defines the gradient to remove
  95211. * @returns the current particle system
  95212. */
  95213. removeDragGradient(gradient: number): IParticleSystem;
  95214. /**
  95215. * Gets the current list of drag gradients.
  95216. * You must use addDragGradient and removeDragGradient to udpate this list
  95217. * @returns the list of drag gradients
  95218. */
  95219. getDragGradients(): Nullable<Array<FactorGradient>>;
  95220. /**
  95221. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95222. * @param gradient defines the gradient to use (between 0 and 1)
  95223. * @param factor defines the emit rate to affect to the specified gradient
  95224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95225. * @returns the current particle system
  95226. */
  95227. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95228. /**
  95229. * Remove a specific emit rate gradient
  95230. * @param gradient defines the gradient to remove
  95231. * @returns the current particle system
  95232. */
  95233. removeEmitRateGradient(gradient: number): IParticleSystem;
  95234. /**
  95235. * Gets the current list of emit rate gradients.
  95236. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95237. * @returns the list of emit rate gradients
  95238. */
  95239. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95240. /**
  95241. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95242. * @param gradient defines the gradient to use (between 0 and 1)
  95243. * @param factor defines the start size to affect to the specified gradient
  95244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95245. * @returns the current particle system
  95246. */
  95247. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95248. /**
  95249. * Remove a specific start size gradient
  95250. * @param gradient defines the gradient to remove
  95251. * @returns the current particle system
  95252. */
  95253. removeStartSizeGradient(gradient: number): IParticleSystem;
  95254. /**
  95255. * Gets the current list of start size gradients.
  95256. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95257. * @returns the list of start size gradients
  95258. */
  95259. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95260. /**
  95261. * Adds a new life time gradient
  95262. * @param gradient defines the gradient to use (between 0 and 1)
  95263. * @param factor defines the life time factor to affect to the specified gradient
  95264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95265. * @returns the current particle system
  95266. */
  95267. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95268. /**
  95269. * Remove a specific life time gradient
  95270. * @param gradient defines the gradient to remove
  95271. * @returns the current particle system
  95272. */
  95273. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95274. /**
  95275. * Gets the current list of life time gradients.
  95276. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95277. * @returns the list of life time gradients
  95278. */
  95279. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95280. /**
  95281. * Gets the current list of color gradients.
  95282. * You must use addColorGradient and removeColorGradient to udpate this list
  95283. * @returns the list of color gradients
  95284. */
  95285. getColorGradients(): Nullable<Array<ColorGradient>>;
  95286. /**
  95287. * Adds a new ramp gradient used to remap particle colors
  95288. * @param gradient defines the gradient to use (between 0 and 1)
  95289. * @param color defines the color to affect to the specified gradient
  95290. * @returns the current particle system
  95291. */
  95292. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95293. /**
  95294. * Gets the current list of ramp gradients.
  95295. * You must use addRampGradient and removeRampGradient to udpate this list
  95296. * @returns the list of ramp gradients
  95297. */
  95298. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95299. /** Gets or sets a boolean indicating that ramp gradients must be used
  95300. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95301. */
  95302. useRampGradients: boolean;
  95303. /**
  95304. * Adds a new color remap gradient
  95305. * @param gradient defines the gradient to use (between 0 and 1)
  95306. * @param min defines the color remap minimal range
  95307. * @param max defines the color remap maximal range
  95308. * @returns the current particle system
  95309. */
  95310. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95311. /**
  95312. * Gets the current list of color remap gradients.
  95313. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95314. * @returns the list of color remap gradients
  95315. */
  95316. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95317. /**
  95318. * Adds a new alpha remap gradient
  95319. * @param gradient defines the gradient to use (between 0 and 1)
  95320. * @param min defines the alpha remap minimal range
  95321. * @param max defines the alpha remap maximal range
  95322. * @returns the current particle system
  95323. */
  95324. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95325. /**
  95326. * Gets the current list of alpha remap gradients.
  95327. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95328. * @returns the list of alpha remap gradients
  95329. */
  95330. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95331. /**
  95332. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95333. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95334. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95335. * @returns the emitter
  95336. */
  95337. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95338. /**
  95339. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95340. * @param radius The radius of the hemisphere to emit from
  95341. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95342. * @returns the emitter
  95343. */
  95344. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95345. /**
  95346. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95347. * @param radius The radius of the sphere to emit from
  95348. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95349. * @returns the emitter
  95350. */
  95351. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95352. /**
  95353. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95354. * @param radius The radius of the sphere to emit from
  95355. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95356. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95357. * @returns the emitter
  95358. */
  95359. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95360. /**
  95361. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95362. * @param radius The radius of the emission cylinder
  95363. * @param height The height of the emission cylinder
  95364. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95365. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95366. * @returns the emitter
  95367. */
  95368. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95369. /**
  95370. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95371. * @param radius The radius of the cylinder to emit from
  95372. * @param height The height of the emission cylinder
  95373. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95374. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95375. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95376. * @returns the emitter
  95377. */
  95378. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95379. /**
  95380. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95381. * @param radius The radius of the cone to emit from
  95382. * @param angle The base angle of the cone
  95383. * @returns the emitter
  95384. */
  95385. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95386. /**
  95387. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95388. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95389. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95390. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95391. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95392. * @returns the emitter
  95393. */
  95394. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95395. /**
  95396. * Get hosting scene
  95397. * @returns the scene
  95398. */
  95399. getScene(): Nullable<Scene>;
  95400. }
  95401. }
  95402. declare module BABYLON {
  95403. /**
  95404. * 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.
  95405. * @see https://doc.babylonjs.com/how_to/transformnode
  95406. */
  95407. export class TransformNode extends Node {
  95408. /**
  95409. * Object will not rotate to face the camera
  95410. */
  95411. static BILLBOARDMODE_NONE: number;
  95412. /**
  95413. * Object will rotate to face the camera but only on the x axis
  95414. */
  95415. static BILLBOARDMODE_X: number;
  95416. /**
  95417. * Object will rotate to face the camera but only on the y axis
  95418. */
  95419. static BILLBOARDMODE_Y: number;
  95420. /**
  95421. * Object will rotate to face the camera but only on the z axis
  95422. */
  95423. static BILLBOARDMODE_Z: number;
  95424. /**
  95425. * Object will rotate to face the camera
  95426. */
  95427. static BILLBOARDMODE_ALL: number;
  95428. /**
  95429. * Object will rotate to face the camera's position instead of orientation
  95430. */
  95431. static BILLBOARDMODE_USE_POSITION: number;
  95432. private static _TmpRotation;
  95433. private static _TmpScaling;
  95434. private static _TmpTranslation;
  95435. private _forward;
  95436. private _forwardInverted;
  95437. private _up;
  95438. private _right;
  95439. private _rightInverted;
  95440. private _position;
  95441. private _rotation;
  95442. private _rotationQuaternion;
  95443. protected _scaling: Vector3;
  95444. protected _isDirty: boolean;
  95445. private _transformToBoneReferal;
  95446. private _isAbsoluteSynced;
  95447. private _billboardMode;
  95448. /**
  95449. * Gets or sets the billboard mode. Default is 0.
  95450. *
  95451. * | Value | Type | Description |
  95452. * | --- | --- | --- |
  95453. * | 0 | BILLBOARDMODE_NONE | |
  95454. * | 1 | BILLBOARDMODE_X | |
  95455. * | 2 | BILLBOARDMODE_Y | |
  95456. * | 4 | BILLBOARDMODE_Z | |
  95457. * | 7 | BILLBOARDMODE_ALL | |
  95458. *
  95459. */
  95460. get billboardMode(): number;
  95461. set billboardMode(value: number);
  95462. private _preserveParentRotationForBillboard;
  95463. /**
  95464. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95465. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95466. */
  95467. get preserveParentRotationForBillboard(): boolean;
  95468. set preserveParentRotationForBillboard(value: boolean);
  95469. /**
  95470. * 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
  95471. */
  95472. scalingDeterminant: number;
  95473. private _infiniteDistance;
  95474. /**
  95475. * Gets or sets the distance of the object to max, often used by skybox
  95476. */
  95477. get infiniteDistance(): boolean;
  95478. set infiniteDistance(value: boolean);
  95479. /**
  95480. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95481. * By default the system will update normals to compensate
  95482. */
  95483. ignoreNonUniformScaling: boolean;
  95484. /**
  95485. * 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
  95486. */
  95487. reIntegrateRotationIntoRotationQuaternion: boolean;
  95488. /** @hidden */
  95489. _poseMatrix: Nullable<Matrix>;
  95490. /** @hidden */
  95491. _localMatrix: Matrix;
  95492. private _usePivotMatrix;
  95493. private _absolutePosition;
  95494. private _absoluteScaling;
  95495. private _absoluteRotationQuaternion;
  95496. private _pivotMatrix;
  95497. private _pivotMatrixInverse;
  95498. /** @hidden */
  95499. _postMultiplyPivotMatrix: boolean;
  95500. protected _isWorldMatrixFrozen: boolean;
  95501. /** @hidden */
  95502. _indexInSceneTransformNodesArray: number;
  95503. /**
  95504. * An event triggered after the world matrix is updated
  95505. */
  95506. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95507. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95508. /**
  95509. * Gets a string identifying the name of the class
  95510. * @returns "TransformNode" string
  95511. */
  95512. getClassName(): string;
  95513. /**
  95514. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95515. */
  95516. get position(): Vector3;
  95517. set position(newPosition: Vector3);
  95518. /**
  95519. * 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)).
  95520. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95521. */
  95522. get rotation(): Vector3;
  95523. set rotation(newRotation: Vector3);
  95524. /**
  95525. * 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)).
  95526. */
  95527. get scaling(): Vector3;
  95528. set scaling(newScaling: Vector3);
  95529. /**
  95530. * 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).
  95531. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95532. */
  95533. get rotationQuaternion(): Nullable<Quaternion>;
  95534. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95535. /**
  95536. * The forward direction of that transform in world space.
  95537. */
  95538. get forward(): Vector3;
  95539. /**
  95540. * The up direction of that transform in world space.
  95541. */
  95542. get up(): Vector3;
  95543. /**
  95544. * The right direction of that transform in world space.
  95545. */
  95546. get right(): Vector3;
  95547. /**
  95548. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95549. * @param matrix the matrix to copy the pose from
  95550. * @returns this TransformNode.
  95551. */
  95552. updatePoseMatrix(matrix: Matrix): TransformNode;
  95553. /**
  95554. * Returns the mesh Pose matrix.
  95555. * @returns the pose matrix
  95556. */
  95557. getPoseMatrix(): Matrix;
  95558. /** @hidden */
  95559. _isSynchronized(): boolean;
  95560. /** @hidden */
  95561. _initCache(): void;
  95562. /**
  95563. * Flag the transform node as dirty (Forcing it to update everything)
  95564. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95565. * @returns this transform node
  95566. */
  95567. markAsDirty(property: string): TransformNode;
  95568. /**
  95569. * Returns the current mesh absolute position.
  95570. * Returns a Vector3.
  95571. */
  95572. get absolutePosition(): Vector3;
  95573. /**
  95574. * Returns the current mesh absolute scaling.
  95575. * Returns a Vector3.
  95576. */
  95577. get absoluteScaling(): Vector3;
  95578. /**
  95579. * Returns the current mesh absolute rotation.
  95580. * Returns a Quaternion.
  95581. */
  95582. get absoluteRotationQuaternion(): Quaternion;
  95583. /**
  95584. * Sets a new matrix to apply before all other transformation
  95585. * @param matrix defines the transform matrix
  95586. * @returns the current TransformNode
  95587. */
  95588. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95589. /**
  95590. * Sets a new pivot matrix to the current node
  95591. * @param matrix defines the new pivot matrix to use
  95592. * @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
  95593. * @returns the current TransformNode
  95594. */
  95595. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95596. /**
  95597. * Returns the mesh pivot matrix.
  95598. * Default : Identity.
  95599. * @returns the matrix
  95600. */
  95601. getPivotMatrix(): Matrix;
  95602. /**
  95603. * Instantiate (when possible) or clone that node with its hierarchy
  95604. * @param newParent defines the new parent to use for the instance (or clone)
  95605. * @param options defines options to configure how copy is done
  95606. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95607. * @returns an instance (or a clone) of the current node with its hiearchy
  95608. */
  95609. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95610. doNotInstantiate: boolean;
  95611. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95612. /**
  95613. * Prevents the World matrix to be computed any longer
  95614. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95615. * @returns the TransformNode.
  95616. */
  95617. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95618. /**
  95619. * Allows back the World matrix computation.
  95620. * @returns the TransformNode.
  95621. */
  95622. unfreezeWorldMatrix(): this;
  95623. /**
  95624. * True if the World matrix has been frozen.
  95625. */
  95626. get isWorldMatrixFrozen(): boolean;
  95627. /**
  95628. * Retuns the mesh absolute position in the World.
  95629. * @returns a Vector3.
  95630. */
  95631. getAbsolutePosition(): Vector3;
  95632. /**
  95633. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95634. * @param absolutePosition the absolute position to set
  95635. * @returns the TransformNode.
  95636. */
  95637. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95638. /**
  95639. * Sets the mesh position in its local space.
  95640. * @param vector3 the position to set in localspace
  95641. * @returns the TransformNode.
  95642. */
  95643. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95644. /**
  95645. * Returns the mesh position in the local space from the current World matrix values.
  95646. * @returns a new Vector3.
  95647. */
  95648. getPositionExpressedInLocalSpace(): Vector3;
  95649. /**
  95650. * Translates the mesh along the passed Vector3 in its local space.
  95651. * @param vector3 the distance to translate in localspace
  95652. * @returns the TransformNode.
  95653. */
  95654. locallyTranslate(vector3: Vector3): TransformNode;
  95655. private static _lookAtVectorCache;
  95656. /**
  95657. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95658. * @param targetPoint the position (must be in same space as current mesh) to look at
  95659. * @param yawCor optional yaw (y-axis) correction in radians
  95660. * @param pitchCor optional pitch (x-axis) correction in radians
  95661. * @param rollCor optional roll (z-axis) correction in radians
  95662. * @param space the choosen space of the target
  95663. * @returns the TransformNode.
  95664. */
  95665. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95666. /**
  95667. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95668. * This Vector3 is expressed in the World space.
  95669. * @param localAxis axis to rotate
  95670. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95671. */
  95672. getDirection(localAxis: Vector3): Vector3;
  95673. /**
  95674. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95675. * localAxis is expressed in the mesh local space.
  95676. * result is computed in the Wordl space from the mesh World matrix.
  95677. * @param localAxis axis to rotate
  95678. * @param result the resulting transformnode
  95679. * @returns this TransformNode.
  95680. */
  95681. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95682. /**
  95683. * Sets this transform node rotation to the given local axis.
  95684. * @param localAxis the axis in local space
  95685. * @param yawCor optional yaw (y-axis) correction in radians
  95686. * @param pitchCor optional pitch (x-axis) correction in radians
  95687. * @param rollCor optional roll (z-axis) correction in radians
  95688. * @returns this TransformNode
  95689. */
  95690. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95691. /**
  95692. * Sets a new pivot point to the current node
  95693. * @param point defines the new pivot point to use
  95694. * @param space defines if the point is in world or local space (local by default)
  95695. * @returns the current TransformNode
  95696. */
  95697. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95698. /**
  95699. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95700. * @returns the pivot point
  95701. */
  95702. getPivotPoint(): Vector3;
  95703. /**
  95704. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95705. * @param result the vector3 to store the result
  95706. * @returns this TransformNode.
  95707. */
  95708. getPivotPointToRef(result: Vector3): TransformNode;
  95709. /**
  95710. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95711. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95712. */
  95713. getAbsolutePivotPoint(): Vector3;
  95714. /**
  95715. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95716. * @param result vector3 to store the result
  95717. * @returns this TransformNode.
  95718. */
  95719. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95720. /**
  95721. * Defines the passed node as the parent of the current node.
  95722. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95723. * @see https://doc.babylonjs.com/how_to/parenting
  95724. * @param node the node ot set as the parent
  95725. * @returns this TransformNode.
  95726. */
  95727. setParent(node: Nullable<Node>): TransformNode;
  95728. private _nonUniformScaling;
  95729. /**
  95730. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95731. */
  95732. get nonUniformScaling(): boolean;
  95733. /** @hidden */
  95734. _updateNonUniformScalingState(value: boolean): boolean;
  95735. /**
  95736. * Attach the current TransformNode to another TransformNode associated with a bone
  95737. * @param bone Bone affecting the TransformNode
  95738. * @param affectedTransformNode TransformNode associated with the bone
  95739. * @returns this object
  95740. */
  95741. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95742. /**
  95743. * Detach the transform node if its associated with a bone
  95744. * @returns this object
  95745. */
  95746. detachFromBone(): TransformNode;
  95747. private static _rotationAxisCache;
  95748. /**
  95749. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95750. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95751. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95752. * The passed axis is also normalized.
  95753. * @param axis the axis to rotate around
  95754. * @param amount the amount to rotate in radians
  95755. * @param space Space to rotate in (Default: local)
  95756. * @returns the TransformNode.
  95757. */
  95758. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95759. /**
  95760. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95761. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95762. * The passed axis is also normalized. .
  95763. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95764. * @param point the point to rotate around
  95765. * @param axis the axis to rotate around
  95766. * @param amount the amount to rotate in radians
  95767. * @returns the TransformNode
  95768. */
  95769. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95770. /**
  95771. * Translates the mesh along the axis vector for the passed distance in the given space.
  95772. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95773. * @param axis the axis to translate in
  95774. * @param distance the distance to translate
  95775. * @param space Space to rotate in (Default: local)
  95776. * @returns the TransformNode.
  95777. */
  95778. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95779. /**
  95780. * Adds a rotation step to the mesh current rotation.
  95781. * x, y, z are Euler angles expressed in radians.
  95782. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95783. * This means this rotation is made in the mesh local space only.
  95784. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95785. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95786. * ```javascript
  95787. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95788. * ```
  95789. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95790. * 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.
  95791. * @param x Rotation to add
  95792. * @param y Rotation to add
  95793. * @param z Rotation to add
  95794. * @returns the TransformNode.
  95795. */
  95796. addRotation(x: number, y: number, z: number): TransformNode;
  95797. /**
  95798. * @hidden
  95799. */
  95800. protected _getEffectiveParent(): Nullable<Node>;
  95801. /**
  95802. * Computes the world matrix of the node
  95803. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95804. * @returns the world matrix
  95805. */
  95806. computeWorldMatrix(force?: boolean): Matrix;
  95807. /**
  95808. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95809. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95810. */
  95811. resetLocalMatrix(independentOfChildren?: boolean): void;
  95812. protected _afterComputeWorldMatrix(): void;
  95813. /**
  95814. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95815. * @param func callback function to add
  95816. *
  95817. * @returns the TransformNode.
  95818. */
  95819. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95820. /**
  95821. * Removes a registered callback function.
  95822. * @param func callback function to remove
  95823. * @returns the TransformNode.
  95824. */
  95825. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95826. /**
  95827. * Gets the position of the current mesh in camera space
  95828. * @param camera defines the camera to use
  95829. * @returns a position
  95830. */
  95831. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95832. /**
  95833. * Returns the distance from the mesh to the active camera
  95834. * @param camera defines the camera to use
  95835. * @returns the distance
  95836. */
  95837. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95838. /**
  95839. * Clone the current transform node
  95840. * @param name Name of the new clone
  95841. * @param newParent New parent for the clone
  95842. * @param doNotCloneChildren Do not clone children hierarchy
  95843. * @returns the new transform node
  95844. */
  95845. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95846. /**
  95847. * Serializes the objects information.
  95848. * @param currentSerializationObject defines the object to serialize in
  95849. * @returns the serialized object
  95850. */
  95851. serialize(currentSerializationObject?: any): any;
  95852. /**
  95853. * Returns a new TransformNode object parsed from the source provided.
  95854. * @param parsedTransformNode is the source.
  95855. * @param scene the scne the object belongs to
  95856. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95857. * @returns a new TransformNode object parsed from the source provided.
  95858. */
  95859. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95860. /**
  95861. * Get all child-transformNodes of this node
  95862. * @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
  95863. * @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
  95864. * @returns an array of TransformNode
  95865. */
  95866. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95867. /**
  95868. * Releases resources associated with this transform node.
  95869. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95870. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95871. */
  95872. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95873. /**
  95874. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95875. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95876. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95877. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95878. * @returns the current mesh
  95879. */
  95880. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95881. private _syncAbsoluteScalingAndRotation;
  95882. }
  95883. }
  95884. declare module BABYLON {
  95885. /**
  95886. * Class used to override all child animations of a given target
  95887. */
  95888. export class AnimationPropertiesOverride {
  95889. /**
  95890. * Gets or sets a value indicating if animation blending must be used
  95891. */
  95892. enableBlending: boolean;
  95893. /**
  95894. * Gets or sets the blending speed to use when enableBlending is true
  95895. */
  95896. blendingSpeed: number;
  95897. /**
  95898. * Gets or sets the default loop mode to use
  95899. */
  95900. loopMode: number;
  95901. }
  95902. }
  95903. declare module BABYLON {
  95904. /**
  95905. * Class used to store bone information
  95906. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95907. */
  95908. export class Bone extends Node {
  95909. /**
  95910. * defines the bone name
  95911. */
  95912. name: string;
  95913. private static _tmpVecs;
  95914. private static _tmpQuat;
  95915. private static _tmpMats;
  95916. /**
  95917. * Gets the list of child bones
  95918. */
  95919. children: Bone[];
  95920. /** Gets the animations associated with this bone */
  95921. animations: Animation[];
  95922. /**
  95923. * Gets or sets bone length
  95924. */
  95925. length: number;
  95926. /**
  95927. * @hidden Internal only
  95928. * Set this value to map this bone to a different index in the transform matrices
  95929. * Set this value to -1 to exclude the bone from the transform matrices
  95930. */
  95931. _index: Nullable<number>;
  95932. private _skeleton;
  95933. private _localMatrix;
  95934. private _restPose;
  95935. private _bindPose;
  95936. private _baseMatrix;
  95937. private _absoluteTransform;
  95938. private _invertedAbsoluteTransform;
  95939. private _parent;
  95940. private _scalingDeterminant;
  95941. private _worldTransform;
  95942. private _localScaling;
  95943. private _localRotation;
  95944. private _localPosition;
  95945. private _needToDecompose;
  95946. private _needToCompose;
  95947. /** @hidden */
  95948. _linkedTransformNode: Nullable<TransformNode>;
  95949. /** @hidden */
  95950. _waitingTransformNodeId: Nullable<string>;
  95951. /** @hidden */
  95952. get _matrix(): Matrix;
  95953. /** @hidden */
  95954. set _matrix(value: Matrix);
  95955. /**
  95956. * Create a new bone
  95957. * @param name defines the bone name
  95958. * @param skeleton defines the parent skeleton
  95959. * @param parentBone defines the parent (can be null if the bone is the root)
  95960. * @param localMatrix defines the local matrix
  95961. * @param restPose defines the rest pose matrix
  95962. * @param baseMatrix defines the base matrix
  95963. * @param index defines index of the bone in the hiearchy
  95964. */
  95965. constructor(
  95966. /**
  95967. * defines the bone name
  95968. */
  95969. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95970. /**
  95971. * Gets the current object class name.
  95972. * @return the class name
  95973. */
  95974. getClassName(): string;
  95975. /**
  95976. * Gets the parent skeleton
  95977. * @returns a skeleton
  95978. */
  95979. getSkeleton(): Skeleton;
  95980. /**
  95981. * Gets parent bone
  95982. * @returns a bone or null if the bone is the root of the bone hierarchy
  95983. */
  95984. getParent(): Nullable<Bone>;
  95985. /**
  95986. * Returns an array containing the root bones
  95987. * @returns an array containing the root bones
  95988. */
  95989. getChildren(): Array<Bone>;
  95990. /**
  95991. * Gets the node index in matrix array generated for rendering
  95992. * @returns the node index
  95993. */
  95994. getIndex(): number;
  95995. /**
  95996. * Sets the parent bone
  95997. * @param parent defines the parent (can be null if the bone is the root)
  95998. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95999. */
  96000. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  96001. /**
  96002. * Gets the local matrix
  96003. * @returns a matrix
  96004. */
  96005. getLocalMatrix(): Matrix;
  96006. /**
  96007. * Gets the base matrix (initial matrix which remains unchanged)
  96008. * @returns a matrix
  96009. */
  96010. getBaseMatrix(): Matrix;
  96011. /**
  96012. * Gets the rest pose matrix
  96013. * @returns a matrix
  96014. */
  96015. getRestPose(): Matrix;
  96016. /**
  96017. * Sets the rest pose matrix
  96018. * @param matrix the local-space rest pose to set for this bone
  96019. */
  96020. setRestPose(matrix: Matrix): void;
  96021. /**
  96022. * Gets the bind pose matrix
  96023. * @returns the bind pose matrix
  96024. */
  96025. getBindPose(): Matrix;
  96026. /**
  96027. * Sets the bind pose matrix
  96028. * @param matrix the local-space bind pose to set for this bone
  96029. */
  96030. setBindPose(matrix: Matrix): void;
  96031. /**
  96032. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  96033. */
  96034. getWorldMatrix(): Matrix;
  96035. /**
  96036. * Sets the local matrix to rest pose matrix
  96037. */
  96038. returnToRest(): void;
  96039. /**
  96040. * Gets the inverse of the absolute transform matrix.
  96041. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  96042. * @returns a matrix
  96043. */
  96044. getInvertedAbsoluteTransform(): Matrix;
  96045. /**
  96046. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  96047. * @returns a matrix
  96048. */
  96049. getAbsoluteTransform(): Matrix;
  96050. /**
  96051. * Links with the given transform node.
  96052. * The local matrix of this bone is copied from the transform node every frame.
  96053. * @param transformNode defines the transform node to link to
  96054. */
  96055. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  96056. /**
  96057. * Gets the node used to drive the bone's transformation
  96058. * @returns a transform node or null
  96059. */
  96060. getTransformNode(): Nullable<TransformNode>;
  96061. /** Gets or sets current position (in local space) */
  96062. get position(): Vector3;
  96063. set position(newPosition: Vector3);
  96064. /** Gets or sets current rotation (in local space) */
  96065. get rotation(): Vector3;
  96066. set rotation(newRotation: Vector3);
  96067. /** Gets or sets current rotation quaternion (in local space) */
  96068. get rotationQuaternion(): Quaternion;
  96069. set rotationQuaternion(newRotation: Quaternion);
  96070. /** Gets or sets current scaling (in local space) */
  96071. get scaling(): Vector3;
  96072. set scaling(newScaling: Vector3);
  96073. /**
  96074. * Gets the animation properties override
  96075. */
  96076. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96077. private _decompose;
  96078. private _compose;
  96079. /**
  96080. * Update the base and local matrices
  96081. * @param matrix defines the new base or local matrix
  96082. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96083. * @param updateLocalMatrix defines if the local matrix should be updated
  96084. */
  96085. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  96086. /** @hidden */
  96087. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96088. /**
  96089. * Flag the bone as dirty (Forcing it to update everything)
  96090. */
  96091. markAsDirty(): void;
  96092. /** @hidden */
  96093. _markAsDirtyAndCompose(): void;
  96094. private _markAsDirtyAndDecompose;
  96095. /**
  96096. * Translate the bone in local or world space
  96097. * @param vec The amount to translate the bone
  96098. * @param space The space that the translation is in
  96099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96100. */
  96101. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96102. /**
  96103. * Set the postion of the bone in local or world space
  96104. * @param position The position to set the bone
  96105. * @param space The space that the position is in
  96106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96107. */
  96108. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96109. /**
  96110. * Set the absolute position of the bone (world space)
  96111. * @param position The position to set the bone
  96112. * @param mesh The mesh that this bone is attached to
  96113. */
  96114. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96115. /**
  96116. * Scale the bone on the x, y and z axes (in local space)
  96117. * @param x The amount to scale the bone on the x axis
  96118. * @param y The amount to scale the bone on the y axis
  96119. * @param z The amount to scale the bone on the z axis
  96120. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96121. */
  96122. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96123. /**
  96124. * Set the bone scaling in local space
  96125. * @param scale defines the scaling vector
  96126. */
  96127. setScale(scale: Vector3): void;
  96128. /**
  96129. * Gets the current scaling in local space
  96130. * @returns the current scaling vector
  96131. */
  96132. getScale(): Vector3;
  96133. /**
  96134. * Gets the current scaling in local space and stores it in a target vector
  96135. * @param result defines the target vector
  96136. */
  96137. getScaleToRef(result: Vector3): void;
  96138. /**
  96139. * Set the yaw, pitch, and roll of the bone in local or world space
  96140. * @param yaw The rotation of the bone on the y axis
  96141. * @param pitch The rotation of the bone on the x axis
  96142. * @param roll The rotation of the bone on the z axis
  96143. * @param space The space that the axes of rotation are in
  96144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96145. */
  96146. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96147. /**
  96148. * Add a rotation to the bone on an axis in local or world space
  96149. * @param axis The axis to rotate the bone on
  96150. * @param amount The amount to rotate the bone
  96151. * @param space The space that the axis is in
  96152. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96153. */
  96154. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96155. /**
  96156. * Set the rotation of the bone to a particular axis angle in local or world space
  96157. * @param axis The axis to rotate the bone on
  96158. * @param angle The angle that the bone should be rotated to
  96159. * @param space The space that the axis is in
  96160. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96161. */
  96162. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96163. /**
  96164. * Set the euler rotation of the bone in local or world space
  96165. * @param rotation The euler rotation that the bone should be set to
  96166. * @param space The space that the rotation is in
  96167. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96168. */
  96169. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96170. /**
  96171. * Set the quaternion rotation of the bone in local or world space
  96172. * @param quat The quaternion rotation that the bone should be set to
  96173. * @param space The space that the rotation is in
  96174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96175. */
  96176. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96177. /**
  96178. * Set the rotation matrix of the bone in local or world space
  96179. * @param rotMat The rotation matrix that the bone should be set to
  96180. * @param space The space that the rotation is in
  96181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96182. */
  96183. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96184. private _rotateWithMatrix;
  96185. private _getNegativeRotationToRef;
  96186. /**
  96187. * Get the position of the bone in local or world space
  96188. * @param space The space that the returned position is in
  96189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96190. * @returns The position of the bone
  96191. */
  96192. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96193. /**
  96194. * Copy the position of the bone to a vector3 in local or world space
  96195. * @param space The space that the returned position is in
  96196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96197. * @param result The vector3 to copy the position to
  96198. */
  96199. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96200. /**
  96201. * Get the absolute position of the bone (world space)
  96202. * @param mesh The mesh that this bone is attached to
  96203. * @returns The absolute position of the bone
  96204. */
  96205. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96206. /**
  96207. * Copy the absolute position of the bone (world space) to the result param
  96208. * @param mesh The mesh that this bone is attached to
  96209. * @param result The vector3 to copy the absolute position to
  96210. */
  96211. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96212. /**
  96213. * Compute the absolute transforms of this bone and its children
  96214. */
  96215. computeAbsoluteTransforms(): void;
  96216. /**
  96217. * Get the world direction from an axis that is in the local space of the bone
  96218. * @param localAxis The local direction that is used to compute the world direction
  96219. * @param mesh The mesh that this bone is attached to
  96220. * @returns The world direction
  96221. */
  96222. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96223. /**
  96224. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96225. * @param localAxis The local direction that is used to compute the world direction
  96226. * @param mesh The mesh that this bone is attached to
  96227. * @param result The vector3 that the world direction will be copied to
  96228. */
  96229. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96230. /**
  96231. * Get the euler rotation of the bone in local or world space
  96232. * @param space The space that the rotation should be in
  96233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96234. * @returns The euler rotation
  96235. */
  96236. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96237. /**
  96238. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96239. * @param space The space that the rotation should be in
  96240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96241. * @param result The vector3 that the rotation should be copied to
  96242. */
  96243. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96244. /**
  96245. * Get the quaternion rotation of the bone in either local or world space
  96246. * @param space The space that the rotation should be in
  96247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96248. * @returns The quaternion rotation
  96249. */
  96250. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96251. /**
  96252. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96253. * @param space The space that the rotation should be in
  96254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96255. * @param result The quaternion that the rotation should be copied to
  96256. */
  96257. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96258. /**
  96259. * Get the rotation matrix of the bone in local or world space
  96260. * @param space The space that the rotation should be in
  96261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96262. * @returns The rotation matrix
  96263. */
  96264. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96265. /**
  96266. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96267. * @param space The space that the rotation should be in
  96268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96269. * @param result The quaternion that the rotation should be copied to
  96270. */
  96271. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96272. /**
  96273. * Get the world position of a point that is in the local space of the bone
  96274. * @param position The local position
  96275. * @param mesh The mesh that this bone is attached to
  96276. * @returns The world position
  96277. */
  96278. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96279. /**
  96280. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96281. * @param position The local position
  96282. * @param mesh The mesh that this bone is attached to
  96283. * @param result The vector3 that the world position should be copied to
  96284. */
  96285. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96286. /**
  96287. * Get the local position of a point that is in world space
  96288. * @param position The world position
  96289. * @param mesh The mesh that this bone is attached to
  96290. * @returns The local position
  96291. */
  96292. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96293. /**
  96294. * Get the local position of a point that is in world space and copy it to the result param
  96295. * @param position The world position
  96296. * @param mesh The mesh that this bone is attached to
  96297. * @param result The vector3 that the local position should be copied to
  96298. */
  96299. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96300. /**
  96301. * Set the current local matrix as the restPose for this bone.
  96302. */
  96303. setCurrentPoseAsRest(): void;
  96304. }
  96305. }
  96306. declare module BABYLON {
  96307. /**
  96308. * Defines a runtime animation
  96309. */
  96310. export class RuntimeAnimation {
  96311. private _events;
  96312. /**
  96313. * The current frame of the runtime animation
  96314. */
  96315. private _currentFrame;
  96316. /**
  96317. * The animation used by the runtime animation
  96318. */
  96319. private _animation;
  96320. /**
  96321. * The target of the runtime animation
  96322. */
  96323. private _target;
  96324. /**
  96325. * The initiating animatable
  96326. */
  96327. private _host;
  96328. /**
  96329. * The original value of the runtime animation
  96330. */
  96331. private _originalValue;
  96332. /**
  96333. * The original blend value of the runtime animation
  96334. */
  96335. private _originalBlendValue;
  96336. /**
  96337. * The offsets cache of the runtime animation
  96338. */
  96339. private _offsetsCache;
  96340. /**
  96341. * The high limits cache of the runtime animation
  96342. */
  96343. private _highLimitsCache;
  96344. /**
  96345. * Specifies if the runtime animation has been stopped
  96346. */
  96347. private _stopped;
  96348. /**
  96349. * The blending factor of the runtime animation
  96350. */
  96351. private _blendingFactor;
  96352. /**
  96353. * The BabylonJS scene
  96354. */
  96355. private _scene;
  96356. /**
  96357. * The current value of the runtime animation
  96358. */
  96359. private _currentValue;
  96360. /** @hidden */
  96361. _animationState: _IAnimationState;
  96362. /**
  96363. * The active target of the runtime animation
  96364. */
  96365. private _activeTargets;
  96366. private _currentActiveTarget;
  96367. private _directTarget;
  96368. /**
  96369. * The target path of the runtime animation
  96370. */
  96371. private _targetPath;
  96372. /**
  96373. * The weight of the runtime animation
  96374. */
  96375. private _weight;
  96376. /**
  96377. * The ratio offset of the runtime animation
  96378. */
  96379. private _ratioOffset;
  96380. /**
  96381. * The previous delay of the runtime animation
  96382. */
  96383. private _previousDelay;
  96384. /**
  96385. * The previous ratio of the runtime animation
  96386. */
  96387. private _previousRatio;
  96388. private _enableBlending;
  96389. private _keys;
  96390. private _minFrame;
  96391. private _maxFrame;
  96392. private _minValue;
  96393. private _maxValue;
  96394. private _targetIsArray;
  96395. /**
  96396. * Gets the current frame of the runtime animation
  96397. */
  96398. get currentFrame(): number;
  96399. /**
  96400. * Gets the weight of the runtime animation
  96401. */
  96402. get weight(): number;
  96403. /**
  96404. * Gets the current value of the runtime animation
  96405. */
  96406. get currentValue(): any;
  96407. /**
  96408. * Gets the target path of the runtime animation
  96409. */
  96410. get targetPath(): string;
  96411. /**
  96412. * Gets the actual target of the runtime animation
  96413. */
  96414. get target(): any;
  96415. /**
  96416. * Gets the additive state of the runtime animation
  96417. */
  96418. get isAdditive(): boolean;
  96419. /** @hidden */
  96420. _onLoop: () => void;
  96421. /**
  96422. * Create a new RuntimeAnimation object
  96423. * @param target defines the target of the animation
  96424. * @param animation defines the source animation object
  96425. * @param scene defines the hosting scene
  96426. * @param host defines the initiating Animatable
  96427. */
  96428. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96429. private _preparePath;
  96430. /**
  96431. * Gets the animation from the runtime animation
  96432. */
  96433. get animation(): Animation;
  96434. /**
  96435. * Resets the runtime animation to the beginning
  96436. * @param restoreOriginal defines whether to restore the target property to the original value
  96437. */
  96438. reset(restoreOriginal?: boolean): void;
  96439. /**
  96440. * Specifies if the runtime animation is stopped
  96441. * @returns Boolean specifying if the runtime animation is stopped
  96442. */
  96443. isStopped(): boolean;
  96444. /**
  96445. * Disposes of the runtime animation
  96446. */
  96447. dispose(): void;
  96448. /**
  96449. * Apply the interpolated value to the target
  96450. * @param currentValue defines the value computed by the animation
  96451. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96452. */
  96453. setValue(currentValue: any, weight: number): void;
  96454. private _getOriginalValues;
  96455. private _setValue;
  96456. /**
  96457. * Gets the loop pmode of the runtime animation
  96458. * @returns Loop Mode
  96459. */
  96460. private _getCorrectLoopMode;
  96461. /**
  96462. * Move the current animation to a given frame
  96463. * @param frame defines the frame to move to
  96464. */
  96465. goToFrame(frame: number): void;
  96466. /**
  96467. * @hidden Internal use only
  96468. */
  96469. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96470. /**
  96471. * Execute the current animation
  96472. * @param delay defines the delay to add to the current frame
  96473. * @param from defines the lower bound of the animation range
  96474. * @param to defines the upper bound of the animation range
  96475. * @param loop defines if the current animation must loop
  96476. * @param speedRatio defines the current speed ratio
  96477. * @param weight defines the weight of the animation (default is -1 so no weight)
  96478. * @param onLoop optional callback called when animation loops
  96479. * @returns a boolean indicating if the animation is running
  96480. */
  96481. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96482. }
  96483. }
  96484. declare module BABYLON {
  96485. /**
  96486. * Class used to store an actual running animation
  96487. */
  96488. export class Animatable {
  96489. /** defines the target object */
  96490. target: any;
  96491. /** defines the starting frame number (default is 0) */
  96492. fromFrame: number;
  96493. /** defines the ending frame number (default is 100) */
  96494. toFrame: number;
  96495. /** defines if the animation must loop (default is false) */
  96496. loopAnimation: boolean;
  96497. /** defines a callback to call when animation ends if it is not looping */
  96498. onAnimationEnd?: (() => void) | null | undefined;
  96499. /** defines a callback to call when animation loops */
  96500. onAnimationLoop?: (() => void) | null | undefined;
  96501. /** defines whether the animation should be evaluated additively */
  96502. isAdditive: boolean;
  96503. private _localDelayOffset;
  96504. private _pausedDelay;
  96505. private _runtimeAnimations;
  96506. private _paused;
  96507. private _scene;
  96508. private _speedRatio;
  96509. private _weight;
  96510. private _syncRoot;
  96511. /**
  96512. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96513. * This will only apply for non looping animation (default is true)
  96514. */
  96515. disposeOnEnd: boolean;
  96516. /**
  96517. * Gets a boolean indicating if the animation has started
  96518. */
  96519. animationStarted: boolean;
  96520. /**
  96521. * Observer raised when the animation ends
  96522. */
  96523. onAnimationEndObservable: Observable<Animatable>;
  96524. /**
  96525. * Observer raised when the animation loops
  96526. */
  96527. onAnimationLoopObservable: Observable<Animatable>;
  96528. /**
  96529. * Gets the root Animatable used to synchronize and normalize animations
  96530. */
  96531. get syncRoot(): Nullable<Animatable>;
  96532. /**
  96533. * Gets the current frame of the first RuntimeAnimation
  96534. * Used to synchronize Animatables
  96535. */
  96536. get masterFrame(): number;
  96537. /**
  96538. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96539. */
  96540. get weight(): number;
  96541. set weight(value: number);
  96542. /**
  96543. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96544. */
  96545. get speedRatio(): number;
  96546. set speedRatio(value: number);
  96547. /**
  96548. * Creates a new Animatable
  96549. * @param scene defines the hosting scene
  96550. * @param target defines the target object
  96551. * @param fromFrame defines the starting frame number (default is 0)
  96552. * @param toFrame defines the ending frame number (default is 100)
  96553. * @param loopAnimation defines if the animation must loop (default is false)
  96554. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96555. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96556. * @param animations defines a group of animation to add to the new Animatable
  96557. * @param onAnimationLoop defines a callback to call when animation loops
  96558. * @param isAdditive defines whether the animation should be evaluated additively
  96559. */
  96560. constructor(scene: Scene,
  96561. /** defines the target object */
  96562. target: any,
  96563. /** defines the starting frame number (default is 0) */
  96564. fromFrame?: number,
  96565. /** defines the ending frame number (default is 100) */
  96566. toFrame?: number,
  96567. /** defines if the animation must loop (default is false) */
  96568. loopAnimation?: boolean, speedRatio?: number,
  96569. /** defines a callback to call when animation ends if it is not looping */
  96570. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96571. /** defines a callback to call when animation loops */
  96572. onAnimationLoop?: (() => void) | null | undefined,
  96573. /** defines whether the animation should be evaluated additively */
  96574. isAdditive?: boolean);
  96575. /**
  96576. * Synchronize and normalize current Animatable with a source Animatable
  96577. * This is useful when using animation weights and when animations are not of the same length
  96578. * @param root defines the root Animatable to synchronize with
  96579. * @returns the current Animatable
  96580. */
  96581. syncWith(root: Animatable): Animatable;
  96582. /**
  96583. * Gets the list of runtime animations
  96584. * @returns an array of RuntimeAnimation
  96585. */
  96586. getAnimations(): RuntimeAnimation[];
  96587. /**
  96588. * Adds more animations to the current animatable
  96589. * @param target defines the target of the animations
  96590. * @param animations defines the new animations to add
  96591. */
  96592. appendAnimations(target: any, animations: Animation[]): void;
  96593. /**
  96594. * Gets the source animation for a specific property
  96595. * @param property defines the propertyu to look for
  96596. * @returns null or the source animation for the given property
  96597. */
  96598. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96599. /**
  96600. * Gets the runtime animation for a specific property
  96601. * @param property defines the propertyu to look for
  96602. * @returns null or the runtime animation for the given property
  96603. */
  96604. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96605. /**
  96606. * Resets the animatable to its original state
  96607. */
  96608. reset(): void;
  96609. /**
  96610. * Allows the animatable to blend with current running animations
  96611. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96612. * @param blendingSpeed defines the blending speed to use
  96613. */
  96614. enableBlending(blendingSpeed: number): void;
  96615. /**
  96616. * Disable animation blending
  96617. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96618. */
  96619. disableBlending(): void;
  96620. /**
  96621. * Jump directly to a given frame
  96622. * @param frame defines the frame to jump to
  96623. */
  96624. goToFrame(frame: number): void;
  96625. /**
  96626. * Pause the animation
  96627. */
  96628. pause(): void;
  96629. /**
  96630. * Restart the animation
  96631. */
  96632. restart(): void;
  96633. private _raiseOnAnimationEnd;
  96634. /**
  96635. * Stop and delete the current animation
  96636. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96637. * @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)
  96638. */
  96639. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96640. /**
  96641. * Wait asynchronously for the animation to end
  96642. * @returns a promise which will be fullfilled when the animation ends
  96643. */
  96644. waitAsync(): Promise<Animatable>;
  96645. /** @hidden */
  96646. _animate(delay: number): boolean;
  96647. }
  96648. interface Scene {
  96649. /** @hidden */
  96650. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96651. /** @hidden */
  96652. _processLateAnimationBindingsForMatrices(holder: {
  96653. totalWeight: number;
  96654. totalAdditiveWeight: number;
  96655. animations: RuntimeAnimation[];
  96656. additiveAnimations: RuntimeAnimation[];
  96657. originalValue: Matrix;
  96658. }): any;
  96659. /** @hidden */
  96660. _processLateAnimationBindingsForQuaternions(holder: {
  96661. totalWeight: number;
  96662. totalAdditiveWeight: number;
  96663. animations: RuntimeAnimation[];
  96664. additiveAnimations: RuntimeAnimation[];
  96665. originalValue: Quaternion;
  96666. }, refQuaternion: Quaternion): Quaternion;
  96667. /** @hidden */
  96668. _processLateAnimationBindings(): void;
  96669. /**
  96670. * Will start the animation sequence of a given target
  96671. * @param target defines the target
  96672. * @param from defines from which frame should animation start
  96673. * @param to defines until which frame should animation run.
  96674. * @param weight defines the weight to apply to the animation (1.0 by default)
  96675. * @param loop defines if the animation loops
  96676. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96677. * @param onAnimationEnd defines the function to be executed when the animation ends
  96678. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96679. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96680. * @param onAnimationLoop defines the callback to call when an animation loops
  96681. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96682. * @returns the animatable object created for this animation
  96683. */
  96684. 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;
  96685. /**
  96686. * Will start the animation sequence of a given target
  96687. * @param target defines the target
  96688. * @param from defines from which frame should animation start
  96689. * @param to defines until which frame should animation run.
  96690. * @param loop defines if the animation loops
  96691. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96692. * @param onAnimationEnd defines the function to be executed when the animation ends
  96693. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96694. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96695. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96696. * @param onAnimationLoop defines the callback to call when an animation loops
  96697. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96698. * @returns the animatable object created for this animation
  96699. */
  96700. 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;
  96701. /**
  96702. * Will start the animation sequence of a given target and its hierarchy
  96703. * @param target defines the target
  96704. * @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.
  96705. * @param from defines from which frame should animation start
  96706. * @param to defines until which frame should animation run.
  96707. * @param loop defines if the animation loops
  96708. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96709. * @param onAnimationEnd defines the function to be executed when the animation ends
  96710. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96711. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96712. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96713. * @param onAnimationLoop defines the callback to call when an animation loops
  96714. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96715. * @returns the list of created animatables
  96716. */
  96717. 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[];
  96718. /**
  96719. * Begin a new animation on a given node
  96720. * @param target defines the target where the animation will take place
  96721. * @param animations defines the list of animations to start
  96722. * @param from defines the initial value
  96723. * @param to defines the final value
  96724. * @param loop defines if you want animation to loop (off by default)
  96725. * @param speedRatio defines the speed ratio to apply to all animations
  96726. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96727. * @param onAnimationLoop defines the callback to call when an animation loops
  96728. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96729. * @returns the list of created animatables
  96730. */
  96731. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96732. /**
  96733. * Begin a new animation on a given node and its hierarchy
  96734. * @param target defines the root node where the animation will take place
  96735. * @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.
  96736. * @param animations defines the list of animations to start
  96737. * @param from defines the initial value
  96738. * @param to defines the final value
  96739. * @param loop defines if you want animation to loop (off by default)
  96740. * @param speedRatio defines the speed ratio to apply to all animations
  96741. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96742. * @param onAnimationLoop defines the callback to call when an animation loops
  96743. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96744. * @returns the list of animatables created for all nodes
  96745. */
  96746. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96747. /**
  96748. * Gets the animatable associated with a specific target
  96749. * @param target defines the target of the animatable
  96750. * @returns the required animatable if found
  96751. */
  96752. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96753. /**
  96754. * Gets all animatables associated with a given target
  96755. * @param target defines the target to look animatables for
  96756. * @returns an array of Animatables
  96757. */
  96758. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96759. /**
  96760. * Stops and removes all animations that have been applied to the scene
  96761. */
  96762. stopAllAnimations(): void;
  96763. /**
  96764. * Gets the current delta time used by animation engine
  96765. */
  96766. deltaTime: number;
  96767. }
  96768. interface Bone {
  96769. /**
  96770. * Copy an animation range from another bone
  96771. * @param source defines the source bone
  96772. * @param rangeName defines the range name to copy
  96773. * @param frameOffset defines the frame offset
  96774. * @param rescaleAsRequired defines if rescaling must be applied if required
  96775. * @param skelDimensionsRatio defines the scaling ratio
  96776. * @returns true if operation was successful
  96777. */
  96778. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96779. }
  96780. }
  96781. declare module BABYLON {
  96782. /**
  96783. * Class used to handle skinning animations
  96784. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96785. */
  96786. export class Skeleton implements IAnimatable {
  96787. /** defines the skeleton name */
  96788. name: string;
  96789. /** defines the skeleton Id */
  96790. id: string;
  96791. /**
  96792. * Defines the list of child bones
  96793. */
  96794. bones: Bone[];
  96795. /**
  96796. * Defines an estimate of the dimension of the skeleton at rest
  96797. */
  96798. dimensionsAtRest: Vector3;
  96799. /**
  96800. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96801. */
  96802. needInitialSkinMatrix: boolean;
  96803. /**
  96804. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96805. */
  96806. overrideMesh: Nullable<AbstractMesh>;
  96807. /**
  96808. * Gets the list of animations attached to this skeleton
  96809. */
  96810. animations: Array<Animation>;
  96811. private _scene;
  96812. private _isDirty;
  96813. private _transformMatrices;
  96814. private _transformMatrixTexture;
  96815. private _meshesWithPoseMatrix;
  96816. private _animatables;
  96817. private _identity;
  96818. private _synchronizedWithMesh;
  96819. private _ranges;
  96820. private _lastAbsoluteTransformsUpdateId;
  96821. private _canUseTextureForBones;
  96822. private _uniqueId;
  96823. /** @hidden */
  96824. _numBonesWithLinkedTransformNode: number;
  96825. /** @hidden */
  96826. _hasWaitingData: Nullable<boolean>;
  96827. /** @hidden */
  96828. _waitingOverrideMeshId: Nullable<string>;
  96829. /**
  96830. * Specifies if the skeleton should be serialized
  96831. */
  96832. doNotSerialize: boolean;
  96833. private _useTextureToStoreBoneMatrices;
  96834. /**
  96835. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96836. * Please note that this option is not available if the hardware does not support it
  96837. */
  96838. get useTextureToStoreBoneMatrices(): boolean;
  96839. set useTextureToStoreBoneMatrices(value: boolean);
  96840. private _animationPropertiesOverride;
  96841. /**
  96842. * Gets or sets the animation properties override
  96843. */
  96844. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96845. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96846. /**
  96847. * List of inspectable custom properties (used by the Inspector)
  96848. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96849. */
  96850. inspectableCustomProperties: IInspectable[];
  96851. /**
  96852. * An observable triggered before computing the skeleton's matrices
  96853. */
  96854. onBeforeComputeObservable: Observable<Skeleton>;
  96855. /**
  96856. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96857. */
  96858. get isUsingTextureForMatrices(): boolean;
  96859. /**
  96860. * Gets the unique ID of this skeleton
  96861. */
  96862. get uniqueId(): number;
  96863. /**
  96864. * Creates a new skeleton
  96865. * @param name defines the skeleton name
  96866. * @param id defines the skeleton Id
  96867. * @param scene defines the hosting scene
  96868. */
  96869. constructor(
  96870. /** defines the skeleton name */
  96871. name: string,
  96872. /** defines the skeleton Id */
  96873. id: string, scene: Scene);
  96874. /**
  96875. * Gets the current object class name.
  96876. * @return the class name
  96877. */
  96878. getClassName(): string;
  96879. /**
  96880. * Returns an array containing the root bones
  96881. * @returns an array containing the root bones
  96882. */
  96883. getChildren(): Array<Bone>;
  96884. /**
  96885. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96886. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96887. * @returns a Float32Array containing matrices data
  96888. */
  96889. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96890. /**
  96891. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96892. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96893. * @returns a raw texture containing the data
  96894. */
  96895. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96896. /**
  96897. * Gets the current hosting scene
  96898. * @returns a scene object
  96899. */
  96900. getScene(): Scene;
  96901. /**
  96902. * Gets a string representing the current skeleton data
  96903. * @param fullDetails defines a boolean indicating if we want a verbose version
  96904. * @returns a string representing the current skeleton data
  96905. */
  96906. toString(fullDetails?: boolean): string;
  96907. /**
  96908. * Get bone's index searching by name
  96909. * @param name defines bone's name to search for
  96910. * @return the indice of the bone. Returns -1 if not found
  96911. */
  96912. getBoneIndexByName(name: string): number;
  96913. /**
  96914. * Creater a new animation range
  96915. * @param name defines the name of the range
  96916. * @param from defines the start key
  96917. * @param to defines the end key
  96918. */
  96919. createAnimationRange(name: string, from: number, to: number): void;
  96920. /**
  96921. * Delete a specific animation range
  96922. * @param name defines the name of the range
  96923. * @param deleteFrames defines if frames must be removed as well
  96924. */
  96925. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96926. /**
  96927. * Gets a specific animation range
  96928. * @param name defines the name of the range to look for
  96929. * @returns the requested animation range or null if not found
  96930. */
  96931. getAnimationRange(name: string): Nullable<AnimationRange>;
  96932. /**
  96933. * Gets the list of all animation ranges defined on this skeleton
  96934. * @returns an array
  96935. */
  96936. getAnimationRanges(): Nullable<AnimationRange>[];
  96937. /**
  96938. * Copy animation range from a source skeleton.
  96939. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96940. * @param source defines the source skeleton
  96941. * @param name defines the name of the range to copy
  96942. * @param rescaleAsRequired defines if rescaling must be applied if required
  96943. * @returns true if operation was successful
  96944. */
  96945. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96946. /**
  96947. * Forces the skeleton to go to rest pose
  96948. */
  96949. returnToRest(): void;
  96950. private _getHighestAnimationFrame;
  96951. /**
  96952. * Begin a specific animation range
  96953. * @param name defines the name of the range to start
  96954. * @param loop defines if looping must be turned on (false by default)
  96955. * @param speedRatio defines the speed ratio to apply (1 by default)
  96956. * @param onAnimationEnd defines a callback which will be called when animation will end
  96957. * @returns a new animatable
  96958. */
  96959. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96960. /**
  96961. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96962. * @param skeleton defines the Skeleton containing the animation range to convert
  96963. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96964. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96965. * @returns the original skeleton
  96966. */
  96967. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96968. /** @hidden */
  96969. _markAsDirty(): void;
  96970. /** @hidden */
  96971. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96972. /** @hidden */
  96973. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96974. private _computeTransformMatrices;
  96975. /**
  96976. * Build all resources required to render a skeleton
  96977. */
  96978. prepare(): void;
  96979. /**
  96980. * Gets the list of animatables currently running for this skeleton
  96981. * @returns an array of animatables
  96982. */
  96983. getAnimatables(): IAnimatable[];
  96984. /**
  96985. * Clone the current skeleton
  96986. * @param name defines the name of the new skeleton
  96987. * @param id defines the id of the new skeleton
  96988. * @returns the new skeleton
  96989. */
  96990. clone(name: string, id?: string): Skeleton;
  96991. /**
  96992. * Enable animation blending for this skeleton
  96993. * @param blendingSpeed defines the blending speed to apply
  96994. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96995. */
  96996. enableBlending(blendingSpeed?: number): void;
  96997. /**
  96998. * Releases all resources associated with the current skeleton
  96999. */
  97000. dispose(): void;
  97001. /**
  97002. * Serialize the skeleton in a JSON object
  97003. * @returns a JSON object
  97004. */
  97005. serialize(): any;
  97006. /**
  97007. * Creates a new skeleton from serialized data
  97008. * @param parsedSkeleton defines the serialized data
  97009. * @param scene defines the hosting scene
  97010. * @returns a new skeleton
  97011. */
  97012. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  97013. /**
  97014. * Compute all node absolute transforms
  97015. * @param forceUpdate defines if computation must be done even if cache is up to date
  97016. */
  97017. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  97018. /**
  97019. * Gets the root pose matrix
  97020. * @returns a matrix
  97021. */
  97022. getPoseMatrix(): Nullable<Matrix>;
  97023. /**
  97024. * Sorts bones per internal index
  97025. */
  97026. sortBones(): void;
  97027. private _sortBones;
  97028. /**
  97029. * Set the current local matrix as the restPose for all bones in the skeleton.
  97030. */
  97031. setCurrentPoseAsRest(): void;
  97032. }
  97033. }
  97034. declare module BABYLON {
  97035. /**
  97036. * Creates an instance based on a source mesh.
  97037. */
  97038. export class InstancedMesh extends AbstractMesh {
  97039. private _sourceMesh;
  97040. private _currentLOD;
  97041. /** @hidden */
  97042. _indexInSourceMeshInstanceArray: number;
  97043. constructor(name: string, source: Mesh);
  97044. /**
  97045. * Returns the string "InstancedMesh".
  97046. */
  97047. getClassName(): string;
  97048. /** Gets the list of lights affecting that mesh */
  97049. get lightSources(): Light[];
  97050. _resyncLightSources(): void;
  97051. _resyncLightSource(light: Light): void;
  97052. _removeLightSource(light: Light, dispose: boolean): void;
  97053. /**
  97054. * If the source mesh receives shadows
  97055. */
  97056. get receiveShadows(): boolean;
  97057. /**
  97058. * The material of the source mesh
  97059. */
  97060. get material(): Nullable<Material>;
  97061. /**
  97062. * Visibility of the source mesh
  97063. */
  97064. get visibility(): number;
  97065. /**
  97066. * Skeleton of the source mesh
  97067. */
  97068. get skeleton(): Nullable<Skeleton>;
  97069. /**
  97070. * Rendering ground id of the source mesh
  97071. */
  97072. get renderingGroupId(): number;
  97073. set renderingGroupId(value: number);
  97074. /**
  97075. * Returns the total number of vertices (integer).
  97076. */
  97077. getTotalVertices(): number;
  97078. /**
  97079. * Returns a positive integer : the total number of indices in this mesh geometry.
  97080. * @returns the numner of indices or zero if the mesh has no geometry.
  97081. */
  97082. getTotalIndices(): number;
  97083. /**
  97084. * The source mesh of the instance
  97085. */
  97086. get sourceMesh(): Mesh;
  97087. /**
  97088. * Creates a new InstancedMesh object from the mesh model.
  97089. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97090. * @param name defines the name of the new instance
  97091. * @returns a new InstancedMesh
  97092. */
  97093. createInstance(name: string): InstancedMesh;
  97094. /**
  97095. * Is this node ready to be used/rendered
  97096. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97097. * @return {boolean} is it ready
  97098. */
  97099. isReady(completeCheck?: boolean): boolean;
  97100. /**
  97101. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97102. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97103. * @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.
  97104. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97105. */
  97106. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97107. /**
  97108. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97109. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97110. * The `data` are either a numeric array either a Float32Array.
  97111. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97112. * 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).
  97113. * Note that a new underlying VertexBuffer object is created each call.
  97114. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97115. *
  97116. * Possible `kind` values :
  97117. * - VertexBuffer.PositionKind
  97118. * - VertexBuffer.UVKind
  97119. * - VertexBuffer.UV2Kind
  97120. * - VertexBuffer.UV3Kind
  97121. * - VertexBuffer.UV4Kind
  97122. * - VertexBuffer.UV5Kind
  97123. * - VertexBuffer.UV6Kind
  97124. * - VertexBuffer.ColorKind
  97125. * - VertexBuffer.MatricesIndicesKind
  97126. * - VertexBuffer.MatricesIndicesExtraKind
  97127. * - VertexBuffer.MatricesWeightsKind
  97128. * - VertexBuffer.MatricesWeightsExtraKind
  97129. *
  97130. * Returns the Mesh.
  97131. */
  97132. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97133. /**
  97134. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97135. * If the mesh has no geometry, it is simply returned as it is.
  97136. * The `data` are either a numeric array either a Float32Array.
  97137. * No new underlying VertexBuffer object is created.
  97138. * 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.
  97139. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97140. *
  97141. * Possible `kind` values :
  97142. * - VertexBuffer.PositionKind
  97143. * - VertexBuffer.UVKind
  97144. * - VertexBuffer.UV2Kind
  97145. * - VertexBuffer.UV3Kind
  97146. * - VertexBuffer.UV4Kind
  97147. * - VertexBuffer.UV5Kind
  97148. * - VertexBuffer.UV6Kind
  97149. * - VertexBuffer.ColorKind
  97150. * - VertexBuffer.MatricesIndicesKind
  97151. * - VertexBuffer.MatricesIndicesExtraKind
  97152. * - VertexBuffer.MatricesWeightsKind
  97153. * - VertexBuffer.MatricesWeightsExtraKind
  97154. *
  97155. * Returns the Mesh.
  97156. */
  97157. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97158. /**
  97159. * Sets the mesh indices.
  97160. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97161. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97162. * This method creates a new index buffer each call.
  97163. * Returns the Mesh.
  97164. */
  97165. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97166. /**
  97167. * Boolean : True if the mesh owns the requested kind of data.
  97168. */
  97169. isVerticesDataPresent(kind: string): boolean;
  97170. /**
  97171. * Returns an array of indices (IndicesArray).
  97172. */
  97173. getIndices(): Nullable<IndicesArray>;
  97174. get _positions(): Nullable<Vector3[]>;
  97175. /**
  97176. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97177. * This means the mesh underlying bounding box and sphere are recomputed.
  97178. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97179. * @returns the current mesh
  97180. */
  97181. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97182. /** @hidden */
  97183. _preActivate(): InstancedMesh;
  97184. /** @hidden */
  97185. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97186. /** @hidden */
  97187. _postActivate(): void;
  97188. getWorldMatrix(): Matrix;
  97189. get isAnInstance(): boolean;
  97190. /**
  97191. * Returns the current associated LOD AbstractMesh.
  97192. */
  97193. getLOD(camera: Camera): AbstractMesh;
  97194. /** @hidden */
  97195. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97196. /** @hidden */
  97197. _syncSubMeshes(): InstancedMesh;
  97198. /** @hidden */
  97199. _generatePointsArray(): boolean;
  97200. /** @hidden */
  97201. _updateBoundingInfo(): AbstractMesh;
  97202. /**
  97203. * Creates a new InstancedMesh from the current mesh.
  97204. * - name (string) : the cloned mesh name
  97205. * - newParent (optional Node) : the optional Node to parent the clone to.
  97206. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97207. *
  97208. * Returns the clone.
  97209. */
  97210. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97211. /**
  97212. * Disposes the InstancedMesh.
  97213. * Returns nothing.
  97214. */
  97215. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97216. }
  97217. interface Mesh {
  97218. /**
  97219. * Register a custom buffer that will be instanced
  97220. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97221. * @param kind defines the buffer kind
  97222. * @param stride defines the stride in floats
  97223. */
  97224. registerInstancedBuffer(kind: string, stride: number): void;
  97225. /**
  97226. * true to use the edge renderer for all instances of this mesh
  97227. */
  97228. edgesShareWithInstances: boolean;
  97229. /** @hidden */
  97230. _userInstancedBuffersStorage: {
  97231. data: {
  97232. [key: string]: Float32Array;
  97233. };
  97234. sizes: {
  97235. [key: string]: number;
  97236. };
  97237. vertexBuffers: {
  97238. [key: string]: Nullable<VertexBuffer>;
  97239. };
  97240. strides: {
  97241. [key: string]: number;
  97242. };
  97243. };
  97244. }
  97245. interface AbstractMesh {
  97246. /**
  97247. * Object used to store instanced buffers defined by user
  97248. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97249. */
  97250. instancedBuffers: {
  97251. [key: string]: any;
  97252. };
  97253. }
  97254. }
  97255. declare module BABYLON {
  97256. /**
  97257. * Defines the options associated with the creation of a shader material.
  97258. */
  97259. export interface IShaderMaterialOptions {
  97260. /**
  97261. * Does the material work in alpha blend mode
  97262. */
  97263. needAlphaBlending: boolean;
  97264. /**
  97265. * Does the material work in alpha test mode
  97266. */
  97267. needAlphaTesting: boolean;
  97268. /**
  97269. * The list of attribute names used in the shader
  97270. */
  97271. attributes: string[];
  97272. /**
  97273. * The list of unifrom names used in the shader
  97274. */
  97275. uniforms: string[];
  97276. /**
  97277. * The list of UBO names used in the shader
  97278. */
  97279. uniformBuffers: string[];
  97280. /**
  97281. * The list of sampler names used in the shader
  97282. */
  97283. samplers: string[];
  97284. /**
  97285. * The list of defines used in the shader
  97286. */
  97287. defines: string[];
  97288. }
  97289. /**
  97290. * 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.
  97291. *
  97292. * This returned material effects how the mesh will look based on the code in the shaders.
  97293. *
  97294. * @see https://doc.babylonjs.com/how_to/shader_material
  97295. */
  97296. export class ShaderMaterial extends Material {
  97297. private _shaderPath;
  97298. private _options;
  97299. private _textures;
  97300. private _textureArrays;
  97301. private _floats;
  97302. private _ints;
  97303. private _floatsArrays;
  97304. private _colors3;
  97305. private _colors3Arrays;
  97306. private _colors4;
  97307. private _colors4Arrays;
  97308. private _vectors2;
  97309. private _vectors3;
  97310. private _vectors4;
  97311. private _matrices;
  97312. private _matrixArrays;
  97313. private _matrices3x3;
  97314. private _matrices2x2;
  97315. private _vectors2Arrays;
  97316. private _vectors3Arrays;
  97317. private _vectors4Arrays;
  97318. private _cachedWorldViewMatrix;
  97319. private _cachedWorldViewProjectionMatrix;
  97320. private _renderId;
  97321. private _multiview;
  97322. private _cachedDefines;
  97323. /** Define the Url to load snippets */
  97324. static SnippetUrl: string;
  97325. /** Snippet ID if the material was created from the snippet server */
  97326. snippetId: string;
  97327. /**
  97328. * Instantiate a new shader material.
  97329. * 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.
  97330. * This returned material effects how the mesh will look based on the code in the shaders.
  97331. * @see https://doc.babylonjs.com/how_to/shader_material
  97332. * @param name Define the name of the material in the scene
  97333. * @param scene Define the scene the material belongs to
  97334. * @param shaderPath Defines the route to the shader code in one of three ways:
  97335. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97336. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97337. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97338. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97339. * @param options Define the options used to create the shader
  97340. */
  97341. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97342. /**
  97343. * Gets the shader path used to define the shader code
  97344. * It can be modified to trigger a new compilation
  97345. */
  97346. get shaderPath(): any;
  97347. /**
  97348. * Sets the shader path used to define the shader code
  97349. * It can be modified to trigger a new compilation
  97350. */
  97351. set shaderPath(shaderPath: any);
  97352. /**
  97353. * Gets the options used to compile the shader.
  97354. * They can be modified to trigger a new compilation
  97355. */
  97356. get options(): IShaderMaterialOptions;
  97357. /**
  97358. * Gets the current class name of the material e.g. "ShaderMaterial"
  97359. * Mainly use in serialization.
  97360. * @returns the class name
  97361. */
  97362. getClassName(): string;
  97363. /**
  97364. * Specifies if the material will require alpha blending
  97365. * @returns a boolean specifying if alpha blending is needed
  97366. */
  97367. needAlphaBlending(): boolean;
  97368. /**
  97369. * Specifies if this material should be rendered in alpha test mode
  97370. * @returns a boolean specifying if an alpha test is needed.
  97371. */
  97372. needAlphaTesting(): boolean;
  97373. private _checkUniform;
  97374. /**
  97375. * Set a texture in the shader.
  97376. * @param name Define the name of the uniform samplers as defined in the shader
  97377. * @param texture Define the texture to bind to this sampler
  97378. * @return the material itself allowing "fluent" like uniform updates
  97379. */
  97380. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97381. /**
  97382. * Set a texture array in the shader.
  97383. * @param name Define the name of the uniform sampler array as defined in the shader
  97384. * @param textures Define the list of textures to bind to this sampler
  97385. * @return the material itself allowing "fluent" like uniform updates
  97386. */
  97387. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97388. /**
  97389. * Set a float in the shader.
  97390. * @param name Define the name of the uniform as defined in the shader
  97391. * @param value Define the value to give to the uniform
  97392. * @return the material itself allowing "fluent" like uniform updates
  97393. */
  97394. setFloat(name: string, value: number): ShaderMaterial;
  97395. /**
  97396. * Set a int in the shader.
  97397. * @param name Define the name of the uniform as defined in the shader
  97398. * @param value Define the value to give to the uniform
  97399. * @return the material itself allowing "fluent" like uniform updates
  97400. */
  97401. setInt(name: string, value: number): ShaderMaterial;
  97402. /**
  97403. * Set an array of floats in the shader.
  97404. * @param name Define the name of the uniform as defined in the shader
  97405. * @param value Define the value to give to the uniform
  97406. * @return the material itself allowing "fluent" like uniform updates
  97407. */
  97408. setFloats(name: string, value: number[]): ShaderMaterial;
  97409. /**
  97410. * Set a vec3 in the shader from a Color3.
  97411. * @param name Define the name of the uniform as defined in the shader
  97412. * @param value Define the value to give to the uniform
  97413. * @return the material itself allowing "fluent" like uniform updates
  97414. */
  97415. setColor3(name: string, value: Color3): ShaderMaterial;
  97416. /**
  97417. * Set a vec3 array in the shader from a Color3 array.
  97418. * @param name Define the name of the uniform as defined in the shader
  97419. * @param value Define the value to give to the uniform
  97420. * @return the material itself allowing "fluent" like uniform updates
  97421. */
  97422. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97423. /**
  97424. * Set a vec4 in the shader from a Color4.
  97425. * @param name Define the name of the uniform as defined in the shader
  97426. * @param value Define the value to give to the uniform
  97427. * @return the material itself allowing "fluent" like uniform updates
  97428. */
  97429. setColor4(name: string, value: Color4): ShaderMaterial;
  97430. /**
  97431. * Set a vec4 array in the shader from a Color4 array.
  97432. * @param name Define the name of the uniform as defined in the shader
  97433. * @param value Define the value to give to the uniform
  97434. * @return the material itself allowing "fluent" like uniform updates
  97435. */
  97436. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97437. /**
  97438. * Set a vec2 in the shader from a Vector2.
  97439. * @param name Define the name of the uniform as defined in the shader
  97440. * @param value Define the value to give to the uniform
  97441. * @return the material itself allowing "fluent" like uniform updates
  97442. */
  97443. setVector2(name: string, value: Vector2): ShaderMaterial;
  97444. /**
  97445. * Set a vec3 in the shader from a Vector3.
  97446. * @param name Define the name of the uniform as defined in the shader
  97447. * @param value Define the value to give to the uniform
  97448. * @return the material itself allowing "fluent" like uniform updates
  97449. */
  97450. setVector3(name: string, value: Vector3): ShaderMaterial;
  97451. /**
  97452. * Set a vec4 in the shader from a Vector4.
  97453. * @param name Define the name of the uniform as defined in the shader
  97454. * @param value Define the value to give to the uniform
  97455. * @return the material itself allowing "fluent" like uniform updates
  97456. */
  97457. setVector4(name: string, value: Vector4): ShaderMaterial;
  97458. /**
  97459. * Set a mat4 in the shader from a Matrix.
  97460. * @param name Define the name of the uniform as defined in the shader
  97461. * @param value Define the value to give to the uniform
  97462. * @return the material itself allowing "fluent" like uniform updates
  97463. */
  97464. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97465. /**
  97466. * Set a float32Array in the shader from a matrix array.
  97467. * @param name Define the name of the uniform as defined in the shader
  97468. * @param value Define the value to give to the uniform
  97469. * @return the material itself allowing "fluent" like uniform updates
  97470. */
  97471. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97472. /**
  97473. * Set a mat3 in the shader from a Float32Array.
  97474. * @param name Define the name of the uniform as defined in the shader
  97475. * @param value Define the value to give to the uniform
  97476. * @return the material itself allowing "fluent" like uniform updates
  97477. */
  97478. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97479. /**
  97480. * Set a mat2 in the shader from a Float32Array.
  97481. * @param name Define the name of the uniform as defined in the shader
  97482. * @param value Define the value to give to the uniform
  97483. * @return the material itself allowing "fluent" like uniform updates
  97484. */
  97485. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97486. /**
  97487. * Set a vec2 array in the shader from a number array.
  97488. * @param name Define the name of the uniform as defined in the shader
  97489. * @param value Define the value to give to the uniform
  97490. * @return the material itself allowing "fluent" like uniform updates
  97491. */
  97492. setArray2(name: string, value: number[]): ShaderMaterial;
  97493. /**
  97494. * Set a vec3 array in the shader from a number array.
  97495. * @param name Define the name of the uniform as defined in the shader
  97496. * @param value Define the value to give to the uniform
  97497. * @return the material itself allowing "fluent" like uniform updates
  97498. */
  97499. setArray3(name: string, value: number[]): ShaderMaterial;
  97500. /**
  97501. * Set a vec4 array in the shader from a number array.
  97502. * @param name Define the name of the uniform as defined in the shader
  97503. * @param value Define the value to give to the uniform
  97504. * @return the material itself allowing "fluent" like uniform updates
  97505. */
  97506. setArray4(name: string, value: number[]): ShaderMaterial;
  97507. private _checkCache;
  97508. /**
  97509. * Specifies that the submesh is ready to be used
  97510. * @param mesh defines the mesh to check
  97511. * @param subMesh defines which submesh to check
  97512. * @param useInstances specifies that instances should be used
  97513. * @returns a boolean indicating that the submesh is ready or not
  97514. */
  97515. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97516. /**
  97517. * Checks if the material is ready to render the requested mesh
  97518. * @param mesh Define the mesh to render
  97519. * @param useInstances Define whether or not the material is used with instances
  97520. * @returns true if ready, otherwise false
  97521. */
  97522. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97523. /**
  97524. * Binds the world matrix to the material
  97525. * @param world defines the world transformation matrix
  97526. * @param effectOverride - If provided, use this effect instead of internal effect
  97527. */
  97528. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97529. /**
  97530. * Binds the submesh to this material by preparing the effect and shader to draw
  97531. * @param world defines the world transformation matrix
  97532. * @param mesh defines the mesh containing the submesh
  97533. * @param subMesh defines the submesh to bind the material to
  97534. */
  97535. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97536. /**
  97537. * Binds the material to the mesh
  97538. * @param world defines the world transformation matrix
  97539. * @param mesh defines the mesh to bind the material to
  97540. * @param effectOverride - If provided, use this effect instead of internal effect
  97541. */
  97542. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97543. protected _afterBind(mesh?: Mesh): void;
  97544. /**
  97545. * Gets the active textures from the material
  97546. * @returns an array of textures
  97547. */
  97548. getActiveTextures(): BaseTexture[];
  97549. /**
  97550. * Specifies if the material uses a texture
  97551. * @param texture defines the texture to check against the material
  97552. * @returns a boolean specifying if the material uses the texture
  97553. */
  97554. hasTexture(texture: BaseTexture): boolean;
  97555. /**
  97556. * Makes a duplicate of the material, and gives it a new name
  97557. * @param name defines the new name for the duplicated material
  97558. * @returns the cloned material
  97559. */
  97560. clone(name: string): ShaderMaterial;
  97561. /**
  97562. * Disposes the material
  97563. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97564. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97565. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97566. */
  97567. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97568. /**
  97569. * Serializes this material in a JSON representation
  97570. * @returns the serialized material object
  97571. */
  97572. serialize(): any;
  97573. /**
  97574. * Creates a shader material from parsed shader material data
  97575. * @param source defines the JSON represnetation of the material
  97576. * @param scene defines the hosting scene
  97577. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97578. * @returns a new material
  97579. */
  97580. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97581. /**
  97582. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97583. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97584. * @param url defines the url to load from
  97585. * @param scene defines the hosting scene
  97586. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97587. * @returns a promise that will resolve to the new ShaderMaterial
  97588. */
  97589. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97590. /**
  97591. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97592. * @param snippetId defines the snippet to load
  97593. * @param scene defines the hosting scene
  97594. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97595. * @returns a promise that will resolve to the new ShaderMaterial
  97596. */
  97597. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97598. }
  97599. }
  97600. declare module BABYLON {
  97601. /** @hidden */
  97602. export var colorPixelShader: {
  97603. name: string;
  97604. shader: string;
  97605. };
  97606. }
  97607. declare module BABYLON {
  97608. /** @hidden */
  97609. export var colorVertexShader: {
  97610. name: string;
  97611. shader: string;
  97612. };
  97613. }
  97614. declare module BABYLON {
  97615. /**
  97616. * Line mesh
  97617. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97618. */
  97619. export class LinesMesh extends Mesh {
  97620. /**
  97621. * If vertex color should be applied to the mesh
  97622. */
  97623. readonly useVertexColor?: boolean | undefined;
  97624. /**
  97625. * If vertex alpha should be applied to the mesh
  97626. */
  97627. readonly useVertexAlpha?: boolean | undefined;
  97628. /**
  97629. * Color of the line (Default: White)
  97630. */
  97631. color: Color3;
  97632. /**
  97633. * Alpha of the line (Default: 1)
  97634. */
  97635. alpha: number;
  97636. /**
  97637. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97638. * This margin is expressed in world space coordinates, so its value may vary.
  97639. * Default value is 0.1
  97640. */
  97641. intersectionThreshold: number;
  97642. private _colorShader;
  97643. private color4;
  97644. /**
  97645. * Creates a new LinesMesh
  97646. * @param name defines the name
  97647. * @param scene defines the hosting scene
  97648. * @param parent defines the parent mesh if any
  97649. * @param source defines the optional source LinesMesh used to clone data from
  97650. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97651. * When false, achieved by calling a clone(), also passing False.
  97652. * This will make creation of children, recursive.
  97653. * @param useVertexColor defines if this LinesMesh supports vertex color
  97654. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97655. */
  97656. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97657. /**
  97658. * If vertex color should be applied to the mesh
  97659. */
  97660. useVertexColor?: boolean | undefined,
  97661. /**
  97662. * If vertex alpha should be applied to the mesh
  97663. */
  97664. useVertexAlpha?: boolean | undefined);
  97665. private _addClipPlaneDefine;
  97666. private _removeClipPlaneDefine;
  97667. isReady(): boolean;
  97668. /**
  97669. * Returns the string "LineMesh"
  97670. */
  97671. getClassName(): string;
  97672. /**
  97673. * @hidden
  97674. */
  97675. get material(): Material;
  97676. /**
  97677. * @hidden
  97678. */
  97679. set material(value: Material);
  97680. /**
  97681. * @hidden
  97682. */
  97683. get checkCollisions(): boolean;
  97684. /** @hidden */
  97685. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97686. /** @hidden */
  97687. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97688. /**
  97689. * Disposes of the line mesh
  97690. * @param doNotRecurse If children should be disposed
  97691. */
  97692. dispose(doNotRecurse?: boolean): void;
  97693. /**
  97694. * Returns a new LineMesh object cloned from the current one.
  97695. */
  97696. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97697. /**
  97698. * Creates a new InstancedLinesMesh object from the mesh model.
  97699. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97700. * @param name defines the name of the new instance
  97701. * @returns a new InstancedLinesMesh
  97702. */
  97703. createInstance(name: string): InstancedLinesMesh;
  97704. }
  97705. /**
  97706. * Creates an instance based on a source LinesMesh
  97707. */
  97708. export class InstancedLinesMesh extends InstancedMesh {
  97709. /**
  97710. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97711. * This margin is expressed in world space coordinates, so its value may vary.
  97712. * Initilized with the intersectionThreshold value of the source LinesMesh
  97713. */
  97714. intersectionThreshold: number;
  97715. constructor(name: string, source: LinesMesh);
  97716. /**
  97717. * Returns the string "InstancedLinesMesh".
  97718. */
  97719. getClassName(): string;
  97720. }
  97721. }
  97722. declare module BABYLON {
  97723. /** @hidden */
  97724. export var linePixelShader: {
  97725. name: string;
  97726. shader: string;
  97727. };
  97728. }
  97729. declare module BABYLON {
  97730. /** @hidden */
  97731. export var lineVertexShader: {
  97732. name: string;
  97733. shader: string;
  97734. };
  97735. }
  97736. declare module BABYLON {
  97737. interface Scene {
  97738. /** @hidden */
  97739. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97740. }
  97741. interface AbstractMesh {
  97742. /**
  97743. * Gets the edgesRenderer associated with the mesh
  97744. */
  97745. edgesRenderer: Nullable<EdgesRenderer>;
  97746. }
  97747. interface LinesMesh {
  97748. /**
  97749. * Enables the edge rendering mode on the mesh.
  97750. * This mode makes the mesh edges visible
  97751. * @param epsilon defines the maximal distance between two angles to detect a face
  97752. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97753. * @returns the currentAbstractMesh
  97754. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97755. */
  97756. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97757. }
  97758. interface InstancedLinesMesh {
  97759. /**
  97760. * Enables the edge rendering mode on the mesh.
  97761. * This mode makes the mesh edges visible
  97762. * @param epsilon defines the maximal distance between two angles to detect a face
  97763. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97764. * @returns the current InstancedLinesMesh
  97765. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97766. */
  97767. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97768. }
  97769. /**
  97770. * Defines the minimum contract an Edges renderer should follow.
  97771. */
  97772. export interface IEdgesRenderer extends IDisposable {
  97773. /**
  97774. * Gets or sets a boolean indicating if the edgesRenderer is active
  97775. */
  97776. isEnabled: boolean;
  97777. /**
  97778. * Renders the edges of the attached mesh,
  97779. */
  97780. render(): void;
  97781. /**
  97782. * Checks wether or not the edges renderer is ready to render.
  97783. * @return true if ready, otherwise false.
  97784. */
  97785. isReady(): boolean;
  97786. /**
  97787. * List of instances to render in case the source mesh has instances
  97788. */
  97789. customInstances: SmartArray<Matrix>;
  97790. }
  97791. /**
  97792. * Defines the additional options of the edges renderer
  97793. */
  97794. export interface IEdgesRendererOptions {
  97795. /**
  97796. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97797. * If not defined, the default value is true
  97798. */
  97799. useAlternateEdgeFinder?: boolean;
  97800. /**
  97801. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97802. * If not defined, the default value is true.
  97803. * 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)
  97804. * This option is used only if useAlternateEdgeFinder = true
  97805. */
  97806. useFastVertexMerger?: boolean;
  97807. /**
  97808. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97809. * The default value is 1e-6
  97810. * This option is used only if useAlternateEdgeFinder = true
  97811. */
  97812. epsilonVertexMerge?: number;
  97813. /**
  97814. * 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
  97815. * 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.
  97816. * This option is used only if useAlternateEdgeFinder = true
  97817. */
  97818. applyTessellation?: boolean;
  97819. /**
  97820. * 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
  97821. * The default value is 1e-6
  97822. * This option is used only if useAlternateEdgeFinder = true
  97823. */
  97824. epsilonVertexAligned?: number;
  97825. }
  97826. /**
  97827. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97828. */
  97829. export class EdgesRenderer implements IEdgesRenderer {
  97830. /**
  97831. * Define the size of the edges with an orthographic camera
  97832. */
  97833. edgesWidthScalerForOrthographic: number;
  97834. /**
  97835. * Define the size of the edges with a perspective camera
  97836. */
  97837. edgesWidthScalerForPerspective: number;
  97838. protected _source: AbstractMesh;
  97839. protected _linesPositions: number[];
  97840. protected _linesNormals: number[];
  97841. protected _linesIndices: number[];
  97842. protected _epsilon: number;
  97843. protected _indicesCount: number;
  97844. protected _lineShader: ShaderMaterial;
  97845. protected _ib: DataBuffer;
  97846. protected _buffers: {
  97847. [key: string]: Nullable<VertexBuffer>;
  97848. };
  97849. protected _buffersForInstances: {
  97850. [key: string]: Nullable<VertexBuffer>;
  97851. };
  97852. protected _checkVerticesInsteadOfIndices: boolean;
  97853. protected _options: Nullable<IEdgesRendererOptions>;
  97854. private _meshRebuildObserver;
  97855. private _meshDisposeObserver;
  97856. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97857. isEnabled: boolean;
  97858. /**
  97859. * List of instances to render in case the source mesh has instances
  97860. */
  97861. customInstances: SmartArray<Matrix>;
  97862. private static GetShader;
  97863. /**
  97864. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97865. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97866. * @param source Mesh used to create edges
  97867. * @param epsilon sum of angles in adjacency to check for edge
  97868. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97869. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97870. * @param options The options to apply when generating the edges
  97871. */
  97872. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97873. protected _prepareRessources(): void;
  97874. /** @hidden */
  97875. _rebuild(): void;
  97876. /**
  97877. * Releases the required resources for the edges renderer
  97878. */
  97879. dispose(): void;
  97880. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97881. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97882. /**
  97883. * Checks if the pair of p0 and p1 is en edge
  97884. * @param faceIndex
  97885. * @param edge
  97886. * @param faceNormals
  97887. * @param p0
  97888. * @param p1
  97889. * @private
  97890. */
  97891. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97892. /**
  97893. * push line into the position, normal and index buffer
  97894. * @protected
  97895. */
  97896. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97897. /**
  97898. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97899. */
  97900. private _tessellateTriangle;
  97901. private _generateEdgesLinesAlternate;
  97902. /**
  97903. * Generates lines edges from adjacencjes
  97904. * @private
  97905. */
  97906. _generateEdgesLines(): void;
  97907. /**
  97908. * Checks wether or not the edges renderer is ready to render.
  97909. * @return true if ready, otherwise false.
  97910. */
  97911. isReady(): boolean;
  97912. /**
  97913. * Renders the edges of the attached mesh,
  97914. */
  97915. render(): void;
  97916. }
  97917. /**
  97918. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97919. */
  97920. export class LineEdgesRenderer extends EdgesRenderer {
  97921. /**
  97922. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97923. * @param source LineMesh used to generate edges
  97924. * @param epsilon not important (specified angle for edge detection)
  97925. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97926. */
  97927. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97928. /**
  97929. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97930. */
  97931. _generateEdgesLines(): void;
  97932. }
  97933. }
  97934. declare module BABYLON {
  97935. /**
  97936. * This represents the object necessary to create a rendering group.
  97937. * This is exclusively used and created by the rendering manager.
  97938. * To modify the behavior, you use the available helpers in your scene or meshes.
  97939. * @hidden
  97940. */
  97941. export class RenderingGroup {
  97942. index: number;
  97943. private static _zeroVector;
  97944. private _scene;
  97945. private _opaqueSubMeshes;
  97946. private _transparentSubMeshes;
  97947. private _alphaTestSubMeshes;
  97948. private _depthOnlySubMeshes;
  97949. private _particleSystems;
  97950. private _spriteManagers;
  97951. private _opaqueSortCompareFn;
  97952. private _alphaTestSortCompareFn;
  97953. private _transparentSortCompareFn;
  97954. private _renderOpaque;
  97955. private _renderAlphaTest;
  97956. private _renderTransparent;
  97957. /** @hidden */
  97958. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97959. onBeforeTransparentRendering: () => void;
  97960. /**
  97961. * Set the opaque sort comparison function.
  97962. * If null the sub meshes will be render in the order they were created
  97963. */
  97964. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97965. /**
  97966. * Set the alpha test sort comparison function.
  97967. * If null the sub meshes will be render in the order they were created
  97968. */
  97969. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97970. /**
  97971. * Set the transparent sort comparison function.
  97972. * If null the sub meshes will be render in the order they were created
  97973. */
  97974. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97975. /**
  97976. * Creates a new rendering group.
  97977. * @param index The rendering group index
  97978. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97979. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97980. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97981. */
  97982. 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>);
  97983. /**
  97984. * Render all the sub meshes contained in the group.
  97985. * @param customRenderFunction Used to override the default render behaviour of the group.
  97986. * @returns true if rendered some submeshes.
  97987. */
  97988. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97989. /**
  97990. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97991. * @param subMeshes The submeshes to render
  97992. */
  97993. private renderOpaqueSorted;
  97994. /**
  97995. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97996. * @param subMeshes The submeshes to render
  97997. */
  97998. private renderAlphaTestSorted;
  97999. /**
  98000. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  98001. * @param subMeshes The submeshes to render
  98002. */
  98003. private renderTransparentSorted;
  98004. /**
  98005. * Renders the submeshes in a specified order.
  98006. * @param subMeshes The submeshes to sort before render
  98007. * @param sortCompareFn The comparison function use to sort
  98008. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  98009. * @param transparent Specifies to activate blending if true
  98010. */
  98011. private static renderSorted;
  98012. /**
  98013. * Renders the submeshes in the order they were dispatched (no sort applied).
  98014. * @param subMeshes The submeshes to render
  98015. */
  98016. private static renderUnsorted;
  98017. /**
  98018. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98019. * are rendered back to front if in the same alpha index.
  98020. *
  98021. * @param a The first submesh
  98022. * @param b The second submesh
  98023. * @returns The result of the comparison
  98024. */
  98025. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  98026. /**
  98027. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98028. * are rendered back to front.
  98029. *
  98030. * @param a The first submesh
  98031. * @param b The second submesh
  98032. * @returns The result of the comparison
  98033. */
  98034. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  98035. /**
  98036. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98037. * are rendered front to back (prevent overdraw).
  98038. *
  98039. * @param a The first submesh
  98040. * @param b The second submesh
  98041. * @returns The result of the comparison
  98042. */
  98043. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  98044. /**
  98045. * Resets the different lists of submeshes to prepare a new frame.
  98046. */
  98047. prepare(): void;
  98048. dispose(): void;
  98049. /**
  98050. * Inserts the submesh in its correct queue depending on its material.
  98051. * @param subMesh The submesh to dispatch
  98052. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98053. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98054. */
  98055. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98056. dispatchSprites(spriteManager: ISpriteManager): void;
  98057. dispatchParticles(particleSystem: IParticleSystem): void;
  98058. private _renderParticles;
  98059. private _renderSprites;
  98060. }
  98061. }
  98062. declare module BABYLON {
  98063. /**
  98064. * Interface describing the different options available in the rendering manager
  98065. * regarding Auto Clear between groups.
  98066. */
  98067. export interface IRenderingManagerAutoClearSetup {
  98068. /**
  98069. * Defines whether or not autoclear is enable.
  98070. */
  98071. autoClear: boolean;
  98072. /**
  98073. * Defines whether or not to autoclear the depth buffer.
  98074. */
  98075. depth: boolean;
  98076. /**
  98077. * Defines whether or not to autoclear the stencil buffer.
  98078. */
  98079. stencil: boolean;
  98080. }
  98081. /**
  98082. * This class is used by the onRenderingGroupObservable
  98083. */
  98084. export class RenderingGroupInfo {
  98085. /**
  98086. * The Scene that being rendered
  98087. */
  98088. scene: Scene;
  98089. /**
  98090. * The camera currently used for the rendering pass
  98091. */
  98092. camera: Nullable<Camera>;
  98093. /**
  98094. * The ID of the renderingGroup being processed
  98095. */
  98096. renderingGroupId: number;
  98097. }
  98098. /**
  98099. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98100. * It is enable to manage the different groups as well as the different necessary sort functions.
  98101. * This should not be used directly aside of the few static configurations
  98102. */
  98103. export class RenderingManager {
  98104. /**
  98105. * The max id used for rendering groups (not included)
  98106. */
  98107. static MAX_RENDERINGGROUPS: number;
  98108. /**
  98109. * The min id used for rendering groups (included)
  98110. */
  98111. static MIN_RENDERINGGROUPS: number;
  98112. /**
  98113. * Used to globally prevent autoclearing scenes.
  98114. */
  98115. static AUTOCLEAR: boolean;
  98116. /**
  98117. * @hidden
  98118. */
  98119. _useSceneAutoClearSetup: boolean;
  98120. private _scene;
  98121. private _renderingGroups;
  98122. private _depthStencilBufferAlreadyCleaned;
  98123. private _autoClearDepthStencil;
  98124. private _customOpaqueSortCompareFn;
  98125. private _customAlphaTestSortCompareFn;
  98126. private _customTransparentSortCompareFn;
  98127. private _renderingGroupInfo;
  98128. /**
  98129. * Instantiates a new rendering group for a particular scene
  98130. * @param scene Defines the scene the groups belongs to
  98131. */
  98132. constructor(scene: Scene);
  98133. private _clearDepthStencilBuffer;
  98134. /**
  98135. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98136. * @hidden
  98137. */
  98138. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98139. /**
  98140. * Resets the different information of the group to prepare a new frame
  98141. * @hidden
  98142. */
  98143. reset(): void;
  98144. /**
  98145. * Dispose and release the group and its associated resources.
  98146. * @hidden
  98147. */
  98148. dispose(): void;
  98149. /**
  98150. * Clear the info related to rendering groups preventing retention points during dispose.
  98151. */
  98152. freeRenderingGroups(): void;
  98153. private _prepareRenderingGroup;
  98154. /**
  98155. * Add a sprite manager to the rendering manager in order to render it this frame.
  98156. * @param spriteManager Define the sprite manager to render
  98157. */
  98158. dispatchSprites(spriteManager: ISpriteManager): void;
  98159. /**
  98160. * Add a particle system to the rendering manager in order to render it this frame.
  98161. * @param particleSystem Define the particle system to render
  98162. */
  98163. dispatchParticles(particleSystem: IParticleSystem): void;
  98164. /**
  98165. * Add a submesh to the manager in order to render it this frame
  98166. * @param subMesh The submesh to dispatch
  98167. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98168. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98169. */
  98170. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98171. /**
  98172. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98173. * This allowed control for front to back rendering or reversly depending of the special needs.
  98174. *
  98175. * @param renderingGroupId The rendering group id corresponding to its index
  98176. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98177. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98178. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98179. */
  98180. 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;
  98181. /**
  98182. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98183. *
  98184. * @param renderingGroupId The rendering group id corresponding to its index
  98185. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98186. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98187. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98188. */
  98189. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98190. /**
  98191. * Gets the current auto clear configuration for one rendering group of the rendering
  98192. * manager.
  98193. * @param index the rendering group index to get the information for
  98194. * @returns The auto clear setup for the requested rendering group
  98195. */
  98196. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98197. }
  98198. }
  98199. declare module BABYLON {
  98200. /**
  98201. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98202. */
  98203. export interface ICustomShaderOptions {
  98204. /**
  98205. * Gets or sets the custom shader name to use
  98206. */
  98207. shaderName: string;
  98208. /**
  98209. * The list of attribute names used in the shader
  98210. */
  98211. attributes?: string[];
  98212. /**
  98213. * The list of unifrom names used in the shader
  98214. */
  98215. uniforms?: string[];
  98216. /**
  98217. * The list of sampler names used in the shader
  98218. */
  98219. samplers?: string[];
  98220. /**
  98221. * The list of defines used in the shader
  98222. */
  98223. defines?: string[];
  98224. }
  98225. /**
  98226. * Interface to implement to create a shadow generator compatible with BJS.
  98227. */
  98228. export interface IShadowGenerator {
  98229. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98230. id: string;
  98231. /**
  98232. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98233. * @returns The render target texture if present otherwise, null
  98234. */
  98235. getShadowMap(): Nullable<RenderTargetTexture>;
  98236. /**
  98237. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98238. * @param subMesh The submesh we want to render in the shadow map
  98239. * @param useInstances Defines wether will draw in the map using instances
  98240. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98241. * @returns true if ready otherwise, false
  98242. */
  98243. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98244. /**
  98245. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98246. * @param defines Defines of the material we want to update
  98247. * @param lightIndex Index of the light in the enabled light list of the material
  98248. */
  98249. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98250. /**
  98251. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98252. * defined in the generator but impacting the effect).
  98253. * It implies the unifroms available on the materials are the standard BJS ones.
  98254. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98255. * @param effect The effect we are binfing the information for
  98256. */
  98257. bindShadowLight(lightIndex: string, effect: Effect): void;
  98258. /**
  98259. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98260. * (eq to shadow prjection matrix * light transform matrix)
  98261. * @returns The transform matrix used to create the shadow map
  98262. */
  98263. getTransformMatrix(): Matrix;
  98264. /**
  98265. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98266. * Cube and 2D textures for instance.
  98267. */
  98268. recreateShadowMap(): void;
  98269. /**
  98270. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98271. * @param onCompiled Callback triggered at the and of the effects compilation
  98272. * @param options Sets of optional options forcing the compilation with different modes
  98273. */
  98274. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98275. useInstances: boolean;
  98276. }>): void;
  98277. /**
  98278. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98279. * @param options Sets of optional options forcing the compilation with different modes
  98280. * @returns A promise that resolves when the compilation completes
  98281. */
  98282. forceCompilationAsync(options?: Partial<{
  98283. useInstances: boolean;
  98284. }>): Promise<void>;
  98285. /**
  98286. * Serializes the shadow generator setup to a json object.
  98287. * @returns The serialized JSON object
  98288. */
  98289. serialize(): any;
  98290. /**
  98291. * Disposes the Shadow map and related Textures and effects.
  98292. */
  98293. dispose(): void;
  98294. }
  98295. /**
  98296. * Default implementation IShadowGenerator.
  98297. * This is the main object responsible of generating shadows in the framework.
  98298. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98299. */
  98300. export class ShadowGenerator implements IShadowGenerator {
  98301. /**
  98302. * Name of the shadow generator class
  98303. */
  98304. static CLASSNAME: string;
  98305. /**
  98306. * Shadow generator mode None: no filtering applied.
  98307. */
  98308. static readonly FILTER_NONE: number;
  98309. /**
  98310. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98311. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98312. */
  98313. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98314. /**
  98315. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98316. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98317. */
  98318. static readonly FILTER_POISSONSAMPLING: number;
  98319. /**
  98320. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98321. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98322. */
  98323. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98324. /**
  98325. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98326. * edge artifacts on steep falloff.
  98327. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98328. */
  98329. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98330. /**
  98331. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98332. * edge artifacts on steep falloff.
  98333. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98334. */
  98335. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98336. /**
  98337. * Shadow generator mode PCF: Percentage Closer Filtering
  98338. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98339. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98340. */
  98341. static readonly FILTER_PCF: number;
  98342. /**
  98343. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98344. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98345. * Contact Hardening
  98346. */
  98347. static readonly FILTER_PCSS: number;
  98348. /**
  98349. * Reserved for PCF and PCSS
  98350. * Highest Quality.
  98351. *
  98352. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98353. *
  98354. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98355. */
  98356. static readonly QUALITY_HIGH: number;
  98357. /**
  98358. * Reserved for PCF and PCSS
  98359. * Good tradeoff for quality/perf cross devices
  98360. *
  98361. * Execute PCF on a 3*3 kernel.
  98362. *
  98363. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98364. */
  98365. static readonly QUALITY_MEDIUM: number;
  98366. /**
  98367. * Reserved for PCF and PCSS
  98368. * The lowest quality but the fastest.
  98369. *
  98370. * Execute PCF on a 1*1 kernel.
  98371. *
  98372. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98373. */
  98374. static readonly QUALITY_LOW: number;
  98375. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98376. id: string;
  98377. /** Gets or sets the custom shader name to use */
  98378. customShaderOptions: ICustomShaderOptions;
  98379. /**
  98380. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98381. */
  98382. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98383. /**
  98384. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98385. */
  98386. onAfterShadowMapRenderObservable: Observable<Effect>;
  98387. /**
  98388. * Observable triggered before a mesh is rendered in the shadow map.
  98389. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98390. */
  98391. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98392. /**
  98393. * Observable triggered after a mesh is rendered in the shadow map.
  98394. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98395. */
  98396. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98397. protected _bias: number;
  98398. /**
  98399. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98400. */
  98401. get bias(): number;
  98402. /**
  98403. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98404. */
  98405. set bias(bias: number);
  98406. protected _normalBias: number;
  98407. /**
  98408. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98409. */
  98410. get normalBias(): number;
  98411. /**
  98412. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98413. */
  98414. set normalBias(normalBias: number);
  98415. protected _blurBoxOffset: number;
  98416. /**
  98417. * Gets the blur box offset: offset applied during the blur pass.
  98418. * Only useful if useKernelBlur = false
  98419. */
  98420. get blurBoxOffset(): number;
  98421. /**
  98422. * Sets the blur box offset: offset applied during the blur pass.
  98423. * Only useful if useKernelBlur = false
  98424. */
  98425. set blurBoxOffset(value: number);
  98426. protected _blurScale: number;
  98427. /**
  98428. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98429. * 2 means half of the size.
  98430. */
  98431. get blurScale(): number;
  98432. /**
  98433. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98434. * 2 means half of the size.
  98435. */
  98436. set blurScale(value: number);
  98437. protected _blurKernel: number;
  98438. /**
  98439. * Gets the blur kernel: kernel size of the blur pass.
  98440. * Only useful if useKernelBlur = true
  98441. */
  98442. get blurKernel(): number;
  98443. /**
  98444. * Sets the blur kernel: kernel size of the blur pass.
  98445. * Only useful if useKernelBlur = true
  98446. */
  98447. set blurKernel(value: number);
  98448. protected _useKernelBlur: boolean;
  98449. /**
  98450. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98451. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98452. */
  98453. get useKernelBlur(): boolean;
  98454. /**
  98455. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98456. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98457. */
  98458. set useKernelBlur(value: boolean);
  98459. protected _depthScale: number;
  98460. /**
  98461. * Gets the depth scale used in ESM mode.
  98462. */
  98463. get depthScale(): number;
  98464. /**
  98465. * Sets the depth scale used in ESM mode.
  98466. * This can override the scale stored on the light.
  98467. */
  98468. set depthScale(value: number);
  98469. protected _validateFilter(filter: number): number;
  98470. protected _filter: number;
  98471. /**
  98472. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98473. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98474. */
  98475. get filter(): number;
  98476. /**
  98477. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98478. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98479. */
  98480. set filter(value: number);
  98481. /**
  98482. * Gets if the current filter is set to Poisson Sampling.
  98483. */
  98484. get usePoissonSampling(): boolean;
  98485. /**
  98486. * Sets the current filter to Poisson Sampling.
  98487. */
  98488. set usePoissonSampling(value: boolean);
  98489. /**
  98490. * Gets if the current filter is set to ESM.
  98491. */
  98492. get useExponentialShadowMap(): boolean;
  98493. /**
  98494. * Sets the current filter is to ESM.
  98495. */
  98496. set useExponentialShadowMap(value: boolean);
  98497. /**
  98498. * Gets if the current filter is set to filtered ESM.
  98499. */
  98500. get useBlurExponentialShadowMap(): boolean;
  98501. /**
  98502. * Gets if the current filter is set to filtered ESM.
  98503. */
  98504. set useBlurExponentialShadowMap(value: boolean);
  98505. /**
  98506. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98507. * exponential to prevent steep falloff artifacts).
  98508. */
  98509. get useCloseExponentialShadowMap(): boolean;
  98510. /**
  98511. * Sets the current filter to "close ESM" (using the inverse of the
  98512. * exponential to prevent steep falloff artifacts).
  98513. */
  98514. set useCloseExponentialShadowMap(value: boolean);
  98515. /**
  98516. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98517. * exponential to prevent steep falloff artifacts).
  98518. */
  98519. get useBlurCloseExponentialShadowMap(): boolean;
  98520. /**
  98521. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98522. * exponential to prevent steep falloff artifacts).
  98523. */
  98524. set useBlurCloseExponentialShadowMap(value: boolean);
  98525. /**
  98526. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98527. */
  98528. get usePercentageCloserFiltering(): boolean;
  98529. /**
  98530. * Sets the current filter to "PCF" (percentage closer filtering).
  98531. */
  98532. set usePercentageCloserFiltering(value: boolean);
  98533. protected _filteringQuality: number;
  98534. /**
  98535. * Gets the PCF or PCSS Quality.
  98536. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98537. */
  98538. get filteringQuality(): number;
  98539. /**
  98540. * Sets the PCF or PCSS Quality.
  98541. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98542. */
  98543. set filteringQuality(filteringQuality: number);
  98544. /**
  98545. * Gets if the current filter is set to "PCSS" (contact hardening).
  98546. */
  98547. get useContactHardeningShadow(): boolean;
  98548. /**
  98549. * Sets the current filter to "PCSS" (contact hardening).
  98550. */
  98551. set useContactHardeningShadow(value: boolean);
  98552. protected _contactHardeningLightSizeUVRatio: number;
  98553. /**
  98554. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98555. * Using a ratio helps keeping shape stability independently of the map size.
  98556. *
  98557. * It does not account for the light projection as it was having too much
  98558. * instability during the light setup or during light position changes.
  98559. *
  98560. * Only valid if useContactHardeningShadow is true.
  98561. */
  98562. get contactHardeningLightSizeUVRatio(): number;
  98563. /**
  98564. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98565. * Using a ratio helps keeping shape stability independently of the map size.
  98566. *
  98567. * It does not account for the light projection as it was having too much
  98568. * instability during the light setup or during light position changes.
  98569. *
  98570. * Only valid if useContactHardeningShadow is true.
  98571. */
  98572. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98573. protected _darkness: number;
  98574. /** Gets or sets the actual darkness of a shadow */
  98575. get darkness(): number;
  98576. set darkness(value: number);
  98577. /**
  98578. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98579. * 0 means strongest and 1 would means no shadow.
  98580. * @returns the darkness.
  98581. */
  98582. getDarkness(): number;
  98583. /**
  98584. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98585. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98586. * @returns the shadow generator allowing fluent coding.
  98587. */
  98588. setDarkness(darkness: number): ShadowGenerator;
  98589. protected _transparencyShadow: boolean;
  98590. /** Gets or sets the ability to have transparent shadow */
  98591. get transparencyShadow(): boolean;
  98592. set transparencyShadow(value: boolean);
  98593. /**
  98594. * Sets the ability to have transparent shadow (boolean).
  98595. * @param transparent True if transparent else False
  98596. * @returns the shadow generator allowing fluent coding
  98597. */
  98598. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98599. /**
  98600. * Enables or disables shadows with varying strength based on the transparency
  98601. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98602. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98603. * mesh.visibility * alphaTexture.a
  98604. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98605. */
  98606. enableSoftTransparentShadow: boolean;
  98607. protected _shadowMap: Nullable<RenderTargetTexture>;
  98608. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98609. /**
  98610. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98611. * @returns The render target texture if present otherwise, null
  98612. */
  98613. getShadowMap(): Nullable<RenderTargetTexture>;
  98614. /**
  98615. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98616. * @returns The render target texture if the shadow map is present otherwise, null
  98617. */
  98618. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98619. /**
  98620. * Gets the class name of that object
  98621. * @returns "ShadowGenerator"
  98622. */
  98623. getClassName(): string;
  98624. /**
  98625. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98626. * @param mesh Mesh to add
  98627. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98628. * @returns the Shadow Generator itself
  98629. */
  98630. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98631. /**
  98632. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98633. * @param mesh Mesh to remove
  98634. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98635. * @returns the Shadow Generator itself
  98636. */
  98637. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98638. /**
  98639. * Controls the extent to which the shadows fade out at the edge of the frustum
  98640. */
  98641. frustumEdgeFalloff: number;
  98642. protected _light: IShadowLight;
  98643. /**
  98644. * Returns the associated light object.
  98645. * @returns the light generating the shadow
  98646. */
  98647. getLight(): IShadowLight;
  98648. /**
  98649. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98650. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98651. * It might on the other hand introduce peter panning.
  98652. */
  98653. forceBackFacesOnly: boolean;
  98654. protected _scene: Scene;
  98655. protected _lightDirection: Vector3;
  98656. protected _effect: Effect;
  98657. protected _viewMatrix: Matrix;
  98658. protected _projectionMatrix: Matrix;
  98659. protected _transformMatrix: Matrix;
  98660. protected _cachedPosition: Vector3;
  98661. protected _cachedDirection: Vector3;
  98662. protected _cachedDefines: string;
  98663. protected _currentRenderID: number;
  98664. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98665. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98666. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98667. protected _blurPostProcesses: PostProcess[];
  98668. protected _mapSize: number;
  98669. protected _currentFaceIndex: number;
  98670. protected _currentFaceIndexCache: number;
  98671. protected _textureType: number;
  98672. protected _defaultTextureMatrix: Matrix;
  98673. protected _storedUniqueId: Nullable<number>;
  98674. /** @hidden */
  98675. static _SceneComponentInitialization: (scene: Scene) => void;
  98676. /**
  98677. * Gets or sets the size of the texture what stores the shadows
  98678. */
  98679. get mapSize(): number;
  98680. set mapSize(size: number);
  98681. /**
  98682. * Creates a ShadowGenerator object.
  98683. * A ShadowGenerator is the required tool to use the shadows.
  98684. * Each light casting shadows needs to use its own ShadowGenerator.
  98685. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98686. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98687. * @param light The light object generating the shadows.
  98688. * @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.
  98689. */
  98690. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98691. protected _initializeGenerator(): void;
  98692. protected _createTargetRenderTexture(): void;
  98693. protected _initializeShadowMap(): void;
  98694. protected _initializeBlurRTTAndPostProcesses(): void;
  98695. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98696. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98697. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98698. protected _applyFilterValues(): void;
  98699. /**
  98700. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98701. * @param onCompiled Callback triggered at the and of the effects compilation
  98702. * @param options Sets of optional options forcing the compilation with different modes
  98703. */
  98704. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98705. useInstances: boolean;
  98706. }>): void;
  98707. /**
  98708. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98709. * @param options Sets of optional options forcing the compilation with different modes
  98710. * @returns A promise that resolves when the compilation completes
  98711. */
  98712. forceCompilationAsync(options?: Partial<{
  98713. useInstances: boolean;
  98714. }>): Promise<void>;
  98715. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98716. private _prepareShadowDefines;
  98717. /**
  98718. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98719. * @param subMesh The submesh we want to render in the shadow map
  98720. * @param useInstances Defines wether will draw in the map using instances
  98721. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98722. * @returns true if ready otherwise, false
  98723. */
  98724. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98725. /**
  98726. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98727. * @param defines Defines of the material we want to update
  98728. * @param lightIndex Index of the light in the enabled light list of the material
  98729. */
  98730. prepareDefines(defines: any, lightIndex: number): void;
  98731. /**
  98732. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98733. * defined in the generator but impacting the effect).
  98734. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98735. * @param effect The effect we are binfing the information for
  98736. */
  98737. bindShadowLight(lightIndex: string, effect: Effect): void;
  98738. /**
  98739. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98740. * (eq to shadow prjection matrix * light transform matrix)
  98741. * @returns The transform matrix used to create the shadow map
  98742. */
  98743. getTransformMatrix(): Matrix;
  98744. /**
  98745. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98746. * Cube and 2D textures for instance.
  98747. */
  98748. recreateShadowMap(): void;
  98749. protected _disposeBlurPostProcesses(): void;
  98750. protected _disposeRTTandPostProcesses(): void;
  98751. /**
  98752. * Disposes the ShadowGenerator.
  98753. * Returns nothing.
  98754. */
  98755. dispose(): void;
  98756. /**
  98757. * Serializes the shadow generator setup to a json object.
  98758. * @returns The serialized JSON object
  98759. */
  98760. serialize(): any;
  98761. /**
  98762. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98763. * @param parsedShadowGenerator The JSON object to parse
  98764. * @param scene The scene to create the shadow map for
  98765. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98766. * @returns The parsed shadow generator
  98767. */
  98768. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98769. }
  98770. }
  98771. declare module BABYLON {
  98772. /**
  98773. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98774. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98775. * 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.
  98776. */
  98777. export abstract class Light extends Node {
  98778. /**
  98779. * Falloff Default: light is falling off following the material specification:
  98780. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98781. */
  98782. static readonly FALLOFF_DEFAULT: number;
  98783. /**
  98784. * Falloff Physical: light is falling off following the inverse squared distance law.
  98785. */
  98786. static readonly FALLOFF_PHYSICAL: number;
  98787. /**
  98788. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98789. * to enhance interoperability with other engines.
  98790. */
  98791. static readonly FALLOFF_GLTF: number;
  98792. /**
  98793. * Falloff Standard: light is falling off like in the standard material
  98794. * to enhance interoperability with other materials.
  98795. */
  98796. static readonly FALLOFF_STANDARD: number;
  98797. /**
  98798. * If every light affecting the material is in this lightmapMode,
  98799. * material.lightmapTexture adds or multiplies
  98800. * (depends on material.useLightmapAsShadowmap)
  98801. * after every other light calculations.
  98802. */
  98803. static readonly LIGHTMAP_DEFAULT: number;
  98804. /**
  98805. * material.lightmapTexture as only diffuse lighting from this light
  98806. * adds only specular lighting from this light
  98807. * adds dynamic shadows
  98808. */
  98809. static readonly LIGHTMAP_SPECULAR: number;
  98810. /**
  98811. * material.lightmapTexture as only lighting
  98812. * no light calculation from this light
  98813. * only adds dynamic shadows from this light
  98814. */
  98815. static readonly LIGHTMAP_SHADOWSONLY: number;
  98816. /**
  98817. * Each light type uses the default quantity according to its type:
  98818. * point/spot lights use luminous intensity
  98819. * directional lights use illuminance
  98820. */
  98821. static readonly INTENSITYMODE_AUTOMATIC: number;
  98822. /**
  98823. * lumen (lm)
  98824. */
  98825. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98826. /**
  98827. * candela (lm/sr)
  98828. */
  98829. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98830. /**
  98831. * lux (lm/m^2)
  98832. */
  98833. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98834. /**
  98835. * nit (cd/m^2)
  98836. */
  98837. static readonly INTENSITYMODE_LUMINANCE: number;
  98838. /**
  98839. * Light type const id of the point light.
  98840. */
  98841. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98842. /**
  98843. * Light type const id of the directional light.
  98844. */
  98845. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98846. /**
  98847. * Light type const id of the spot light.
  98848. */
  98849. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98850. /**
  98851. * Light type const id of the hemispheric light.
  98852. */
  98853. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98854. /**
  98855. * Diffuse gives the basic color to an object.
  98856. */
  98857. diffuse: Color3;
  98858. /**
  98859. * Specular produces a highlight color on an object.
  98860. * Note: This is note affecting PBR materials.
  98861. */
  98862. specular: Color3;
  98863. /**
  98864. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98865. * falling off base on range or angle.
  98866. * This can be set to any values in Light.FALLOFF_x.
  98867. *
  98868. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98869. * other types of materials.
  98870. */
  98871. falloffType: number;
  98872. /**
  98873. * Strength of the light.
  98874. * Note: By default it is define in the framework own unit.
  98875. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98876. */
  98877. intensity: number;
  98878. private _range;
  98879. protected _inverseSquaredRange: number;
  98880. /**
  98881. * Defines how far from the source the light is impacting in scene units.
  98882. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98883. */
  98884. get range(): number;
  98885. /**
  98886. * Defines how far from the source the light is impacting in scene units.
  98887. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98888. */
  98889. set range(value: number);
  98890. /**
  98891. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98892. * of light.
  98893. */
  98894. private _photometricScale;
  98895. private _intensityMode;
  98896. /**
  98897. * Gets the photometric scale used to interpret the intensity.
  98898. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98899. */
  98900. get intensityMode(): number;
  98901. /**
  98902. * Sets the photometric scale used to interpret the intensity.
  98903. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98904. */
  98905. set intensityMode(value: number);
  98906. private _radius;
  98907. /**
  98908. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98909. */
  98910. get radius(): number;
  98911. /**
  98912. * sets the light radius used by PBR Materials to simulate soft area lights.
  98913. */
  98914. set radius(value: number);
  98915. private _renderPriority;
  98916. /**
  98917. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98918. * exceeding the number allowed of the materials.
  98919. */
  98920. renderPriority: number;
  98921. private _shadowEnabled;
  98922. /**
  98923. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98924. * the current shadow generator.
  98925. */
  98926. get shadowEnabled(): boolean;
  98927. /**
  98928. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98929. * the current shadow generator.
  98930. */
  98931. set shadowEnabled(value: boolean);
  98932. private _includedOnlyMeshes;
  98933. /**
  98934. * Gets the only meshes impacted by this light.
  98935. */
  98936. get includedOnlyMeshes(): AbstractMesh[];
  98937. /**
  98938. * Sets the only meshes impacted by this light.
  98939. */
  98940. set includedOnlyMeshes(value: AbstractMesh[]);
  98941. private _excludedMeshes;
  98942. /**
  98943. * Gets the meshes not impacted by this light.
  98944. */
  98945. get excludedMeshes(): AbstractMesh[];
  98946. /**
  98947. * Sets the meshes not impacted by this light.
  98948. */
  98949. set excludedMeshes(value: AbstractMesh[]);
  98950. private _excludeWithLayerMask;
  98951. /**
  98952. * Gets the layer id use to find what meshes are not impacted by the light.
  98953. * Inactive if 0
  98954. */
  98955. get excludeWithLayerMask(): number;
  98956. /**
  98957. * Sets the layer id use to find what meshes are not impacted by the light.
  98958. * Inactive if 0
  98959. */
  98960. set excludeWithLayerMask(value: number);
  98961. private _includeOnlyWithLayerMask;
  98962. /**
  98963. * Gets the layer id use to find what meshes are impacted by the light.
  98964. * Inactive if 0
  98965. */
  98966. get includeOnlyWithLayerMask(): number;
  98967. /**
  98968. * Sets the layer id use to find what meshes are impacted by the light.
  98969. * Inactive if 0
  98970. */
  98971. set includeOnlyWithLayerMask(value: number);
  98972. private _lightmapMode;
  98973. /**
  98974. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98975. */
  98976. get lightmapMode(): number;
  98977. /**
  98978. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98979. */
  98980. set lightmapMode(value: number);
  98981. /**
  98982. * Shadow generator associted to the light.
  98983. * @hidden Internal use only.
  98984. */
  98985. _shadowGenerator: Nullable<IShadowGenerator>;
  98986. /**
  98987. * @hidden Internal use only.
  98988. */
  98989. _excludedMeshesIds: string[];
  98990. /**
  98991. * @hidden Internal use only.
  98992. */
  98993. _includedOnlyMeshesIds: string[];
  98994. /**
  98995. * The current light unifom buffer.
  98996. * @hidden Internal use only.
  98997. */
  98998. _uniformBuffer: UniformBuffer;
  98999. /** @hidden */
  99000. _renderId: number;
  99001. /**
  99002. * Creates a Light object in the scene.
  99003. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99004. * @param name The firendly name of the light
  99005. * @param scene The scene the light belongs too
  99006. */
  99007. constructor(name: string, scene: Scene);
  99008. protected abstract _buildUniformLayout(): void;
  99009. /**
  99010. * Sets the passed Effect "effect" with the Light information.
  99011. * @param effect The effect to update
  99012. * @param lightIndex The index of the light in the effect to update
  99013. * @returns The light
  99014. */
  99015. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  99016. /**
  99017. * Sets the passed Effect "effect" with the Light textures.
  99018. * @param effect The effect to update
  99019. * @param lightIndex The index of the light in the effect to update
  99020. * @returns The light
  99021. */
  99022. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  99023. /**
  99024. * Binds the lights information from the scene to the effect for the given mesh.
  99025. * @param lightIndex Light index
  99026. * @param scene The scene where the light belongs to
  99027. * @param effect The effect we are binding the data to
  99028. * @param useSpecular Defines if specular is supported
  99029. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99030. */
  99031. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99032. /**
  99033. * Sets the passed Effect "effect" with the Light information.
  99034. * @param effect The effect to update
  99035. * @param lightDataUniformName The uniform used to store light data (position or direction)
  99036. * @returns The light
  99037. */
  99038. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  99039. /**
  99040. * Returns the string "Light".
  99041. * @returns the class name
  99042. */
  99043. getClassName(): string;
  99044. /** @hidden */
  99045. readonly _isLight: boolean;
  99046. /**
  99047. * Converts the light information to a readable string for debug purpose.
  99048. * @param fullDetails Supports for multiple levels of logging within scene loading
  99049. * @returns the human readable light info
  99050. */
  99051. toString(fullDetails?: boolean): string;
  99052. /** @hidden */
  99053. protected _syncParentEnabledState(): void;
  99054. /**
  99055. * Set the enabled state of this node.
  99056. * @param value - the new enabled state
  99057. */
  99058. setEnabled(value: boolean): void;
  99059. /**
  99060. * Returns the Light associated shadow generator if any.
  99061. * @return the associated shadow generator.
  99062. */
  99063. getShadowGenerator(): Nullable<IShadowGenerator>;
  99064. /**
  99065. * Returns a Vector3, the absolute light position in the World.
  99066. * @returns the world space position of the light
  99067. */
  99068. getAbsolutePosition(): Vector3;
  99069. /**
  99070. * Specifies if the light will affect the passed mesh.
  99071. * @param mesh The mesh to test against the light
  99072. * @return true the mesh is affected otherwise, false.
  99073. */
  99074. canAffectMesh(mesh: AbstractMesh): boolean;
  99075. /**
  99076. * Sort function to order lights for rendering.
  99077. * @param a First Light object to compare to second.
  99078. * @param b Second Light object to compare first.
  99079. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  99080. */
  99081. static CompareLightsPriority(a: Light, b: Light): number;
  99082. /**
  99083. * Releases resources associated with this node.
  99084. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99085. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99086. */
  99087. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99088. /**
  99089. * Returns the light type ID (integer).
  99090. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99091. */
  99092. getTypeID(): number;
  99093. /**
  99094. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99095. * @returns the scaled intensity in intensity mode unit
  99096. */
  99097. getScaledIntensity(): number;
  99098. /**
  99099. * Returns a new Light object, named "name", from the current one.
  99100. * @param name The name of the cloned light
  99101. * @param newParent The parent of this light, if it has one
  99102. * @returns the new created light
  99103. */
  99104. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99105. /**
  99106. * Serializes the current light into a Serialization object.
  99107. * @returns the serialized object.
  99108. */
  99109. serialize(): any;
  99110. /**
  99111. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99112. * This new light is named "name" and added to the passed scene.
  99113. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99114. * @param name The friendly name of the light
  99115. * @param scene The scene the new light will belong to
  99116. * @returns the constructor function
  99117. */
  99118. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99119. /**
  99120. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99121. * @param parsedLight The JSON representation of the light
  99122. * @param scene The scene to create the parsed light in
  99123. * @returns the created light after parsing
  99124. */
  99125. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99126. private _hookArrayForExcluded;
  99127. private _hookArrayForIncludedOnly;
  99128. private _resyncMeshes;
  99129. /**
  99130. * Forces the meshes to update their light related information in their rendering used effects
  99131. * @hidden Internal Use Only
  99132. */
  99133. _markMeshesAsLightDirty(): void;
  99134. /**
  99135. * Recomputes the cached photometric scale if needed.
  99136. */
  99137. private _computePhotometricScale;
  99138. /**
  99139. * Returns the Photometric Scale according to the light type and intensity mode.
  99140. */
  99141. private _getPhotometricScale;
  99142. /**
  99143. * Reorder the light in the scene according to their defined priority.
  99144. * @hidden Internal Use Only
  99145. */
  99146. _reorderLightsInScene(): void;
  99147. /**
  99148. * Prepares the list of defines specific to the light type.
  99149. * @param defines the list of defines
  99150. * @param lightIndex defines the index of the light for the effect
  99151. */
  99152. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99153. }
  99154. }
  99155. declare module BABYLON {
  99156. /**
  99157. * Configuration needed for prepass-capable materials
  99158. */
  99159. export class PrePassConfiguration {
  99160. /**
  99161. * Previous world matrices of meshes carrying this material
  99162. * Used for computing velocity
  99163. */
  99164. previousWorldMatrices: {
  99165. [index: number]: Matrix;
  99166. };
  99167. /**
  99168. * Previous view project matrix
  99169. * Used for computing velocity
  99170. */
  99171. previousViewProjection: Matrix;
  99172. /**
  99173. * Previous bones of meshes carrying this material
  99174. * Used for computing velocity
  99175. */
  99176. previousBones: {
  99177. [index: number]: Float32Array;
  99178. };
  99179. /**
  99180. * Add the required uniforms to the current list.
  99181. * @param uniforms defines the current uniform list.
  99182. */
  99183. static AddUniforms(uniforms: string[]): void;
  99184. /**
  99185. * Add the required samplers to the current list.
  99186. * @param samplers defines the current sampler list.
  99187. */
  99188. static AddSamplers(samplers: string[]): void;
  99189. /**
  99190. * Binds the material data.
  99191. * @param effect defines the effect to update
  99192. * @param scene defines the scene the material belongs to.
  99193. * @param mesh The mesh
  99194. * @param world World matrix of this mesh
  99195. * @param isFrozen Is the material frozen
  99196. */
  99197. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99198. }
  99199. }
  99200. declare module BABYLON {
  99201. /**
  99202. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99203. * This is the base of the follow, arc rotate cameras and Free camera
  99204. * @see https://doc.babylonjs.com/features/cameras
  99205. */
  99206. export class TargetCamera extends Camera {
  99207. private static _RigCamTransformMatrix;
  99208. private static _TargetTransformMatrix;
  99209. private static _TargetFocalPoint;
  99210. private _tmpUpVector;
  99211. private _tmpTargetVector;
  99212. /**
  99213. * Define the current direction the camera is moving to
  99214. */
  99215. cameraDirection: Vector3;
  99216. /**
  99217. * Define the current rotation the camera is rotating to
  99218. */
  99219. cameraRotation: Vector2;
  99220. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99221. ignoreParentScaling: boolean;
  99222. /**
  99223. * When set, the up vector of the camera will be updated by the rotation of the camera
  99224. */
  99225. updateUpVectorFromRotation: boolean;
  99226. private _tmpQuaternion;
  99227. /**
  99228. * Define the current rotation of the camera
  99229. */
  99230. rotation: Vector3;
  99231. /**
  99232. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99233. */
  99234. rotationQuaternion: Quaternion;
  99235. /**
  99236. * Define the current speed of the camera
  99237. */
  99238. speed: number;
  99239. /**
  99240. * Add constraint to the camera to prevent it to move freely in all directions and
  99241. * around all axis.
  99242. */
  99243. noRotationConstraint: boolean;
  99244. /**
  99245. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99246. * panning
  99247. */
  99248. invertRotation: boolean;
  99249. /**
  99250. * Speed multiplier for inverse camera panning
  99251. */
  99252. inverseRotationSpeed: number;
  99253. /**
  99254. * Define the current target of the camera as an object or a position.
  99255. */
  99256. lockedTarget: any;
  99257. /** @hidden */
  99258. _currentTarget: Vector3;
  99259. /** @hidden */
  99260. _initialFocalDistance: number;
  99261. /** @hidden */
  99262. _viewMatrix: Matrix;
  99263. /** @hidden */
  99264. _camMatrix: Matrix;
  99265. /** @hidden */
  99266. _cameraTransformMatrix: Matrix;
  99267. /** @hidden */
  99268. _cameraRotationMatrix: Matrix;
  99269. /** @hidden */
  99270. _referencePoint: Vector3;
  99271. /** @hidden */
  99272. _transformedReferencePoint: Vector3;
  99273. /** @hidden */
  99274. _reset: () => void;
  99275. private _defaultUp;
  99276. /**
  99277. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99278. * This is the base of the follow, arc rotate cameras and Free camera
  99279. * @see https://doc.babylonjs.com/features/cameras
  99280. * @param name Defines the name of the camera in the scene
  99281. * @param position Defines the start position of the camera in the scene
  99282. * @param scene Defines the scene the camera belongs to
  99283. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99284. */
  99285. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99286. /**
  99287. * Gets the position in front of the camera at a given distance.
  99288. * @param distance The distance from the camera we want the position to be
  99289. * @returns the position
  99290. */
  99291. getFrontPosition(distance: number): Vector3;
  99292. /** @hidden */
  99293. _getLockedTargetPosition(): Nullable<Vector3>;
  99294. private _storedPosition;
  99295. private _storedRotation;
  99296. private _storedRotationQuaternion;
  99297. /**
  99298. * Store current camera state of the camera (fov, position, rotation, etc..)
  99299. * @returns the camera
  99300. */
  99301. storeState(): Camera;
  99302. /**
  99303. * Restored camera state. You must call storeState() first
  99304. * @returns whether it was successful or not
  99305. * @hidden
  99306. */
  99307. _restoreStateValues(): boolean;
  99308. /** @hidden */
  99309. _initCache(): void;
  99310. /** @hidden */
  99311. _updateCache(ignoreParentClass?: boolean): void;
  99312. /** @hidden */
  99313. _isSynchronizedViewMatrix(): boolean;
  99314. /** @hidden */
  99315. _computeLocalCameraSpeed(): number;
  99316. /**
  99317. * Defines the target the camera should look at.
  99318. * @param target Defines the new target as a Vector or a mesh
  99319. */
  99320. setTarget(target: Vector3): void;
  99321. /**
  99322. * Defines the target point of the camera.
  99323. * The camera looks towards it form the radius distance.
  99324. */
  99325. get target(): Vector3;
  99326. set target(value: Vector3);
  99327. /**
  99328. * Return the current target position of the camera. This value is expressed in local space.
  99329. * @returns the target position
  99330. */
  99331. getTarget(): Vector3;
  99332. /** @hidden */
  99333. _decideIfNeedsToMove(): boolean;
  99334. /** @hidden */
  99335. _updatePosition(): void;
  99336. /** @hidden */
  99337. _checkInputs(): void;
  99338. protected _updateCameraRotationMatrix(): void;
  99339. /**
  99340. * 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)
  99341. * @returns the current camera
  99342. */
  99343. private _rotateUpVectorWithCameraRotationMatrix;
  99344. private _cachedRotationZ;
  99345. private _cachedQuaternionRotationZ;
  99346. /** @hidden */
  99347. _getViewMatrix(): Matrix;
  99348. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99349. /**
  99350. * @hidden
  99351. */
  99352. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99353. /**
  99354. * @hidden
  99355. */
  99356. _updateRigCameras(): void;
  99357. private _getRigCamPositionAndTarget;
  99358. /**
  99359. * Gets the current object class name.
  99360. * @return the class name
  99361. */
  99362. getClassName(): string;
  99363. }
  99364. }
  99365. declare module BABYLON {
  99366. /**
  99367. * Gather the list of keyboard event types as constants.
  99368. */
  99369. export class KeyboardEventTypes {
  99370. /**
  99371. * The keydown event is fired when a key becomes active (pressed).
  99372. */
  99373. static readonly KEYDOWN: number;
  99374. /**
  99375. * The keyup event is fired when a key has been released.
  99376. */
  99377. static readonly KEYUP: number;
  99378. }
  99379. /**
  99380. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99381. */
  99382. export class KeyboardInfo {
  99383. /**
  99384. * Defines the type of event (KeyboardEventTypes)
  99385. */
  99386. type: number;
  99387. /**
  99388. * Defines the related dom event
  99389. */
  99390. event: KeyboardEvent;
  99391. /**
  99392. * Instantiates a new keyboard info.
  99393. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99394. * @param type Defines the type of event (KeyboardEventTypes)
  99395. * @param event Defines the related dom event
  99396. */
  99397. constructor(
  99398. /**
  99399. * Defines the type of event (KeyboardEventTypes)
  99400. */
  99401. type: number,
  99402. /**
  99403. * Defines the related dom event
  99404. */
  99405. event: KeyboardEvent);
  99406. }
  99407. /**
  99408. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99409. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99410. */
  99411. export class KeyboardInfoPre extends KeyboardInfo {
  99412. /**
  99413. * Defines the type of event (KeyboardEventTypes)
  99414. */
  99415. type: number;
  99416. /**
  99417. * Defines the related dom event
  99418. */
  99419. event: KeyboardEvent;
  99420. /**
  99421. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99422. */
  99423. skipOnPointerObservable: boolean;
  99424. /**
  99425. * Instantiates a new keyboard pre info.
  99426. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99427. * @param type Defines the type of event (KeyboardEventTypes)
  99428. * @param event Defines the related dom event
  99429. */
  99430. constructor(
  99431. /**
  99432. * Defines the type of event (KeyboardEventTypes)
  99433. */
  99434. type: number,
  99435. /**
  99436. * Defines the related dom event
  99437. */
  99438. event: KeyboardEvent);
  99439. }
  99440. }
  99441. declare module BABYLON {
  99442. /**
  99443. * Manage the keyboard inputs to control the movement of a free camera.
  99444. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99445. */
  99446. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99447. /**
  99448. * Defines the camera the input is attached to.
  99449. */
  99450. camera: FreeCamera;
  99451. /**
  99452. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99453. */
  99454. keysUp: number[];
  99455. /**
  99456. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99457. */
  99458. keysUpward: number[];
  99459. /**
  99460. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99461. */
  99462. keysDown: number[];
  99463. /**
  99464. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99465. */
  99466. keysDownward: number[];
  99467. /**
  99468. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99469. */
  99470. keysLeft: number[];
  99471. /**
  99472. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99473. */
  99474. keysRight: number[];
  99475. private _keys;
  99476. private _onCanvasBlurObserver;
  99477. private _onKeyboardObserver;
  99478. private _engine;
  99479. private _scene;
  99480. /**
  99481. * Attach the input controls to a specific dom element to get the input from.
  99482. * @param element Defines the element the controls should be listened from
  99483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99484. */
  99485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99486. /**
  99487. * Detach the current controls from the specified dom element.
  99488. * @param element Defines the element to stop listening the inputs from
  99489. */
  99490. detachControl(element: Nullable<HTMLElement>): void;
  99491. /**
  99492. * Update the current camera state depending on the inputs that have been used this frame.
  99493. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99494. */
  99495. checkInputs(): void;
  99496. /**
  99497. * Gets the class name of the current intput.
  99498. * @returns the class name
  99499. */
  99500. getClassName(): string;
  99501. /** @hidden */
  99502. _onLostFocus(): void;
  99503. /**
  99504. * Get the friendly name associated with the input class.
  99505. * @returns the input friendly name
  99506. */
  99507. getSimpleName(): string;
  99508. }
  99509. }
  99510. declare module BABYLON {
  99511. /**
  99512. * Gather the list of pointer event types as constants.
  99513. */
  99514. export class PointerEventTypes {
  99515. /**
  99516. * 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.
  99517. */
  99518. static readonly POINTERDOWN: number;
  99519. /**
  99520. * The pointerup event is fired when a pointer is no longer active.
  99521. */
  99522. static readonly POINTERUP: number;
  99523. /**
  99524. * The pointermove event is fired when a pointer changes coordinates.
  99525. */
  99526. static readonly POINTERMOVE: number;
  99527. /**
  99528. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99529. */
  99530. static readonly POINTERWHEEL: number;
  99531. /**
  99532. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99533. */
  99534. static readonly POINTERPICK: number;
  99535. /**
  99536. * The pointertap event is fired when a the object has been touched and released without drag.
  99537. */
  99538. static readonly POINTERTAP: number;
  99539. /**
  99540. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99541. */
  99542. static readonly POINTERDOUBLETAP: number;
  99543. }
  99544. /**
  99545. * Base class of pointer info types.
  99546. */
  99547. export class PointerInfoBase {
  99548. /**
  99549. * Defines the type of event (PointerEventTypes)
  99550. */
  99551. type: number;
  99552. /**
  99553. * Defines the related dom event
  99554. */
  99555. event: PointerEvent | MouseWheelEvent;
  99556. /**
  99557. * Instantiates the base class of pointers info.
  99558. * @param type Defines the type of event (PointerEventTypes)
  99559. * @param event Defines the related dom event
  99560. */
  99561. constructor(
  99562. /**
  99563. * Defines the type of event (PointerEventTypes)
  99564. */
  99565. type: number,
  99566. /**
  99567. * Defines the related dom event
  99568. */
  99569. event: PointerEvent | MouseWheelEvent);
  99570. }
  99571. /**
  99572. * This class is used to store pointer related info for the onPrePointerObservable event.
  99573. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99574. */
  99575. export class PointerInfoPre extends PointerInfoBase {
  99576. /**
  99577. * Ray from a pointer if availible (eg. 6dof controller)
  99578. */
  99579. ray: Nullable<Ray>;
  99580. /**
  99581. * Defines the local position of the pointer on the canvas.
  99582. */
  99583. localPosition: Vector2;
  99584. /**
  99585. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99586. */
  99587. skipOnPointerObservable: boolean;
  99588. /**
  99589. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99590. * @param type Defines the type of event (PointerEventTypes)
  99591. * @param event Defines the related dom event
  99592. * @param localX Defines the local x coordinates of the pointer when the event occured
  99593. * @param localY Defines the local y coordinates of the pointer when the event occured
  99594. */
  99595. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99596. }
  99597. /**
  99598. * This type contains all the data related to a pointer event in Babylon.js.
  99599. * 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.
  99600. */
  99601. export class PointerInfo extends PointerInfoBase {
  99602. /**
  99603. * Defines the picking info associated to the info (if any)\
  99604. */
  99605. pickInfo: Nullable<PickingInfo>;
  99606. /**
  99607. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99608. * @param type Defines the type of event (PointerEventTypes)
  99609. * @param event Defines the related dom event
  99610. * @param pickInfo Defines the picking info associated to the info (if any)\
  99611. */
  99612. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99613. /**
  99614. * Defines the picking info associated to the info (if any)\
  99615. */
  99616. pickInfo: Nullable<PickingInfo>);
  99617. }
  99618. /**
  99619. * Data relating to a touch event on the screen.
  99620. */
  99621. export interface PointerTouch {
  99622. /**
  99623. * X coordinate of touch.
  99624. */
  99625. x: number;
  99626. /**
  99627. * Y coordinate of touch.
  99628. */
  99629. y: number;
  99630. /**
  99631. * Id of touch. Unique for each finger.
  99632. */
  99633. pointerId: number;
  99634. /**
  99635. * Event type passed from DOM.
  99636. */
  99637. type: any;
  99638. }
  99639. }
  99640. declare module BABYLON {
  99641. /**
  99642. * Manage the mouse inputs to control the movement of a free camera.
  99643. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99644. */
  99645. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99646. /**
  99647. * Define if touch is enabled in the mouse input
  99648. */
  99649. touchEnabled: boolean;
  99650. /**
  99651. * Defines the camera the input is attached to.
  99652. */
  99653. camera: FreeCamera;
  99654. /**
  99655. * Defines the buttons associated with the input to handle camera move.
  99656. */
  99657. buttons: number[];
  99658. /**
  99659. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99660. */
  99661. angularSensibility: number;
  99662. private _pointerInput;
  99663. private _onMouseMove;
  99664. private _observer;
  99665. private previousPosition;
  99666. /**
  99667. * Observable for when a pointer move event occurs containing the move offset
  99668. */
  99669. onPointerMovedObservable: Observable<{
  99670. offsetX: number;
  99671. offsetY: number;
  99672. }>;
  99673. /**
  99674. * @hidden
  99675. * If the camera should be rotated automatically based on pointer movement
  99676. */
  99677. _allowCameraRotation: boolean;
  99678. /**
  99679. * Manage the mouse inputs to control the movement of a free camera.
  99680. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99681. * @param touchEnabled Defines if touch is enabled or not
  99682. */
  99683. constructor(
  99684. /**
  99685. * Define if touch is enabled in the mouse input
  99686. */
  99687. touchEnabled?: boolean);
  99688. /**
  99689. * Attach the input controls to a specific dom element to get the input from.
  99690. * @param element Defines the element the controls should be listened from
  99691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99692. */
  99693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99694. /**
  99695. * Called on JS contextmenu event.
  99696. * Override this method to provide functionality.
  99697. */
  99698. protected onContextMenu(evt: PointerEvent): void;
  99699. /**
  99700. * Detach the current controls from the specified dom element.
  99701. * @param element Defines the element to stop listening the inputs from
  99702. */
  99703. detachControl(element: Nullable<HTMLElement>): void;
  99704. /**
  99705. * Gets the class name of the current intput.
  99706. * @returns the class name
  99707. */
  99708. getClassName(): string;
  99709. /**
  99710. * Get the friendly name associated with the input class.
  99711. * @returns the input friendly name
  99712. */
  99713. getSimpleName(): string;
  99714. }
  99715. }
  99716. declare module BABYLON {
  99717. /**
  99718. * Manage the touch inputs to control the movement of a free camera.
  99719. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99720. */
  99721. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99722. /**
  99723. * Define if mouse events can be treated as touch events
  99724. */
  99725. allowMouse: boolean;
  99726. /**
  99727. * Defines the camera the input is attached to.
  99728. */
  99729. camera: FreeCamera;
  99730. /**
  99731. * Defines the touch sensibility for rotation.
  99732. * The higher the faster.
  99733. */
  99734. touchAngularSensibility: number;
  99735. /**
  99736. * Defines the touch sensibility for move.
  99737. * The higher the faster.
  99738. */
  99739. touchMoveSensibility: number;
  99740. private _offsetX;
  99741. private _offsetY;
  99742. private _pointerPressed;
  99743. private _pointerInput;
  99744. private _observer;
  99745. private _onLostFocus;
  99746. /**
  99747. * Manage the touch inputs to control the movement of a free camera.
  99748. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99749. * @param allowMouse Defines if mouse events can be treated as touch events
  99750. */
  99751. constructor(
  99752. /**
  99753. * Define if mouse events can be treated as touch events
  99754. */
  99755. allowMouse?: boolean);
  99756. /**
  99757. * Attach the input controls to a specific dom element to get the input from.
  99758. * @param element Defines the element the controls should be listened from
  99759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99760. */
  99761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99762. /**
  99763. * Detach the current controls from the specified dom element.
  99764. * @param element Defines the element to stop listening the inputs from
  99765. */
  99766. detachControl(element: Nullable<HTMLElement>): void;
  99767. /**
  99768. * Update the current camera state depending on the inputs that have been used this frame.
  99769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99770. */
  99771. checkInputs(): void;
  99772. /**
  99773. * Gets the class name of the current intput.
  99774. * @returns the class name
  99775. */
  99776. getClassName(): string;
  99777. /**
  99778. * Get the friendly name associated with the input class.
  99779. * @returns the input friendly name
  99780. */
  99781. getSimpleName(): string;
  99782. }
  99783. }
  99784. declare module BABYLON {
  99785. /**
  99786. * Default Inputs manager for the FreeCamera.
  99787. * It groups all the default supported inputs for ease of use.
  99788. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99789. */
  99790. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99791. /**
  99792. * @hidden
  99793. */
  99794. _mouseInput: Nullable<FreeCameraMouseInput>;
  99795. /**
  99796. * Instantiates a new FreeCameraInputsManager.
  99797. * @param camera Defines the camera the inputs belong to
  99798. */
  99799. constructor(camera: FreeCamera);
  99800. /**
  99801. * Add keyboard input support to the input manager.
  99802. * @returns the current input manager
  99803. */
  99804. addKeyboard(): FreeCameraInputsManager;
  99805. /**
  99806. * Add mouse input support to the input manager.
  99807. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99808. * @returns the current input manager
  99809. */
  99810. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99811. /**
  99812. * Removes the mouse input support from the manager
  99813. * @returns the current input manager
  99814. */
  99815. removeMouse(): FreeCameraInputsManager;
  99816. /**
  99817. * Add touch input support to the input manager.
  99818. * @returns the current input manager
  99819. */
  99820. addTouch(): FreeCameraInputsManager;
  99821. /**
  99822. * Remove all attached input methods from a camera
  99823. */
  99824. clear(): void;
  99825. }
  99826. }
  99827. declare module BABYLON {
  99828. /**
  99829. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99830. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99831. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99832. */
  99833. export class FreeCamera extends TargetCamera {
  99834. /**
  99835. * Define the collision ellipsoid of the camera.
  99836. * This is helpful to simulate a camera body like the player body around the camera
  99837. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99838. */
  99839. ellipsoid: Vector3;
  99840. /**
  99841. * Define an offset for the position of the ellipsoid around the camera.
  99842. * This can be helpful to determine the center of the body near the gravity center of the body
  99843. * instead of its head.
  99844. */
  99845. ellipsoidOffset: Vector3;
  99846. /**
  99847. * Enable or disable collisions of the camera with the rest of the scene objects.
  99848. */
  99849. checkCollisions: boolean;
  99850. /**
  99851. * Enable or disable gravity on the camera.
  99852. */
  99853. applyGravity: boolean;
  99854. /**
  99855. * Define the input manager associated to the camera.
  99856. */
  99857. inputs: FreeCameraInputsManager;
  99858. /**
  99859. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99860. * Higher values reduce sensitivity.
  99861. */
  99862. get angularSensibility(): number;
  99863. /**
  99864. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99865. * Higher values reduce sensitivity.
  99866. */
  99867. set angularSensibility(value: number);
  99868. /**
  99869. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99870. */
  99871. get keysUp(): number[];
  99872. set keysUp(value: number[]);
  99873. /**
  99874. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99875. */
  99876. get keysUpward(): number[];
  99877. set keysUpward(value: number[]);
  99878. /**
  99879. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99880. */
  99881. get keysDown(): number[];
  99882. set keysDown(value: number[]);
  99883. /**
  99884. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99885. */
  99886. get keysDownward(): number[];
  99887. set keysDownward(value: number[]);
  99888. /**
  99889. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99890. */
  99891. get keysLeft(): number[];
  99892. set keysLeft(value: number[]);
  99893. /**
  99894. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99895. */
  99896. get keysRight(): number[];
  99897. set keysRight(value: number[]);
  99898. /**
  99899. * Event raised when the camera collide with a mesh in the scene.
  99900. */
  99901. onCollide: (collidedMesh: AbstractMesh) => void;
  99902. private _collider;
  99903. private _needMoveForGravity;
  99904. private _oldPosition;
  99905. private _diffPosition;
  99906. private _newPosition;
  99907. /** @hidden */
  99908. _localDirection: Vector3;
  99909. /** @hidden */
  99910. _transformedDirection: Vector3;
  99911. /**
  99912. * Instantiates a Free Camera.
  99913. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99914. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99915. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99916. * @param name Define the name of the camera in the scene
  99917. * @param position Define the start position of the camera in the scene
  99918. * @param scene Define the scene the camera belongs to
  99919. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99920. */
  99921. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99922. /**
  99923. * Attached controls to the current camera.
  99924. * @param element Defines the element the controls should be listened from
  99925. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99926. */
  99927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99928. /**
  99929. * Detach the current controls from the camera.
  99930. * The camera will stop reacting to inputs.
  99931. * @param element Defines the element to stop listening the inputs from
  99932. */
  99933. detachControl(element: HTMLElement): void;
  99934. private _collisionMask;
  99935. /**
  99936. * Define a collision mask to limit the list of object the camera can collide with
  99937. */
  99938. get collisionMask(): number;
  99939. set collisionMask(mask: number);
  99940. /** @hidden */
  99941. _collideWithWorld(displacement: Vector3): void;
  99942. private _onCollisionPositionChange;
  99943. /** @hidden */
  99944. _checkInputs(): void;
  99945. /** @hidden */
  99946. _decideIfNeedsToMove(): boolean;
  99947. /** @hidden */
  99948. _updatePosition(): void;
  99949. /**
  99950. * Destroy the camera and release the current resources hold by it.
  99951. */
  99952. dispose(): void;
  99953. /**
  99954. * Gets the current object class name.
  99955. * @return the class name
  99956. */
  99957. getClassName(): string;
  99958. }
  99959. }
  99960. declare module BABYLON {
  99961. /**
  99962. * Represents a gamepad control stick position
  99963. */
  99964. export class StickValues {
  99965. /**
  99966. * The x component of the control stick
  99967. */
  99968. x: number;
  99969. /**
  99970. * The y component of the control stick
  99971. */
  99972. y: number;
  99973. /**
  99974. * Initializes the gamepad x and y control stick values
  99975. * @param x The x component of the gamepad control stick value
  99976. * @param y The y component of the gamepad control stick value
  99977. */
  99978. constructor(
  99979. /**
  99980. * The x component of the control stick
  99981. */
  99982. x: number,
  99983. /**
  99984. * The y component of the control stick
  99985. */
  99986. y: number);
  99987. }
  99988. /**
  99989. * An interface which manages callbacks for gamepad button changes
  99990. */
  99991. export interface GamepadButtonChanges {
  99992. /**
  99993. * Called when a gamepad has been changed
  99994. */
  99995. changed: boolean;
  99996. /**
  99997. * Called when a gamepad press event has been triggered
  99998. */
  99999. pressChanged: boolean;
  100000. /**
  100001. * Called when a touch event has been triggered
  100002. */
  100003. touchChanged: boolean;
  100004. /**
  100005. * Called when a value has changed
  100006. */
  100007. valueChanged: boolean;
  100008. }
  100009. /**
  100010. * Represents a gamepad
  100011. */
  100012. export class Gamepad {
  100013. /**
  100014. * The id of the gamepad
  100015. */
  100016. id: string;
  100017. /**
  100018. * The index of the gamepad
  100019. */
  100020. index: number;
  100021. /**
  100022. * The browser gamepad
  100023. */
  100024. browserGamepad: any;
  100025. /**
  100026. * Specifies what type of gamepad this represents
  100027. */
  100028. type: number;
  100029. private _leftStick;
  100030. private _rightStick;
  100031. /** @hidden */
  100032. _isConnected: boolean;
  100033. private _leftStickAxisX;
  100034. private _leftStickAxisY;
  100035. private _rightStickAxisX;
  100036. private _rightStickAxisY;
  100037. /**
  100038. * Triggered when the left control stick has been changed
  100039. */
  100040. private _onleftstickchanged;
  100041. /**
  100042. * Triggered when the right control stick has been changed
  100043. */
  100044. private _onrightstickchanged;
  100045. /**
  100046. * Represents a gamepad controller
  100047. */
  100048. static GAMEPAD: number;
  100049. /**
  100050. * Represents a generic controller
  100051. */
  100052. static GENERIC: number;
  100053. /**
  100054. * Represents an XBox controller
  100055. */
  100056. static XBOX: number;
  100057. /**
  100058. * Represents a pose-enabled controller
  100059. */
  100060. static POSE_ENABLED: number;
  100061. /**
  100062. * Represents an Dual Shock controller
  100063. */
  100064. static DUALSHOCK: number;
  100065. /**
  100066. * Specifies whether the left control stick should be Y-inverted
  100067. */
  100068. protected _invertLeftStickY: boolean;
  100069. /**
  100070. * Specifies if the gamepad has been connected
  100071. */
  100072. get isConnected(): boolean;
  100073. /**
  100074. * Initializes the gamepad
  100075. * @param id The id of the gamepad
  100076. * @param index The index of the gamepad
  100077. * @param browserGamepad The browser gamepad
  100078. * @param leftStickX The x component of the left joystick
  100079. * @param leftStickY The y component of the left joystick
  100080. * @param rightStickX The x component of the right joystick
  100081. * @param rightStickY The y component of the right joystick
  100082. */
  100083. constructor(
  100084. /**
  100085. * The id of the gamepad
  100086. */
  100087. id: string,
  100088. /**
  100089. * The index of the gamepad
  100090. */
  100091. index: number,
  100092. /**
  100093. * The browser gamepad
  100094. */
  100095. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100096. /**
  100097. * Callback triggered when the left joystick has changed
  100098. * @param callback
  100099. */
  100100. onleftstickchanged(callback: (values: StickValues) => void): void;
  100101. /**
  100102. * Callback triggered when the right joystick has changed
  100103. * @param callback
  100104. */
  100105. onrightstickchanged(callback: (values: StickValues) => void): void;
  100106. /**
  100107. * Gets the left joystick
  100108. */
  100109. get leftStick(): StickValues;
  100110. /**
  100111. * Sets the left joystick values
  100112. */
  100113. set leftStick(newValues: StickValues);
  100114. /**
  100115. * Gets the right joystick
  100116. */
  100117. get rightStick(): StickValues;
  100118. /**
  100119. * Sets the right joystick value
  100120. */
  100121. set rightStick(newValues: StickValues);
  100122. /**
  100123. * Updates the gamepad joystick positions
  100124. */
  100125. update(): void;
  100126. /**
  100127. * Disposes the gamepad
  100128. */
  100129. dispose(): void;
  100130. }
  100131. /**
  100132. * Represents a generic gamepad
  100133. */
  100134. export class GenericPad extends Gamepad {
  100135. private _buttons;
  100136. private _onbuttondown;
  100137. private _onbuttonup;
  100138. /**
  100139. * Observable triggered when a button has been pressed
  100140. */
  100141. onButtonDownObservable: Observable<number>;
  100142. /**
  100143. * Observable triggered when a button has been released
  100144. */
  100145. onButtonUpObservable: Observable<number>;
  100146. /**
  100147. * Callback triggered when a button has been pressed
  100148. * @param callback Called when a button has been pressed
  100149. */
  100150. onbuttondown(callback: (buttonPressed: number) => void): void;
  100151. /**
  100152. * Callback triggered when a button has been released
  100153. * @param callback Called when a button has been released
  100154. */
  100155. onbuttonup(callback: (buttonReleased: number) => void): void;
  100156. /**
  100157. * Initializes the generic gamepad
  100158. * @param id The id of the generic gamepad
  100159. * @param index The index of the generic gamepad
  100160. * @param browserGamepad The browser gamepad
  100161. */
  100162. constructor(id: string, index: number, browserGamepad: any);
  100163. private _setButtonValue;
  100164. /**
  100165. * Updates the generic gamepad
  100166. */
  100167. update(): void;
  100168. /**
  100169. * Disposes the generic gamepad
  100170. */
  100171. dispose(): void;
  100172. }
  100173. }
  100174. declare module BABYLON {
  100175. /**
  100176. * Defines the types of pose enabled controllers that are supported
  100177. */
  100178. export enum PoseEnabledControllerType {
  100179. /**
  100180. * HTC Vive
  100181. */
  100182. VIVE = 0,
  100183. /**
  100184. * Oculus Rift
  100185. */
  100186. OCULUS = 1,
  100187. /**
  100188. * Windows mixed reality
  100189. */
  100190. WINDOWS = 2,
  100191. /**
  100192. * Samsung gear VR
  100193. */
  100194. GEAR_VR = 3,
  100195. /**
  100196. * Google Daydream
  100197. */
  100198. DAYDREAM = 4,
  100199. /**
  100200. * Generic
  100201. */
  100202. GENERIC = 5
  100203. }
  100204. /**
  100205. * Defines the MutableGamepadButton interface for the state of a gamepad button
  100206. */
  100207. export interface MutableGamepadButton {
  100208. /**
  100209. * Value of the button/trigger
  100210. */
  100211. value: number;
  100212. /**
  100213. * If the button/trigger is currently touched
  100214. */
  100215. touched: boolean;
  100216. /**
  100217. * If the button/trigger is currently pressed
  100218. */
  100219. pressed: boolean;
  100220. }
  100221. /**
  100222. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  100223. * @hidden
  100224. */
  100225. export interface ExtendedGamepadButton extends GamepadButton {
  100226. /**
  100227. * If the button/trigger is currently pressed
  100228. */
  100229. readonly pressed: boolean;
  100230. /**
  100231. * If the button/trigger is currently touched
  100232. */
  100233. readonly touched: boolean;
  100234. /**
  100235. * Value of the button/trigger
  100236. */
  100237. readonly value: number;
  100238. }
  100239. /** @hidden */
  100240. export interface _GamePadFactory {
  100241. /**
  100242. * Returns whether or not the current gamepad can be created for this type of controller.
  100243. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100244. * @returns true if it can be created, otherwise false
  100245. */
  100246. canCreate(gamepadInfo: any): boolean;
  100247. /**
  100248. * Creates a new instance of the Gamepad.
  100249. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100250. * @returns the new gamepad instance
  100251. */
  100252. create(gamepadInfo: any): Gamepad;
  100253. }
  100254. /**
  100255. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100256. */
  100257. export class PoseEnabledControllerHelper {
  100258. /** @hidden */
  100259. static _ControllerFactories: _GamePadFactory[];
  100260. /** @hidden */
  100261. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100262. /**
  100263. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100264. * @param vrGamepad the gamepad to initialized
  100265. * @returns a vr controller of the type the gamepad identified as
  100266. */
  100267. static InitiateController(vrGamepad: any): Gamepad;
  100268. }
  100269. /**
  100270. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100271. */
  100272. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100273. /**
  100274. * If the controller is used in a webXR session
  100275. */
  100276. isXR: boolean;
  100277. private _deviceRoomPosition;
  100278. private _deviceRoomRotationQuaternion;
  100279. /**
  100280. * The device position in babylon space
  100281. */
  100282. devicePosition: Vector3;
  100283. /**
  100284. * The device rotation in babylon space
  100285. */
  100286. deviceRotationQuaternion: Quaternion;
  100287. /**
  100288. * The scale factor of the device in babylon space
  100289. */
  100290. deviceScaleFactor: number;
  100291. /**
  100292. * (Likely devicePosition should be used instead) The device position in its room space
  100293. */
  100294. position: Vector3;
  100295. /**
  100296. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  100297. */
  100298. rotationQuaternion: Quaternion;
  100299. /**
  100300. * The type of controller (Eg. Windows mixed reality)
  100301. */
  100302. controllerType: PoseEnabledControllerType;
  100303. protected _calculatedPosition: Vector3;
  100304. private _calculatedRotation;
  100305. /**
  100306. * The raw pose from the device
  100307. */
  100308. rawPose: DevicePose;
  100309. private _trackPosition;
  100310. private _maxRotationDistFromHeadset;
  100311. private _draggedRoomRotation;
  100312. /**
  100313. * @hidden
  100314. */
  100315. _disableTrackPosition(fixedPosition: Vector3): void;
  100316. /**
  100317. * Internal, the mesh attached to the controller
  100318. * @hidden
  100319. */
  100320. _mesh: Nullable<AbstractMesh>;
  100321. private _poseControlledCamera;
  100322. private _leftHandSystemQuaternion;
  100323. /**
  100324. * Internal, matrix used to convert room space to babylon space
  100325. * @hidden
  100326. */
  100327. _deviceToWorld: Matrix;
  100328. /**
  100329. * Node to be used when casting a ray from the controller
  100330. * @hidden
  100331. */
  100332. _pointingPoseNode: Nullable<TransformNode>;
  100333. /**
  100334. * Name of the child mesh that can be used to cast a ray from the controller
  100335. */
  100336. static readonly POINTING_POSE: string;
  100337. /**
  100338. * Creates a new PoseEnabledController from a gamepad
  100339. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  100340. */
  100341. constructor(browserGamepad: any);
  100342. private _workingMatrix;
  100343. /**
  100344. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  100345. */
  100346. update(): void;
  100347. /**
  100348. * Updates only the pose device and mesh without doing any button event checking
  100349. */
  100350. protected _updatePoseAndMesh(): void;
  100351. /**
  100352. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  100353. * @param poseData raw pose fromthe device
  100354. */
  100355. updateFromDevice(poseData: DevicePose): void;
  100356. /**
  100357. * @hidden
  100358. */
  100359. _meshAttachedObservable: Observable<AbstractMesh>;
  100360. /**
  100361. * Attaches a mesh to the controller
  100362. * @param mesh the mesh to be attached
  100363. */
  100364. attachToMesh(mesh: AbstractMesh): void;
  100365. /**
  100366. * Attaches the controllers mesh to a camera
  100367. * @param camera the camera the mesh should be attached to
  100368. */
  100369. attachToPoseControlledCamera(camera: TargetCamera): void;
  100370. /**
  100371. * Disposes of the controller
  100372. */
  100373. dispose(): void;
  100374. /**
  100375. * The mesh that is attached to the controller
  100376. */
  100377. get mesh(): Nullable<AbstractMesh>;
  100378. /**
  100379. * Gets the ray of the controller in the direction the controller is pointing
  100380. * @param length the length the resulting ray should be
  100381. * @returns a ray in the direction the controller is pointing
  100382. */
  100383. getForwardRay(length?: number): Ray;
  100384. }
  100385. }
  100386. declare module BABYLON {
  100387. /**
  100388. * Defines the WebVRController object that represents controllers tracked in 3D space
  100389. */
  100390. export abstract class WebVRController extends PoseEnabledController {
  100391. /**
  100392. * Internal, the default controller model for the controller
  100393. */
  100394. protected _defaultModel: Nullable<AbstractMesh>;
  100395. /**
  100396. * Fired when the trigger state has changed
  100397. */
  100398. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100399. /**
  100400. * Fired when the main button state has changed
  100401. */
  100402. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100403. /**
  100404. * Fired when the secondary button state has changed
  100405. */
  100406. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100407. /**
  100408. * Fired when the pad state has changed
  100409. */
  100410. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  100411. /**
  100412. * Fired when controllers stick values have changed
  100413. */
  100414. onPadValuesChangedObservable: Observable<StickValues>;
  100415. /**
  100416. * Array of button availible on the controller
  100417. */
  100418. protected _buttons: Array<MutableGamepadButton>;
  100419. private _onButtonStateChange;
  100420. /**
  100421. * Fired when a controller button's state has changed
  100422. * @param callback the callback containing the button that was modified
  100423. */
  100424. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  100425. /**
  100426. * X and Y axis corresponding to the controllers joystick
  100427. */
  100428. pad: StickValues;
  100429. /**
  100430. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  100431. */
  100432. hand: string;
  100433. /**
  100434. * The default controller model for the controller
  100435. */
  100436. get defaultModel(): Nullable<AbstractMesh>;
  100437. /**
  100438. * Creates a new WebVRController from a gamepad
  100439. * @param vrGamepad the gamepad that the WebVRController should be created from
  100440. */
  100441. constructor(vrGamepad: any);
  100442. /**
  100443. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  100444. */
  100445. update(): void;
  100446. /**
  100447. * Function to be called when a button is modified
  100448. */
  100449. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100450. /**
  100451. * Loads a mesh and attaches it to the controller
  100452. * @param scene the scene the mesh should be added to
  100453. * @param meshLoaded callback for when the mesh has been loaded
  100454. */
  100455. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100456. private _setButtonValue;
  100457. private _changes;
  100458. private _checkChanges;
  100459. /**
  100460. * Disposes of th webVRCOntroller
  100461. */
  100462. dispose(): void;
  100463. }
  100464. }
  100465. declare module BABYLON {
  100466. /**
  100467. * The HemisphericLight simulates the ambient environment light,
  100468. * so the passed direction is the light reflection direction, not the incoming direction.
  100469. */
  100470. export class HemisphericLight extends Light {
  100471. /**
  100472. * The groundColor is the light in the opposite direction to the one specified during creation.
  100473. * 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.
  100474. */
  100475. groundColor: Color3;
  100476. /**
  100477. * The light reflection direction, not the incoming direction.
  100478. */
  100479. direction: Vector3;
  100480. /**
  100481. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100482. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100483. * The HemisphericLight can't cast shadows.
  100484. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100485. * @param name The friendly name of the light
  100486. * @param direction The direction of the light reflection
  100487. * @param scene The scene the light belongs to
  100488. */
  100489. constructor(name: string, direction: Vector3, scene: Scene);
  100490. protected _buildUniformLayout(): void;
  100491. /**
  100492. * Returns the string "HemisphericLight".
  100493. * @return The class name
  100494. */
  100495. getClassName(): string;
  100496. /**
  100497. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100498. * Returns the updated direction.
  100499. * @param target The target the direction should point to
  100500. * @return The computed direction
  100501. */
  100502. setDirectionToTarget(target: Vector3): Vector3;
  100503. /**
  100504. * Returns the shadow generator associated to the light.
  100505. * @returns Always null for hemispheric lights because it does not support shadows.
  100506. */
  100507. getShadowGenerator(): Nullable<IShadowGenerator>;
  100508. /**
  100509. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100510. * @param effect The effect to update
  100511. * @param lightIndex The index of the light in the effect to update
  100512. * @returns The hemispheric light
  100513. */
  100514. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100515. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100516. /**
  100517. * Computes the world matrix of the node
  100518. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100519. * @param useWasUpdatedFlag defines a reserved property
  100520. * @returns the world matrix
  100521. */
  100522. computeWorldMatrix(): Matrix;
  100523. /**
  100524. * Returns the integer 3.
  100525. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100526. */
  100527. getTypeID(): number;
  100528. /**
  100529. * Prepares the list of defines specific to the light type.
  100530. * @param defines the list of defines
  100531. * @param lightIndex defines the index of the light for the effect
  100532. */
  100533. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100534. }
  100535. }
  100536. declare module BABYLON {
  100537. /** @hidden */
  100538. export var vrMultiviewToSingleviewPixelShader: {
  100539. name: string;
  100540. shader: string;
  100541. };
  100542. }
  100543. declare module BABYLON {
  100544. /**
  100545. * Renders to multiple views with a single draw call
  100546. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100547. */
  100548. export class MultiviewRenderTarget extends RenderTargetTexture {
  100549. /**
  100550. * Creates a multiview render target
  100551. * @param scene scene used with the render target
  100552. * @param size the size of the render target (used for each view)
  100553. */
  100554. constructor(scene: Scene, size?: number | {
  100555. width: number;
  100556. height: number;
  100557. } | {
  100558. ratio: number;
  100559. });
  100560. /**
  100561. * @hidden
  100562. * @param faceIndex the face index, if its a cube texture
  100563. */
  100564. _bindFrameBuffer(faceIndex?: number): void;
  100565. /**
  100566. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100567. * @returns the view count
  100568. */
  100569. getViewCount(): number;
  100570. }
  100571. }
  100572. declare module BABYLON {
  100573. interface Engine {
  100574. /**
  100575. * Creates a new multiview render target
  100576. * @param width defines the width of the texture
  100577. * @param height defines the height of the texture
  100578. * @returns the created multiview texture
  100579. */
  100580. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100581. /**
  100582. * Binds a multiview framebuffer to be drawn to
  100583. * @param multiviewTexture texture to bind
  100584. */
  100585. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100586. }
  100587. interface Camera {
  100588. /**
  100589. * @hidden
  100590. * 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)
  100591. */
  100592. _useMultiviewToSingleView: boolean;
  100593. /**
  100594. * @hidden
  100595. * 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)
  100596. */
  100597. _multiviewTexture: Nullable<RenderTargetTexture>;
  100598. /**
  100599. * @hidden
  100600. * ensures the multiview texture of the camera exists and has the specified width/height
  100601. * @param width height to set on the multiview texture
  100602. * @param height width to set on the multiview texture
  100603. */
  100604. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100605. }
  100606. interface Scene {
  100607. /** @hidden */
  100608. _transformMatrixR: Matrix;
  100609. /** @hidden */
  100610. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100611. /** @hidden */
  100612. _createMultiviewUbo(): void;
  100613. /** @hidden */
  100614. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100615. /** @hidden */
  100616. _renderMultiviewToSingleView(camera: Camera): void;
  100617. }
  100618. }
  100619. declare module BABYLON {
  100620. /**
  100621. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100622. * This will not be used for webXR as it supports displaying texture arrays directly
  100623. */
  100624. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100625. /**
  100626. * Gets a string identifying the name of the class
  100627. * @returns "VRMultiviewToSingleviewPostProcess" string
  100628. */
  100629. getClassName(): string;
  100630. /**
  100631. * Initializes a VRMultiviewToSingleview
  100632. * @param name name of the post process
  100633. * @param camera camera to be applied to
  100634. * @param scaleFactor scaling factor to the size of the output texture
  100635. */
  100636. constructor(name: string, camera: Camera, scaleFactor: number);
  100637. }
  100638. }
  100639. declare module BABYLON {
  100640. /**
  100641. * Interface used to define additional presentation attributes
  100642. */
  100643. export interface IVRPresentationAttributes {
  100644. /**
  100645. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100646. */
  100647. highRefreshRate: boolean;
  100648. /**
  100649. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100650. */
  100651. foveationLevel: number;
  100652. }
  100653. interface Engine {
  100654. /** @hidden */
  100655. _vrDisplay: any;
  100656. /** @hidden */
  100657. _vrSupported: boolean;
  100658. /** @hidden */
  100659. _oldSize: Size;
  100660. /** @hidden */
  100661. _oldHardwareScaleFactor: number;
  100662. /** @hidden */
  100663. _vrExclusivePointerMode: boolean;
  100664. /** @hidden */
  100665. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100666. /** @hidden */
  100667. _onVRDisplayPointerRestricted: () => void;
  100668. /** @hidden */
  100669. _onVRDisplayPointerUnrestricted: () => void;
  100670. /** @hidden */
  100671. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100672. /** @hidden */
  100673. _onVrDisplayDisconnect: Nullable<() => void>;
  100674. /** @hidden */
  100675. _onVrDisplayPresentChange: Nullable<() => void>;
  100676. /**
  100677. * Observable signaled when VR display mode changes
  100678. */
  100679. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100680. /**
  100681. * Observable signaled when VR request present is complete
  100682. */
  100683. onVRRequestPresentComplete: Observable<boolean>;
  100684. /**
  100685. * Observable signaled when VR request present starts
  100686. */
  100687. onVRRequestPresentStart: Observable<Engine>;
  100688. /**
  100689. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100690. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100691. */
  100692. isInVRExclusivePointerMode: boolean;
  100693. /**
  100694. * Gets a boolean indicating if a webVR device was detected
  100695. * @returns true if a webVR device was detected
  100696. */
  100697. isVRDevicePresent(): boolean;
  100698. /**
  100699. * Gets the current webVR device
  100700. * @returns the current webVR device (or null)
  100701. */
  100702. getVRDevice(): any;
  100703. /**
  100704. * Initializes a webVR display and starts listening to display change events
  100705. * The onVRDisplayChangedObservable will be notified upon these changes
  100706. * @returns A promise containing a VRDisplay and if vr is supported
  100707. */
  100708. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100709. /** @hidden */
  100710. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100711. /**
  100712. * Gets or sets the presentation attributes used to configure VR rendering
  100713. */
  100714. vrPresentationAttributes?: IVRPresentationAttributes;
  100715. /**
  100716. * Call this function to switch to webVR mode
  100717. * Will do nothing if webVR is not supported or if there is no webVR device
  100718. * @param options the webvr options provided to the camera. mainly used for multiview
  100719. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100720. */
  100721. enableVR(options: WebVROptions): void;
  100722. /** @hidden */
  100723. _onVRFullScreenTriggered(): void;
  100724. }
  100725. }
  100726. declare module BABYLON {
  100727. /**
  100728. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100729. * IMPORTANT!! The data is right-hand data.
  100730. * @export
  100731. * @interface DevicePose
  100732. */
  100733. export interface DevicePose {
  100734. /**
  100735. * The position of the device, values in array are [x,y,z].
  100736. */
  100737. readonly position: Nullable<Float32Array>;
  100738. /**
  100739. * The linearVelocity of the device, values in array are [x,y,z].
  100740. */
  100741. readonly linearVelocity: Nullable<Float32Array>;
  100742. /**
  100743. * The linearAcceleration of the device, values in array are [x,y,z].
  100744. */
  100745. readonly linearAcceleration: Nullable<Float32Array>;
  100746. /**
  100747. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100748. */
  100749. readonly orientation: Nullable<Float32Array>;
  100750. /**
  100751. * The angularVelocity of the device, values in array are [x,y,z].
  100752. */
  100753. readonly angularVelocity: Nullable<Float32Array>;
  100754. /**
  100755. * The angularAcceleration of the device, values in array are [x,y,z].
  100756. */
  100757. readonly angularAcceleration: Nullable<Float32Array>;
  100758. }
  100759. /**
  100760. * Interface representing a pose controlled object in Babylon.
  100761. * A pose controlled object has both regular pose values as well as pose values
  100762. * from an external device such as a VR head mounted display
  100763. */
  100764. export interface PoseControlled {
  100765. /**
  100766. * The position of the object in babylon space.
  100767. */
  100768. position: Vector3;
  100769. /**
  100770. * The rotation quaternion of the object in babylon space.
  100771. */
  100772. rotationQuaternion: Quaternion;
  100773. /**
  100774. * The position of the device in babylon space.
  100775. */
  100776. devicePosition?: Vector3;
  100777. /**
  100778. * The rotation quaternion of the device in babylon space.
  100779. */
  100780. deviceRotationQuaternion: Quaternion;
  100781. /**
  100782. * The raw pose coming from the device.
  100783. */
  100784. rawPose: Nullable<DevicePose>;
  100785. /**
  100786. * The scale of the device to be used when translating from device space to babylon space.
  100787. */
  100788. deviceScaleFactor: number;
  100789. /**
  100790. * Updates the poseControlled values based on the input device pose.
  100791. * @param poseData the pose data to update the object with
  100792. */
  100793. updateFromDevice(poseData: DevicePose): void;
  100794. }
  100795. /**
  100796. * Set of options to customize the webVRCamera
  100797. */
  100798. export interface WebVROptions {
  100799. /**
  100800. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100801. */
  100802. trackPosition?: boolean;
  100803. /**
  100804. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100805. */
  100806. positionScale?: number;
  100807. /**
  100808. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100809. */
  100810. displayName?: string;
  100811. /**
  100812. * Should the native controller meshes be initialized. (default: true)
  100813. */
  100814. controllerMeshes?: boolean;
  100815. /**
  100816. * Creating a default HemiLight only on controllers. (default: true)
  100817. */
  100818. defaultLightingOnControllers?: boolean;
  100819. /**
  100820. * If you don't want to use the default VR button of the helper. (default: false)
  100821. */
  100822. useCustomVRButton?: boolean;
  100823. /**
  100824. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100825. */
  100826. customVRButton?: HTMLButtonElement;
  100827. /**
  100828. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100829. */
  100830. rayLength?: number;
  100831. /**
  100832. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100833. */
  100834. defaultHeight?: number;
  100835. /**
  100836. * If multiview should be used if availible (default: false)
  100837. */
  100838. useMultiview?: boolean;
  100839. }
  100840. /**
  100841. * This represents a WebVR camera.
  100842. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100843. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100844. */
  100845. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100846. private webVROptions;
  100847. /**
  100848. * @hidden
  100849. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100850. */
  100851. _vrDevice: any;
  100852. /**
  100853. * The rawPose of the vrDevice.
  100854. */
  100855. rawPose: Nullable<DevicePose>;
  100856. private _onVREnabled;
  100857. private _specsVersion;
  100858. private _attached;
  100859. private _frameData;
  100860. protected _descendants: Array<Node>;
  100861. private _deviceRoomPosition;
  100862. /** @hidden */
  100863. _deviceRoomRotationQuaternion: Quaternion;
  100864. private _standingMatrix;
  100865. /**
  100866. * Represents device position in babylon space.
  100867. */
  100868. devicePosition: Vector3;
  100869. /**
  100870. * Represents device rotation in babylon space.
  100871. */
  100872. deviceRotationQuaternion: Quaternion;
  100873. /**
  100874. * The scale of the device to be used when translating from device space to babylon space.
  100875. */
  100876. deviceScaleFactor: number;
  100877. private _deviceToWorld;
  100878. private _worldToDevice;
  100879. /**
  100880. * References to the webVR controllers for the vrDevice.
  100881. */
  100882. controllers: Array<WebVRController>;
  100883. /**
  100884. * Emits an event when a controller is attached.
  100885. */
  100886. onControllersAttachedObservable: Observable<WebVRController[]>;
  100887. /**
  100888. * Emits an event when a controller's mesh has been loaded;
  100889. */
  100890. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100891. /**
  100892. * Emits an event when the HMD's pose has been updated.
  100893. */
  100894. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100895. private _poseSet;
  100896. /**
  100897. * If the rig cameras be used as parent instead of this camera.
  100898. */
  100899. rigParenting: boolean;
  100900. private _lightOnControllers;
  100901. private _defaultHeight?;
  100902. /**
  100903. * Instantiates a WebVRFreeCamera.
  100904. * @param name The name of the WebVRFreeCamera
  100905. * @param position The starting anchor position for the camera
  100906. * @param scene The scene the camera belongs to
  100907. * @param webVROptions a set of customizable options for the webVRCamera
  100908. */
  100909. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100910. /**
  100911. * Gets the device distance from the ground in meters.
  100912. * @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.
  100913. */
  100914. deviceDistanceToRoomGround(): number;
  100915. /**
  100916. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100917. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100918. */
  100919. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100920. /**
  100921. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100922. * @returns A promise with a boolean set to if the standing matrix is supported.
  100923. */
  100924. useStandingMatrixAsync(): Promise<boolean>;
  100925. /**
  100926. * Disposes the camera
  100927. */
  100928. dispose(): void;
  100929. /**
  100930. * Gets a vrController by name.
  100931. * @param name The name of the controller to retreive
  100932. * @returns the controller matching the name specified or null if not found
  100933. */
  100934. getControllerByName(name: string): Nullable<WebVRController>;
  100935. private _leftController;
  100936. /**
  100937. * The controller corresponding to the users left hand.
  100938. */
  100939. get leftController(): Nullable<WebVRController>;
  100940. private _rightController;
  100941. /**
  100942. * The controller corresponding to the users right hand.
  100943. */
  100944. get rightController(): Nullable<WebVRController>;
  100945. /**
  100946. * Casts a ray forward from the vrCamera's gaze.
  100947. * @param length Length of the ray (default: 100)
  100948. * @returns the ray corresponding to the gaze
  100949. */
  100950. getForwardRay(length?: number): Ray;
  100951. /**
  100952. * @hidden
  100953. * Updates the camera based on device's frame data
  100954. */
  100955. _checkInputs(): void;
  100956. /**
  100957. * Updates the poseControlled values based on the input device pose.
  100958. * @param poseData Pose coming from the device
  100959. */
  100960. updateFromDevice(poseData: DevicePose): void;
  100961. private _htmlElementAttached;
  100962. private _detachIfAttached;
  100963. /**
  100964. * WebVR's attach control will start broadcasting frames to the device.
  100965. * Note that in certain browsers (chrome for example) this function must be called
  100966. * within a user-interaction callback. Example:
  100967. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100968. *
  100969. * @param element html element to attach the vrDevice to
  100970. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100971. */
  100972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100973. /**
  100974. * Detaches the camera from the html element and disables VR
  100975. *
  100976. * @param element html element to detach from
  100977. */
  100978. detachControl(element: HTMLElement): void;
  100979. /**
  100980. * @returns the name of this class
  100981. */
  100982. getClassName(): string;
  100983. /**
  100984. * Calls resetPose on the vrDisplay
  100985. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100986. */
  100987. resetToCurrentRotation(): void;
  100988. /**
  100989. * @hidden
  100990. * Updates the rig cameras (left and right eye)
  100991. */
  100992. _updateRigCameras(): void;
  100993. private _workingVector;
  100994. private _oneVector;
  100995. private _workingMatrix;
  100996. private updateCacheCalled;
  100997. private _correctPositionIfNotTrackPosition;
  100998. /**
  100999. * @hidden
  101000. * Updates the cached values of the camera
  101001. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  101002. */
  101003. _updateCache(ignoreParentClass?: boolean): void;
  101004. /**
  101005. * @hidden
  101006. * Get current device position in babylon world
  101007. */
  101008. _computeDevicePosition(): void;
  101009. /**
  101010. * Updates the current device position and rotation in the babylon world
  101011. */
  101012. update(): void;
  101013. /**
  101014. * @hidden
  101015. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  101016. * @returns an identity matrix
  101017. */
  101018. _getViewMatrix(): Matrix;
  101019. private _tmpMatrix;
  101020. /**
  101021. * This function is called by the two RIG cameras.
  101022. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  101023. * @hidden
  101024. */
  101025. _getWebVRViewMatrix(): Matrix;
  101026. /** @hidden */
  101027. _getWebVRProjectionMatrix(): Matrix;
  101028. private _onGamepadConnectedObserver;
  101029. private _onGamepadDisconnectedObserver;
  101030. private _updateCacheWhenTrackingDisabledObserver;
  101031. /**
  101032. * Initializes the controllers and their meshes
  101033. */
  101034. initControllers(): void;
  101035. }
  101036. }
  101037. declare module BABYLON {
  101038. /**
  101039. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  101040. *
  101041. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  101042. *
  101043. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  101044. */
  101045. export class MaterialHelper {
  101046. /**
  101047. * Bind the current view position to an effect.
  101048. * @param effect The effect to be bound
  101049. * @param scene The scene the eyes position is used from
  101050. * @param variableName name of the shader variable that will hold the eye position
  101051. */
  101052. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  101053. /**
  101054. * Helps preparing the defines values about the UVs in used in the effect.
  101055. * UVs are shared as much as we can accross channels in the shaders.
  101056. * @param texture The texture we are preparing the UVs for
  101057. * @param defines The defines to update
  101058. * @param key The channel key "diffuse", "specular"... used in the shader
  101059. */
  101060. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  101061. /**
  101062. * Binds a texture matrix value to its corrsponding uniform
  101063. * @param texture The texture to bind the matrix for
  101064. * @param uniformBuffer The uniform buffer receivin the data
  101065. * @param key The channel key "diffuse", "specular"... used in the shader
  101066. */
  101067. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  101068. /**
  101069. * Gets the current status of the fog (should it be enabled?)
  101070. * @param mesh defines the mesh to evaluate for fog support
  101071. * @param scene defines the hosting scene
  101072. * @returns true if fog must be enabled
  101073. */
  101074. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  101075. /**
  101076. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  101077. * @param mesh defines the current mesh
  101078. * @param scene defines the current scene
  101079. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  101080. * @param pointsCloud defines if point cloud rendering has to be turned on
  101081. * @param fogEnabled defines if fog has to be turned on
  101082. * @param alphaTest defines if alpha testing has to be turned on
  101083. * @param defines defines the current list of defines
  101084. */
  101085. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  101086. /**
  101087. * Helper used to prepare the list of defines associated with frame values for shader compilation
  101088. * @param scene defines the current scene
  101089. * @param engine defines the current engine
  101090. * @param defines specifies the list of active defines
  101091. * @param useInstances defines if instances have to be turned on
  101092. * @param useClipPlane defines if clip plane have to be turned on
  101093. * @param useInstances defines if instances have to be turned on
  101094. * @param useThinInstances defines if thin instances have to be turned on
  101095. */
  101096. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101097. /**
  101098. * Prepares the defines for bones
  101099. * @param mesh The mesh containing the geometry data we will draw
  101100. * @param defines The defines to update
  101101. */
  101102. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101103. /**
  101104. * Prepares the defines for morph targets
  101105. * @param mesh The mesh containing the geometry data we will draw
  101106. * @param defines The defines to update
  101107. */
  101108. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101109. /**
  101110. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101111. * @param mesh The mesh containing the geometry data we will draw
  101112. * @param defines The defines to update
  101113. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101114. * @param useBones Precise whether bones should be used or not (override mesh info)
  101115. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101116. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101117. * @returns false if defines are considered not dirty and have not been checked
  101118. */
  101119. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101120. /**
  101121. * Prepares the defines related to multiview
  101122. * @param scene The scene we are intending to draw
  101123. * @param defines The defines to update
  101124. */
  101125. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101126. /**
  101127. * Prepares the defines related to the prepass
  101128. * @param scene The scene we are intending to draw
  101129. * @param defines The defines to update
  101130. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101131. */
  101132. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101133. /**
  101134. * Prepares the defines related to the light information passed in parameter
  101135. * @param scene The scene we are intending to draw
  101136. * @param mesh The mesh the effect is compiling for
  101137. * @param light The light the effect is compiling for
  101138. * @param lightIndex The index of the light
  101139. * @param defines The defines to update
  101140. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101141. * @param state Defines the current state regarding what is needed (normals, etc...)
  101142. */
  101143. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101144. needNormals: boolean;
  101145. needRebuild: boolean;
  101146. shadowEnabled: boolean;
  101147. specularEnabled: boolean;
  101148. lightmapMode: boolean;
  101149. }): void;
  101150. /**
  101151. * Prepares the defines related to the light information passed in parameter
  101152. * @param scene The scene we are intending to draw
  101153. * @param mesh The mesh the effect is compiling for
  101154. * @param defines The defines to update
  101155. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101156. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101157. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101158. * @returns true if normals will be required for the rest of the effect
  101159. */
  101160. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101161. /**
  101162. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101163. * @param lightIndex defines the light index
  101164. * @param uniformsList The uniform list
  101165. * @param samplersList The sampler list
  101166. * @param projectedLightTexture defines if projected texture must be used
  101167. * @param uniformBuffersList defines an optional list of uniform buffers
  101168. */
  101169. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101170. /**
  101171. * Prepares the uniforms and samplers list to be used in the effect
  101172. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101173. * @param samplersList The sampler list
  101174. * @param defines The defines helping in the list generation
  101175. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101176. */
  101177. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101178. /**
  101179. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101180. * @param defines The defines to update while falling back
  101181. * @param fallbacks The authorized effect fallbacks
  101182. * @param maxSimultaneousLights The maximum number of lights allowed
  101183. * @param rank the current rank of the Effect
  101184. * @returns The newly affected rank
  101185. */
  101186. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101187. private static _TmpMorphInfluencers;
  101188. /**
  101189. * Prepares the list of attributes required for morph targets according to the effect defines.
  101190. * @param attribs The current list of supported attribs
  101191. * @param mesh The mesh to prepare the morph targets attributes for
  101192. * @param influencers The number of influencers
  101193. */
  101194. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101195. /**
  101196. * Prepares the list of attributes required for morph targets according to the effect defines.
  101197. * @param attribs The current list of supported attribs
  101198. * @param mesh The mesh to prepare the morph targets attributes for
  101199. * @param defines The current Defines of the effect
  101200. */
  101201. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  101202. /**
  101203. * Prepares the list of attributes required for bones according to the effect defines.
  101204. * @param attribs The current list of supported attribs
  101205. * @param mesh The mesh to prepare the bones attributes for
  101206. * @param defines The current Defines of the effect
  101207. * @param fallbacks The current efffect fallback strategy
  101208. */
  101209. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  101210. /**
  101211. * Check and prepare the list of attributes required for instances according to the effect defines.
  101212. * @param attribs The current list of supported attribs
  101213. * @param defines The current MaterialDefines of the effect
  101214. */
  101215. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  101216. /**
  101217. * Add the list of attributes required for instances to the attribs array.
  101218. * @param attribs The current list of supported attribs
  101219. */
  101220. static PushAttributesForInstances(attribs: string[]): void;
  101221. /**
  101222. * Binds the light information to the effect.
  101223. * @param light The light containing the generator
  101224. * @param effect The effect we are binding the data to
  101225. * @param lightIndex The light index in the effect used to render
  101226. */
  101227. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  101228. /**
  101229. * Binds the lights information from the scene to the effect for the given mesh.
  101230. * @param light Light to bind
  101231. * @param lightIndex Light index
  101232. * @param scene The scene where the light belongs to
  101233. * @param effect The effect we are binding the data to
  101234. * @param useSpecular Defines if specular is supported
  101235. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101236. */
  101237. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  101238. /**
  101239. * Binds the lights information from the scene to the effect for the given mesh.
  101240. * @param scene The scene the lights belongs to
  101241. * @param mesh The mesh we are binding the information to render
  101242. * @param effect The effect we are binding the data to
  101243. * @param defines The generated defines for the effect
  101244. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  101245. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101246. */
  101247. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101248. private static _tempFogColor;
  101249. /**
  101250. * Binds the fog information from the scene to the effect for the given mesh.
  101251. * @param scene The scene the lights belongs to
  101252. * @param mesh The mesh we are binding the information to render
  101253. * @param effect The effect we are binding the data to
  101254. * @param linearSpace Defines if the fog effect is applied in linear space
  101255. */
  101256. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101257. /**
  101258. * Binds the bones information from the mesh to the effect.
  101259. * @param mesh The mesh we are binding the information to render
  101260. * @param effect The effect we are binding the data to
  101261. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101262. */
  101263. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101264. private static _CopyBonesTransformationMatrices;
  101265. /**
  101266. * Binds the morph targets information from the mesh to the effect.
  101267. * @param abstractMesh The mesh we are binding the information to render
  101268. * @param effect The effect we are binding the data to
  101269. */
  101270. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101271. /**
  101272. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101273. * @param defines The generated defines used in the effect
  101274. * @param effect The effect we are binding the data to
  101275. * @param scene The scene we are willing to render with logarithmic scale for
  101276. */
  101277. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101278. /**
  101279. * Binds the clip plane information from the scene to the effect.
  101280. * @param scene The scene the clip plane information are extracted from
  101281. * @param effect The effect we are binding the data to
  101282. */
  101283. static BindClipPlane(effect: Effect, scene: Scene): void;
  101284. }
  101285. }
  101286. declare module BABYLON {
  101287. /**
  101288. * Block used to expose an input value
  101289. */
  101290. export class InputBlock extends NodeMaterialBlock {
  101291. private _mode;
  101292. private _associatedVariableName;
  101293. private _storedValue;
  101294. private _valueCallback;
  101295. private _type;
  101296. private _animationType;
  101297. /** Gets or set a value used to limit the range of float values */
  101298. min: number;
  101299. /** Gets or set a value used to limit the range of float values */
  101300. max: number;
  101301. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  101302. isBoolean: boolean;
  101303. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  101304. matrixMode: number;
  101305. /** @hidden */
  101306. _systemValue: Nullable<NodeMaterialSystemValues>;
  101307. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  101308. isConstant: boolean;
  101309. /** Gets or sets the group to use to display this block in the Inspector */
  101310. groupInInspector: string;
  101311. /** Gets an observable raised when the value is changed */
  101312. onValueChangedObservable: Observable<InputBlock>;
  101313. /**
  101314. * Gets or sets the connection point type (default is float)
  101315. */
  101316. get type(): NodeMaterialBlockConnectionPointTypes;
  101317. /**
  101318. * Creates a new InputBlock
  101319. * @param name defines the block name
  101320. * @param target defines the target of that block (Vertex by default)
  101321. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  101322. */
  101323. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  101324. /**
  101325. * Validates if a name is a reserve word.
  101326. * @param newName the new name to be given to the node.
  101327. * @returns false if the name is a reserve word, else true.
  101328. */
  101329. validateBlockName(newName: string): boolean;
  101330. /**
  101331. * Gets the output component
  101332. */
  101333. get output(): NodeMaterialConnectionPoint;
  101334. /**
  101335. * Set the source of this connection point to a vertex attribute
  101336. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  101337. * @returns the current connection point
  101338. */
  101339. setAsAttribute(attributeName?: string): InputBlock;
  101340. /**
  101341. * Set the source of this connection point to a system value
  101342. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  101343. * @returns the current connection point
  101344. */
  101345. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  101346. /**
  101347. * Gets or sets the value of that point.
  101348. * Please note that this value will be ignored if valueCallback is defined
  101349. */
  101350. get value(): any;
  101351. set value(value: any);
  101352. /**
  101353. * Gets or sets a callback used to get the value of that point.
  101354. * Please note that setting this value will force the connection point to ignore the value property
  101355. */
  101356. get valueCallback(): () => any;
  101357. set valueCallback(value: () => any);
  101358. /**
  101359. * Gets or sets the associated variable name in the shader
  101360. */
  101361. get associatedVariableName(): string;
  101362. set associatedVariableName(value: string);
  101363. /** Gets or sets the type of animation applied to the input */
  101364. get animationType(): AnimatedInputBlockTypes;
  101365. set animationType(value: AnimatedInputBlockTypes);
  101366. /**
  101367. * Gets a boolean indicating that this connection point not defined yet
  101368. */
  101369. get isUndefined(): boolean;
  101370. /**
  101371. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  101372. * In this case the connection point name must be the name of the uniform to use.
  101373. * Can only be set on inputs
  101374. */
  101375. get isUniform(): boolean;
  101376. set isUniform(value: boolean);
  101377. /**
  101378. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  101379. * In this case the connection point name must be the name of the attribute to use
  101380. * Can only be set on inputs
  101381. */
  101382. get isAttribute(): boolean;
  101383. set isAttribute(value: boolean);
  101384. /**
  101385. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  101386. * Can only be set on exit points
  101387. */
  101388. get isVarying(): boolean;
  101389. set isVarying(value: boolean);
  101390. /**
  101391. * Gets a boolean indicating that the current connection point is a system value
  101392. */
  101393. get isSystemValue(): boolean;
  101394. /**
  101395. * Gets or sets the current well known value or null if not defined as a system value
  101396. */
  101397. get systemValue(): Nullable<NodeMaterialSystemValues>;
  101398. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  101399. /**
  101400. * Gets the current class name
  101401. * @returns the class name
  101402. */
  101403. getClassName(): string;
  101404. /**
  101405. * Animate the input if animationType !== None
  101406. * @param scene defines the rendering scene
  101407. */
  101408. animate(scene: Scene): void;
  101409. private _emitDefine;
  101410. initialize(state: NodeMaterialBuildState): void;
  101411. /**
  101412. * Set the input block to its default value (based on its type)
  101413. */
  101414. setDefaultValue(): void;
  101415. private _emitConstant;
  101416. /** @hidden */
  101417. get _noContextSwitch(): boolean;
  101418. private _emit;
  101419. /** @hidden */
  101420. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  101421. /** @hidden */
  101422. _transmit(effect: Effect, scene: Scene): void;
  101423. protected _buildBlock(state: NodeMaterialBuildState): void;
  101424. protected _dumpPropertiesCode(): string;
  101425. dispose(): void;
  101426. serialize(): any;
  101427. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101428. }
  101429. }
  101430. declare module BABYLON {
  101431. /**
  101432. * Enum used to define the compatibility state between two connection points
  101433. */
  101434. export enum NodeMaterialConnectionPointCompatibilityStates {
  101435. /** Points are compatibles */
  101436. Compatible = 0,
  101437. /** Points are incompatible because of their types */
  101438. TypeIncompatible = 1,
  101439. /** Points are incompatible because of their targets (vertex vs fragment) */
  101440. TargetIncompatible = 2
  101441. }
  101442. /**
  101443. * Defines the direction of a connection point
  101444. */
  101445. export enum NodeMaterialConnectionPointDirection {
  101446. /** Input */
  101447. Input = 0,
  101448. /** Output */
  101449. Output = 1
  101450. }
  101451. /**
  101452. * Defines a connection point for a block
  101453. */
  101454. export class NodeMaterialConnectionPoint {
  101455. /** @hidden */
  101456. _ownerBlock: NodeMaterialBlock;
  101457. /** @hidden */
  101458. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  101459. private _endpoints;
  101460. private _associatedVariableName;
  101461. private _direction;
  101462. /** @hidden */
  101463. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101464. /** @hidden */
  101465. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101466. private _type;
  101467. /** @hidden */
  101468. _enforceAssociatedVariableName: boolean;
  101469. /** Gets the direction of the point */
  101470. get direction(): NodeMaterialConnectionPointDirection;
  101471. /** Indicates that this connection point needs dual validation before being connected to another point */
  101472. needDualDirectionValidation: boolean;
  101473. /**
  101474. * Gets or sets the additional types supported by this connection point
  101475. */
  101476. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101477. /**
  101478. * Gets or sets the additional types excluded by this connection point
  101479. */
  101480. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101481. /**
  101482. * Observable triggered when this point is connected
  101483. */
  101484. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101485. /**
  101486. * Gets or sets the associated variable name in the shader
  101487. */
  101488. get associatedVariableName(): string;
  101489. set associatedVariableName(value: string);
  101490. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101491. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101492. /**
  101493. * Gets or sets the connection point type (default is float)
  101494. */
  101495. get type(): NodeMaterialBlockConnectionPointTypes;
  101496. set type(value: NodeMaterialBlockConnectionPointTypes);
  101497. /**
  101498. * Gets or sets the connection point name
  101499. */
  101500. name: string;
  101501. /**
  101502. * Gets or sets the connection point name
  101503. */
  101504. displayName: string;
  101505. /**
  101506. * Gets or sets a boolean indicating that this connection point can be omitted
  101507. */
  101508. isOptional: boolean;
  101509. /**
  101510. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101511. */
  101512. isExposedOnFrame: boolean;
  101513. /**
  101514. * Gets or sets number indicating the position that the port is exposed to on a frame
  101515. */
  101516. exposedPortPosition: number;
  101517. /**
  101518. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101519. */
  101520. define: string;
  101521. /** @hidden */
  101522. _prioritizeVertex: boolean;
  101523. private _target;
  101524. /** Gets or sets the target of that connection point */
  101525. get target(): NodeMaterialBlockTargets;
  101526. set target(value: NodeMaterialBlockTargets);
  101527. /**
  101528. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101529. */
  101530. get isConnected(): boolean;
  101531. /**
  101532. * Gets a boolean indicating that the current point is connected to an input block
  101533. */
  101534. get isConnectedToInputBlock(): boolean;
  101535. /**
  101536. * Gets a the connected input block (if any)
  101537. */
  101538. get connectInputBlock(): Nullable<InputBlock>;
  101539. /** Get the other side of the connection (if any) */
  101540. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101541. /** Get the block that owns this connection point */
  101542. get ownerBlock(): NodeMaterialBlock;
  101543. /** Get the block connected on the other side of this connection (if any) */
  101544. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101545. /** Get the block connected on the endpoints of this connection (if any) */
  101546. get connectedBlocks(): Array<NodeMaterialBlock>;
  101547. /** Gets the list of connected endpoints */
  101548. get endpoints(): NodeMaterialConnectionPoint[];
  101549. /** Gets a boolean indicating if that output point is connected to at least one input */
  101550. get hasEndpoints(): boolean;
  101551. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101552. get isConnectedInVertexShader(): boolean;
  101553. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101554. get isConnectedInFragmentShader(): boolean;
  101555. /**
  101556. * Creates a block suitable to be used as an input for this input point.
  101557. * If null is returned, a block based on the point type will be created.
  101558. * @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
  101559. */
  101560. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101561. /**
  101562. * Creates a new connection point
  101563. * @param name defines the connection point name
  101564. * @param ownerBlock defines the block hosting this connection point
  101565. * @param direction defines the direction of the connection point
  101566. */
  101567. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101568. /**
  101569. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101570. * @returns the class name
  101571. */
  101572. getClassName(): string;
  101573. /**
  101574. * Gets a boolean indicating if the current point can be connected to another point
  101575. * @param connectionPoint defines the other connection point
  101576. * @returns a boolean
  101577. */
  101578. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101579. /**
  101580. * Gets a number indicating if the current point can be connected to another point
  101581. * @param connectionPoint defines the other connection point
  101582. * @returns a number defining the compatibility state
  101583. */
  101584. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101585. /**
  101586. * Connect this point to another connection point
  101587. * @param connectionPoint defines the other connection point
  101588. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101589. * @returns the current connection point
  101590. */
  101591. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101592. /**
  101593. * Disconnect this point from one of his endpoint
  101594. * @param endpoint defines the other connection point
  101595. * @returns the current connection point
  101596. */
  101597. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101598. /**
  101599. * Serializes this point in a JSON representation
  101600. * @param isInput defines if the connection point is an input (default is true)
  101601. * @returns the serialized point object
  101602. */
  101603. serialize(isInput?: boolean): any;
  101604. /**
  101605. * Release resources
  101606. */
  101607. dispose(): void;
  101608. }
  101609. }
  101610. declare module BABYLON {
  101611. /**
  101612. * Enum used to define the material modes
  101613. */
  101614. export enum NodeMaterialModes {
  101615. /** Regular material */
  101616. Material = 0,
  101617. /** For post process */
  101618. PostProcess = 1,
  101619. /** For particle system */
  101620. Particle = 2,
  101621. /** For procedural texture */
  101622. ProceduralTexture = 3
  101623. }
  101624. }
  101625. declare module BABYLON {
  101626. /**
  101627. * Block used to read a texture from a sampler
  101628. */
  101629. export class TextureBlock extends NodeMaterialBlock {
  101630. private _defineName;
  101631. private _linearDefineName;
  101632. private _gammaDefineName;
  101633. private _tempTextureRead;
  101634. private _samplerName;
  101635. private _transformedUVName;
  101636. private _textureTransformName;
  101637. private _textureInfoName;
  101638. private _mainUVName;
  101639. private _mainUVDefineName;
  101640. private _fragmentOnly;
  101641. /**
  101642. * Gets or sets the texture associated with the node
  101643. */
  101644. texture: Nullable<Texture>;
  101645. /**
  101646. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101647. */
  101648. convertToGammaSpace: boolean;
  101649. /**
  101650. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101651. */
  101652. convertToLinearSpace: boolean;
  101653. /**
  101654. * Create a new TextureBlock
  101655. * @param name defines the block name
  101656. */
  101657. constructor(name: string, fragmentOnly?: boolean);
  101658. /**
  101659. * Gets the current class name
  101660. * @returns the class name
  101661. */
  101662. getClassName(): string;
  101663. /**
  101664. * Gets the uv input component
  101665. */
  101666. get uv(): NodeMaterialConnectionPoint;
  101667. /**
  101668. * Gets the rgba output component
  101669. */
  101670. get rgba(): NodeMaterialConnectionPoint;
  101671. /**
  101672. * Gets the rgb output component
  101673. */
  101674. get rgb(): NodeMaterialConnectionPoint;
  101675. /**
  101676. * Gets the r output component
  101677. */
  101678. get r(): NodeMaterialConnectionPoint;
  101679. /**
  101680. * Gets the g output component
  101681. */
  101682. get g(): NodeMaterialConnectionPoint;
  101683. /**
  101684. * Gets the b output component
  101685. */
  101686. get b(): NodeMaterialConnectionPoint;
  101687. /**
  101688. * Gets the a output component
  101689. */
  101690. get a(): NodeMaterialConnectionPoint;
  101691. get target(): NodeMaterialBlockTargets;
  101692. autoConfigure(material: NodeMaterial): void;
  101693. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101695. isReady(): boolean;
  101696. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101697. private get _isMixed();
  101698. private _injectVertexCode;
  101699. private _writeTextureRead;
  101700. private _writeOutput;
  101701. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101702. protected _dumpPropertiesCode(): string;
  101703. serialize(): any;
  101704. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101705. }
  101706. }
  101707. declare module BABYLON {
  101708. /** @hidden */
  101709. export var reflectionFunction: {
  101710. name: string;
  101711. shader: string;
  101712. };
  101713. }
  101714. declare module BABYLON {
  101715. /**
  101716. * Base block used to read a reflection texture from a sampler
  101717. */
  101718. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101719. /** @hidden */
  101720. _define3DName: string;
  101721. /** @hidden */
  101722. _defineCubicName: string;
  101723. /** @hidden */
  101724. _defineExplicitName: string;
  101725. /** @hidden */
  101726. _defineProjectionName: string;
  101727. /** @hidden */
  101728. _defineLocalCubicName: string;
  101729. /** @hidden */
  101730. _defineSphericalName: string;
  101731. /** @hidden */
  101732. _definePlanarName: string;
  101733. /** @hidden */
  101734. _defineEquirectangularName: string;
  101735. /** @hidden */
  101736. _defineMirroredEquirectangularFixedName: string;
  101737. /** @hidden */
  101738. _defineEquirectangularFixedName: string;
  101739. /** @hidden */
  101740. _defineSkyboxName: string;
  101741. /** @hidden */
  101742. _defineOppositeZ: string;
  101743. /** @hidden */
  101744. _cubeSamplerName: string;
  101745. /** @hidden */
  101746. _2DSamplerName: string;
  101747. protected _positionUVWName: string;
  101748. protected _directionWName: string;
  101749. protected _reflectionVectorName: string;
  101750. /** @hidden */
  101751. _reflectionCoordsName: string;
  101752. /** @hidden */
  101753. _reflectionMatrixName: string;
  101754. protected _reflectionColorName: string;
  101755. /**
  101756. * Gets or sets the texture associated with the node
  101757. */
  101758. texture: Nullable<BaseTexture>;
  101759. /**
  101760. * Create a new ReflectionTextureBaseBlock
  101761. * @param name defines the block name
  101762. */
  101763. constructor(name: string);
  101764. /**
  101765. * Gets the current class name
  101766. * @returns the class name
  101767. */
  101768. getClassName(): string;
  101769. /**
  101770. * Gets the world position input component
  101771. */
  101772. abstract get position(): NodeMaterialConnectionPoint;
  101773. /**
  101774. * Gets the world position input component
  101775. */
  101776. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101777. /**
  101778. * Gets the world normal input component
  101779. */
  101780. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101781. /**
  101782. * Gets the world input component
  101783. */
  101784. abstract get world(): NodeMaterialConnectionPoint;
  101785. /**
  101786. * Gets the camera (or eye) position component
  101787. */
  101788. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101789. /**
  101790. * Gets the view input component
  101791. */
  101792. abstract get view(): NodeMaterialConnectionPoint;
  101793. protected _getTexture(): Nullable<BaseTexture>;
  101794. autoConfigure(material: NodeMaterial): void;
  101795. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101796. isReady(): boolean;
  101797. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101798. /**
  101799. * Gets the code to inject in the vertex shader
  101800. * @param state current state of the node material building
  101801. * @returns the shader code
  101802. */
  101803. handleVertexSide(state: NodeMaterialBuildState): string;
  101804. /**
  101805. * Handles the inits for the fragment code path
  101806. * @param state node material build state
  101807. */
  101808. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101809. /**
  101810. * Generates the reflection coords code for the fragment code path
  101811. * @param worldNormalVarName name of the world normal variable
  101812. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101813. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101814. * @returns the shader code
  101815. */
  101816. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101817. /**
  101818. * Generates the reflection color code for the fragment code path
  101819. * @param lodVarName name of the lod variable
  101820. * @param swizzleLookupTexture swizzle to use for the final color variable
  101821. * @returns the shader code
  101822. */
  101823. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101824. /**
  101825. * Generates the code corresponding to the connected output points
  101826. * @param state node material build state
  101827. * @param varName name of the variable to output
  101828. * @returns the shader code
  101829. */
  101830. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101831. protected _buildBlock(state: NodeMaterialBuildState): this;
  101832. protected _dumpPropertiesCode(): string;
  101833. serialize(): any;
  101834. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101835. }
  101836. }
  101837. declare module BABYLON {
  101838. /**
  101839. * Defines a connection point to be used for points with a custom object type
  101840. */
  101841. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101842. private _blockType;
  101843. private _blockName;
  101844. private _nameForCheking?;
  101845. /**
  101846. * Creates a new connection point
  101847. * @param name defines the connection point name
  101848. * @param ownerBlock defines the block hosting this connection point
  101849. * @param direction defines the direction of the connection point
  101850. */
  101851. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101852. /**
  101853. * Gets a number indicating if the current point can be connected to another point
  101854. * @param connectionPoint defines the other connection point
  101855. * @returns a number defining the compatibility state
  101856. */
  101857. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101858. /**
  101859. * Creates a block suitable to be used as an input for this input point.
  101860. * If null is returned, a block based on the point type will be created.
  101861. * @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
  101862. */
  101863. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101864. }
  101865. }
  101866. declare module BABYLON {
  101867. /**
  101868. * Enum defining the type of properties that can be edited in the property pages in the NME
  101869. */
  101870. export enum PropertyTypeForEdition {
  101871. /** property is a boolean */
  101872. Boolean = 0,
  101873. /** property is a float */
  101874. Float = 1,
  101875. /** property is a Vector2 */
  101876. Vector2 = 2,
  101877. /** property is a list of values */
  101878. List = 3
  101879. }
  101880. /**
  101881. * Interface that defines an option in a variable of type list
  101882. */
  101883. export interface IEditablePropertyListOption {
  101884. /** label of the option */
  101885. "label": string;
  101886. /** value of the option */
  101887. "value": number;
  101888. }
  101889. /**
  101890. * Interface that defines the options available for an editable property
  101891. */
  101892. export interface IEditablePropertyOption {
  101893. /** min value */
  101894. "min"?: number;
  101895. /** max value */
  101896. "max"?: number;
  101897. /** notifiers: indicates which actions to take when the property is changed */
  101898. "notifiers"?: {
  101899. /** the material should be rebuilt */
  101900. "rebuild"?: boolean;
  101901. /** the preview should be updated */
  101902. "update"?: boolean;
  101903. };
  101904. /** list of the options for a variable of type list */
  101905. "options"?: IEditablePropertyListOption[];
  101906. }
  101907. /**
  101908. * Interface that describes an editable property
  101909. */
  101910. export interface IPropertyDescriptionForEdition {
  101911. /** name of the property */
  101912. "propertyName": string;
  101913. /** display name of the property */
  101914. "displayName": string;
  101915. /** type of the property */
  101916. "type": PropertyTypeForEdition;
  101917. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101918. "groupName": string;
  101919. /** options for the property */
  101920. "options": IEditablePropertyOption;
  101921. }
  101922. /**
  101923. * Decorator that flags a property in a node material block as being editable
  101924. */
  101925. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101926. }
  101927. declare module BABYLON {
  101928. /**
  101929. * Block used to implement the refraction part of the sub surface module of the PBR material
  101930. */
  101931. export class RefractionBlock extends NodeMaterialBlock {
  101932. /** @hidden */
  101933. _define3DName: string;
  101934. /** @hidden */
  101935. _refractionMatrixName: string;
  101936. /** @hidden */
  101937. _defineLODRefractionAlpha: string;
  101938. /** @hidden */
  101939. _defineLinearSpecularRefraction: string;
  101940. /** @hidden */
  101941. _defineOppositeZ: string;
  101942. /** @hidden */
  101943. _cubeSamplerName: string;
  101944. /** @hidden */
  101945. _2DSamplerName: string;
  101946. /** @hidden */
  101947. _vRefractionMicrosurfaceInfosName: string;
  101948. /** @hidden */
  101949. _vRefractionInfosName: string;
  101950. private _scene;
  101951. /**
  101952. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101953. * Materials half opaque for instance using refraction could benefit from this control.
  101954. */
  101955. linkRefractionWithTransparency: boolean;
  101956. /**
  101957. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101958. */
  101959. invertRefractionY: boolean;
  101960. /**
  101961. * Gets or sets the texture associated with the node
  101962. */
  101963. texture: Nullable<BaseTexture>;
  101964. /**
  101965. * Create a new RefractionBlock
  101966. * @param name defines the block name
  101967. */
  101968. constructor(name: string);
  101969. /**
  101970. * Gets the current class name
  101971. * @returns the class name
  101972. */
  101973. getClassName(): string;
  101974. /**
  101975. * Gets the intensity input component
  101976. */
  101977. get intensity(): NodeMaterialConnectionPoint;
  101978. /**
  101979. * Gets the index of refraction input component
  101980. */
  101981. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101982. /**
  101983. * Gets the tint at distance input component
  101984. */
  101985. get tintAtDistance(): NodeMaterialConnectionPoint;
  101986. /**
  101987. * Gets the view input component
  101988. */
  101989. get view(): NodeMaterialConnectionPoint;
  101990. /**
  101991. * Gets the refraction object output component
  101992. */
  101993. get refraction(): NodeMaterialConnectionPoint;
  101994. /**
  101995. * Returns true if the block has a texture
  101996. */
  101997. get hasTexture(): boolean;
  101998. protected _getTexture(): Nullable<BaseTexture>;
  101999. autoConfigure(material: NodeMaterial): void;
  102000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102001. isReady(): boolean;
  102002. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102003. /**
  102004. * Gets the main code of the block (fragment side)
  102005. * @param state current state of the node material building
  102006. * @returns the shader code
  102007. */
  102008. getCode(state: NodeMaterialBuildState): string;
  102009. protected _buildBlock(state: NodeMaterialBuildState): this;
  102010. protected _dumpPropertiesCode(): string;
  102011. serialize(): any;
  102012. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102013. }
  102014. }
  102015. declare module BABYLON {
  102016. /**
  102017. * Base block used as input for post process
  102018. */
  102019. export class CurrentScreenBlock extends NodeMaterialBlock {
  102020. private _samplerName;
  102021. private _linearDefineName;
  102022. private _gammaDefineName;
  102023. private _mainUVName;
  102024. private _tempTextureRead;
  102025. /**
  102026. * Gets or sets the texture associated with the node
  102027. */
  102028. texture: Nullable<BaseTexture>;
  102029. /**
  102030. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102031. */
  102032. convertToGammaSpace: boolean;
  102033. /**
  102034. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102035. */
  102036. convertToLinearSpace: boolean;
  102037. /**
  102038. * Create a new CurrentScreenBlock
  102039. * @param name defines the block name
  102040. */
  102041. constructor(name: string);
  102042. /**
  102043. * Gets the current class name
  102044. * @returns the class name
  102045. */
  102046. getClassName(): string;
  102047. /**
  102048. * Gets the uv input component
  102049. */
  102050. get uv(): NodeMaterialConnectionPoint;
  102051. /**
  102052. * Gets the rgba output component
  102053. */
  102054. get rgba(): NodeMaterialConnectionPoint;
  102055. /**
  102056. * Gets the rgb output component
  102057. */
  102058. get rgb(): NodeMaterialConnectionPoint;
  102059. /**
  102060. * Gets the r output component
  102061. */
  102062. get r(): NodeMaterialConnectionPoint;
  102063. /**
  102064. * Gets the g output component
  102065. */
  102066. get g(): NodeMaterialConnectionPoint;
  102067. /**
  102068. * Gets the b output component
  102069. */
  102070. get b(): NodeMaterialConnectionPoint;
  102071. /**
  102072. * Gets the a output component
  102073. */
  102074. get a(): NodeMaterialConnectionPoint;
  102075. /**
  102076. * Initialize the block and prepare the context for build
  102077. * @param state defines the state that will be used for the build
  102078. */
  102079. initialize(state: NodeMaterialBuildState): void;
  102080. get target(): NodeMaterialBlockTargets;
  102081. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102082. isReady(): boolean;
  102083. private _injectVertexCode;
  102084. private _writeTextureRead;
  102085. private _writeOutput;
  102086. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102087. serialize(): any;
  102088. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102089. }
  102090. }
  102091. declare module BABYLON {
  102092. /**
  102093. * Base block used for the particle texture
  102094. */
  102095. export class ParticleTextureBlock extends NodeMaterialBlock {
  102096. private _samplerName;
  102097. private _linearDefineName;
  102098. private _gammaDefineName;
  102099. private _tempTextureRead;
  102100. /**
  102101. * Gets or sets the texture associated with the node
  102102. */
  102103. texture: Nullable<BaseTexture>;
  102104. /**
  102105. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102106. */
  102107. convertToGammaSpace: boolean;
  102108. /**
  102109. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102110. */
  102111. convertToLinearSpace: boolean;
  102112. /**
  102113. * Create a new ParticleTextureBlock
  102114. * @param name defines the block name
  102115. */
  102116. constructor(name: string);
  102117. /**
  102118. * Gets the current class name
  102119. * @returns the class name
  102120. */
  102121. getClassName(): string;
  102122. /**
  102123. * Gets the uv input component
  102124. */
  102125. get uv(): NodeMaterialConnectionPoint;
  102126. /**
  102127. * Gets the rgba output component
  102128. */
  102129. get rgba(): NodeMaterialConnectionPoint;
  102130. /**
  102131. * Gets the rgb output component
  102132. */
  102133. get rgb(): NodeMaterialConnectionPoint;
  102134. /**
  102135. * Gets the r output component
  102136. */
  102137. get r(): NodeMaterialConnectionPoint;
  102138. /**
  102139. * Gets the g output component
  102140. */
  102141. get g(): NodeMaterialConnectionPoint;
  102142. /**
  102143. * Gets the b output component
  102144. */
  102145. get b(): NodeMaterialConnectionPoint;
  102146. /**
  102147. * Gets the a output component
  102148. */
  102149. get a(): NodeMaterialConnectionPoint;
  102150. /**
  102151. * Initialize the block and prepare the context for build
  102152. * @param state defines the state that will be used for the build
  102153. */
  102154. initialize(state: NodeMaterialBuildState): void;
  102155. autoConfigure(material: NodeMaterial): void;
  102156. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102157. isReady(): boolean;
  102158. private _writeOutput;
  102159. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102160. serialize(): any;
  102161. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102162. }
  102163. }
  102164. declare module BABYLON {
  102165. /**
  102166. * Class used to store shared data between 2 NodeMaterialBuildState
  102167. */
  102168. export class NodeMaterialBuildStateSharedData {
  102169. /**
  102170. * Gets the list of emitted varyings
  102171. */
  102172. temps: string[];
  102173. /**
  102174. * Gets the list of emitted varyings
  102175. */
  102176. varyings: string[];
  102177. /**
  102178. * Gets the varying declaration string
  102179. */
  102180. varyingDeclaration: string;
  102181. /**
  102182. * Input blocks
  102183. */
  102184. inputBlocks: InputBlock[];
  102185. /**
  102186. * Input blocks
  102187. */
  102188. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102189. /**
  102190. * Bindable blocks (Blocks that need to set data to the effect)
  102191. */
  102192. bindableBlocks: NodeMaterialBlock[];
  102193. /**
  102194. * List of blocks that can provide a compilation fallback
  102195. */
  102196. blocksWithFallbacks: NodeMaterialBlock[];
  102197. /**
  102198. * List of blocks that can provide a define update
  102199. */
  102200. blocksWithDefines: NodeMaterialBlock[];
  102201. /**
  102202. * List of blocks that can provide a repeatable content
  102203. */
  102204. repeatableContentBlocks: NodeMaterialBlock[];
  102205. /**
  102206. * List of blocks that can provide a dynamic list of uniforms
  102207. */
  102208. dynamicUniformBlocks: NodeMaterialBlock[];
  102209. /**
  102210. * List of blocks that can block the isReady function for the material
  102211. */
  102212. blockingBlocks: NodeMaterialBlock[];
  102213. /**
  102214. * Gets the list of animated inputs
  102215. */
  102216. animatedInputs: InputBlock[];
  102217. /**
  102218. * Build Id used to avoid multiple recompilations
  102219. */
  102220. buildId: number;
  102221. /** List of emitted variables */
  102222. variableNames: {
  102223. [key: string]: number;
  102224. };
  102225. /** List of emitted defines */
  102226. defineNames: {
  102227. [key: string]: number;
  102228. };
  102229. /** Should emit comments? */
  102230. emitComments: boolean;
  102231. /** Emit build activity */
  102232. verbose: boolean;
  102233. /** Gets or sets the hosting scene */
  102234. scene: Scene;
  102235. /**
  102236. * Gets the compilation hints emitted at compilation time
  102237. */
  102238. hints: {
  102239. needWorldViewMatrix: boolean;
  102240. needWorldViewProjectionMatrix: boolean;
  102241. needAlphaBlending: boolean;
  102242. needAlphaTesting: boolean;
  102243. };
  102244. /**
  102245. * List of compilation checks
  102246. */
  102247. checks: {
  102248. emitVertex: boolean;
  102249. emitFragment: boolean;
  102250. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102251. };
  102252. /**
  102253. * Is vertex program allowed to be empty?
  102254. */
  102255. allowEmptyVertexProgram: boolean;
  102256. /** Creates a new shared data */
  102257. constructor();
  102258. /**
  102259. * Emits console errors and exceptions if there is a failing check
  102260. */
  102261. emitErrors(): void;
  102262. }
  102263. }
  102264. declare module BABYLON {
  102265. /**
  102266. * Class used to store node based material build state
  102267. */
  102268. export class NodeMaterialBuildState {
  102269. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102270. supportUniformBuffers: boolean;
  102271. /**
  102272. * Gets the list of emitted attributes
  102273. */
  102274. attributes: string[];
  102275. /**
  102276. * Gets the list of emitted uniforms
  102277. */
  102278. uniforms: string[];
  102279. /**
  102280. * Gets the list of emitted constants
  102281. */
  102282. constants: string[];
  102283. /**
  102284. * Gets the list of emitted samplers
  102285. */
  102286. samplers: string[];
  102287. /**
  102288. * Gets the list of emitted functions
  102289. */
  102290. functions: {
  102291. [key: string]: string;
  102292. };
  102293. /**
  102294. * Gets the list of emitted extensions
  102295. */
  102296. extensions: {
  102297. [key: string]: string;
  102298. };
  102299. /**
  102300. * Gets the target of the compilation state
  102301. */
  102302. target: NodeMaterialBlockTargets;
  102303. /**
  102304. * Gets the list of emitted counters
  102305. */
  102306. counters: {
  102307. [key: string]: number;
  102308. };
  102309. /**
  102310. * Shared data between multiple NodeMaterialBuildState instances
  102311. */
  102312. sharedData: NodeMaterialBuildStateSharedData;
  102313. /** @hidden */
  102314. _vertexState: NodeMaterialBuildState;
  102315. /** @hidden */
  102316. _attributeDeclaration: string;
  102317. /** @hidden */
  102318. _uniformDeclaration: string;
  102319. /** @hidden */
  102320. _constantDeclaration: string;
  102321. /** @hidden */
  102322. _samplerDeclaration: string;
  102323. /** @hidden */
  102324. _varyingTransfer: string;
  102325. /** @hidden */
  102326. _injectAtEnd: string;
  102327. private _repeatableContentAnchorIndex;
  102328. /** @hidden */
  102329. _builtCompilationString: string;
  102330. /**
  102331. * Gets the emitted compilation strings
  102332. */
  102333. compilationString: string;
  102334. /**
  102335. * Finalize the compilation strings
  102336. * @param state defines the current compilation state
  102337. */
  102338. finalize(state: NodeMaterialBuildState): void;
  102339. /** @hidden */
  102340. get _repeatableContentAnchor(): string;
  102341. /** @hidden */
  102342. _getFreeVariableName(prefix: string): string;
  102343. /** @hidden */
  102344. _getFreeDefineName(prefix: string): string;
  102345. /** @hidden */
  102346. _excludeVariableName(name: string): void;
  102347. /** @hidden */
  102348. _emit2DSampler(name: string): void;
  102349. /** @hidden */
  102350. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  102351. /** @hidden */
  102352. _emitExtension(name: string, extension: string, define?: string): void;
  102353. /** @hidden */
  102354. _emitFunction(name: string, code: string, comments: string): void;
  102355. /** @hidden */
  102356. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  102357. replaceStrings?: {
  102358. search: RegExp;
  102359. replace: string;
  102360. }[];
  102361. repeatKey?: string;
  102362. }): string;
  102363. /** @hidden */
  102364. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  102365. repeatKey?: string;
  102366. removeAttributes?: boolean;
  102367. removeUniforms?: boolean;
  102368. removeVaryings?: boolean;
  102369. removeIfDef?: boolean;
  102370. replaceStrings?: {
  102371. search: RegExp;
  102372. replace: string;
  102373. }[];
  102374. }, storeKey?: string): void;
  102375. /** @hidden */
  102376. _registerTempVariable(name: string): boolean;
  102377. /** @hidden */
  102378. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  102379. /** @hidden */
  102380. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  102381. /** @hidden */
  102382. _emitFloat(value: number): string;
  102383. }
  102384. }
  102385. declare module BABYLON {
  102386. /**
  102387. * Helper class used to generate session unique ID
  102388. */
  102389. export class UniqueIdGenerator {
  102390. private static _UniqueIdCounter;
  102391. /**
  102392. * Gets an unique (relatively to the current scene) Id
  102393. */
  102394. static get UniqueId(): number;
  102395. }
  102396. }
  102397. declare module BABYLON {
  102398. /**
  102399. * Defines a block that can be used inside a node based material
  102400. */
  102401. export class NodeMaterialBlock {
  102402. private _buildId;
  102403. private _buildTarget;
  102404. private _target;
  102405. private _isFinalMerger;
  102406. private _isInput;
  102407. private _name;
  102408. protected _isUnique: boolean;
  102409. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  102410. inputsAreExclusive: boolean;
  102411. /** @hidden */
  102412. _codeVariableName: string;
  102413. /** @hidden */
  102414. _inputs: NodeMaterialConnectionPoint[];
  102415. /** @hidden */
  102416. _outputs: NodeMaterialConnectionPoint[];
  102417. /** @hidden */
  102418. _preparationId: number;
  102419. /**
  102420. * Gets the name of the block
  102421. */
  102422. get name(): string;
  102423. /**
  102424. * Sets the name of the block. Will check if the name is valid.
  102425. */
  102426. set name(newName: string);
  102427. /**
  102428. * Gets or sets the unique id of the node
  102429. */
  102430. uniqueId: number;
  102431. /**
  102432. * Gets or sets the comments associated with this block
  102433. */
  102434. comments: string;
  102435. /**
  102436. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  102437. */
  102438. get isUnique(): boolean;
  102439. /**
  102440. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  102441. */
  102442. get isFinalMerger(): boolean;
  102443. /**
  102444. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  102445. */
  102446. get isInput(): boolean;
  102447. /**
  102448. * Gets or sets the build Id
  102449. */
  102450. get buildId(): number;
  102451. set buildId(value: number);
  102452. /**
  102453. * Gets or sets the target of the block
  102454. */
  102455. get target(): NodeMaterialBlockTargets;
  102456. set target(value: NodeMaterialBlockTargets);
  102457. /**
  102458. * Gets the list of input points
  102459. */
  102460. get inputs(): NodeMaterialConnectionPoint[];
  102461. /** Gets the list of output points */
  102462. get outputs(): NodeMaterialConnectionPoint[];
  102463. /**
  102464. * Find an input by its name
  102465. * @param name defines the name of the input to look for
  102466. * @returns the input or null if not found
  102467. */
  102468. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102469. /**
  102470. * Find an output by its name
  102471. * @param name defines the name of the outputto look for
  102472. * @returns the output or null if not found
  102473. */
  102474. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102475. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102476. visibleInInspector: boolean;
  102477. /**
  102478. * Creates a new NodeMaterialBlock
  102479. * @param name defines the block name
  102480. * @param target defines the target of that block (Vertex by default)
  102481. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102482. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102483. */
  102484. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102485. /**
  102486. * Initialize the block and prepare the context for build
  102487. * @param state defines the state that will be used for the build
  102488. */
  102489. initialize(state: NodeMaterialBuildState): void;
  102490. /**
  102491. * Bind data to effect. Will only be called for blocks with isBindable === true
  102492. * @param effect defines the effect to bind data to
  102493. * @param nodeMaterial defines the hosting NodeMaterial
  102494. * @param mesh defines the mesh that will be rendered
  102495. * @param subMesh defines the submesh that will be rendered
  102496. */
  102497. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102498. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102499. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102500. protected _writeFloat(value: number): string;
  102501. /**
  102502. * Gets the current class name e.g. "NodeMaterialBlock"
  102503. * @returns the class name
  102504. */
  102505. getClassName(): string;
  102506. /**
  102507. * Register a new input. Must be called inside a block constructor
  102508. * @param name defines the connection point name
  102509. * @param type defines the connection point type
  102510. * @param isOptional defines a boolean indicating that this input can be omitted
  102511. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102512. * @param point an already created connection point. If not provided, create a new one
  102513. * @returns the current block
  102514. */
  102515. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102516. /**
  102517. * Register a new output. Must be called inside a block constructor
  102518. * @param name defines the connection point name
  102519. * @param type defines the connection point type
  102520. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102521. * @param point an already created connection point. If not provided, create a new one
  102522. * @returns the current block
  102523. */
  102524. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102525. /**
  102526. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102527. * @param forOutput defines an optional connection point to check compatibility with
  102528. * @returns the first available input or null
  102529. */
  102530. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102531. /**
  102532. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102533. * @param forBlock defines an optional block to check compatibility with
  102534. * @returns the first available input or null
  102535. */
  102536. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102537. /**
  102538. * Gets the sibling of the given output
  102539. * @param current defines the current output
  102540. * @returns the next output in the list or null
  102541. */
  102542. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102543. /**
  102544. * Connect current block with another block
  102545. * @param other defines the block to connect with
  102546. * @param options define the various options to help pick the right connections
  102547. * @returns the current block
  102548. */
  102549. connectTo(other: NodeMaterialBlock, options?: {
  102550. input?: string;
  102551. output?: string;
  102552. outputSwizzle?: string;
  102553. }): this | undefined;
  102554. protected _buildBlock(state: NodeMaterialBuildState): void;
  102555. /**
  102556. * Add uniforms, samplers and uniform buffers at compilation time
  102557. * @param state defines the state to update
  102558. * @param nodeMaterial defines the node material requesting the update
  102559. * @param defines defines the material defines to update
  102560. * @param uniformBuffers defines the list of uniform buffer names
  102561. */
  102562. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102563. /**
  102564. * Add potential fallbacks if shader compilation fails
  102565. * @param mesh defines the mesh to be rendered
  102566. * @param fallbacks defines the current prioritized list of fallbacks
  102567. */
  102568. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102569. /**
  102570. * Initialize defines for shader compilation
  102571. * @param mesh defines the mesh to be rendered
  102572. * @param nodeMaterial defines the node material requesting the update
  102573. * @param defines defines the material defines to update
  102574. * @param useInstances specifies that instances should be used
  102575. */
  102576. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102577. /**
  102578. * Update defines for shader compilation
  102579. * @param mesh defines the mesh to be rendered
  102580. * @param nodeMaterial defines the node material requesting the update
  102581. * @param defines defines the material defines to update
  102582. * @param useInstances specifies that instances should be used
  102583. * @param subMesh defines which submesh to render
  102584. */
  102585. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102586. /**
  102587. * Lets the block try to connect some inputs automatically
  102588. * @param material defines the hosting NodeMaterial
  102589. */
  102590. autoConfigure(material: NodeMaterial): void;
  102591. /**
  102592. * Function called when a block is declared as repeatable content generator
  102593. * @param vertexShaderState defines the current compilation state for the vertex shader
  102594. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102595. * @param mesh defines the mesh to be rendered
  102596. * @param defines defines the material defines to update
  102597. */
  102598. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102599. /**
  102600. * Checks if the block is ready
  102601. * @param mesh defines the mesh to be rendered
  102602. * @param nodeMaterial defines the node material requesting the update
  102603. * @param defines defines the material defines to update
  102604. * @param useInstances specifies that instances should be used
  102605. * @returns true if the block is ready
  102606. */
  102607. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102608. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102609. private _processBuild;
  102610. /**
  102611. * Validates the new name for the block node.
  102612. * @param newName the new name to be given to the node.
  102613. * @returns false if the name is a reserve word, else true.
  102614. */
  102615. validateBlockName(newName: string): boolean;
  102616. /**
  102617. * Compile the current node and generate the shader code
  102618. * @param state defines the current compilation state (uniforms, samplers, current string)
  102619. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102620. * @returns true if already built
  102621. */
  102622. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102623. protected _inputRename(name: string): string;
  102624. protected _outputRename(name: string): string;
  102625. protected _dumpPropertiesCode(): string;
  102626. /** @hidden */
  102627. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102628. /** @hidden */
  102629. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102630. /**
  102631. * Clone the current block to a new identical block
  102632. * @param scene defines the hosting scene
  102633. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102634. * @returns a copy of the current block
  102635. */
  102636. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102637. /**
  102638. * Serializes this block in a JSON representation
  102639. * @returns the serialized block object
  102640. */
  102641. serialize(): any;
  102642. /** @hidden */
  102643. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102644. private _deserializePortDisplayNamesAndExposedOnFrame;
  102645. /**
  102646. * Release resources
  102647. */
  102648. dispose(): void;
  102649. }
  102650. }
  102651. declare module BABYLON {
  102652. /**
  102653. * Base class of materials working in push mode in babylon JS
  102654. * @hidden
  102655. */
  102656. export class PushMaterial extends Material {
  102657. protected _activeEffect: Effect;
  102658. protected _normalMatrix: Matrix;
  102659. constructor(name: string, scene: Scene);
  102660. getEffect(): Effect;
  102661. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102662. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102663. /**
  102664. * Binds the given world matrix to the active effect
  102665. *
  102666. * @param world the matrix to bind
  102667. */
  102668. bindOnlyWorldMatrix(world: Matrix): void;
  102669. /**
  102670. * Binds the given normal matrix to the active effect
  102671. *
  102672. * @param normalMatrix the matrix to bind
  102673. */
  102674. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102675. bind(world: Matrix, mesh?: Mesh): void;
  102676. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102677. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102678. }
  102679. }
  102680. declare module BABYLON {
  102681. /**
  102682. * Root class for all node material optimizers
  102683. */
  102684. export class NodeMaterialOptimizer {
  102685. /**
  102686. * Function used to optimize a NodeMaterial graph
  102687. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102688. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102689. */
  102690. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102691. }
  102692. }
  102693. declare module BABYLON {
  102694. /**
  102695. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102696. */
  102697. export class TransformBlock extends NodeMaterialBlock {
  102698. /**
  102699. * Defines the value to use to complement W value to transform it to a Vector4
  102700. */
  102701. complementW: number;
  102702. /**
  102703. * Defines the value to use to complement z value to transform it to a Vector4
  102704. */
  102705. complementZ: number;
  102706. /**
  102707. * Creates a new TransformBlock
  102708. * @param name defines the block name
  102709. */
  102710. constructor(name: string);
  102711. /**
  102712. * Gets the current class name
  102713. * @returns the class name
  102714. */
  102715. getClassName(): string;
  102716. /**
  102717. * Gets the vector input
  102718. */
  102719. get vector(): NodeMaterialConnectionPoint;
  102720. /**
  102721. * Gets the output component
  102722. */
  102723. get output(): NodeMaterialConnectionPoint;
  102724. /**
  102725. * Gets the xyz output component
  102726. */
  102727. get xyz(): NodeMaterialConnectionPoint;
  102728. /**
  102729. * Gets the matrix transform input
  102730. */
  102731. get transform(): NodeMaterialConnectionPoint;
  102732. protected _buildBlock(state: NodeMaterialBuildState): this;
  102733. /**
  102734. * Update defines for shader compilation
  102735. * @param mesh defines the mesh to be rendered
  102736. * @param nodeMaterial defines the node material requesting the update
  102737. * @param defines defines the material defines to update
  102738. * @param useInstances specifies that instances should be used
  102739. * @param subMesh defines which submesh to render
  102740. */
  102741. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102742. serialize(): any;
  102743. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102744. protected _dumpPropertiesCode(): string;
  102745. }
  102746. }
  102747. declare module BABYLON {
  102748. /**
  102749. * Block used to output the vertex position
  102750. */
  102751. export class VertexOutputBlock extends NodeMaterialBlock {
  102752. /**
  102753. * Creates a new VertexOutputBlock
  102754. * @param name defines the block name
  102755. */
  102756. constructor(name: string);
  102757. /**
  102758. * Gets the current class name
  102759. * @returns the class name
  102760. */
  102761. getClassName(): string;
  102762. /**
  102763. * Gets the vector input component
  102764. */
  102765. get vector(): NodeMaterialConnectionPoint;
  102766. protected _buildBlock(state: NodeMaterialBuildState): this;
  102767. }
  102768. }
  102769. declare module BABYLON {
  102770. /**
  102771. * Block used to output the final color
  102772. */
  102773. export class FragmentOutputBlock extends NodeMaterialBlock {
  102774. /**
  102775. * Create a new FragmentOutputBlock
  102776. * @param name defines the block name
  102777. */
  102778. constructor(name: string);
  102779. /**
  102780. * Gets the current class name
  102781. * @returns the class name
  102782. */
  102783. getClassName(): string;
  102784. /**
  102785. * Gets the rgba input component
  102786. */
  102787. get rgba(): NodeMaterialConnectionPoint;
  102788. /**
  102789. * Gets the rgb input component
  102790. */
  102791. get rgb(): NodeMaterialConnectionPoint;
  102792. /**
  102793. * Gets the a input component
  102794. */
  102795. get a(): NodeMaterialConnectionPoint;
  102796. protected _buildBlock(state: NodeMaterialBuildState): this;
  102797. }
  102798. }
  102799. declare module BABYLON {
  102800. /**
  102801. * Block used for the particle ramp gradient section
  102802. */
  102803. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102804. /**
  102805. * Create a new ParticleRampGradientBlock
  102806. * @param name defines the block name
  102807. */
  102808. constructor(name: string);
  102809. /**
  102810. * Gets the current class name
  102811. * @returns the class name
  102812. */
  102813. getClassName(): string;
  102814. /**
  102815. * Gets the color input component
  102816. */
  102817. get color(): NodeMaterialConnectionPoint;
  102818. /**
  102819. * Gets the rampColor output component
  102820. */
  102821. get rampColor(): NodeMaterialConnectionPoint;
  102822. /**
  102823. * Initialize the block and prepare the context for build
  102824. * @param state defines the state that will be used for the build
  102825. */
  102826. initialize(state: NodeMaterialBuildState): void;
  102827. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102828. }
  102829. }
  102830. declare module BABYLON {
  102831. /**
  102832. * Block used for the particle blend multiply section
  102833. */
  102834. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102835. /**
  102836. * Create a new ParticleBlendMultiplyBlock
  102837. * @param name defines the block name
  102838. */
  102839. constructor(name: string);
  102840. /**
  102841. * Gets the current class name
  102842. * @returns the class name
  102843. */
  102844. getClassName(): string;
  102845. /**
  102846. * Gets the color input component
  102847. */
  102848. get color(): NodeMaterialConnectionPoint;
  102849. /**
  102850. * Gets the alphaTexture input component
  102851. */
  102852. get alphaTexture(): NodeMaterialConnectionPoint;
  102853. /**
  102854. * Gets the alphaColor input component
  102855. */
  102856. get alphaColor(): NodeMaterialConnectionPoint;
  102857. /**
  102858. * Gets the blendColor output component
  102859. */
  102860. get blendColor(): NodeMaterialConnectionPoint;
  102861. /**
  102862. * Initialize the block and prepare the context for build
  102863. * @param state defines the state that will be used for the build
  102864. */
  102865. initialize(state: NodeMaterialBuildState): void;
  102866. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102867. }
  102868. }
  102869. declare module BABYLON {
  102870. /**
  102871. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102872. */
  102873. export class VectorMergerBlock extends NodeMaterialBlock {
  102874. /**
  102875. * Create a new VectorMergerBlock
  102876. * @param name defines the block name
  102877. */
  102878. constructor(name: string);
  102879. /**
  102880. * Gets the current class name
  102881. * @returns the class name
  102882. */
  102883. getClassName(): string;
  102884. /**
  102885. * Gets the xyz component (input)
  102886. */
  102887. get xyzIn(): NodeMaterialConnectionPoint;
  102888. /**
  102889. * Gets the xy component (input)
  102890. */
  102891. get xyIn(): NodeMaterialConnectionPoint;
  102892. /**
  102893. * Gets the x component (input)
  102894. */
  102895. get x(): NodeMaterialConnectionPoint;
  102896. /**
  102897. * Gets the y component (input)
  102898. */
  102899. get y(): NodeMaterialConnectionPoint;
  102900. /**
  102901. * Gets the z component (input)
  102902. */
  102903. get z(): NodeMaterialConnectionPoint;
  102904. /**
  102905. * Gets the w component (input)
  102906. */
  102907. get w(): NodeMaterialConnectionPoint;
  102908. /**
  102909. * Gets the xyzw component (output)
  102910. */
  102911. get xyzw(): NodeMaterialConnectionPoint;
  102912. /**
  102913. * Gets the xyz component (output)
  102914. */
  102915. get xyzOut(): NodeMaterialConnectionPoint;
  102916. /**
  102917. * Gets the xy component (output)
  102918. */
  102919. get xyOut(): NodeMaterialConnectionPoint;
  102920. /**
  102921. * Gets the xy component (output)
  102922. * @deprecated Please use xyOut instead.
  102923. */
  102924. get xy(): NodeMaterialConnectionPoint;
  102925. /**
  102926. * Gets the xyz component (output)
  102927. * @deprecated Please use xyzOut instead.
  102928. */
  102929. get xyz(): NodeMaterialConnectionPoint;
  102930. protected _buildBlock(state: NodeMaterialBuildState): this;
  102931. }
  102932. }
  102933. declare module BABYLON {
  102934. /**
  102935. * Block used to remap a float from a range to a new one
  102936. */
  102937. export class RemapBlock extends NodeMaterialBlock {
  102938. /**
  102939. * Gets or sets the source range
  102940. */
  102941. sourceRange: Vector2;
  102942. /**
  102943. * Gets or sets the target range
  102944. */
  102945. targetRange: Vector2;
  102946. /**
  102947. * Creates a new RemapBlock
  102948. * @param name defines the block name
  102949. */
  102950. constructor(name: string);
  102951. /**
  102952. * Gets the current class name
  102953. * @returns the class name
  102954. */
  102955. getClassName(): string;
  102956. /**
  102957. * Gets the input component
  102958. */
  102959. get input(): NodeMaterialConnectionPoint;
  102960. /**
  102961. * Gets the source min input component
  102962. */
  102963. get sourceMin(): NodeMaterialConnectionPoint;
  102964. /**
  102965. * Gets the source max input component
  102966. */
  102967. get sourceMax(): NodeMaterialConnectionPoint;
  102968. /**
  102969. * Gets the target min input component
  102970. */
  102971. get targetMin(): NodeMaterialConnectionPoint;
  102972. /**
  102973. * Gets the target max input component
  102974. */
  102975. get targetMax(): NodeMaterialConnectionPoint;
  102976. /**
  102977. * Gets the output component
  102978. */
  102979. get output(): NodeMaterialConnectionPoint;
  102980. protected _buildBlock(state: NodeMaterialBuildState): this;
  102981. protected _dumpPropertiesCode(): string;
  102982. serialize(): any;
  102983. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102984. }
  102985. }
  102986. declare module BABYLON {
  102987. /**
  102988. * Block used to multiply 2 values
  102989. */
  102990. export class MultiplyBlock extends NodeMaterialBlock {
  102991. /**
  102992. * Creates a new MultiplyBlock
  102993. * @param name defines the block name
  102994. */
  102995. constructor(name: string);
  102996. /**
  102997. * Gets the current class name
  102998. * @returns the class name
  102999. */
  103000. getClassName(): string;
  103001. /**
  103002. * Gets the left operand input component
  103003. */
  103004. get left(): NodeMaterialConnectionPoint;
  103005. /**
  103006. * Gets the right operand input component
  103007. */
  103008. get right(): NodeMaterialConnectionPoint;
  103009. /**
  103010. * Gets the output component
  103011. */
  103012. get output(): NodeMaterialConnectionPoint;
  103013. protected _buildBlock(state: NodeMaterialBuildState): this;
  103014. }
  103015. }
  103016. declare module BABYLON {
  103017. /**
  103018. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  103019. */
  103020. export class ColorSplitterBlock extends NodeMaterialBlock {
  103021. /**
  103022. * Create a new ColorSplitterBlock
  103023. * @param name defines the block name
  103024. */
  103025. constructor(name: string);
  103026. /**
  103027. * Gets the current class name
  103028. * @returns the class name
  103029. */
  103030. getClassName(): string;
  103031. /**
  103032. * Gets the rgba component (input)
  103033. */
  103034. get rgba(): NodeMaterialConnectionPoint;
  103035. /**
  103036. * Gets the rgb component (input)
  103037. */
  103038. get rgbIn(): NodeMaterialConnectionPoint;
  103039. /**
  103040. * Gets the rgb component (output)
  103041. */
  103042. get rgbOut(): NodeMaterialConnectionPoint;
  103043. /**
  103044. * Gets the r component (output)
  103045. */
  103046. get r(): NodeMaterialConnectionPoint;
  103047. /**
  103048. * Gets the g component (output)
  103049. */
  103050. get g(): NodeMaterialConnectionPoint;
  103051. /**
  103052. * Gets the b component (output)
  103053. */
  103054. get b(): NodeMaterialConnectionPoint;
  103055. /**
  103056. * Gets the a component (output)
  103057. */
  103058. get a(): NodeMaterialConnectionPoint;
  103059. protected _inputRename(name: string): string;
  103060. protected _outputRename(name: string): string;
  103061. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103062. }
  103063. }
  103064. declare module BABYLON {
  103065. /**
  103066. * Operations supported by the Trigonometry block
  103067. */
  103068. export enum TrigonometryBlockOperations {
  103069. /** Cos */
  103070. Cos = 0,
  103071. /** Sin */
  103072. Sin = 1,
  103073. /** Abs */
  103074. Abs = 2,
  103075. /** Exp */
  103076. Exp = 3,
  103077. /** Exp2 */
  103078. Exp2 = 4,
  103079. /** Round */
  103080. Round = 5,
  103081. /** Floor */
  103082. Floor = 6,
  103083. /** Ceiling */
  103084. Ceiling = 7,
  103085. /** Square root */
  103086. Sqrt = 8,
  103087. /** Log */
  103088. Log = 9,
  103089. /** Tangent */
  103090. Tan = 10,
  103091. /** Arc tangent */
  103092. ArcTan = 11,
  103093. /** Arc cosinus */
  103094. ArcCos = 12,
  103095. /** Arc sinus */
  103096. ArcSin = 13,
  103097. /** Fraction */
  103098. Fract = 14,
  103099. /** Sign */
  103100. Sign = 15,
  103101. /** To radians (from degrees) */
  103102. Radians = 16,
  103103. /** To degrees (from radians) */
  103104. Degrees = 17
  103105. }
  103106. /**
  103107. * Block used to apply trigonometry operation to floats
  103108. */
  103109. export class TrigonometryBlock extends NodeMaterialBlock {
  103110. /**
  103111. * Gets or sets the operation applied by the block
  103112. */
  103113. operation: TrigonometryBlockOperations;
  103114. /**
  103115. * Creates a new TrigonometryBlock
  103116. * @param name defines the block name
  103117. */
  103118. constructor(name: string);
  103119. /**
  103120. * Gets the current class name
  103121. * @returns the class name
  103122. */
  103123. getClassName(): string;
  103124. /**
  103125. * Gets the input component
  103126. */
  103127. get input(): NodeMaterialConnectionPoint;
  103128. /**
  103129. * Gets the output component
  103130. */
  103131. get output(): NodeMaterialConnectionPoint;
  103132. protected _buildBlock(state: NodeMaterialBuildState): this;
  103133. serialize(): any;
  103134. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103135. protected _dumpPropertiesCode(): string;
  103136. }
  103137. }
  103138. declare module BABYLON {
  103139. /**
  103140. * Interface used to configure the node material editor
  103141. */
  103142. export interface INodeMaterialEditorOptions {
  103143. /** Define the URl to load node editor script */
  103144. editorURL?: string;
  103145. }
  103146. /** @hidden */
  103147. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103148. NORMAL: boolean;
  103149. TANGENT: boolean;
  103150. UV1: boolean;
  103151. /** BONES */
  103152. NUM_BONE_INFLUENCERS: number;
  103153. BonesPerMesh: number;
  103154. BONETEXTURE: boolean;
  103155. /** MORPH TARGETS */
  103156. MORPHTARGETS: boolean;
  103157. MORPHTARGETS_NORMAL: boolean;
  103158. MORPHTARGETS_TANGENT: boolean;
  103159. MORPHTARGETS_UV: boolean;
  103160. NUM_MORPH_INFLUENCERS: number;
  103161. /** IMAGE PROCESSING */
  103162. IMAGEPROCESSING: boolean;
  103163. VIGNETTE: boolean;
  103164. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103165. VIGNETTEBLENDMODEOPAQUE: boolean;
  103166. TONEMAPPING: boolean;
  103167. TONEMAPPING_ACES: boolean;
  103168. CONTRAST: boolean;
  103169. EXPOSURE: boolean;
  103170. COLORCURVES: boolean;
  103171. COLORGRADING: boolean;
  103172. COLORGRADING3D: boolean;
  103173. SAMPLER3DGREENDEPTH: boolean;
  103174. SAMPLER3DBGRMAP: boolean;
  103175. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103176. /** MISC. */
  103177. BUMPDIRECTUV: number;
  103178. constructor();
  103179. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103180. }
  103181. /**
  103182. * Class used to configure NodeMaterial
  103183. */
  103184. export interface INodeMaterialOptions {
  103185. /**
  103186. * Defines if blocks should emit comments
  103187. */
  103188. emitComments: boolean;
  103189. }
  103190. /**
  103191. * Class used to create a node based material built by assembling shader blocks
  103192. */
  103193. export class NodeMaterial extends PushMaterial {
  103194. private static _BuildIdGenerator;
  103195. private _options;
  103196. private _vertexCompilationState;
  103197. private _fragmentCompilationState;
  103198. private _sharedData;
  103199. private _buildId;
  103200. private _buildWasSuccessful;
  103201. private _cachedWorldViewMatrix;
  103202. private _cachedWorldViewProjectionMatrix;
  103203. private _optimizers;
  103204. private _animationFrame;
  103205. /** Define the Url to load node editor script */
  103206. static EditorURL: string;
  103207. /** Define the Url to load snippets */
  103208. static SnippetUrl: string;
  103209. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  103210. static IgnoreTexturesAtLoadTime: boolean;
  103211. private BJSNODEMATERIALEDITOR;
  103212. /** Get the inspector from bundle or global */
  103213. private _getGlobalNodeMaterialEditor;
  103214. /**
  103215. * Snippet ID if the material was created from the snippet server
  103216. */
  103217. snippetId: string;
  103218. /**
  103219. * Gets or sets data used by visual editor
  103220. * @see https://nme.babylonjs.com
  103221. */
  103222. editorData: any;
  103223. /**
  103224. * 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)
  103225. */
  103226. ignoreAlpha: boolean;
  103227. /**
  103228. * Defines the maximum number of lights that can be used in the material
  103229. */
  103230. maxSimultaneousLights: number;
  103231. /**
  103232. * Observable raised when the material is built
  103233. */
  103234. onBuildObservable: Observable<NodeMaterial>;
  103235. /**
  103236. * Gets or sets the root nodes of the material vertex shader
  103237. */
  103238. _vertexOutputNodes: NodeMaterialBlock[];
  103239. /**
  103240. * Gets or sets the root nodes of the material fragment (pixel) shader
  103241. */
  103242. _fragmentOutputNodes: NodeMaterialBlock[];
  103243. /** Gets or sets options to control the node material overall behavior */
  103244. get options(): INodeMaterialOptions;
  103245. set options(options: INodeMaterialOptions);
  103246. /**
  103247. * Default configuration related to image processing available in the standard Material.
  103248. */
  103249. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103250. /**
  103251. * Gets the image processing configuration used either in this material.
  103252. */
  103253. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103254. /**
  103255. * Sets the Default image processing configuration used either in the this material.
  103256. *
  103257. * If sets to null, the scene one is in use.
  103258. */
  103259. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103260. /**
  103261. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103262. */
  103263. attachedBlocks: NodeMaterialBlock[];
  103264. /**
  103265. * Specifies the mode of the node material
  103266. * @hidden
  103267. */
  103268. _mode: NodeMaterialModes;
  103269. /**
  103270. * Gets the mode property
  103271. */
  103272. get mode(): NodeMaterialModes;
  103273. /**
  103274. * Create a new node based material
  103275. * @param name defines the material name
  103276. * @param scene defines the hosting scene
  103277. * @param options defines creation option
  103278. */
  103279. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103280. /**
  103281. * Gets the current class name of the material e.g. "NodeMaterial"
  103282. * @returns the class name
  103283. */
  103284. getClassName(): string;
  103285. /**
  103286. * Keep track of the image processing observer to allow dispose and replace.
  103287. */
  103288. private _imageProcessingObserver;
  103289. /**
  103290. * Attaches a new image processing configuration to the Standard Material.
  103291. * @param configuration
  103292. */
  103293. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103294. /**
  103295. * Get a block by its name
  103296. * @param name defines the name of the block to retrieve
  103297. * @returns the required block or null if not found
  103298. */
  103299. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103300. /**
  103301. * Get a block by its name
  103302. * @param predicate defines the predicate used to find the good candidate
  103303. * @returns the required block or null if not found
  103304. */
  103305. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103306. /**
  103307. * Get an input block by its name
  103308. * @param predicate defines the predicate used to find the good candidate
  103309. * @returns the required input block or null if not found
  103310. */
  103311. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103312. /**
  103313. * Gets the list of input blocks attached to this material
  103314. * @returns an array of InputBlocks
  103315. */
  103316. getInputBlocks(): InputBlock[];
  103317. /**
  103318. * Adds a new optimizer to the list of optimizers
  103319. * @param optimizer defines the optimizers to add
  103320. * @returns the current material
  103321. */
  103322. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103323. /**
  103324. * Remove an optimizer from the list of optimizers
  103325. * @param optimizer defines the optimizers to remove
  103326. * @returns the current material
  103327. */
  103328. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103329. /**
  103330. * Add a new block to the list of output nodes
  103331. * @param node defines the node to add
  103332. * @returns the current material
  103333. */
  103334. addOutputNode(node: NodeMaterialBlock): this;
  103335. /**
  103336. * Remove a block from the list of root nodes
  103337. * @param node defines the node to remove
  103338. * @returns the current material
  103339. */
  103340. removeOutputNode(node: NodeMaterialBlock): this;
  103341. private _addVertexOutputNode;
  103342. private _removeVertexOutputNode;
  103343. private _addFragmentOutputNode;
  103344. private _removeFragmentOutputNode;
  103345. /**
  103346. * Specifies if the material will require alpha blending
  103347. * @returns a boolean specifying if alpha blending is needed
  103348. */
  103349. needAlphaBlending(): boolean;
  103350. /**
  103351. * Specifies if this material should be rendered in alpha test mode
  103352. * @returns a boolean specifying if an alpha test is needed.
  103353. */
  103354. needAlphaTesting(): boolean;
  103355. private _initializeBlock;
  103356. private _resetDualBlocks;
  103357. /**
  103358. * Remove a block from the current node material
  103359. * @param block defines the block to remove
  103360. */
  103361. removeBlock(block: NodeMaterialBlock): void;
  103362. /**
  103363. * Build the material and generates the inner effect
  103364. * @param verbose defines if the build should log activity
  103365. */
  103366. build(verbose?: boolean): void;
  103367. /**
  103368. * Runs an otpimization phase to try to improve the shader code
  103369. */
  103370. optimize(): void;
  103371. private _prepareDefinesForAttributes;
  103372. /**
  103373. * Create a post process from the material
  103374. * @param camera The camera to apply the render pass to.
  103375. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103377. * @param engine The engine which the post process will be applied. (default: current engine)
  103378. * @param reusable If the post process can be reused on the same frame. (default: false)
  103379. * @param textureType Type of textures used when performing the post process. (default: 0)
  103380. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103381. * @returns the post process created
  103382. */
  103383. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103384. /**
  103385. * Create the post process effect from the material
  103386. * @param postProcess The post process to create the effect for
  103387. */
  103388. createEffectForPostProcess(postProcess: PostProcess): void;
  103389. private _createEffectForPostProcess;
  103390. /**
  103391. * Create a new procedural texture based on this node material
  103392. * @param size defines the size of the texture
  103393. * @param scene defines the hosting scene
  103394. * @returns the new procedural texture attached to this node material
  103395. */
  103396. createProceduralTexture(size: number | {
  103397. width: number;
  103398. height: number;
  103399. layers?: number;
  103400. }, scene: Scene): Nullable<ProceduralTexture>;
  103401. private _createEffectForParticles;
  103402. private _checkInternals;
  103403. /**
  103404. * Create the effect to be used as the custom effect for a particle system
  103405. * @param particleSystem Particle system to create the effect for
  103406. * @param onCompiled defines a function to call when the effect creation is successful
  103407. * @param onError defines a function to call when the effect creation has failed
  103408. */
  103409. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103410. private _processDefines;
  103411. /**
  103412. * Get if the submesh is ready to be used and all its information available.
  103413. * Child classes can use it to update shaders
  103414. * @param mesh defines the mesh to check
  103415. * @param subMesh defines which submesh to check
  103416. * @param useInstances specifies that instances should be used
  103417. * @returns a boolean indicating that the submesh is ready or not
  103418. */
  103419. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103420. /**
  103421. * Get a string representing the shaders built by the current node graph
  103422. */
  103423. get compiledShaders(): string;
  103424. /**
  103425. * Binds the world matrix to the material
  103426. * @param world defines the world transformation matrix
  103427. */
  103428. bindOnlyWorldMatrix(world: Matrix): void;
  103429. /**
  103430. * Binds the submesh to this material by preparing the effect and shader to draw
  103431. * @param world defines the world transformation matrix
  103432. * @param mesh defines the mesh containing the submesh
  103433. * @param subMesh defines the submesh to bind the material to
  103434. */
  103435. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103436. /**
  103437. * Gets the active textures from the material
  103438. * @returns an array of textures
  103439. */
  103440. getActiveTextures(): BaseTexture[];
  103441. /**
  103442. * Gets the list of texture blocks
  103443. * @returns an array of texture blocks
  103444. */
  103445. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103446. /**
  103447. * Specifies if the material uses a texture
  103448. * @param texture defines the texture to check against the material
  103449. * @returns a boolean specifying if the material uses the texture
  103450. */
  103451. hasTexture(texture: BaseTexture): boolean;
  103452. /**
  103453. * Disposes the material
  103454. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103455. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103456. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103457. */
  103458. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103459. /** Creates the node editor window. */
  103460. private _createNodeEditor;
  103461. /**
  103462. * Launch the node material editor
  103463. * @param config Define the configuration of the editor
  103464. * @return a promise fulfilled when the node editor is visible
  103465. */
  103466. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103467. /**
  103468. * Clear the current material
  103469. */
  103470. clear(): void;
  103471. /**
  103472. * Clear the current material and set it to a default state
  103473. */
  103474. setToDefault(): void;
  103475. /**
  103476. * Clear the current material and set it to a default state for post process
  103477. */
  103478. setToDefaultPostProcess(): void;
  103479. /**
  103480. * Clear the current material and set it to a default state for procedural texture
  103481. */
  103482. setToDefaultProceduralTexture(): void;
  103483. /**
  103484. * Clear the current material and set it to a default state for particle
  103485. */
  103486. setToDefaultParticle(): void;
  103487. /**
  103488. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103489. * @param url defines the url to load from
  103490. * @returns a promise that will fullfil when the material is fully loaded
  103491. */
  103492. loadAsync(url: string): Promise<void>;
  103493. private _gatherBlocks;
  103494. /**
  103495. * Generate a string containing the code declaration required to create an equivalent of this material
  103496. * @returns a string
  103497. */
  103498. generateCode(): string;
  103499. /**
  103500. * Serializes this material in a JSON representation
  103501. * @returns the serialized material object
  103502. */
  103503. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103504. private _restoreConnections;
  103505. /**
  103506. * Clear the current graph and load a new one from a serialization object
  103507. * @param source defines the JSON representation of the material
  103508. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103509. * @param merge defines whether or not the source must be merged or replace the current content
  103510. */
  103511. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103512. /**
  103513. * Makes a duplicate of the current material.
  103514. * @param name - name to use for the new material.
  103515. */
  103516. clone(name: string): NodeMaterial;
  103517. /**
  103518. * Creates a node material from parsed material data
  103519. * @param source defines the JSON representation of the material
  103520. * @param scene defines the hosting scene
  103521. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103522. * @returns a new node material
  103523. */
  103524. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103525. /**
  103526. * Creates a node material from a snippet saved in a remote file
  103527. * @param name defines the name of the material to create
  103528. * @param url defines the url to load from
  103529. * @param scene defines the hosting scene
  103530. * @returns a promise that will resolve to the new node material
  103531. */
  103532. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103533. /**
  103534. * Creates a node material from a snippet saved by the node material editor
  103535. * @param snippetId defines the snippet to load
  103536. * @param scene defines the hosting scene
  103537. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103538. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103539. * @returns a promise that will resolve to the new node material
  103540. */
  103541. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103542. /**
  103543. * Creates a new node material set to default basic configuration
  103544. * @param name defines the name of the material
  103545. * @param scene defines the hosting scene
  103546. * @returns a new NodeMaterial
  103547. */
  103548. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103549. }
  103550. }
  103551. declare module BABYLON {
  103552. interface ThinEngine {
  103553. /**
  103554. * Unbind a list of render target textures from the webGL context
  103555. * This is used only when drawBuffer extension or webGL2 are active
  103556. * @param textures defines the render target textures to unbind
  103557. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103558. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103559. */
  103560. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103561. /**
  103562. * Create a multi render target texture
  103563. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103564. * @param size defines the size of the texture
  103565. * @param options defines the creation options
  103566. * @returns the cube texture as an InternalTexture
  103567. */
  103568. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103569. /**
  103570. * Update the sample count for a given multiple render target texture
  103571. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103572. * @param textures defines the textures to update
  103573. * @param samples defines the sample count to set
  103574. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103575. */
  103576. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103577. /**
  103578. * Select a subsets of attachments to draw to.
  103579. * @param attachments gl attachments
  103580. */
  103581. bindAttachments(attachments: number[]): void;
  103582. /**
  103583. * Creates a layout object to draw/clear on specific textures in a MRT
  103584. * @param textureStatus textureStatus[i] indicates if the i-th is active
  103585. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  103586. */
  103587. buildTextureLayout(textureStatus: boolean[]): number[];
  103588. /**
  103589. * Restores the webgl state to only draw on the main color attachment
  103590. */
  103591. restoreSingleAttachment(): void;
  103592. }
  103593. }
  103594. declare module BABYLON {
  103595. /**
  103596. * Creation options of the multi render target texture.
  103597. */
  103598. export interface IMultiRenderTargetOptions {
  103599. /**
  103600. * Define if the texture needs to create mip maps after render.
  103601. */
  103602. generateMipMaps?: boolean;
  103603. /**
  103604. * Define the types of all the draw buffers we want to create
  103605. */
  103606. types?: number[];
  103607. /**
  103608. * Define the sampling modes of all the draw buffers we want to create
  103609. */
  103610. samplingModes?: number[];
  103611. /**
  103612. * Define if a depth buffer is required
  103613. */
  103614. generateDepthBuffer?: boolean;
  103615. /**
  103616. * Define if a stencil buffer is required
  103617. */
  103618. generateStencilBuffer?: boolean;
  103619. /**
  103620. * Define if a depth texture is required instead of a depth buffer
  103621. */
  103622. generateDepthTexture?: boolean;
  103623. /**
  103624. * Define the number of desired draw buffers
  103625. */
  103626. textureCount?: number;
  103627. /**
  103628. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103629. */
  103630. doNotChangeAspectRatio?: boolean;
  103631. /**
  103632. * Define the default type of the buffers we are creating
  103633. */
  103634. defaultType?: number;
  103635. }
  103636. /**
  103637. * A multi render target, like a render target provides the ability to render to a texture.
  103638. * Unlike the render target, it can render to several draw buffers in one draw.
  103639. * This is specially interesting in deferred rendering or for any effects requiring more than
  103640. * just one color from a single pass.
  103641. */
  103642. export class MultiRenderTarget extends RenderTargetTexture {
  103643. private _internalTextures;
  103644. private _textures;
  103645. private _multiRenderTargetOptions;
  103646. private _count;
  103647. /**
  103648. * Get if draw buffers are currently supported by the used hardware and browser.
  103649. */
  103650. get isSupported(): boolean;
  103651. /**
  103652. * Get the list of textures generated by the multi render target.
  103653. */
  103654. get textures(): Texture[];
  103655. /**
  103656. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103657. */
  103658. get count(): number;
  103659. /**
  103660. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103661. */
  103662. get depthTexture(): Texture;
  103663. /**
  103664. * Set the wrapping mode on U of all the textures we are rendering to.
  103665. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103666. */
  103667. set wrapU(wrap: number);
  103668. /**
  103669. * Set the wrapping mode on V of all the textures we are rendering to.
  103670. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103671. */
  103672. set wrapV(wrap: number);
  103673. /**
  103674. * Instantiate a new multi render target texture.
  103675. * A multi render target, like a render target provides the ability to render to a texture.
  103676. * Unlike the render target, it can render to several draw buffers in one draw.
  103677. * This is specially interesting in deferred rendering or for any effects requiring more than
  103678. * just one color from a single pass.
  103679. * @param name Define the name of the texture
  103680. * @param size Define the size of the buffers to render to
  103681. * @param count Define the number of target we are rendering into
  103682. * @param scene Define the scene the texture belongs to
  103683. * @param options Define the options used to create the multi render target
  103684. */
  103685. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103686. private _initTypes;
  103687. /** @hidden */
  103688. _rebuild(forceFullRebuild?: boolean): void;
  103689. private _createInternalTextures;
  103690. private _createTextures;
  103691. /**
  103692. * Replaces a texture within the MRT.
  103693. * @param texture The new texture to insert in the MRT
  103694. * @param index The index of the texture to replace
  103695. */
  103696. replaceTexture(texture: Texture, index: number): void;
  103697. /**
  103698. * Define the number of samples used if MSAA is enabled.
  103699. */
  103700. get samples(): number;
  103701. set samples(value: number);
  103702. /**
  103703. * Resize all the textures in the multi render target.
  103704. * Be careful as it will recreate all the data in the new texture.
  103705. * @param size Define the new size
  103706. */
  103707. resize(size: any): void;
  103708. /**
  103709. * Changes the number of render targets in this MRT
  103710. * Be careful as it will recreate all the data in the new texture.
  103711. * @param count new texture count
  103712. * @param options Specifies texture types and sampling modes for new textures
  103713. */
  103714. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103715. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103716. /**
  103717. * Dispose the render targets and their associated resources
  103718. */
  103719. dispose(): void;
  103720. /**
  103721. * Release all the underlying texture used as draw buffers.
  103722. */
  103723. releaseInternalTextures(): void;
  103724. }
  103725. }
  103726. declare module BABYLON {
  103727. /** @hidden */
  103728. export var imageProcessingPixelShader: {
  103729. name: string;
  103730. shader: string;
  103731. };
  103732. }
  103733. declare module BABYLON {
  103734. /**
  103735. * ImageProcessingPostProcess
  103736. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103737. */
  103738. export class ImageProcessingPostProcess extends PostProcess {
  103739. /**
  103740. * Default configuration related to image processing available in the PBR Material.
  103741. */
  103742. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103743. /**
  103744. * Gets the image processing configuration used either in this material.
  103745. */
  103746. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103747. /**
  103748. * Sets the Default image processing configuration used either in the this material.
  103749. *
  103750. * If sets to null, the scene one is in use.
  103751. */
  103752. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103753. /**
  103754. * Keep track of the image processing observer to allow dispose and replace.
  103755. */
  103756. private _imageProcessingObserver;
  103757. /**
  103758. * Attaches a new image processing configuration to the PBR Material.
  103759. * @param configuration
  103760. */
  103761. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103762. /**
  103763. * If the post process is supported.
  103764. */
  103765. get isSupported(): boolean;
  103766. /**
  103767. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103768. */
  103769. get colorCurves(): Nullable<ColorCurves>;
  103770. /**
  103771. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103772. */
  103773. set colorCurves(value: Nullable<ColorCurves>);
  103774. /**
  103775. * Gets wether the color curves effect is enabled.
  103776. */
  103777. get colorCurvesEnabled(): boolean;
  103778. /**
  103779. * Sets wether the color curves effect is enabled.
  103780. */
  103781. set colorCurvesEnabled(value: boolean);
  103782. /**
  103783. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103784. */
  103785. get colorGradingTexture(): Nullable<BaseTexture>;
  103786. /**
  103787. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103788. */
  103789. set colorGradingTexture(value: Nullable<BaseTexture>);
  103790. /**
  103791. * Gets wether the color grading effect is enabled.
  103792. */
  103793. get colorGradingEnabled(): boolean;
  103794. /**
  103795. * Gets wether the color grading effect is enabled.
  103796. */
  103797. set colorGradingEnabled(value: boolean);
  103798. /**
  103799. * Gets exposure used in the effect.
  103800. */
  103801. get exposure(): number;
  103802. /**
  103803. * Sets exposure used in the effect.
  103804. */
  103805. set exposure(value: number);
  103806. /**
  103807. * Gets wether tonemapping is enabled or not.
  103808. */
  103809. get toneMappingEnabled(): boolean;
  103810. /**
  103811. * Sets wether tonemapping is enabled or not
  103812. */
  103813. set toneMappingEnabled(value: boolean);
  103814. /**
  103815. * Gets the type of tone mapping effect.
  103816. */
  103817. get toneMappingType(): number;
  103818. /**
  103819. * Sets the type of tone mapping effect.
  103820. */
  103821. set toneMappingType(value: number);
  103822. /**
  103823. * Gets contrast used in the effect.
  103824. */
  103825. get contrast(): number;
  103826. /**
  103827. * Sets contrast used in the effect.
  103828. */
  103829. set contrast(value: number);
  103830. /**
  103831. * Gets Vignette stretch size.
  103832. */
  103833. get vignetteStretch(): number;
  103834. /**
  103835. * Sets Vignette stretch size.
  103836. */
  103837. set vignetteStretch(value: number);
  103838. /**
  103839. * Gets Vignette centre X Offset.
  103840. */
  103841. get vignetteCentreX(): number;
  103842. /**
  103843. * Sets Vignette centre X Offset.
  103844. */
  103845. set vignetteCentreX(value: number);
  103846. /**
  103847. * Gets Vignette centre Y Offset.
  103848. */
  103849. get vignetteCentreY(): number;
  103850. /**
  103851. * Sets Vignette centre Y Offset.
  103852. */
  103853. set vignetteCentreY(value: number);
  103854. /**
  103855. * Gets Vignette weight or intensity of the vignette effect.
  103856. */
  103857. get vignetteWeight(): number;
  103858. /**
  103859. * Sets Vignette weight or intensity of the vignette effect.
  103860. */
  103861. set vignetteWeight(value: number);
  103862. /**
  103863. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103864. * if vignetteEnabled is set to true.
  103865. */
  103866. get vignetteColor(): Color4;
  103867. /**
  103868. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103869. * if vignetteEnabled is set to true.
  103870. */
  103871. set vignetteColor(value: Color4);
  103872. /**
  103873. * Gets Camera field of view used by the Vignette effect.
  103874. */
  103875. get vignetteCameraFov(): number;
  103876. /**
  103877. * Sets Camera field of view used by the Vignette effect.
  103878. */
  103879. set vignetteCameraFov(value: number);
  103880. /**
  103881. * Gets the vignette blend mode allowing different kind of effect.
  103882. */
  103883. get vignetteBlendMode(): number;
  103884. /**
  103885. * Sets the vignette blend mode allowing different kind of effect.
  103886. */
  103887. set vignetteBlendMode(value: number);
  103888. /**
  103889. * Gets wether the vignette effect is enabled.
  103890. */
  103891. get vignetteEnabled(): boolean;
  103892. /**
  103893. * Sets wether the vignette effect is enabled.
  103894. */
  103895. set vignetteEnabled(value: boolean);
  103896. private _fromLinearSpace;
  103897. /**
  103898. * Gets wether the input of the processing is in Gamma or Linear Space.
  103899. */
  103900. get fromLinearSpace(): boolean;
  103901. /**
  103902. * Sets wether the input of the processing is in Gamma or Linear Space.
  103903. */
  103904. set fromLinearSpace(value: boolean);
  103905. /**
  103906. * Defines cache preventing GC.
  103907. */
  103908. private _defines;
  103909. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103910. /**
  103911. * "ImageProcessingPostProcess"
  103912. * @returns "ImageProcessingPostProcess"
  103913. */
  103914. getClassName(): string;
  103915. /**
  103916. * @hidden
  103917. */
  103918. _updateParameters(): void;
  103919. dispose(camera?: Camera): void;
  103920. }
  103921. }
  103922. declare module BABYLON {
  103923. /**
  103924. * Interface for defining prepass effects in the prepass post-process pipeline
  103925. */
  103926. export interface PrePassEffectConfiguration {
  103927. /**
  103928. * Name of the effect
  103929. */
  103930. name: string;
  103931. /**
  103932. * Post process to attach for this effect
  103933. */
  103934. postProcess?: PostProcess;
  103935. /**
  103936. * Textures required in the MRT
  103937. */
  103938. texturesRequired: number[];
  103939. /**
  103940. * Is the effect enabled
  103941. */
  103942. enabled: boolean;
  103943. /**
  103944. * Disposes the effect configuration
  103945. */
  103946. dispose?: () => void;
  103947. /**
  103948. * Creates the associated post process
  103949. */
  103950. createPostProcess?: () => PostProcess;
  103951. }
  103952. }
  103953. declare module BABYLON {
  103954. /**
  103955. * Options to be used when creating a FresnelParameters.
  103956. */
  103957. export type IFresnelParametersCreationOptions = {
  103958. /**
  103959. * Define the color used on edges (grazing angle)
  103960. */
  103961. leftColor?: Color3;
  103962. /**
  103963. * Define the color used on center
  103964. */
  103965. rightColor?: Color3;
  103966. /**
  103967. * Define bias applied to computed fresnel term
  103968. */
  103969. bias?: number;
  103970. /**
  103971. * Defined the power exponent applied to fresnel term
  103972. */
  103973. power?: number;
  103974. /**
  103975. * Define if the fresnel effect is enable or not.
  103976. */
  103977. isEnabled?: boolean;
  103978. };
  103979. /**
  103980. * Serialized format for FresnelParameters.
  103981. */
  103982. export type IFresnelParametersSerialized = {
  103983. /**
  103984. * Define the color used on edges (grazing angle) [as an array]
  103985. */
  103986. leftColor: number[];
  103987. /**
  103988. * Define the color used on center [as an array]
  103989. */
  103990. rightColor: number[];
  103991. /**
  103992. * Define bias applied to computed fresnel term
  103993. */
  103994. bias: number;
  103995. /**
  103996. * Defined the power exponent applied to fresnel term
  103997. */
  103998. power?: number;
  103999. /**
  104000. * Define if the fresnel effect is enable or not.
  104001. */
  104002. isEnabled: boolean;
  104003. };
  104004. /**
  104005. * This represents all the required information to add a fresnel effect on a material:
  104006. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104007. */
  104008. export class FresnelParameters {
  104009. private _isEnabled;
  104010. /**
  104011. * Define if the fresnel effect is enable or not.
  104012. */
  104013. get isEnabled(): boolean;
  104014. set isEnabled(value: boolean);
  104015. /**
  104016. * Define the color used on edges (grazing angle)
  104017. */
  104018. leftColor: Color3;
  104019. /**
  104020. * Define the color used on center
  104021. */
  104022. rightColor: Color3;
  104023. /**
  104024. * Define bias applied to computed fresnel term
  104025. */
  104026. bias: number;
  104027. /**
  104028. * Defined the power exponent applied to fresnel term
  104029. */
  104030. power: number;
  104031. /**
  104032. * Creates a new FresnelParameters object.
  104033. *
  104034. * @param options provide your own settings to optionally to override defaults
  104035. */
  104036. constructor(options?: IFresnelParametersCreationOptions);
  104037. /**
  104038. * Clones the current fresnel and its valuues
  104039. * @returns a clone fresnel configuration
  104040. */
  104041. clone(): FresnelParameters;
  104042. /**
  104043. * Determines equality between FresnelParameters objects
  104044. * @param otherFresnelParameters defines the second operand
  104045. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  104046. */
  104047. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  104048. /**
  104049. * Serializes the current fresnel parameters to a JSON representation.
  104050. * @return the JSON serialization
  104051. */
  104052. serialize(): IFresnelParametersSerialized;
  104053. /**
  104054. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  104055. * @param parsedFresnelParameters Define the JSON representation
  104056. * @returns the parsed parameters
  104057. */
  104058. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  104059. }
  104060. }
  104061. declare module BABYLON {
  104062. /**
  104063. * This groups all the flags used to control the materials channel.
  104064. */
  104065. export class MaterialFlags {
  104066. private static _DiffuseTextureEnabled;
  104067. /**
  104068. * Are diffuse textures enabled in the application.
  104069. */
  104070. static get DiffuseTextureEnabled(): boolean;
  104071. static set DiffuseTextureEnabled(value: boolean);
  104072. private static _DetailTextureEnabled;
  104073. /**
  104074. * Are detail textures enabled in the application.
  104075. */
  104076. static get DetailTextureEnabled(): boolean;
  104077. static set DetailTextureEnabled(value: boolean);
  104078. private static _AmbientTextureEnabled;
  104079. /**
  104080. * Are ambient textures enabled in the application.
  104081. */
  104082. static get AmbientTextureEnabled(): boolean;
  104083. static set AmbientTextureEnabled(value: boolean);
  104084. private static _OpacityTextureEnabled;
  104085. /**
  104086. * Are opacity textures enabled in the application.
  104087. */
  104088. static get OpacityTextureEnabled(): boolean;
  104089. static set OpacityTextureEnabled(value: boolean);
  104090. private static _ReflectionTextureEnabled;
  104091. /**
  104092. * Are reflection textures enabled in the application.
  104093. */
  104094. static get ReflectionTextureEnabled(): boolean;
  104095. static set ReflectionTextureEnabled(value: boolean);
  104096. private static _EmissiveTextureEnabled;
  104097. /**
  104098. * Are emissive textures enabled in the application.
  104099. */
  104100. static get EmissiveTextureEnabled(): boolean;
  104101. static set EmissiveTextureEnabled(value: boolean);
  104102. private static _SpecularTextureEnabled;
  104103. /**
  104104. * Are specular textures enabled in the application.
  104105. */
  104106. static get SpecularTextureEnabled(): boolean;
  104107. static set SpecularTextureEnabled(value: boolean);
  104108. private static _BumpTextureEnabled;
  104109. /**
  104110. * Are bump textures enabled in the application.
  104111. */
  104112. static get BumpTextureEnabled(): boolean;
  104113. static set BumpTextureEnabled(value: boolean);
  104114. private static _LightmapTextureEnabled;
  104115. /**
  104116. * Are lightmap textures enabled in the application.
  104117. */
  104118. static get LightmapTextureEnabled(): boolean;
  104119. static set LightmapTextureEnabled(value: boolean);
  104120. private static _RefractionTextureEnabled;
  104121. /**
  104122. * Are refraction textures enabled in the application.
  104123. */
  104124. static get RefractionTextureEnabled(): boolean;
  104125. static set RefractionTextureEnabled(value: boolean);
  104126. private static _ColorGradingTextureEnabled;
  104127. /**
  104128. * Are color grading textures enabled in the application.
  104129. */
  104130. static get ColorGradingTextureEnabled(): boolean;
  104131. static set ColorGradingTextureEnabled(value: boolean);
  104132. private static _FresnelEnabled;
  104133. /**
  104134. * Are fresnels enabled in the application.
  104135. */
  104136. static get FresnelEnabled(): boolean;
  104137. static set FresnelEnabled(value: boolean);
  104138. private static _ClearCoatTextureEnabled;
  104139. /**
  104140. * Are clear coat textures enabled in the application.
  104141. */
  104142. static get ClearCoatTextureEnabled(): boolean;
  104143. static set ClearCoatTextureEnabled(value: boolean);
  104144. private static _ClearCoatBumpTextureEnabled;
  104145. /**
  104146. * Are clear coat bump textures enabled in the application.
  104147. */
  104148. static get ClearCoatBumpTextureEnabled(): boolean;
  104149. static set ClearCoatBumpTextureEnabled(value: boolean);
  104150. private static _ClearCoatTintTextureEnabled;
  104151. /**
  104152. * Are clear coat tint textures enabled in the application.
  104153. */
  104154. static get ClearCoatTintTextureEnabled(): boolean;
  104155. static set ClearCoatTintTextureEnabled(value: boolean);
  104156. private static _SheenTextureEnabled;
  104157. /**
  104158. * Are sheen textures enabled in the application.
  104159. */
  104160. static get SheenTextureEnabled(): boolean;
  104161. static set SheenTextureEnabled(value: boolean);
  104162. private static _AnisotropicTextureEnabled;
  104163. /**
  104164. * Are anisotropic textures enabled in the application.
  104165. */
  104166. static get AnisotropicTextureEnabled(): boolean;
  104167. static set AnisotropicTextureEnabled(value: boolean);
  104168. private static _ThicknessTextureEnabled;
  104169. /**
  104170. * Are thickness textures enabled in the application.
  104171. */
  104172. static get ThicknessTextureEnabled(): boolean;
  104173. static set ThicknessTextureEnabled(value: boolean);
  104174. }
  104175. }
  104176. declare module BABYLON {
  104177. /** @hidden */
  104178. export var defaultFragmentDeclaration: {
  104179. name: string;
  104180. shader: string;
  104181. };
  104182. }
  104183. declare module BABYLON {
  104184. /** @hidden */
  104185. export var defaultUboDeclaration: {
  104186. name: string;
  104187. shader: string;
  104188. };
  104189. }
  104190. declare module BABYLON {
  104191. /** @hidden */
  104192. export var prePassDeclaration: {
  104193. name: string;
  104194. shader: string;
  104195. };
  104196. }
  104197. declare module BABYLON {
  104198. /** @hidden */
  104199. export var lightFragmentDeclaration: {
  104200. name: string;
  104201. shader: string;
  104202. };
  104203. }
  104204. declare module BABYLON {
  104205. /** @hidden */
  104206. export var lightUboDeclaration: {
  104207. name: string;
  104208. shader: string;
  104209. };
  104210. }
  104211. declare module BABYLON {
  104212. /** @hidden */
  104213. export var lightsFragmentFunctions: {
  104214. name: string;
  104215. shader: string;
  104216. };
  104217. }
  104218. declare module BABYLON {
  104219. /** @hidden */
  104220. export var shadowsFragmentFunctions: {
  104221. name: string;
  104222. shader: string;
  104223. };
  104224. }
  104225. declare module BABYLON {
  104226. /** @hidden */
  104227. export var fresnelFunction: {
  104228. name: string;
  104229. shader: string;
  104230. };
  104231. }
  104232. declare module BABYLON {
  104233. /** @hidden */
  104234. export var bumpFragmentMainFunctions: {
  104235. name: string;
  104236. shader: string;
  104237. };
  104238. }
  104239. declare module BABYLON {
  104240. /** @hidden */
  104241. export var bumpFragmentFunctions: {
  104242. name: string;
  104243. shader: string;
  104244. };
  104245. }
  104246. declare module BABYLON {
  104247. /** @hidden */
  104248. export var logDepthDeclaration: {
  104249. name: string;
  104250. shader: string;
  104251. };
  104252. }
  104253. declare module BABYLON {
  104254. /** @hidden */
  104255. export var bumpFragment: {
  104256. name: string;
  104257. shader: string;
  104258. };
  104259. }
  104260. declare module BABYLON {
  104261. /** @hidden */
  104262. export var depthPrePass: {
  104263. name: string;
  104264. shader: string;
  104265. };
  104266. }
  104267. declare module BABYLON {
  104268. /** @hidden */
  104269. export var lightFragment: {
  104270. name: string;
  104271. shader: string;
  104272. };
  104273. }
  104274. declare module BABYLON {
  104275. /** @hidden */
  104276. export var logDepthFragment: {
  104277. name: string;
  104278. shader: string;
  104279. };
  104280. }
  104281. declare module BABYLON {
  104282. /** @hidden */
  104283. export var defaultPixelShader: {
  104284. name: string;
  104285. shader: string;
  104286. };
  104287. }
  104288. declare module BABYLON {
  104289. /** @hidden */
  104290. export var defaultVertexDeclaration: {
  104291. name: string;
  104292. shader: string;
  104293. };
  104294. }
  104295. declare module BABYLON {
  104296. /** @hidden */
  104297. export var prePassVertexDeclaration: {
  104298. name: string;
  104299. shader: string;
  104300. };
  104301. }
  104302. declare module BABYLON {
  104303. /** @hidden */
  104304. export var bumpVertexDeclaration: {
  104305. name: string;
  104306. shader: string;
  104307. };
  104308. }
  104309. declare module BABYLON {
  104310. /** @hidden */
  104311. export var prePassVertex: {
  104312. name: string;
  104313. shader: string;
  104314. };
  104315. }
  104316. declare module BABYLON {
  104317. /** @hidden */
  104318. export var bumpVertex: {
  104319. name: string;
  104320. shader: string;
  104321. };
  104322. }
  104323. declare module BABYLON {
  104324. /** @hidden */
  104325. export var fogVertex: {
  104326. name: string;
  104327. shader: string;
  104328. };
  104329. }
  104330. declare module BABYLON {
  104331. /** @hidden */
  104332. export var shadowsVertex: {
  104333. name: string;
  104334. shader: string;
  104335. };
  104336. }
  104337. declare module BABYLON {
  104338. /** @hidden */
  104339. export var pointCloudVertex: {
  104340. name: string;
  104341. shader: string;
  104342. };
  104343. }
  104344. declare module BABYLON {
  104345. /** @hidden */
  104346. export var logDepthVertex: {
  104347. name: string;
  104348. shader: string;
  104349. };
  104350. }
  104351. declare module BABYLON {
  104352. /** @hidden */
  104353. export var defaultVertexShader: {
  104354. name: string;
  104355. shader: string;
  104356. };
  104357. }
  104358. declare module BABYLON {
  104359. /**
  104360. * @hidden
  104361. */
  104362. export interface IMaterialDetailMapDefines {
  104363. DETAIL: boolean;
  104364. DETAILDIRECTUV: number;
  104365. DETAIL_NORMALBLENDMETHOD: number;
  104366. /** @hidden */
  104367. _areTexturesDirty: boolean;
  104368. }
  104369. /**
  104370. * Define the code related to the detail map parameters of a material
  104371. *
  104372. * Inspired from:
  104373. * 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
  104374. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  104375. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  104376. */
  104377. export class DetailMapConfiguration {
  104378. private _texture;
  104379. /**
  104380. * The detail texture of the material.
  104381. */
  104382. texture: Nullable<BaseTexture>;
  104383. /**
  104384. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  104385. * Bigger values mean stronger blending
  104386. */
  104387. diffuseBlendLevel: number;
  104388. /**
  104389. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  104390. * Bigger values mean stronger blending. Only used with PBR materials
  104391. */
  104392. roughnessBlendLevel: number;
  104393. /**
  104394. * Defines how strong the bump effect from the detail map is
  104395. * Bigger values mean stronger effect
  104396. */
  104397. bumpLevel: number;
  104398. private _normalBlendMethod;
  104399. /**
  104400. * The method used to blend the bump and detail normals together
  104401. */
  104402. normalBlendMethod: number;
  104403. private _isEnabled;
  104404. /**
  104405. * Enable or disable the detail map on this material
  104406. */
  104407. isEnabled: boolean;
  104408. /** @hidden */
  104409. private _internalMarkAllSubMeshesAsTexturesDirty;
  104410. /** @hidden */
  104411. _markAllSubMeshesAsTexturesDirty(): void;
  104412. /**
  104413. * Instantiate a new detail map
  104414. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104415. */
  104416. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104417. /**
  104418. * Gets whether the submesh is ready to be used or not.
  104419. * @param defines the list of "defines" to update.
  104420. * @param scene defines the scene the material belongs to.
  104421. * @returns - boolean indicating that the submesh is ready or not.
  104422. */
  104423. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  104424. /**
  104425. * Update the defines for detail map usage
  104426. * @param defines the list of "defines" to update.
  104427. * @param scene defines the scene the material belongs to.
  104428. */
  104429. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  104430. /**
  104431. * Binds the material data.
  104432. * @param uniformBuffer defines the Uniform buffer to fill in.
  104433. * @param scene defines the scene the material belongs to.
  104434. * @param isFrozen defines whether the material is frozen or not.
  104435. */
  104436. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104437. /**
  104438. * Checks to see if a texture is used in the material.
  104439. * @param texture - Base texture to use.
  104440. * @returns - Boolean specifying if a texture is used in the material.
  104441. */
  104442. hasTexture(texture: BaseTexture): boolean;
  104443. /**
  104444. * Returns an array of the actively used textures.
  104445. * @param activeTextures Array of BaseTextures
  104446. */
  104447. getActiveTextures(activeTextures: BaseTexture[]): void;
  104448. /**
  104449. * Returns the animatable textures.
  104450. * @param animatables Array of animatable textures.
  104451. */
  104452. getAnimatables(animatables: IAnimatable[]): void;
  104453. /**
  104454. * Disposes the resources of the material.
  104455. * @param forceDisposeTextures - Forces the disposal of all textures.
  104456. */
  104457. dispose(forceDisposeTextures?: boolean): void;
  104458. /**
  104459. * Get the current class name useful for serialization or dynamic coding.
  104460. * @returns "DetailMap"
  104461. */
  104462. getClassName(): string;
  104463. /**
  104464. * Add the required uniforms to the current list.
  104465. * @param uniforms defines the current uniform list.
  104466. */
  104467. static AddUniforms(uniforms: string[]): void;
  104468. /**
  104469. * Add the required samplers to the current list.
  104470. * @param samplers defines the current sampler list.
  104471. */
  104472. static AddSamplers(samplers: string[]): void;
  104473. /**
  104474. * Add the required uniforms to the current buffer.
  104475. * @param uniformBuffer defines the current uniform buffer.
  104476. */
  104477. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104478. /**
  104479. * Makes a duplicate of the current instance into another one.
  104480. * @param detailMap define the instance where to copy the info
  104481. */
  104482. copyTo(detailMap: DetailMapConfiguration): void;
  104483. /**
  104484. * Serializes this detail map instance
  104485. * @returns - An object with the serialized instance.
  104486. */
  104487. serialize(): any;
  104488. /**
  104489. * Parses a detail map setting from a serialized object.
  104490. * @param source - Serialized object.
  104491. * @param scene Defines the scene we are parsing for
  104492. * @param rootUrl Defines the rootUrl to load from
  104493. */
  104494. parse(source: any, scene: Scene, rootUrl: string): void;
  104495. }
  104496. }
  104497. declare module BABYLON {
  104498. /** @hidden */
  104499. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  104500. MAINUV1: boolean;
  104501. MAINUV2: boolean;
  104502. DIFFUSE: boolean;
  104503. DIFFUSEDIRECTUV: number;
  104504. DETAIL: boolean;
  104505. DETAILDIRECTUV: number;
  104506. DETAIL_NORMALBLENDMETHOD: number;
  104507. AMBIENT: boolean;
  104508. AMBIENTDIRECTUV: number;
  104509. OPACITY: boolean;
  104510. OPACITYDIRECTUV: number;
  104511. OPACITYRGB: boolean;
  104512. REFLECTION: boolean;
  104513. EMISSIVE: boolean;
  104514. EMISSIVEDIRECTUV: number;
  104515. SPECULAR: boolean;
  104516. SPECULARDIRECTUV: number;
  104517. BUMP: boolean;
  104518. BUMPDIRECTUV: number;
  104519. PARALLAX: boolean;
  104520. PARALLAXOCCLUSION: boolean;
  104521. SPECULAROVERALPHA: boolean;
  104522. CLIPPLANE: boolean;
  104523. CLIPPLANE2: boolean;
  104524. CLIPPLANE3: boolean;
  104525. CLIPPLANE4: boolean;
  104526. CLIPPLANE5: boolean;
  104527. CLIPPLANE6: boolean;
  104528. ALPHATEST: boolean;
  104529. DEPTHPREPASS: boolean;
  104530. ALPHAFROMDIFFUSE: boolean;
  104531. POINTSIZE: boolean;
  104532. FOG: boolean;
  104533. SPECULARTERM: boolean;
  104534. DIFFUSEFRESNEL: boolean;
  104535. OPACITYFRESNEL: boolean;
  104536. REFLECTIONFRESNEL: boolean;
  104537. REFRACTIONFRESNEL: boolean;
  104538. EMISSIVEFRESNEL: boolean;
  104539. FRESNEL: boolean;
  104540. NORMAL: boolean;
  104541. UV1: boolean;
  104542. UV2: boolean;
  104543. VERTEXCOLOR: boolean;
  104544. VERTEXALPHA: boolean;
  104545. NUM_BONE_INFLUENCERS: number;
  104546. BonesPerMesh: number;
  104547. BONETEXTURE: boolean;
  104548. BONES_VELOCITY_ENABLED: boolean;
  104549. INSTANCES: boolean;
  104550. THIN_INSTANCES: boolean;
  104551. GLOSSINESS: boolean;
  104552. ROUGHNESS: boolean;
  104553. EMISSIVEASILLUMINATION: boolean;
  104554. LINKEMISSIVEWITHDIFFUSE: boolean;
  104555. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104556. LIGHTMAP: boolean;
  104557. LIGHTMAPDIRECTUV: number;
  104558. OBJECTSPACE_NORMALMAP: boolean;
  104559. USELIGHTMAPASSHADOWMAP: boolean;
  104560. REFLECTIONMAP_3D: boolean;
  104561. REFLECTIONMAP_SPHERICAL: boolean;
  104562. REFLECTIONMAP_PLANAR: boolean;
  104563. REFLECTIONMAP_CUBIC: boolean;
  104564. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104565. REFLECTIONMAP_PROJECTION: boolean;
  104566. REFLECTIONMAP_SKYBOX: boolean;
  104567. REFLECTIONMAP_EXPLICIT: boolean;
  104568. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104569. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104570. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104571. INVERTCUBICMAP: boolean;
  104572. LOGARITHMICDEPTH: boolean;
  104573. REFRACTION: boolean;
  104574. REFRACTIONMAP_3D: boolean;
  104575. REFLECTIONOVERALPHA: boolean;
  104576. TWOSIDEDLIGHTING: boolean;
  104577. SHADOWFLOAT: boolean;
  104578. MORPHTARGETS: boolean;
  104579. MORPHTARGETS_NORMAL: boolean;
  104580. MORPHTARGETS_TANGENT: boolean;
  104581. MORPHTARGETS_UV: boolean;
  104582. NUM_MORPH_INFLUENCERS: number;
  104583. NONUNIFORMSCALING: boolean;
  104584. PREMULTIPLYALPHA: boolean;
  104585. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  104586. ALPHABLEND: boolean;
  104587. PREPASS: boolean;
  104588. PREPASS_IRRADIANCE: boolean;
  104589. PREPASS_IRRADIANCE_INDEX: number;
  104590. PREPASS_ALBEDO: boolean;
  104591. PREPASS_ALBEDO_INDEX: number;
  104592. PREPASS_DEPTHNORMAL: boolean;
  104593. PREPASS_DEPTHNORMAL_INDEX: number;
  104594. PREPASS_POSITION: boolean;
  104595. PREPASS_POSITION_INDEX: number;
  104596. PREPASS_VELOCITY: boolean;
  104597. PREPASS_VELOCITY_INDEX: number;
  104598. PREPASS_REFLECTIVITY: boolean;
  104599. PREPASS_REFLECTIVITY_INDEX: number;
  104600. SCENE_MRT_COUNT: number;
  104601. RGBDLIGHTMAP: boolean;
  104602. RGBDREFLECTION: boolean;
  104603. RGBDREFRACTION: boolean;
  104604. IMAGEPROCESSING: boolean;
  104605. VIGNETTE: boolean;
  104606. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104607. VIGNETTEBLENDMODEOPAQUE: boolean;
  104608. TONEMAPPING: boolean;
  104609. TONEMAPPING_ACES: boolean;
  104610. CONTRAST: boolean;
  104611. COLORCURVES: boolean;
  104612. COLORGRADING: boolean;
  104613. COLORGRADING3D: boolean;
  104614. SAMPLER3DGREENDEPTH: boolean;
  104615. SAMPLER3DBGRMAP: boolean;
  104616. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104617. MULTIVIEW: boolean;
  104618. /**
  104619. * If the reflection texture on this material is in linear color space
  104620. * @hidden
  104621. */
  104622. IS_REFLECTION_LINEAR: boolean;
  104623. /**
  104624. * If the refraction texture on this material is in linear color space
  104625. * @hidden
  104626. */
  104627. IS_REFRACTION_LINEAR: boolean;
  104628. EXPOSURE: boolean;
  104629. constructor();
  104630. setReflectionMode(modeToEnable: string): void;
  104631. }
  104632. /**
  104633. * This is the default material used in Babylon. It is the best trade off between quality
  104634. * and performances.
  104635. * @see https://doc.babylonjs.com/babylon101/materials
  104636. */
  104637. export class StandardMaterial extends PushMaterial {
  104638. private _diffuseTexture;
  104639. /**
  104640. * The basic texture of the material as viewed under a light.
  104641. */
  104642. diffuseTexture: Nullable<BaseTexture>;
  104643. private _ambientTexture;
  104644. /**
  104645. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104646. */
  104647. ambientTexture: Nullable<BaseTexture>;
  104648. private _opacityTexture;
  104649. /**
  104650. * Define the transparency of the material from a texture.
  104651. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104652. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104653. */
  104654. opacityTexture: Nullable<BaseTexture>;
  104655. private _reflectionTexture;
  104656. /**
  104657. * Define the texture used to display the reflection.
  104658. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104659. */
  104660. reflectionTexture: Nullable<BaseTexture>;
  104661. private _emissiveTexture;
  104662. /**
  104663. * Define texture of the material as if self lit.
  104664. * This will be mixed in the final result even in the absence of light.
  104665. */
  104666. emissiveTexture: Nullable<BaseTexture>;
  104667. private _specularTexture;
  104668. /**
  104669. * Define how the color and intensity of the highlight given by the light in the material.
  104670. */
  104671. specularTexture: Nullable<BaseTexture>;
  104672. private _bumpTexture;
  104673. /**
  104674. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104675. * 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.
  104676. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  104677. */
  104678. bumpTexture: Nullable<BaseTexture>;
  104679. private _lightmapTexture;
  104680. /**
  104681. * Complex lighting can be computationally expensive to compute at runtime.
  104682. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104683. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  104684. */
  104685. lightmapTexture: Nullable<BaseTexture>;
  104686. private _refractionTexture;
  104687. /**
  104688. * Define the texture used to display the refraction.
  104689. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104690. */
  104691. refractionTexture: Nullable<BaseTexture>;
  104692. /**
  104693. * The color of the material lit by the environmental background lighting.
  104694. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104695. */
  104696. ambientColor: Color3;
  104697. /**
  104698. * The basic color of the material as viewed under a light.
  104699. */
  104700. diffuseColor: Color3;
  104701. /**
  104702. * Define how the color and intensity of the highlight given by the light in the material.
  104703. */
  104704. specularColor: Color3;
  104705. /**
  104706. * Define the color of the material as if self lit.
  104707. * This will be mixed in the final result even in the absence of light.
  104708. */
  104709. emissiveColor: Color3;
  104710. /**
  104711. * Defines how sharp are the highlights in the material.
  104712. * The bigger the value the sharper giving a more glossy feeling to the result.
  104713. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104714. */
  104715. specularPower: number;
  104716. private _useAlphaFromDiffuseTexture;
  104717. /**
  104718. * Does the transparency come from the diffuse texture alpha channel.
  104719. */
  104720. useAlphaFromDiffuseTexture: boolean;
  104721. private _useEmissiveAsIllumination;
  104722. /**
  104723. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104724. */
  104725. useEmissiveAsIllumination: boolean;
  104726. private _linkEmissiveWithDiffuse;
  104727. /**
  104728. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104729. * the emissive level when the final color is close to one.
  104730. */
  104731. linkEmissiveWithDiffuse: boolean;
  104732. private _useSpecularOverAlpha;
  104733. /**
  104734. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104735. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104736. */
  104737. useSpecularOverAlpha: boolean;
  104738. private _useReflectionOverAlpha;
  104739. /**
  104740. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104741. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104742. */
  104743. useReflectionOverAlpha: boolean;
  104744. private _disableLighting;
  104745. /**
  104746. * Does lights from the scene impacts this material.
  104747. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104748. */
  104749. disableLighting: boolean;
  104750. private _useObjectSpaceNormalMap;
  104751. /**
  104752. * Allows using an object space normal map (instead of tangent space).
  104753. */
  104754. useObjectSpaceNormalMap: boolean;
  104755. private _useParallax;
  104756. /**
  104757. * Is parallax enabled or not.
  104758. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104759. */
  104760. useParallax: boolean;
  104761. private _useParallaxOcclusion;
  104762. /**
  104763. * Is parallax occlusion enabled or not.
  104764. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104765. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104766. */
  104767. useParallaxOcclusion: boolean;
  104768. /**
  104769. * 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.
  104770. */
  104771. parallaxScaleBias: number;
  104772. private _roughness;
  104773. /**
  104774. * Helps to define how blurry the reflections should appears in the material.
  104775. */
  104776. roughness: number;
  104777. /**
  104778. * In case of refraction, define the value of the index of refraction.
  104779. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104780. */
  104781. indexOfRefraction: number;
  104782. /**
  104783. * Invert the refraction texture alongside the y axis.
  104784. * It can be useful with procedural textures or probe for instance.
  104785. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104786. */
  104787. invertRefractionY: boolean;
  104788. /**
  104789. * Defines the alpha limits in alpha test mode.
  104790. */
  104791. alphaCutOff: number;
  104792. private _useLightmapAsShadowmap;
  104793. /**
  104794. * In case of light mapping, define whether the map contains light or shadow informations.
  104795. */
  104796. useLightmapAsShadowmap: boolean;
  104797. private _diffuseFresnelParameters;
  104798. /**
  104799. * Define the diffuse fresnel parameters of the material.
  104800. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104801. */
  104802. diffuseFresnelParameters: FresnelParameters;
  104803. private _opacityFresnelParameters;
  104804. /**
  104805. * Define the opacity fresnel parameters of the material.
  104806. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104807. */
  104808. opacityFresnelParameters: FresnelParameters;
  104809. private _reflectionFresnelParameters;
  104810. /**
  104811. * Define the reflection fresnel parameters of the material.
  104812. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104813. */
  104814. reflectionFresnelParameters: FresnelParameters;
  104815. private _refractionFresnelParameters;
  104816. /**
  104817. * Define the refraction fresnel parameters of the material.
  104818. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104819. */
  104820. refractionFresnelParameters: FresnelParameters;
  104821. private _emissiveFresnelParameters;
  104822. /**
  104823. * Define the emissive fresnel parameters of the material.
  104824. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104825. */
  104826. emissiveFresnelParameters: FresnelParameters;
  104827. private _useReflectionFresnelFromSpecular;
  104828. /**
  104829. * If true automatically deducts the fresnels values from the material specularity.
  104830. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104831. */
  104832. useReflectionFresnelFromSpecular: boolean;
  104833. private _useGlossinessFromSpecularMapAlpha;
  104834. /**
  104835. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104836. */
  104837. useGlossinessFromSpecularMapAlpha: boolean;
  104838. private _maxSimultaneousLights;
  104839. /**
  104840. * Defines the maximum number of lights that can be used in the material
  104841. */
  104842. maxSimultaneousLights: number;
  104843. private _invertNormalMapX;
  104844. /**
  104845. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104846. */
  104847. invertNormalMapX: boolean;
  104848. private _invertNormalMapY;
  104849. /**
  104850. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104851. */
  104852. invertNormalMapY: boolean;
  104853. private _twoSidedLighting;
  104854. /**
  104855. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104856. */
  104857. twoSidedLighting: boolean;
  104858. /**
  104859. * Default configuration related to image processing available in the standard Material.
  104860. */
  104861. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104862. /**
  104863. * Gets the image processing configuration used either in this material.
  104864. */
  104865. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104866. /**
  104867. * Sets the Default image processing configuration used either in the this material.
  104868. *
  104869. * If sets to null, the scene one is in use.
  104870. */
  104871. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104872. /**
  104873. * Keep track of the image processing observer to allow dispose and replace.
  104874. */
  104875. private _imageProcessingObserver;
  104876. /**
  104877. * Attaches a new image processing configuration to the Standard Material.
  104878. * @param configuration
  104879. */
  104880. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104881. /**
  104882. * Defines additionnal PrePass parameters for the material.
  104883. */
  104884. readonly prePassConfiguration: PrePassConfiguration;
  104885. /**
  104886. * Gets wether the color curves effect is enabled.
  104887. */
  104888. get cameraColorCurvesEnabled(): boolean;
  104889. /**
  104890. * Sets wether the color curves effect is enabled.
  104891. */
  104892. set cameraColorCurvesEnabled(value: boolean);
  104893. /**
  104894. * Gets wether the color grading effect is enabled.
  104895. */
  104896. get cameraColorGradingEnabled(): boolean;
  104897. /**
  104898. * Gets wether the color grading effect is enabled.
  104899. */
  104900. set cameraColorGradingEnabled(value: boolean);
  104901. /**
  104902. * Gets wether tonemapping is enabled or not.
  104903. */
  104904. get cameraToneMappingEnabled(): boolean;
  104905. /**
  104906. * Sets wether tonemapping is enabled or not
  104907. */
  104908. set cameraToneMappingEnabled(value: boolean);
  104909. /**
  104910. * The camera exposure used on this material.
  104911. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104912. * This corresponds to a photographic exposure.
  104913. */
  104914. get cameraExposure(): number;
  104915. /**
  104916. * The camera exposure used on this material.
  104917. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104918. * This corresponds to a photographic exposure.
  104919. */
  104920. set cameraExposure(value: number);
  104921. /**
  104922. * Gets The camera contrast used on this material.
  104923. */
  104924. get cameraContrast(): number;
  104925. /**
  104926. * Sets The camera contrast used on this material.
  104927. */
  104928. set cameraContrast(value: number);
  104929. /**
  104930. * Gets the Color Grading 2D Lookup Texture.
  104931. */
  104932. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  104933. /**
  104934. * Sets the Color Grading 2D Lookup Texture.
  104935. */
  104936. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  104937. /**
  104938. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104939. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104940. * 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;
  104941. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104942. */
  104943. get cameraColorCurves(): Nullable<ColorCurves>;
  104944. /**
  104945. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104946. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104947. * 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;
  104948. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104949. */
  104950. set cameraColorCurves(value: Nullable<ColorCurves>);
  104951. /**
  104952. * Can this material render to several textures at once
  104953. */
  104954. get canRenderToMRT(): boolean;
  104955. /**
  104956. * Defines the detail map parameters for the material.
  104957. */
  104958. readonly detailMap: DetailMapConfiguration;
  104959. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104960. protected _worldViewProjectionMatrix: Matrix;
  104961. protected _globalAmbientColor: Color3;
  104962. protected _useLogarithmicDepth: boolean;
  104963. protected _rebuildInParallel: boolean;
  104964. /**
  104965. * Instantiates a new standard material.
  104966. * This is the default material used in Babylon. It is the best trade off between quality
  104967. * and performances.
  104968. * @see https://doc.babylonjs.com/babylon101/materials
  104969. * @param name Define the name of the material in the scene
  104970. * @param scene Define the scene the material belong to
  104971. */
  104972. constructor(name: string, scene: Scene);
  104973. /**
  104974. * Gets a boolean indicating that current material needs to register RTT
  104975. */
  104976. get hasRenderTargetTextures(): boolean;
  104977. /**
  104978. * Gets the current class name of the material e.g. "StandardMaterial"
  104979. * Mainly use in serialization.
  104980. * @returns the class name
  104981. */
  104982. getClassName(): string;
  104983. /**
  104984. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104985. * You can try switching to logarithmic depth.
  104986. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104987. */
  104988. get useLogarithmicDepth(): boolean;
  104989. set useLogarithmicDepth(value: boolean);
  104990. /**
  104991. * Specifies if the material will require alpha blending
  104992. * @returns a boolean specifying if alpha blending is needed
  104993. */
  104994. needAlphaBlending(): boolean;
  104995. /**
  104996. * Specifies if this material should be rendered in alpha test mode
  104997. * @returns a boolean specifying if an alpha test is needed.
  104998. */
  104999. needAlphaTesting(): boolean;
  105000. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105001. /**
  105002. * Get the texture used for alpha test purpose.
  105003. * @returns the diffuse texture in case of the standard material.
  105004. */
  105005. getAlphaTestTexture(): Nullable<BaseTexture>;
  105006. /**
  105007. * Get if the submesh is ready to be used and all its information available.
  105008. * Child classes can use it to update shaders
  105009. * @param mesh defines the mesh to check
  105010. * @param subMesh defines which submesh to check
  105011. * @param useInstances specifies that instances should be used
  105012. * @returns a boolean indicating that the submesh is ready or not
  105013. */
  105014. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105015. /**
  105016. * Builds the material UBO layouts.
  105017. * Used internally during the effect preparation.
  105018. */
  105019. buildUniformLayout(): void;
  105020. /**
  105021. * Unbinds the material from the mesh
  105022. */
  105023. unbind(): void;
  105024. /**
  105025. * Binds the submesh to this material by preparing the effect and shader to draw
  105026. * @param world defines the world transformation matrix
  105027. * @param mesh defines the mesh containing the submesh
  105028. * @param subMesh defines the submesh to bind the material to
  105029. */
  105030. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105031. /**
  105032. * Get the list of animatables in the material.
  105033. * @returns the list of animatables object used in the material
  105034. */
  105035. getAnimatables(): IAnimatable[];
  105036. /**
  105037. * Gets the active textures from the material
  105038. * @returns an array of textures
  105039. */
  105040. getActiveTextures(): BaseTexture[];
  105041. /**
  105042. * Specifies if the material uses a texture
  105043. * @param texture defines the texture to check against the material
  105044. * @returns a boolean specifying if the material uses the texture
  105045. */
  105046. hasTexture(texture: BaseTexture): boolean;
  105047. /**
  105048. * Disposes the material
  105049. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105050. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105051. */
  105052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105053. /**
  105054. * Makes a duplicate of the material, and gives it a new name
  105055. * @param name defines the new name for the duplicated material
  105056. * @returns the cloned material
  105057. */
  105058. clone(name: string): StandardMaterial;
  105059. /**
  105060. * Serializes this material in a JSON representation
  105061. * @returns the serialized material object
  105062. */
  105063. serialize(): any;
  105064. /**
  105065. * Creates a standard material from parsed material data
  105066. * @param source defines the JSON representation of the material
  105067. * @param scene defines the hosting scene
  105068. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105069. * @returns a new standard material
  105070. */
  105071. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105072. /**
  105073. * Are diffuse textures enabled in the application.
  105074. */
  105075. static get DiffuseTextureEnabled(): boolean;
  105076. static set DiffuseTextureEnabled(value: boolean);
  105077. /**
  105078. * Are detail textures enabled in the application.
  105079. */
  105080. static get DetailTextureEnabled(): boolean;
  105081. static set DetailTextureEnabled(value: boolean);
  105082. /**
  105083. * Are ambient textures enabled in the application.
  105084. */
  105085. static get AmbientTextureEnabled(): boolean;
  105086. static set AmbientTextureEnabled(value: boolean);
  105087. /**
  105088. * Are opacity textures enabled in the application.
  105089. */
  105090. static get OpacityTextureEnabled(): boolean;
  105091. static set OpacityTextureEnabled(value: boolean);
  105092. /**
  105093. * Are reflection textures enabled in the application.
  105094. */
  105095. static get ReflectionTextureEnabled(): boolean;
  105096. static set ReflectionTextureEnabled(value: boolean);
  105097. /**
  105098. * Are emissive textures enabled in the application.
  105099. */
  105100. static get EmissiveTextureEnabled(): boolean;
  105101. static set EmissiveTextureEnabled(value: boolean);
  105102. /**
  105103. * Are specular textures enabled in the application.
  105104. */
  105105. static get SpecularTextureEnabled(): boolean;
  105106. static set SpecularTextureEnabled(value: boolean);
  105107. /**
  105108. * Are bump textures enabled in the application.
  105109. */
  105110. static get BumpTextureEnabled(): boolean;
  105111. static set BumpTextureEnabled(value: boolean);
  105112. /**
  105113. * Are lightmap textures enabled in the application.
  105114. */
  105115. static get LightmapTextureEnabled(): boolean;
  105116. static set LightmapTextureEnabled(value: boolean);
  105117. /**
  105118. * Are refraction textures enabled in the application.
  105119. */
  105120. static get RefractionTextureEnabled(): boolean;
  105121. static set RefractionTextureEnabled(value: boolean);
  105122. /**
  105123. * Are color grading textures enabled in the application.
  105124. */
  105125. static get ColorGradingTextureEnabled(): boolean;
  105126. static set ColorGradingTextureEnabled(value: boolean);
  105127. /**
  105128. * Are fresnels enabled in the application.
  105129. */
  105130. static get FresnelEnabled(): boolean;
  105131. static set FresnelEnabled(value: boolean);
  105132. }
  105133. }
  105134. declare module BABYLON {
  105135. /** @hidden */
  105136. export var rgbdDecodePixelShader: {
  105137. name: string;
  105138. shader: string;
  105139. };
  105140. }
  105141. declare module BABYLON {
  105142. /**
  105143. * Class used to host RGBD texture specific utilities
  105144. */
  105145. export class RGBDTextureTools {
  105146. /**
  105147. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105148. * @param texture the texture to expand.
  105149. */
  105150. static ExpandRGBDTexture(texture: Texture): void;
  105151. }
  105152. }
  105153. declare module BABYLON {
  105154. /**
  105155. * Class used to host texture specific utilities
  105156. */
  105157. export class BRDFTextureTools {
  105158. /**
  105159. * Prevents texture cache collision
  105160. */
  105161. private static _instanceNumber;
  105162. /**
  105163. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105164. * @param scene defines the hosting scene
  105165. * @returns the environment BRDF texture
  105166. */
  105167. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105168. private static _environmentBRDFBase64Texture;
  105169. }
  105170. }
  105171. declare module BABYLON {
  105172. /**
  105173. * @hidden
  105174. */
  105175. export interface IMaterialClearCoatDefines {
  105176. CLEARCOAT: boolean;
  105177. CLEARCOAT_DEFAULTIOR: boolean;
  105178. CLEARCOAT_TEXTURE: boolean;
  105179. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  105180. CLEARCOAT_TEXTUREDIRECTUV: number;
  105181. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  105182. CLEARCOAT_BUMP: boolean;
  105183. CLEARCOAT_BUMPDIRECTUV: number;
  105184. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105185. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105186. CLEARCOAT_REMAP_F0: boolean;
  105187. CLEARCOAT_TINT: boolean;
  105188. CLEARCOAT_TINT_TEXTURE: boolean;
  105189. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105190. /** @hidden */
  105191. _areTexturesDirty: boolean;
  105192. }
  105193. /**
  105194. * Define the code related to the clear coat parameters of the pbr material.
  105195. */
  105196. export class PBRClearCoatConfiguration {
  105197. /**
  105198. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105199. * The default fits with a polyurethane material.
  105200. */
  105201. private static readonly _DefaultIndexOfRefraction;
  105202. private _isEnabled;
  105203. /**
  105204. * Defines if the clear coat is enabled in the material.
  105205. */
  105206. isEnabled: boolean;
  105207. /**
  105208. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105209. */
  105210. intensity: number;
  105211. /**
  105212. * Defines the clear coat layer roughness.
  105213. */
  105214. roughness: number;
  105215. private _indexOfRefraction;
  105216. /**
  105217. * Defines the index of refraction of the clear coat.
  105218. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105219. * The default fits with a polyurethane material.
  105220. * Changing the default value is more performance intensive.
  105221. */
  105222. indexOfRefraction: number;
  105223. private _texture;
  105224. /**
  105225. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  105226. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  105227. * if textureRoughness is not empty, else no texture roughness is used
  105228. */
  105229. texture: Nullable<BaseTexture>;
  105230. private _useRoughnessFromMainTexture;
  105231. /**
  105232. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  105233. * If false, the green channel from textureRoughness is used for roughness
  105234. */
  105235. useRoughnessFromMainTexture: boolean;
  105236. private _textureRoughness;
  105237. /**
  105238. * Stores the clear coat roughness in a texture (green channel)
  105239. * Not used if useRoughnessFromMainTexture is true
  105240. */
  105241. textureRoughness: Nullable<BaseTexture>;
  105242. private _remapF0OnInterfaceChange;
  105243. /**
  105244. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105245. */
  105246. remapF0OnInterfaceChange: boolean;
  105247. private _bumpTexture;
  105248. /**
  105249. * Define the clear coat specific bump texture.
  105250. */
  105251. bumpTexture: Nullable<BaseTexture>;
  105252. private _isTintEnabled;
  105253. /**
  105254. * Defines if the clear coat tint is enabled in the material.
  105255. */
  105256. isTintEnabled: boolean;
  105257. /**
  105258. * Defines the clear coat tint of the material.
  105259. * This is only use if tint is enabled
  105260. */
  105261. tintColor: Color3;
  105262. /**
  105263. * Defines the distance at which the tint color should be found in the
  105264. * clear coat media.
  105265. * This is only use if tint is enabled
  105266. */
  105267. tintColorAtDistance: number;
  105268. /**
  105269. * Defines the clear coat layer thickness.
  105270. * This is only use if tint is enabled
  105271. */
  105272. tintThickness: number;
  105273. private _tintTexture;
  105274. /**
  105275. * Stores the clear tint values in a texture.
  105276. * rgb is tint
  105277. * a is a thickness factor
  105278. */
  105279. tintTexture: Nullable<BaseTexture>;
  105280. /** @hidden */
  105281. private _internalMarkAllSubMeshesAsTexturesDirty;
  105282. /** @hidden */
  105283. _markAllSubMeshesAsTexturesDirty(): void;
  105284. /**
  105285. * Instantiate a new istance of clear coat configuration.
  105286. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105287. */
  105288. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105289. /**
  105290. * Gets wehter the submesh is ready to be used or not.
  105291. * @param defines the list of "defines" to update.
  105292. * @param scene defines the scene the material belongs to.
  105293. * @param engine defines the engine the material belongs to.
  105294. * @param disableBumpMap defines wether the material disables bump or not.
  105295. * @returns - boolean indicating that the submesh is ready or not.
  105296. */
  105297. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  105298. /**
  105299. * Checks to see if a texture is used in the material.
  105300. * @param defines the list of "defines" to update.
  105301. * @param scene defines the scene to the material belongs to.
  105302. */
  105303. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  105304. /**
  105305. * Binds the material data.
  105306. * @param uniformBuffer defines the Uniform buffer to fill in.
  105307. * @param scene defines the scene the material belongs to.
  105308. * @param engine defines the engine the material belongs to.
  105309. * @param disableBumpMap defines wether the material disables bump or not.
  105310. * @param isFrozen defines wether the material is frozen or not.
  105311. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105312. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105313. * @param subMesh the submesh to bind data for
  105314. */
  105315. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  105316. /**
  105317. * Checks to see if a texture is used in the material.
  105318. * @param texture - Base texture to use.
  105319. * @returns - Boolean specifying if a texture is used in the material.
  105320. */
  105321. hasTexture(texture: BaseTexture): boolean;
  105322. /**
  105323. * Returns an array of the actively used textures.
  105324. * @param activeTextures Array of BaseTextures
  105325. */
  105326. getActiveTextures(activeTextures: BaseTexture[]): void;
  105327. /**
  105328. * Returns the animatable textures.
  105329. * @param animatables Array of animatable textures.
  105330. */
  105331. getAnimatables(animatables: IAnimatable[]): void;
  105332. /**
  105333. * Disposes the resources of the material.
  105334. * @param forceDisposeTextures - Forces the disposal of all textures.
  105335. */
  105336. dispose(forceDisposeTextures?: boolean): void;
  105337. /**
  105338. * Get the current class name of the texture useful for serialization or dynamic coding.
  105339. * @returns "PBRClearCoatConfiguration"
  105340. */
  105341. getClassName(): string;
  105342. /**
  105343. * Add fallbacks to the effect fallbacks list.
  105344. * @param defines defines the Base texture to use.
  105345. * @param fallbacks defines the current fallback list.
  105346. * @param currentRank defines the current fallback rank.
  105347. * @returns the new fallback rank.
  105348. */
  105349. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105350. /**
  105351. * Add the required uniforms to the current list.
  105352. * @param uniforms defines the current uniform list.
  105353. */
  105354. static AddUniforms(uniforms: string[]): void;
  105355. /**
  105356. * Add the required samplers to the current list.
  105357. * @param samplers defines the current sampler list.
  105358. */
  105359. static AddSamplers(samplers: string[]): void;
  105360. /**
  105361. * Add the required uniforms to the current buffer.
  105362. * @param uniformBuffer defines the current uniform buffer.
  105363. */
  105364. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105365. /**
  105366. * Makes a duplicate of the current configuration into another one.
  105367. * @param clearCoatConfiguration define the config where to copy the info
  105368. */
  105369. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  105370. /**
  105371. * Serializes this clear coat configuration.
  105372. * @returns - An object with the serialized config.
  105373. */
  105374. serialize(): any;
  105375. /**
  105376. * Parses a anisotropy Configuration from a serialized object.
  105377. * @param source - Serialized object.
  105378. * @param scene Defines the scene we are parsing for
  105379. * @param rootUrl Defines the rootUrl to load from
  105380. */
  105381. parse(source: any, scene: Scene, rootUrl: string): void;
  105382. }
  105383. }
  105384. declare module BABYLON {
  105385. /**
  105386. * @hidden
  105387. */
  105388. export interface IMaterialAnisotropicDefines {
  105389. ANISOTROPIC: boolean;
  105390. ANISOTROPIC_TEXTURE: boolean;
  105391. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105392. MAINUV1: boolean;
  105393. _areTexturesDirty: boolean;
  105394. _needUVs: boolean;
  105395. }
  105396. /**
  105397. * Define the code related to the anisotropic parameters of the pbr material.
  105398. */
  105399. export class PBRAnisotropicConfiguration {
  105400. private _isEnabled;
  105401. /**
  105402. * Defines if the anisotropy is enabled in the material.
  105403. */
  105404. isEnabled: boolean;
  105405. /**
  105406. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  105407. */
  105408. intensity: number;
  105409. /**
  105410. * Defines if the effect is along the tangents, bitangents or in between.
  105411. * By default, the effect is "strectching" the highlights along the tangents.
  105412. */
  105413. direction: Vector2;
  105414. private _texture;
  105415. /**
  105416. * Stores the anisotropy values in a texture.
  105417. * rg is direction (like normal from -1 to 1)
  105418. * b is a intensity
  105419. */
  105420. texture: Nullable<BaseTexture>;
  105421. /** @hidden */
  105422. private _internalMarkAllSubMeshesAsTexturesDirty;
  105423. /** @hidden */
  105424. _markAllSubMeshesAsTexturesDirty(): void;
  105425. /**
  105426. * Instantiate a new istance of anisotropy configuration.
  105427. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105428. */
  105429. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105430. /**
  105431. * Specifies that the submesh is ready to be used.
  105432. * @param defines the list of "defines" to update.
  105433. * @param scene defines the scene the material belongs to.
  105434. * @returns - boolean indicating that the submesh is ready or not.
  105435. */
  105436. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  105437. /**
  105438. * Checks to see if a texture is used in the material.
  105439. * @param defines the list of "defines" to update.
  105440. * @param mesh the mesh we are preparing the defines for.
  105441. * @param scene defines the scene the material belongs to.
  105442. */
  105443. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  105444. /**
  105445. * Binds the material data.
  105446. * @param uniformBuffer defines the Uniform buffer to fill in.
  105447. * @param scene defines the scene the material belongs to.
  105448. * @param isFrozen defines wether the material is frozen or not.
  105449. */
  105450. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105451. /**
  105452. * Checks to see if a texture is used in the material.
  105453. * @param texture - Base texture to use.
  105454. * @returns - Boolean specifying if a texture is used in the material.
  105455. */
  105456. hasTexture(texture: BaseTexture): boolean;
  105457. /**
  105458. * Returns an array of the actively used textures.
  105459. * @param activeTextures Array of BaseTextures
  105460. */
  105461. getActiveTextures(activeTextures: BaseTexture[]): void;
  105462. /**
  105463. * Returns the animatable textures.
  105464. * @param animatables Array of animatable textures.
  105465. */
  105466. getAnimatables(animatables: IAnimatable[]): void;
  105467. /**
  105468. * Disposes the resources of the material.
  105469. * @param forceDisposeTextures - Forces the disposal of all textures.
  105470. */
  105471. dispose(forceDisposeTextures?: boolean): void;
  105472. /**
  105473. * Get the current class name of the texture useful for serialization or dynamic coding.
  105474. * @returns "PBRAnisotropicConfiguration"
  105475. */
  105476. getClassName(): string;
  105477. /**
  105478. * Add fallbacks to the effect fallbacks list.
  105479. * @param defines defines the Base texture to use.
  105480. * @param fallbacks defines the current fallback list.
  105481. * @param currentRank defines the current fallback rank.
  105482. * @returns the new fallback rank.
  105483. */
  105484. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105485. /**
  105486. * Add the required uniforms to the current list.
  105487. * @param uniforms defines the current uniform list.
  105488. */
  105489. static AddUniforms(uniforms: string[]): void;
  105490. /**
  105491. * Add the required uniforms to the current buffer.
  105492. * @param uniformBuffer defines the current uniform buffer.
  105493. */
  105494. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105495. /**
  105496. * Add the required samplers to the current list.
  105497. * @param samplers defines the current sampler list.
  105498. */
  105499. static AddSamplers(samplers: string[]): void;
  105500. /**
  105501. * Makes a duplicate of the current configuration into another one.
  105502. * @param anisotropicConfiguration define the config where to copy the info
  105503. */
  105504. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  105505. /**
  105506. * Serializes this anisotropy configuration.
  105507. * @returns - An object with the serialized config.
  105508. */
  105509. serialize(): any;
  105510. /**
  105511. * Parses a anisotropy Configuration from a serialized object.
  105512. * @param source - Serialized object.
  105513. * @param scene Defines the scene we are parsing for
  105514. * @param rootUrl Defines the rootUrl to load from
  105515. */
  105516. parse(source: any, scene: Scene, rootUrl: string): void;
  105517. }
  105518. }
  105519. declare module BABYLON {
  105520. /**
  105521. * @hidden
  105522. */
  105523. export interface IMaterialBRDFDefines {
  105524. BRDF_V_HEIGHT_CORRELATED: boolean;
  105525. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105526. SPHERICAL_HARMONICS: boolean;
  105527. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  105528. /** @hidden */
  105529. _areMiscDirty: boolean;
  105530. }
  105531. /**
  105532. * Define the code related to the BRDF parameters of the pbr material.
  105533. */
  105534. export class PBRBRDFConfiguration {
  105535. /**
  105536. * Default value used for the energy conservation.
  105537. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105538. */
  105539. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  105540. /**
  105541. * Default value used for the Smith Visibility Height Correlated mode.
  105542. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105543. */
  105544. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  105545. /**
  105546. * Default value used for the IBL diffuse part.
  105547. * This can help switching back to the polynomials mode globally which is a tiny bit
  105548. * less GPU intensive at the drawback of a lower quality.
  105549. */
  105550. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  105551. /**
  105552. * Default value used for activating energy conservation for the specular workflow.
  105553. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105554. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105555. */
  105556. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  105557. private _useEnergyConservation;
  105558. /**
  105559. * Defines if the material uses energy conservation.
  105560. */
  105561. useEnergyConservation: boolean;
  105562. private _useSmithVisibilityHeightCorrelated;
  105563. /**
  105564. * LEGACY Mode set to false
  105565. * Defines if the material uses height smith correlated visibility term.
  105566. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  105567. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105568. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  105569. * Not relying on height correlated will also disable energy conservation.
  105570. */
  105571. useSmithVisibilityHeightCorrelated: boolean;
  105572. private _useSphericalHarmonics;
  105573. /**
  105574. * LEGACY Mode set to false
  105575. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  105576. * diffuse part of the IBL.
  105577. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  105578. * to the ground truth.
  105579. */
  105580. useSphericalHarmonics: boolean;
  105581. private _useSpecularGlossinessInputEnergyConservation;
  105582. /**
  105583. * Defines if the material uses energy conservation, when the specular workflow is active.
  105584. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105585. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105586. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  105587. */
  105588. useSpecularGlossinessInputEnergyConservation: boolean;
  105589. /** @hidden */
  105590. private _internalMarkAllSubMeshesAsMiscDirty;
  105591. /** @hidden */
  105592. _markAllSubMeshesAsMiscDirty(): void;
  105593. /**
  105594. * Instantiate a new istance of clear coat configuration.
  105595. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  105596. */
  105597. constructor(markAllSubMeshesAsMiscDirty: () => void);
  105598. /**
  105599. * Checks to see if a texture is used in the material.
  105600. * @param defines the list of "defines" to update.
  105601. */
  105602. prepareDefines(defines: IMaterialBRDFDefines): void;
  105603. /**
  105604. * Get the current class name of the texture useful for serialization or dynamic coding.
  105605. * @returns "PBRClearCoatConfiguration"
  105606. */
  105607. getClassName(): string;
  105608. /**
  105609. * Makes a duplicate of the current configuration into another one.
  105610. * @param brdfConfiguration define the config where to copy the info
  105611. */
  105612. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  105613. /**
  105614. * Serializes this BRDF configuration.
  105615. * @returns - An object with the serialized config.
  105616. */
  105617. serialize(): any;
  105618. /**
  105619. * Parses a anisotropy Configuration from a serialized object.
  105620. * @param source - Serialized object.
  105621. * @param scene Defines the scene we are parsing for
  105622. * @param rootUrl Defines the rootUrl to load from
  105623. */
  105624. parse(source: any, scene: Scene, rootUrl: string): void;
  105625. }
  105626. }
  105627. declare module BABYLON {
  105628. /**
  105629. * @hidden
  105630. */
  105631. export interface IMaterialSheenDefines {
  105632. SHEEN: boolean;
  105633. SHEEN_TEXTURE: boolean;
  105634. SHEEN_TEXTURE_ROUGHNESS: boolean;
  105635. SHEEN_TEXTUREDIRECTUV: number;
  105636. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  105637. SHEEN_LINKWITHALBEDO: boolean;
  105638. SHEEN_ROUGHNESS: boolean;
  105639. SHEEN_ALBEDOSCALING: boolean;
  105640. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105641. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105642. /** @hidden */
  105643. _areTexturesDirty: boolean;
  105644. }
  105645. /**
  105646. * Define the code related to the Sheen parameters of the pbr material.
  105647. */
  105648. export class PBRSheenConfiguration {
  105649. private _isEnabled;
  105650. /**
  105651. * Defines if the material uses sheen.
  105652. */
  105653. isEnabled: boolean;
  105654. private _linkSheenWithAlbedo;
  105655. /**
  105656. * Defines if the sheen is linked to the sheen color.
  105657. */
  105658. linkSheenWithAlbedo: boolean;
  105659. /**
  105660. * Defines the sheen intensity.
  105661. */
  105662. intensity: number;
  105663. /**
  105664. * Defines the sheen color.
  105665. */
  105666. color: Color3;
  105667. private _texture;
  105668. /**
  105669. * Stores the sheen tint values in a texture.
  105670. * rgb is tint
  105671. * 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)
  105672. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  105673. */
  105674. texture: Nullable<BaseTexture>;
  105675. private _useRoughnessFromMainTexture;
  105676. /**
  105677. * Indicates that the alpha channel of the texture property will be used for roughness.
  105678. * Has no effect if the roughness (and texture!) property is not defined
  105679. */
  105680. useRoughnessFromMainTexture: boolean;
  105681. private _roughness;
  105682. /**
  105683. * Defines the sheen roughness.
  105684. * It is not taken into account if linkSheenWithAlbedo is true.
  105685. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105686. */
  105687. roughness: Nullable<number>;
  105688. private _textureRoughness;
  105689. /**
  105690. * Stores the sheen roughness in a texture.
  105691. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  105692. */
  105693. textureRoughness: Nullable<BaseTexture>;
  105694. private _albedoScaling;
  105695. /**
  105696. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105697. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105698. * making it easier to setup and tweak the effect
  105699. */
  105700. albedoScaling: boolean;
  105701. /** @hidden */
  105702. private _internalMarkAllSubMeshesAsTexturesDirty;
  105703. /** @hidden */
  105704. _markAllSubMeshesAsTexturesDirty(): void;
  105705. /**
  105706. * Instantiate a new istance of clear coat configuration.
  105707. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105708. */
  105709. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105710. /**
  105711. * Specifies that the submesh is ready to be used.
  105712. * @param defines the list of "defines" to update.
  105713. * @param scene defines the scene the material belongs to.
  105714. * @returns - boolean indicating that the submesh is ready or not.
  105715. */
  105716. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105717. /**
  105718. * Checks to see if a texture is used in the material.
  105719. * @param defines the list of "defines" to update.
  105720. * @param scene defines the scene the material belongs to.
  105721. */
  105722. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105723. /**
  105724. * Binds the material data.
  105725. * @param uniformBuffer defines the Uniform buffer to fill in.
  105726. * @param scene defines the scene the material belongs to.
  105727. * @param isFrozen defines wether the material is frozen or not.
  105728. * @param subMesh the submesh to bind data for
  105729. */
  105730. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  105731. /**
  105732. * Checks to see if a texture is used in the material.
  105733. * @param texture - Base texture to use.
  105734. * @returns - Boolean specifying if a texture is used in the material.
  105735. */
  105736. hasTexture(texture: BaseTexture): boolean;
  105737. /**
  105738. * Returns an array of the actively used textures.
  105739. * @param activeTextures Array of BaseTextures
  105740. */
  105741. getActiveTextures(activeTextures: BaseTexture[]): void;
  105742. /**
  105743. * Returns the animatable textures.
  105744. * @param animatables Array of animatable textures.
  105745. */
  105746. getAnimatables(animatables: IAnimatable[]): void;
  105747. /**
  105748. * Disposes the resources of the material.
  105749. * @param forceDisposeTextures - Forces the disposal of all textures.
  105750. */
  105751. dispose(forceDisposeTextures?: boolean): void;
  105752. /**
  105753. * Get the current class name of the texture useful for serialization or dynamic coding.
  105754. * @returns "PBRSheenConfiguration"
  105755. */
  105756. getClassName(): string;
  105757. /**
  105758. * Add fallbacks to the effect fallbacks list.
  105759. * @param defines defines the Base texture to use.
  105760. * @param fallbacks defines the current fallback list.
  105761. * @param currentRank defines the current fallback rank.
  105762. * @returns the new fallback rank.
  105763. */
  105764. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105765. /**
  105766. * Add the required uniforms to the current list.
  105767. * @param uniforms defines the current uniform list.
  105768. */
  105769. static AddUniforms(uniforms: string[]): void;
  105770. /**
  105771. * Add the required uniforms to the current buffer.
  105772. * @param uniformBuffer defines the current uniform buffer.
  105773. */
  105774. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105775. /**
  105776. * Add the required samplers to the current list.
  105777. * @param samplers defines the current sampler list.
  105778. */
  105779. static AddSamplers(samplers: string[]): void;
  105780. /**
  105781. * Makes a duplicate of the current configuration into another one.
  105782. * @param sheenConfiguration define the config where to copy the info
  105783. */
  105784. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105785. /**
  105786. * Serializes this BRDF configuration.
  105787. * @returns - An object with the serialized config.
  105788. */
  105789. serialize(): any;
  105790. /**
  105791. * Parses a anisotropy Configuration from a serialized object.
  105792. * @param source - Serialized object.
  105793. * @param scene Defines the scene we are parsing for
  105794. * @param rootUrl Defines the rootUrl to load from
  105795. */
  105796. parse(source: any, scene: Scene, rootUrl: string): void;
  105797. }
  105798. }
  105799. declare module BABYLON {
  105800. /**
  105801. * @hidden
  105802. */
  105803. export interface IMaterialSubSurfaceDefines {
  105804. SUBSURFACE: boolean;
  105805. SS_REFRACTION: boolean;
  105806. SS_TRANSLUCENCY: boolean;
  105807. SS_SCATTERING: boolean;
  105808. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105809. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105810. SS_REFRACTIONMAP_3D: boolean;
  105811. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105812. SS_LODINREFRACTIONALPHA: boolean;
  105813. SS_GAMMAREFRACTION: boolean;
  105814. SS_RGBDREFRACTION: boolean;
  105815. SS_LINEARSPECULARREFRACTION: boolean;
  105816. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105817. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105818. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105819. /** @hidden */
  105820. _areTexturesDirty: boolean;
  105821. }
  105822. /**
  105823. * Define the code related to the sub surface parameters of the pbr material.
  105824. */
  105825. export class PBRSubSurfaceConfiguration {
  105826. private _isRefractionEnabled;
  105827. /**
  105828. * Defines if the refraction is enabled in the material.
  105829. */
  105830. isRefractionEnabled: boolean;
  105831. private _isTranslucencyEnabled;
  105832. /**
  105833. * Defines if the translucency is enabled in the material.
  105834. */
  105835. isTranslucencyEnabled: boolean;
  105836. private _isScatteringEnabled;
  105837. /**
  105838. * Defines if the sub surface scattering is enabled in the material.
  105839. */
  105840. isScatteringEnabled: boolean;
  105841. private _scatteringDiffusionProfileIndex;
  105842. /**
  105843. * Diffusion profile for subsurface scattering.
  105844. * Useful for better scattering in the skins or foliages.
  105845. */
  105846. get scatteringDiffusionProfile(): Nullable<Color3>;
  105847. set scatteringDiffusionProfile(c: Nullable<Color3>);
  105848. /**
  105849. * Defines the refraction intensity of the material.
  105850. * The refraction when enabled replaces the Diffuse part of the material.
  105851. * The intensity helps transitionning between diffuse and refraction.
  105852. */
  105853. refractionIntensity: number;
  105854. /**
  105855. * Defines the translucency intensity of the material.
  105856. * When translucency has been enabled, this defines how much of the "translucency"
  105857. * is addded to the diffuse part of the material.
  105858. */
  105859. translucencyIntensity: number;
  105860. /**
  105861. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  105862. */
  105863. useAlbedoToTintRefraction: boolean;
  105864. private _thicknessTexture;
  105865. /**
  105866. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  105867. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  105868. * 0 would mean minimumThickness
  105869. * 1 would mean maximumThickness
  105870. * The other channels might be use as a mask to vary the different effects intensity.
  105871. */
  105872. thicknessTexture: Nullable<BaseTexture>;
  105873. private _refractionTexture;
  105874. /**
  105875. * Defines the texture to use for refraction.
  105876. */
  105877. refractionTexture: Nullable<BaseTexture>;
  105878. private _indexOfRefraction;
  105879. /**
  105880. * Index of refraction of the material base layer.
  105881. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105882. *
  105883. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  105884. *
  105885. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  105886. */
  105887. indexOfRefraction: number;
  105888. private _volumeIndexOfRefraction;
  105889. /**
  105890. * Index of refraction of the material's volume.
  105891. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105892. *
  105893. * This ONLY impacts refraction. If not provided or given a non-valid value,
  105894. * the volume will use the same IOR as the surface.
  105895. */
  105896. get volumeIndexOfRefraction(): number;
  105897. set volumeIndexOfRefraction(value: number);
  105898. private _invertRefractionY;
  105899. /**
  105900. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105901. */
  105902. invertRefractionY: boolean;
  105903. private _linkRefractionWithTransparency;
  105904. /**
  105905. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105906. * Materials half opaque for instance using refraction could benefit from this control.
  105907. */
  105908. linkRefractionWithTransparency: boolean;
  105909. /**
  105910. * Defines the minimum thickness stored in the thickness map.
  105911. * If no thickness map is defined, this value will be used to simulate thickness.
  105912. */
  105913. minimumThickness: number;
  105914. /**
  105915. * Defines the maximum thickness stored in the thickness map.
  105916. */
  105917. maximumThickness: number;
  105918. /**
  105919. * Defines the volume tint of the material.
  105920. * This is used for both translucency and scattering.
  105921. */
  105922. tintColor: Color3;
  105923. /**
  105924. * Defines the distance at which the tint color should be found in the media.
  105925. * This is used for refraction only.
  105926. */
  105927. tintColorAtDistance: number;
  105928. /**
  105929. * Defines how far each channel transmit through the media.
  105930. * It is defined as a color to simplify it selection.
  105931. */
  105932. diffusionDistance: Color3;
  105933. private _useMaskFromThicknessTexture;
  105934. /**
  105935. * Stores the intensity of the different subsurface effects in the thickness texture.
  105936. * * the green channel is the translucency intensity.
  105937. * * the blue channel is the scattering intensity.
  105938. * * the alpha channel is the refraction intensity.
  105939. */
  105940. useMaskFromThicknessTexture: boolean;
  105941. private _scene;
  105942. /** @hidden */
  105943. private _internalMarkAllSubMeshesAsTexturesDirty;
  105944. private _internalMarkScenePrePassDirty;
  105945. /** @hidden */
  105946. _markAllSubMeshesAsTexturesDirty(): void;
  105947. /** @hidden */
  105948. _markScenePrePassDirty(): void;
  105949. /**
  105950. * Instantiate a new istance of sub surface configuration.
  105951. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105952. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  105953. * @param scene The scene
  105954. */
  105955. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  105956. /**
  105957. * Gets wehter the submesh is ready to be used or not.
  105958. * @param defines the list of "defines" to update.
  105959. * @param scene defines the scene the material belongs to.
  105960. * @returns - boolean indicating that the submesh is ready or not.
  105961. */
  105962. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  105963. /**
  105964. * Checks to see if a texture is used in the material.
  105965. * @param defines the list of "defines" to update.
  105966. * @param scene defines the scene to the material belongs to.
  105967. */
  105968. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  105969. /**
  105970. * Binds the material data.
  105971. * @param uniformBuffer defines the Uniform buffer to fill in.
  105972. * @param scene defines the scene the material belongs to.
  105973. * @param engine defines the engine the material belongs to.
  105974. * @param isFrozen defines whether the material is frozen or not.
  105975. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  105976. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  105977. */
  105978. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  105979. /**
  105980. * Unbinds the material from the mesh.
  105981. * @param activeEffect defines the effect that should be unbound from.
  105982. * @returns true if unbound, otherwise false
  105983. */
  105984. unbind(activeEffect: Effect): boolean;
  105985. /**
  105986. * Returns the texture used for refraction or null if none is used.
  105987. * @param scene defines the scene the material belongs to.
  105988. * @returns - Refraction texture if present. If no refraction texture and refraction
  105989. * is linked with transparency, returns environment texture. Otherwise, returns null.
  105990. */
  105991. private _getRefractionTexture;
  105992. /**
  105993. * Returns true if alpha blending should be disabled.
  105994. */
  105995. get disableAlphaBlending(): boolean;
  105996. /**
  105997. * Fills the list of render target textures.
  105998. * @param renderTargets the list of render targets to update
  105999. */
  106000. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  106001. /**
  106002. * Checks to see if a texture is used in the material.
  106003. * @param texture - Base texture to use.
  106004. * @returns - Boolean specifying if a texture is used in the material.
  106005. */
  106006. hasTexture(texture: BaseTexture): boolean;
  106007. /**
  106008. * Gets a boolean indicating that current material needs to register RTT
  106009. * @returns true if this uses a render target otherwise false.
  106010. */
  106011. hasRenderTargetTextures(): boolean;
  106012. /**
  106013. * Returns an array of the actively used textures.
  106014. * @param activeTextures Array of BaseTextures
  106015. */
  106016. getActiveTextures(activeTextures: BaseTexture[]): void;
  106017. /**
  106018. * Returns the animatable textures.
  106019. * @param animatables Array of animatable textures.
  106020. */
  106021. getAnimatables(animatables: IAnimatable[]): void;
  106022. /**
  106023. * Disposes the resources of the material.
  106024. * @param forceDisposeTextures - Forces the disposal of all textures.
  106025. */
  106026. dispose(forceDisposeTextures?: boolean): void;
  106027. /**
  106028. * Get the current class name of the texture useful for serialization or dynamic coding.
  106029. * @returns "PBRSubSurfaceConfiguration"
  106030. */
  106031. getClassName(): string;
  106032. /**
  106033. * Add fallbacks to the effect fallbacks list.
  106034. * @param defines defines the Base texture to use.
  106035. * @param fallbacks defines the current fallback list.
  106036. * @param currentRank defines the current fallback rank.
  106037. * @returns the new fallback rank.
  106038. */
  106039. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106040. /**
  106041. * Add the required uniforms to the current list.
  106042. * @param uniforms defines the current uniform list.
  106043. */
  106044. static AddUniforms(uniforms: string[]): void;
  106045. /**
  106046. * Add the required samplers to the current list.
  106047. * @param samplers defines the current sampler list.
  106048. */
  106049. static AddSamplers(samplers: string[]): void;
  106050. /**
  106051. * Add the required uniforms to the current buffer.
  106052. * @param uniformBuffer defines the current uniform buffer.
  106053. */
  106054. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106055. /**
  106056. * Makes a duplicate of the current configuration into another one.
  106057. * @param configuration define the config where to copy the info
  106058. */
  106059. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106060. /**
  106061. * Serializes this Sub Surface configuration.
  106062. * @returns - An object with the serialized config.
  106063. */
  106064. serialize(): any;
  106065. /**
  106066. * Parses a anisotropy Configuration from a serialized object.
  106067. * @param source - Serialized object.
  106068. * @param scene Defines the scene we are parsing for
  106069. * @param rootUrl Defines the rootUrl to load from
  106070. */
  106071. parse(source: any, scene: Scene, rootUrl: string): void;
  106072. }
  106073. }
  106074. declare module BABYLON {
  106075. /**
  106076. * Class representing spherical harmonics coefficients to the 3rd degree
  106077. */
  106078. export class SphericalHarmonics {
  106079. /**
  106080. * Defines whether or not the harmonics have been prescaled for rendering.
  106081. */
  106082. preScaled: boolean;
  106083. /**
  106084. * The l0,0 coefficients of the spherical harmonics
  106085. */
  106086. l00: Vector3;
  106087. /**
  106088. * The l1,-1 coefficients of the spherical harmonics
  106089. */
  106090. l1_1: Vector3;
  106091. /**
  106092. * The l1,0 coefficients of the spherical harmonics
  106093. */
  106094. l10: Vector3;
  106095. /**
  106096. * The l1,1 coefficients of the spherical harmonics
  106097. */
  106098. l11: Vector3;
  106099. /**
  106100. * The l2,-2 coefficients of the spherical harmonics
  106101. */
  106102. l2_2: Vector3;
  106103. /**
  106104. * The l2,-1 coefficients of the spherical harmonics
  106105. */
  106106. l2_1: Vector3;
  106107. /**
  106108. * The l2,0 coefficients of the spherical harmonics
  106109. */
  106110. l20: Vector3;
  106111. /**
  106112. * The l2,1 coefficients of the spherical harmonics
  106113. */
  106114. l21: Vector3;
  106115. /**
  106116. * The l2,2 coefficients of the spherical harmonics
  106117. */
  106118. l22: Vector3;
  106119. /**
  106120. * Adds a light to the spherical harmonics
  106121. * @param direction the direction of the light
  106122. * @param color the color of the light
  106123. * @param deltaSolidAngle the delta solid angle of the light
  106124. */
  106125. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106126. /**
  106127. * Scales the spherical harmonics by the given amount
  106128. * @param scale the amount to scale
  106129. */
  106130. scaleInPlace(scale: number): void;
  106131. /**
  106132. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106133. *
  106134. * ```
  106135. * E_lm = A_l * L_lm
  106136. * ```
  106137. *
  106138. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106139. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106140. * the scaling factors are given in equation 9.
  106141. */
  106142. convertIncidentRadianceToIrradiance(): void;
  106143. /**
  106144. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106145. *
  106146. * ```
  106147. * L = (1/pi) * E * rho
  106148. * ```
  106149. *
  106150. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106151. */
  106152. convertIrradianceToLambertianRadiance(): void;
  106153. /**
  106154. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106155. * required operations at run time.
  106156. *
  106157. * This is simply done by scaling back the SH with Ylm constants parameter.
  106158. * The trigonometric part being applied by the shader at run time.
  106159. */
  106160. preScaleForRendering(): void;
  106161. /**
  106162. * Constructs a spherical harmonics from an array.
  106163. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106164. * @returns the spherical harmonics
  106165. */
  106166. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106167. /**
  106168. * Gets the spherical harmonics from polynomial
  106169. * @param polynomial the spherical polynomial
  106170. * @returns the spherical harmonics
  106171. */
  106172. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106173. }
  106174. /**
  106175. * Class representing spherical polynomial coefficients to the 3rd degree
  106176. */
  106177. export class SphericalPolynomial {
  106178. private _harmonics;
  106179. /**
  106180. * The spherical harmonics used to create the polynomials.
  106181. */
  106182. get preScaledHarmonics(): SphericalHarmonics;
  106183. /**
  106184. * The x coefficients of the spherical polynomial
  106185. */
  106186. x: Vector3;
  106187. /**
  106188. * The y coefficients of the spherical polynomial
  106189. */
  106190. y: Vector3;
  106191. /**
  106192. * The z coefficients of the spherical polynomial
  106193. */
  106194. z: Vector3;
  106195. /**
  106196. * The xx coefficients of the spherical polynomial
  106197. */
  106198. xx: Vector3;
  106199. /**
  106200. * The yy coefficients of the spherical polynomial
  106201. */
  106202. yy: Vector3;
  106203. /**
  106204. * The zz coefficients of the spherical polynomial
  106205. */
  106206. zz: Vector3;
  106207. /**
  106208. * The xy coefficients of the spherical polynomial
  106209. */
  106210. xy: Vector3;
  106211. /**
  106212. * The yz coefficients of the spherical polynomial
  106213. */
  106214. yz: Vector3;
  106215. /**
  106216. * The zx coefficients of the spherical polynomial
  106217. */
  106218. zx: Vector3;
  106219. /**
  106220. * Adds an ambient color to the spherical polynomial
  106221. * @param color the color to add
  106222. */
  106223. addAmbient(color: Color3): void;
  106224. /**
  106225. * Scales the spherical polynomial by the given amount
  106226. * @param scale the amount to scale
  106227. */
  106228. scaleInPlace(scale: number): void;
  106229. /**
  106230. * Gets the spherical polynomial from harmonics
  106231. * @param harmonics the spherical harmonics
  106232. * @returns the spherical polynomial
  106233. */
  106234. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106235. /**
  106236. * Constructs a spherical polynomial from an array.
  106237. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106238. * @returns the spherical polynomial
  106239. */
  106240. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106241. }
  106242. }
  106243. declare module BABYLON {
  106244. /**
  106245. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106246. */
  106247. export interface CubeMapInfo {
  106248. /**
  106249. * The pixel array for the front face.
  106250. * This is stored in format, left to right, up to down format.
  106251. */
  106252. front: Nullable<ArrayBufferView>;
  106253. /**
  106254. * The pixel array for the back face.
  106255. * This is stored in format, left to right, up to down format.
  106256. */
  106257. back: Nullable<ArrayBufferView>;
  106258. /**
  106259. * The pixel array for the left face.
  106260. * This is stored in format, left to right, up to down format.
  106261. */
  106262. left: Nullable<ArrayBufferView>;
  106263. /**
  106264. * The pixel array for the right face.
  106265. * This is stored in format, left to right, up to down format.
  106266. */
  106267. right: Nullable<ArrayBufferView>;
  106268. /**
  106269. * The pixel array for the up face.
  106270. * This is stored in format, left to right, up to down format.
  106271. */
  106272. up: Nullable<ArrayBufferView>;
  106273. /**
  106274. * The pixel array for the down face.
  106275. * This is stored in format, left to right, up to down format.
  106276. */
  106277. down: Nullable<ArrayBufferView>;
  106278. /**
  106279. * The size of the cubemap stored.
  106280. *
  106281. * Each faces will be size * size pixels.
  106282. */
  106283. size: number;
  106284. /**
  106285. * The format of the texture.
  106286. *
  106287. * RGBA, RGB.
  106288. */
  106289. format: number;
  106290. /**
  106291. * The type of the texture data.
  106292. *
  106293. * UNSIGNED_INT, FLOAT.
  106294. */
  106295. type: number;
  106296. /**
  106297. * Specifies whether the texture is in gamma space.
  106298. */
  106299. gammaSpace: boolean;
  106300. }
  106301. /**
  106302. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106303. */
  106304. export class PanoramaToCubeMapTools {
  106305. private static FACE_LEFT;
  106306. private static FACE_RIGHT;
  106307. private static FACE_FRONT;
  106308. private static FACE_BACK;
  106309. private static FACE_DOWN;
  106310. private static FACE_UP;
  106311. /**
  106312. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  106313. *
  106314. * @param float32Array The source data.
  106315. * @param inputWidth The width of the input panorama.
  106316. * @param inputHeight The height of the input panorama.
  106317. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  106318. * @return The cubemap data
  106319. */
  106320. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  106321. private static CreateCubemapTexture;
  106322. private static CalcProjectionSpherical;
  106323. }
  106324. }
  106325. declare module BABYLON {
  106326. /**
  106327. * Helper class dealing with the extraction of spherical polynomial dataArray
  106328. * from a cube map.
  106329. */
  106330. export class CubeMapToSphericalPolynomialTools {
  106331. private static FileFaces;
  106332. /**
  106333. * Converts a texture to the according Spherical Polynomial data.
  106334. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106335. *
  106336. * @param texture The texture to extract the information from.
  106337. * @return The Spherical Polynomial data.
  106338. */
  106339. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  106340. /**
  106341. * Converts a cubemap to the according Spherical Polynomial data.
  106342. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106343. *
  106344. * @param cubeInfo The Cube map to extract the information from.
  106345. * @return The Spherical Polynomial data.
  106346. */
  106347. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  106348. }
  106349. }
  106350. declare module BABYLON {
  106351. interface BaseTexture {
  106352. /**
  106353. * Get the polynomial representation of the texture data.
  106354. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  106355. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  106356. */
  106357. sphericalPolynomial: Nullable<SphericalPolynomial>;
  106358. }
  106359. }
  106360. declare module BABYLON {
  106361. /** @hidden */
  106362. export var pbrFragmentDeclaration: {
  106363. name: string;
  106364. shader: string;
  106365. };
  106366. }
  106367. declare module BABYLON {
  106368. /** @hidden */
  106369. export var pbrUboDeclaration: {
  106370. name: string;
  106371. shader: string;
  106372. };
  106373. }
  106374. declare module BABYLON {
  106375. /** @hidden */
  106376. export var pbrFragmentExtraDeclaration: {
  106377. name: string;
  106378. shader: string;
  106379. };
  106380. }
  106381. declare module BABYLON {
  106382. /** @hidden */
  106383. export var pbrFragmentSamplersDeclaration: {
  106384. name: string;
  106385. shader: string;
  106386. };
  106387. }
  106388. declare module BABYLON {
  106389. /** @hidden */
  106390. export var subSurfaceScatteringFunctions: {
  106391. name: string;
  106392. shader: string;
  106393. };
  106394. }
  106395. declare module BABYLON {
  106396. /** @hidden */
  106397. export var importanceSampling: {
  106398. name: string;
  106399. shader: string;
  106400. };
  106401. }
  106402. declare module BABYLON {
  106403. /** @hidden */
  106404. export var pbrHelperFunctions: {
  106405. name: string;
  106406. shader: string;
  106407. };
  106408. }
  106409. declare module BABYLON {
  106410. /** @hidden */
  106411. export var harmonicsFunctions: {
  106412. name: string;
  106413. shader: string;
  106414. };
  106415. }
  106416. declare module BABYLON {
  106417. /** @hidden */
  106418. export var pbrDirectLightingSetupFunctions: {
  106419. name: string;
  106420. shader: string;
  106421. };
  106422. }
  106423. declare module BABYLON {
  106424. /** @hidden */
  106425. export var pbrDirectLightingFalloffFunctions: {
  106426. name: string;
  106427. shader: string;
  106428. };
  106429. }
  106430. declare module BABYLON {
  106431. /** @hidden */
  106432. export var pbrBRDFFunctions: {
  106433. name: string;
  106434. shader: string;
  106435. };
  106436. }
  106437. declare module BABYLON {
  106438. /** @hidden */
  106439. export var hdrFilteringFunctions: {
  106440. name: string;
  106441. shader: string;
  106442. };
  106443. }
  106444. declare module BABYLON {
  106445. /** @hidden */
  106446. export var pbrDirectLightingFunctions: {
  106447. name: string;
  106448. shader: string;
  106449. };
  106450. }
  106451. declare module BABYLON {
  106452. /** @hidden */
  106453. export var pbrIBLFunctions: {
  106454. name: string;
  106455. shader: string;
  106456. };
  106457. }
  106458. declare module BABYLON {
  106459. /** @hidden */
  106460. export var pbrBlockAlbedoOpacity: {
  106461. name: string;
  106462. shader: string;
  106463. };
  106464. }
  106465. declare module BABYLON {
  106466. /** @hidden */
  106467. export var pbrBlockReflectivity: {
  106468. name: string;
  106469. shader: string;
  106470. };
  106471. }
  106472. declare module BABYLON {
  106473. /** @hidden */
  106474. export var pbrBlockAmbientOcclusion: {
  106475. name: string;
  106476. shader: string;
  106477. };
  106478. }
  106479. declare module BABYLON {
  106480. /** @hidden */
  106481. export var pbrBlockAlphaFresnel: {
  106482. name: string;
  106483. shader: string;
  106484. };
  106485. }
  106486. declare module BABYLON {
  106487. /** @hidden */
  106488. export var pbrBlockAnisotropic: {
  106489. name: string;
  106490. shader: string;
  106491. };
  106492. }
  106493. declare module BABYLON {
  106494. /** @hidden */
  106495. export var pbrBlockReflection: {
  106496. name: string;
  106497. shader: string;
  106498. };
  106499. }
  106500. declare module BABYLON {
  106501. /** @hidden */
  106502. export var pbrBlockSheen: {
  106503. name: string;
  106504. shader: string;
  106505. };
  106506. }
  106507. declare module BABYLON {
  106508. /** @hidden */
  106509. export var pbrBlockClearcoat: {
  106510. name: string;
  106511. shader: string;
  106512. };
  106513. }
  106514. declare module BABYLON {
  106515. /** @hidden */
  106516. export var pbrBlockSubSurface: {
  106517. name: string;
  106518. shader: string;
  106519. };
  106520. }
  106521. declare module BABYLON {
  106522. /** @hidden */
  106523. export var pbrBlockNormalGeometric: {
  106524. name: string;
  106525. shader: string;
  106526. };
  106527. }
  106528. declare module BABYLON {
  106529. /** @hidden */
  106530. export var pbrBlockNormalFinal: {
  106531. name: string;
  106532. shader: string;
  106533. };
  106534. }
  106535. declare module BABYLON {
  106536. /** @hidden */
  106537. export var pbrBlockLightmapInit: {
  106538. name: string;
  106539. shader: string;
  106540. };
  106541. }
  106542. declare module BABYLON {
  106543. /** @hidden */
  106544. export var pbrBlockGeometryInfo: {
  106545. name: string;
  106546. shader: string;
  106547. };
  106548. }
  106549. declare module BABYLON {
  106550. /** @hidden */
  106551. export var pbrBlockReflectance0: {
  106552. name: string;
  106553. shader: string;
  106554. };
  106555. }
  106556. declare module BABYLON {
  106557. /** @hidden */
  106558. export var pbrBlockReflectance: {
  106559. name: string;
  106560. shader: string;
  106561. };
  106562. }
  106563. declare module BABYLON {
  106564. /** @hidden */
  106565. export var pbrBlockDirectLighting: {
  106566. name: string;
  106567. shader: string;
  106568. };
  106569. }
  106570. declare module BABYLON {
  106571. /** @hidden */
  106572. export var pbrBlockFinalLitComponents: {
  106573. name: string;
  106574. shader: string;
  106575. };
  106576. }
  106577. declare module BABYLON {
  106578. /** @hidden */
  106579. export var pbrBlockFinalUnlitComponents: {
  106580. name: string;
  106581. shader: string;
  106582. };
  106583. }
  106584. declare module BABYLON {
  106585. /** @hidden */
  106586. export var pbrBlockFinalColorComposition: {
  106587. name: string;
  106588. shader: string;
  106589. };
  106590. }
  106591. declare module BABYLON {
  106592. /** @hidden */
  106593. export var pbrBlockImageProcessing: {
  106594. name: string;
  106595. shader: string;
  106596. };
  106597. }
  106598. declare module BABYLON {
  106599. /** @hidden */
  106600. export var pbrDebug: {
  106601. name: string;
  106602. shader: string;
  106603. };
  106604. }
  106605. declare module BABYLON {
  106606. /** @hidden */
  106607. export var pbrPixelShader: {
  106608. name: string;
  106609. shader: string;
  106610. };
  106611. }
  106612. declare module BABYLON {
  106613. /** @hidden */
  106614. export var pbrVertexDeclaration: {
  106615. name: string;
  106616. shader: string;
  106617. };
  106618. }
  106619. declare module BABYLON {
  106620. /** @hidden */
  106621. export var pbrVertexShader: {
  106622. name: string;
  106623. shader: string;
  106624. };
  106625. }
  106626. declare module BABYLON {
  106627. /**
  106628. * Manages the defines for the PBR Material.
  106629. * @hidden
  106630. */
  106631. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  106632. PBR: boolean;
  106633. NUM_SAMPLES: string;
  106634. REALTIME_FILTERING: boolean;
  106635. MAINUV1: boolean;
  106636. MAINUV2: boolean;
  106637. UV1: boolean;
  106638. UV2: boolean;
  106639. ALBEDO: boolean;
  106640. GAMMAALBEDO: boolean;
  106641. ALBEDODIRECTUV: number;
  106642. VERTEXCOLOR: boolean;
  106643. DETAIL: boolean;
  106644. DETAILDIRECTUV: number;
  106645. DETAIL_NORMALBLENDMETHOD: number;
  106646. AMBIENT: boolean;
  106647. AMBIENTDIRECTUV: number;
  106648. AMBIENTINGRAYSCALE: boolean;
  106649. OPACITY: boolean;
  106650. VERTEXALPHA: boolean;
  106651. OPACITYDIRECTUV: number;
  106652. OPACITYRGB: boolean;
  106653. ALPHATEST: boolean;
  106654. DEPTHPREPASS: boolean;
  106655. ALPHABLEND: boolean;
  106656. ALPHAFROMALBEDO: boolean;
  106657. ALPHATESTVALUE: string;
  106658. SPECULAROVERALPHA: boolean;
  106659. RADIANCEOVERALPHA: boolean;
  106660. ALPHAFRESNEL: boolean;
  106661. LINEARALPHAFRESNEL: boolean;
  106662. PREMULTIPLYALPHA: boolean;
  106663. EMISSIVE: boolean;
  106664. EMISSIVEDIRECTUV: number;
  106665. REFLECTIVITY: boolean;
  106666. REFLECTIVITYDIRECTUV: number;
  106667. SPECULARTERM: boolean;
  106668. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  106669. MICROSURFACEAUTOMATIC: boolean;
  106670. LODBASEDMICROSFURACE: boolean;
  106671. MICROSURFACEMAP: boolean;
  106672. MICROSURFACEMAPDIRECTUV: number;
  106673. METALLICWORKFLOW: boolean;
  106674. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106675. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106676. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106677. AOSTOREINMETALMAPRED: boolean;
  106678. METALLIC_REFLECTANCE: boolean;
  106679. METALLIC_REFLECTANCEDIRECTUV: number;
  106680. ENVIRONMENTBRDF: boolean;
  106681. ENVIRONMENTBRDF_RGBD: boolean;
  106682. NORMAL: boolean;
  106683. TANGENT: boolean;
  106684. BUMP: boolean;
  106685. BUMPDIRECTUV: number;
  106686. OBJECTSPACE_NORMALMAP: boolean;
  106687. PARALLAX: boolean;
  106688. PARALLAXOCCLUSION: boolean;
  106689. NORMALXYSCALE: boolean;
  106690. LIGHTMAP: boolean;
  106691. LIGHTMAPDIRECTUV: number;
  106692. USELIGHTMAPASSHADOWMAP: boolean;
  106693. GAMMALIGHTMAP: boolean;
  106694. RGBDLIGHTMAP: boolean;
  106695. REFLECTION: boolean;
  106696. REFLECTIONMAP_3D: boolean;
  106697. REFLECTIONMAP_SPHERICAL: boolean;
  106698. REFLECTIONMAP_PLANAR: boolean;
  106699. REFLECTIONMAP_CUBIC: boolean;
  106700. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106701. REFLECTIONMAP_PROJECTION: boolean;
  106702. REFLECTIONMAP_SKYBOX: boolean;
  106703. REFLECTIONMAP_EXPLICIT: boolean;
  106704. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106705. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106706. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106707. INVERTCUBICMAP: boolean;
  106708. USESPHERICALFROMREFLECTIONMAP: boolean;
  106709. USEIRRADIANCEMAP: boolean;
  106710. SPHERICAL_HARMONICS: boolean;
  106711. USESPHERICALINVERTEX: boolean;
  106712. REFLECTIONMAP_OPPOSITEZ: boolean;
  106713. LODINREFLECTIONALPHA: boolean;
  106714. GAMMAREFLECTION: boolean;
  106715. RGBDREFLECTION: boolean;
  106716. LINEARSPECULARREFLECTION: boolean;
  106717. RADIANCEOCCLUSION: boolean;
  106718. HORIZONOCCLUSION: boolean;
  106719. INSTANCES: boolean;
  106720. THIN_INSTANCES: boolean;
  106721. PREPASS: boolean;
  106722. PREPASS_IRRADIANCE: boolean;
  106723. PREPASS_IRRADIANCE_INDEX: number;
  106724. PREPASS_ALBEDO: boolean;
  106725. PREPASS_ALBEDO_INDEX: number;
  106726. PREPASS_DEPTHNORMAL: boolean;
  106727. PREPASS_DEPTHNORMAL_INDEX: number;
  106728. PREPASS_POSITION: boolean;
  106729. PREPASS_POSITION_INDEX: number;
  106730. PREPASS_VELOCITY: boolean;
  106731. PREPASS_VELOCITY_INDEX: number;
  106732. PREPASS_REFLECTIVITY: boolean;
  106733. PREPASS_REFLECTIVITY_INDEX: number;
  106734. SCENE_MRT_COUNT: number;
  106735. NUM_BONE_INFLUENCERS: number;
  106736. BonesPerMesh: number;
  106737. BONETEXTURE: boolean;
  106738. BONES_VELOCITY_ENABLED: boolean;
  106739. NONUNIFORMSCALING: boolean;
  106740. MORPHTARGETS: boolean;
  106741. MORPHTARGETS_NORMAL: boolean;
  106742. MORPHTARGETS_TANGENT: boolean;
  106743. MORPHTARGETS_UV: boolean;
  106744. NUM_MORPH_INFLUENCERS: number;
  106745. IMAGEPROCESSING: boolean;
  106746. VIGNETTE: boolean;
  106747. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106748. VIGNETTEBLENDMODEOPAQUE: boolean;
  106749. TONEMAPPING: boolean;
  106750. TONEMAPPING_ACES: boolean;
  106751. CONTRAST: boolean;
  106752. COLORCURVES: boolean;
  106753. COLORGRADING: boolean;
  106754. COLORGRADING3D: boolean;
  106755. SAMPLER3DGREENDEPTH: boolean;
  106756. SAMPLER3DBGRMAP: boolean;
  106757. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106758. EXPOSURE: boolean;
  106759. MULTIVIEW: boolean;
  106760. USEPHYSICALLIGHTFALLOFF: boolean;
  106761. USEGLTFLIGHTFALLOFF: boolean;
  106762. TWOSIDEDLIGHTING: boolean;
  106763. SHADOWFLOAT: boolean;
  106764. CLIPPLANE: boolean;
  106765. CLIPPLANE2: boolean;
  106766. CLIPPLANE3: boolean;
  106767. CLIPPLANE4: boolean;
  106768. CLIPPLANE5: boolean;
  106769. CLIPPLANE6: boolean;
  106770. POINTSIZE: boolean;
  106771. FOG: boolean;
  106772. LOGARITHMICDEPTH: boolean;
  106773. FORCENORMALFORWARD: boolean;
  106774. SPECULARAA: boolean;
  106775. CLEARCOAT: boolean;
  106776. CLEARCOAT_DEFAULTIOR: boolean;
  106777. CLEARCOAT_TEXTURE: boolean;
  106778. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  106779. CLEARCOAT_TEXTUREDIRECTUV: number;
  106780. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  106781. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106782. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106783. CLEARCOAT_BUMP: boolean;
  106784. CLEARCOAT_BUMPDIRECTUV: number;
  106785. CLEARCOAT_REMAP_F0: boolean;
  106786. CLEARCOAT_TINT: boolean;
  106787. CLEARCOAT_TINT_TEXTURE: boolean;
  106788. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106789. ANISOTROPIC: boolean;
  106790. ANISOTROPIC_TEXTURE: boolean;
  106791. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106792. BRDF_V_HEIGHT_CORRELATED: boolean;
  106793. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106794. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106795. SHEEN: boolean;
  106796. SHEEN_TEXTURE: boolean;
  106797. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106798. SHEEN_TEXTUREDIRECTUV: number;
  106799. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106800. SHEEN_LINKWITHALBEDO: boolean;
  106801. SHEEN_ROUGHNESS: boolean;
  106802. SHEEN_ALBEDOSCALING: boolean;
  106803. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106804. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106805. SUBSURFACE: boolean;
  106806. SS_REFRACTION: boolean;
  106807. SS_TRANSLUCENCY: boolean;
  106808. SS_SCATTERING: boolean;
  106809. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106810. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106811. SS_REFRACTIONMAP_3D: boolean;
  106812. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106813. SS_LODINREFRACTIONALPHA: boolean;
  106814. SS_GAMMAREFRACTION: boolean;
  106815. SS_RGBDREFRACTION: boolean;
  106816. SS_LINEARSPECULARREFRACTION: boolean;
  106817. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106818. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106819. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106820. UNLIT: boolean;
  106821. DEBUGMODE: number;
  106822. /**
  106823. * Initializes the PBR Material defines.
  106824. */
  106825. constructor();
  106826. /**
  106827. * Resets the PBR Material defines.
  106828. */
  106829. reset(): void;
  106830. }
  106831. /**
  106832. * The Physically based material base class of BJS.
  106833. *
  106834. * This offers the main features of a standard PBR material.
  106835. * For more information, please refer to the documentation :
  106836. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106837. */
  106838. export abstract class PBRBaseMaterial extends PushMaterial {
  106839. /**
  106840. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106841. */
  106842. static readonly PBRMATERIAL_OPAQUE: number;
  106843. /**
  106844. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106845. */
  106846. static readonly PBRMATERIAL_ALPHATEST: number;
  106847. /**
  106848. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106849. */
  106850. static readonly PBRMATERIAL_ALPHABLEND: number;
  106851. /**
  106852. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106853. * They are also discarded below the alpha cutoff threshold to improve performances.
  106854. */
  106855. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106856. /**
  106857. * Defines the default value of how much AO map is occluding the analytical lights
  106858. * (point spot...).
  106859. */
  106860. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106861. /**
  106862. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  106863. */
  106864. static readonly LIGHTFALLOFF_PHYSICAL: number;
  106865. /**
  106866. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  106867. * to enhance interoperability with other engines.
  106868. */
  106869. static readonly LIGHTFALLOFF_GLTF: number;
  106870. /**
  106871. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  106872. * to enhance interoperability with other materials.
  106873. */
  106874. static readonly LIGHTFALLOFF_STANDARD: number;
  106875. /**
  106876. * Intensity of the direct lights e.g. the four lights available in your scene.
  106877. * This impacts both the direct diffuse and specular highlights.
  106878. */
  106879. protected _directIntensity: number;
  106880. /**
  106881. * Intensity of the emissive part of the material.
  106882. * This helps controlling the emissive effect without modifying the emissive color.
  106883. */
  106884. protected _emissiveIntensity: number;
  106885. /**
  106886. * Intensity of the environment e.g. how much the environment will light the object
  106887. * either through harmonics for rough material or through the refelction for shiny ones.
  106888. */
  106889. protected _environmentIntensity: number;
  106890. /**
  106891. * This is a special control allowing the reduction of the specular highlights coming from the
  106892. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106893. */
  106894. protected _specularIntensity: number;
  106895. /**
  106896. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  106897. */
  106898. private _lightingInfos;
  106899. /**
  106900. * Debug Control allowing disabling the bump map on this material.
  106901. */
  106902. protected _disableBumpMap: boolean;
  106903. /**
  106904. * AKA Diffuse Texture in standard nomenclature.
  106905. */
  106906. protected _albedoTexture: Nullable<BaseTexture>;
  106907. /**
  106908. * AKA Occlusion Texture in other nomenclature.
  106909. */
  106910. protected _ambientTexture: Nullable<BaseTexture>;
  106911. /**
  106912. * AKA Occlusion Texture Intensity in other nomenclature.
  106913. */
  106914. protected _ambientTextureStrength: number;
  106915. /**
  106916. * Defines how much the AO map is occluding the analytical lights (point spot...).
  106917. * 1 means it completely occludes it
  106918. * 0 mean it has no impact
  106919. */
  106920. protected _ambientTextureImpactOnAnalyticalLights: number;
  106921. /**
  106922. * Stores the alpha values in a texture.
  106923. */
  106924. protected _opacityTexture: Nullable<BaseTexture>;
  106925. /**
  106926. * Stores the reflection values in a texture.
  106927. */
  106928. protected _reflectionTexture: Nullable<BaseTexture>;
  106929. /**
  106930. * Stores the emissive values in a texture.
  106931. */
  106932. protected _emissiveTexture: Nullable<BaseTexture>;
  106933. /**
  106934. * AKA Specular texture in other nomenclature.
  106935. */
  106936. protected _reflectivityTexture: Nullable<BaseTexture>;
  106937. /**
  106938. * Used to switch from specular/glossiness to metallic/roughness workflow.
  106939. */
  106940. protected _metallicTexture: Nullable<BaseTexture>;
  106941. /**
  106942. * Specifies the metallic scalar of the metallic/roughness workflow.
  106943. * Can also be used to scale the metalness values of the metallic texture.
  106944. */
  106945. protected _metallic: Nullable<number>;
  106946. /**
  106947. * Specifies the roughness scalar of the metallic/roughness workflow.
  106948. * Can also be used to scale the roughness values of the metallic texture.
  106949. */
  106950. protected _roughness: Nullable<number>;
  106951. /**
  106952. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  106953. * By default the indexOfrefraction is used to compute F0;
  106954. *
  106955. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  106956. *
  106957. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  106958. * F90 = metallicReflectanceColor;
  106959. */
  106960. protected _metallicF0Factor: number;
  106961. /**
  106962. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  106963. * By default the F90 is always 1;
  106964. *
  106965. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  106966. *
  106967. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  106968. * F90 = metallicReflectanceColor;
  106969. */
  106970. protected _metallicReflectanceColor: Color3;
  106971. /**
  106972. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  106973. * This is multiply against the scalar values defined in the material.
  106974. */
  106975. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  106976. /**
  106977. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  106978. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  106979. */
  106980. protected _microSurfaceTexture: Nullable<BaseTexture>;
  106981. /**
  106982. * Stores surface normal data used to displace a mesh in a texture.
  106983. */
  106984. protected _bumpTexture: Nullable<BaseTexture>;
  106985. /**
  106986. * Stores the pre-calculated light information of a mesh in a texture.
  106987. */
  106988. protected _lightmapTexture: Nullable<BaseTexture>;
  106989. /**
  106990. * The color of a material in ambient lighting.
  106991. */
  106992. protected _ambientColor: Color3;
  106993. /**
  106994. * AKA Diffuse Color in other nomenclature.
  106995. */
  106996. protected _albedoColor: Color3;
  106997. /**
  106998. * AKA Specular Color in other nomenclature.
  106999. */
  107000. protected _reflectivityColor: Color3;
  107001. /**
  107002. * The color applied when light is reflected from a material.
  107003. */
  107004. protected _reflectionColor: Color3;
  107005. /**
  107006. * The color applied when light is emitted from a material.
  107007. */
  107008. protected _emissiveColor: Color3;
  107009. /**
  107010. * AKA Glossiness in other nomenclature.
  107011. */
  107012. protected _microSurface: number;
  107013. /**
  107014. * Specifies that the material will use the light map as a show map.
  107015. */
  107016. protected _useLightmapAsShadowmap: boolean;
  107017. /**
  107018. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107019. * makes the reflect vector face the model (under horizon).
  107020. */
  107021. protected _useHorizonOcclusion: boolean;
  107022. /**
  107023. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107024. * too much the area relying on ambient texture to define their ambient occlusion.
  107025. */
  107026. protected _useRadianceOcclusion: boolean;
  107027. /**
  107028. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107029. */
  107030. protected _useAlphaFromAlbedoTexture: boolean;
  107031. /**
  107032. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107033. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107034. */
  107035. protected _useSpecularOverAlpha: boolean;
  107036. /**
  107037. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107038. */
  107039. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107040. /**
  107041. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107042. */
  107043. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107044. /**
  107045. * Specifies if the metallic texture contains the roughness information in its green channel.
  107046. */
  107047. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107048. /**
  107049. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107050. */
  107051. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107052. /**
  107053. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107054. */
  107055. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107056. /**
  107057. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107058. */
  107059. protected _useAmbientInGrayScale: boolean;
  107060. /**
  107061. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107062. * The material will try to infer what glossiness each pixel should be.
  107063. */
  107064. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107065. /**
  107066. * Defines the falloff type used in this material.
  107067. * It by default is Physical.
  107068. */
  107069. protected _lightFalloff: number;
  107070. /**
  107071. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107072. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107073. */
  107074. protected _useRadianceOverAlpha: boolean;
  107075. /**
  107076. * Allows using an object space normal map (instead of tangent space).
  107077. */
  107078. protected _useObjectSpaceNormalMap: boolean;
  107079. /**
  107080. * Allows using the bump map in parallax mode.
  107081. */
  107082. protected _useParallax: boolean;
  107083. /**
  107084. * Allows using the bump map in parallax occlusion mode.
  107085. */
  107086. protected _useParallaxOcclusion: boolean;
  107087. /**
  107088. * Controls the scale bias of the parallax mode.
  107089. */
  107090. protected _parallaxScaleBias: number;
  107091. /**
  107092. * If sets to true, disables all the lights affecting the material.
  107093. */
  107094. protected _disableLighting: boolean;
  107095. /**
  107096. * Number of Simultaneous lights allowed on the material.
  107097. */
  107098. protected _maxSimultaneousLights: number;
  107099. /**
  107100. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107101. */
  107102. protected _invertNormalMapX: boolean;
  107103. /**
  107104. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107105. */
  107106. protected _invertNormalMapY: boolean;
  107107. /**
  107108. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107109. */
  107110. protected _twoSidedLighting: boolean;
  107111. /**
  107112. * Defines the alpha limits in alpha test mode.
  107113. */
  107114. protected _alphaCutOff: number;
  107115. /**
  107116. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107117. */
  107118. protected _forceAlphaTest: boolean;
  107119. /**
  107120. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107121. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107122. */
  107123. protected _useAlphaFresnel: boolean;
  107124. /**
  107125. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107126. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107127. */
  107128. protected _useLinearAlphaFresnel: boolean;
  107129. /**
  107130. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107131. * from cos thetav and roughness:
  107132. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107133. */
  107134. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107135. /**
  107136. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107137. */
  107138. protected _forceIrradianceInFragment: boolean;
  107139. private _realTimeFiltering;
  107140. /**
  107141. * Enables realtime filtering on the texture.
  107142. */
  107143. get realTimeFiltering(): boolean;
  107144. set realTimeFiltering(b: boolean);
  107145. private _realTimeFilteringQuality;
  107146. /**
  107147. * Quality switch for realtime filtering
  107148. */
  107149. get realTimeFilteringQuality(): number;
  107150. set realTimeFilteringQuality(n: number);
  107151. /**
  107152. * Can this material render to several textures at once
  107153. */
  107154. get canRenderToMRT(): boolean;
  107155. /**
  107156. * Force normal to face away from face.
  107157. */
  107158. protected _forceNormalForward: boolean;
  107159. /**
  107160. * Enables specular anti aliasing in the PBR shader.
  107161. * It will both interacts on the Geometry for analytical and IBL lighting.
  107162. * It also prefilter the roughness map based on the bump values.
  107163. */
  107164. protected _enableSpecularAntiAliasing: boolean;
  107165. /**
  107166. * Default configuration related to image processing available in the PBR Material.
  107167. */
  107168. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107169. /**
  107170. * Keep track of the image processing observer to allow dispose and replace.
  107171. */
  107172. private _imageProcessingObserver;
  107173. /**
  107174. * Attaches a new image processing configuration to the PBR Material.
  107175. * @param configuration
  107176. */
  107177. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107178. /**
  107179. * Stores the available render targets.
  107180. */
  107181. private _renderTargets;
  107182. /**
  107183. * Sets the global ambient color for the material used in lighting calculations.
  107184. */
  107185. private _globalAmbientColor;
  107186. /**
  107187. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107188. */
  107189. private _useLogarithmicDepth;
  107190. /**
  107191. * If set to true, no lighting calculations will be applied.
  107192. */
  107193. private _unlit;
  107194. private _debugMode;
  107195. /**
  107196. * @hidden
  107197. * This is reserved for the inspector.
  107198. * Defines the material debug mode.
  107199. * It helps seeing only some components of the material while troubleshooting.
  107200. */
  107201. debugMode: number;
  107202. /**
  107203. * @hidden
  107204. * This is reserved for the inspector.
  107205. * Specify from where on screen the debug mode should start.
  107206. * The value goes from -1 (full screen) to 1 (not visible)
  107207. * It helps with side by side comparison against the final render
  107208. * This defaults to -1
  107209. */
  107210. private debugLimit;
  107211. /**
  107212. * @hidden
  107213. * This is reserved for the inspector.
  107214. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107215. * You can use the factor to better multiply the final value.
  107216. */
  107217. private debugFactor;
  107218. /**
  107219. * Defines the clear coat layer parameters for the material.
  107220. */
  107221. readonly clearCoat: PBRClearCoatConfiguration;
  107222. /**
  107223. * Defines the anisotropic parameters for the material.
  107224. */
  107225. readonly anisotropy: PBRAnisotropicConfiguration;
  107226. /**
  107227. * Defines the BRDF parameters for the material.
  107228. */
  107229. readonly brdf: PBRBRDFConfiguration;
  107230. /**
  107231. * Defines the Sheen parameters for the material.
  107232. */
  107233. readonly sheen: PBRSheenConfiguration;
  107234. /**
  107235. * Defines the SubSurface parameters for the material.
  107236. */
  107237. readonly subSurface: PBRSubSurfaceConfiguration;
  107238. /**
  107239. * Defines additionnal PrePass parameters for the material.
  107240. */
  107241. readonly prePassConfiguration: PrePassConfiguration;
  107242. /**
  107243. * Defines the detail map parameters for the material.
  107244. */
  107245. readonly detailMap: DetailMapConfiguration;
  107246. protected _rebuildInParallel: boolean;
  107247. /**
  107248. * Instantiates a new PBRMaterial instance.
  107249. *
  107250. * @param name The material name
  107251. * @param scene The scene the material will be use in.
  107252. */
  107253. constructor(name: string, scene: Scene);
  107254. /**
  107255. * Gets a boolean indicating that current material needs to register RTT
  107256. */
  107257. get hasRenderTargetTextures(): boolean;
  107258. /**
  107259. * Gets the name of the material class.
  107260. */
  107261. getClassName(): string;
  107262. /**
  107263. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107264. */
  107265. get useLogarithmicDepth(): boolean;
  107266. /**
  107267. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107268. */
  107269. set useLogarithmicDepth(value: boolean);
  107270. /**
  107271. * Returns true if alpha blending should be disabled.
  107272. */
  107273. protected get _disableAlphaBlending(): boolean;
  107274. /**
  107275. * Specifies whether or not this material should be rendered in alpha blend mode.
  107276. */
  107277. needAlphaBlending(): boolean;
  107278. /**
  107279. * Specifies whether or not this material should be rendered in alpha test mode.
  107280. */
  107281. needAlphaTesting(): boolean;
  107282. /**
  107283. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107284. */
  107285. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107286. /**
  107287. * Gets the texture used for the alpha test.
  107288. */
  107289. getAlphaTestTexture(): Nullable<BaseTexture>;
  107290. /**
  107291. * Specifies that the submesh is ready to be used.
  107292. * @param mesh - BJS mesh.
  107293. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107294. * @param useInstances - Specifies that instances should be used.
  107295. * @returns - boolean indicating that the submesh is ready or not.
  107296. */
  107297. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107298. /**
  107299. * Specifies if the material uses metallic roughness workflow.
  107300. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107301. */
  107302. isMetallicWorkflow(): boolean;
  107303. private _prepareEffect;
  107304. private _prepareDefines;
  107305. /**
  107306. * Force shader compilation
  107307. */
  107308. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  107309. /**
  107310. * Initializes the uniform buffer layout for the shader.
  107311. */
  107312. buildUniformLayout(): void;
  107313. /**
  107314. * Unbinds the material from the mesh
  107315. */
  107316. unbind(): void;
  107317. /**
  107318. * Binds the submesh data.
  107319. * @param world - The world matrix.
  107320. * @param mesh - The BJS mesh.
  107321. * @param subMesh - A submesh of the BJS mesh.
  107322. */
  107323. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107324. /**
  107325. * Returns the animatable textures.
  107326. * @returns - Array of animatable textures.
  107327. */
  107328. getAnimatables(): IAnimatable[];
  107329. /**
  107330. * Returns the texture used for reflections.
  107331. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107332. */
  107333. private _getReflectionTexture;
  107334. /**
  107335. * Returns an array of the actively used textures.
  107336. * @returns - Array of BaseTextures
  107337. */
  107338. getActiveTextures(): BaseTexture[];
  107339. /**
  107340. * Checks to see if a texture is used in the material.
  107341. * @param texture - Base texture to use.
  107342. * @returns - Boolean specifying if a texture is used in the material.
  107343. */
  107344. hasTexture(texture: BaseTexture): boolean;
  107345. /**
  107346. * Sets the required values to the prepass renderer.
  107347. * @param prePassRenderer defines the prepass renderer to setup
  107348. */
  107349. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107350. /**
  107351. * Disposes the resources of the material.
  107352. * @param forceDisposeEffect - Forces the disposal of effects.
  107353. * @param forceDisposeTextures - Forces the disposal of all textures.
  107354. */
  107355. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107356. }
  107357. }
  107358. declare module BABYLON {
  107359. /**
  107360. * The Physically based material of BJS.
  107361. *
  107362. * This offers the main features of a standard PBR material.
  107363. * For more information, please refer to the documentation :
  107364. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107365. */
  107366. export class PBRMaterial extends PBRBaseMaterial {
  107367. /**
  107368. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107369. */
  107370. static readonly PBRMATERIAL_OPAQUE: number;
  107371. /**
  107372. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107373. */
  107374. static readonly PBRMATERIAL_ALPHATEST: number;
  107375. /**
  107376. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107377. */
  107378. static readonly PBRMATERIAL_ALPHABLEND: number;
  107379. /**
  107380. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107381. * They are also discarded below the alpha cutoff threshold to improve performances.
  107382. */
  107383. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107384. /**
  107385. * Defines the default value of how much AO map is occluding the analytical lights
  107386. * (point spot...).
  107387. */
  107388. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107389. /**
  107390. * Intensity of the direct lights e.g. the four lights available in your scene.
  107391. * This impacts both the direct diffuse and specular highlights.
  107392. */
  107393. directIntensity: number;
  107394. /**
  107395. * Intensity of the emissive part of the material.
  107396. * This helps controlling the emissive effect without modifying the emissive color.
  107397. */
  107398. emissiveIntensity: number;
  107399. /**
  107400. * Intensity of the environment e.g. how much the environment will light the object
  107401. * either through harmonics for rough material or through the refelction for shiny ones.
  107402. */
  107403. environmentIntensity: number;
  107404. /**
  107405. * This is a special control allowing the reduction of the specular highlights coming from the
  107406. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107407. */
  107408. specularIntensity: number;
  107409. /**
  107410. * Debug Control allowing disabling the bump map on this material.
  107411. */
  107412. disableBumpMap: boolean;
  107413. /**
  107414. * AKA Diffuse Texture in standard nomenclature.
  107415. */
  107416. albedoTexture: BaseTexture;
  107417. /**
  107418. * AKA Occlusion Texture in other nomenclature.
  107419. */
  107420. ambientTexture: BaseTexture;
  107421. /**
  107422. * AKA Occlusion Texture Intensity in other nomenclature.
  107423. */
  107424. ambientTextureStrength: number;
  107425. /**
  107426. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107427. * 1 means it completely occludes it
  107428. * 0 mean it has no impact
  107429. */
  107430. ambientTextureImpactOnAnalyticalLights: number;
  107431. /**
  107432. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  107433. */
  107434. opacityTexture: BaseTexture;
  107435. /**
  107436. * Stores the reflection values in a texture.
  107437. */
  107438. reflectionTexture: Nullable<BaseTexture>;
  107439. /**
  107440. * Stores the emissive values in a texture.
  107441. */
  107442. emissiveTexture: BaseTexture;
  107443. /**
  107444. * AKA Specular texture in other nomenclature.
  107445. */
  107446. reflectivityTexture: BaseTexture;
  107447. /**
  107448. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107449. */
  107450. metallicTexture: BaseTexture;
  107451. /**
  107452. * Specifies the metallic scalar of the metallic/roughness workflow.
  107453. * Can also be used to scale the metalness values of the metallic texture.
  107454. */
  107455. metallic: Nullable<number>;
  107456. /**
  107457. * Specifies the roughness scalar of the metallic/roughness workflow.
  107458. * Can also be used to scale the roughness values of the metallic texture.
  107459. */
  107460. roughness: Nullable<number>;
  107461. /**
  107462. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107463. * By default the indexOfrefraction is used to compute F0;
  107464. *
  107465. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107466. *
  107467. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107468. * F90 = metallicReflectanceColor;
  107469. */
  107470. metallicF0Factor: number;
  107471. /**
  107472. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107473. * By default the F90 is always 1;
  107474. *
  107475. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107476. *
  107477. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107478. * F90 = metallicReflectanceColor;
  107479. */
  107480. metallicReflectanceColor: Color3;
  107481. /**
  107482. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107483. * This is multiply against the scalar values defined in the material.
  107484. */
  107485. metallicReflectanceTexture: Nullable<BaseTexture>;
  107486. /**
  107487. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107488. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107489. */
  107490. microSurfaceTexture: BaseTexture;
  107491. /**
  107492. * Stores surface normal data used to displace a mesh in a texture.
  107493. */
  107494. bumpTexture: BaseTexture;
  107495. /**
  107496. * Stores the pre-calculated light information of a mesh in a texture.
  107497. */
  107498. lightmapTexture: BaseTexture;
  107499. /**
  107500. * Stores the refracted light information in a texture.
  107501. */
  107502. get refractionTexture(): Nullable<BaseTexture>;
  107503. set refractionTexture(value: Nullable<BaseTexture>);
  107504. /**
  107505. * The color of a material in ambient lighting.
  107506. */
  107507. ambientColor: Color3;
  107508. /**
  107509. * AKA Diffuse Color in other nomenclature.
  107510. */
  107511. albedoColor: Color3;
  107512. /**
  107513. * AKA Specular Color in other nomenclature.
  107514. */
  107515. reflectivityColor: Color3;
  107516. /**
  107517. * The color reflected from the material.
  107518. */
  107519. reflectionColor: Color3;
  107520. /**
  107521. * The color emitted from the material.
  107522. */
  107523. emissiveColor: Color3;
  107524. /**
  107525. * AKA Glossiness in other nomenclature.
  107526. */
  107527. microSurface: number;
  107528. /**
  107529. * Index of refraction of the material base layer.
  107530. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107531. *
  107532. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  107533. *
  107534. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  107535. */
  107536. get indexOfRefraction(): number;
  107537. set indexOfRefraction(value: number);
  107538. /**
  107539. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107540. */
  107541. get invertRefractionY(): boolean;
  107542. set invertRefractionY(value: boolean);
  107543. /**
  107544. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107545. * Materials half opaque for instance using refraction could benefit from this control.
  107546. */
  107547. get linkRefractionWithTransparency(): boolean;
  107548. set linkRefractionWithTransparency(value: boolean);
  107549. /**
  107550. * If true, the light map contains occlusion information instead of lighting info.
  107551. */
  107552. useLightmapAsShadowmap: boolean;
  107553. /**
  107554. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107555. */
  107556. useAlphaFromAlbedoTexture: boolean;
  107557. /**
  107558. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107559. */
  107560. forceAlphaTest: boolean;
  107561. /**
  107562. * Defines the alpha limits in alpha test mode.
  107563. */
  107564. alphaCutOff: number;
  107565. /**
  107566. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107567. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107568. */
  107569. useSpecularOverAlpha: boolean;
  107570. /**
  107571. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107572. */
  107573. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107574. /**
  107575. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107576. */
  107577. useRoughnessFromMetallicTextureAlpha: boolean;
  107578. /**
  107579. * Specifies if the metallic texture contains the roughness information in its green channel.
  107580. */
  107581. useRoughnessFromMetallicTextureGreen: boolean;
  107582. /**
  107583. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107584. */
  107585. useMetallnessFromMetallicTextureBlue: boolean;
  107586. /**
  107587. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107588. */
  107589. useAmbientOcclusionFromMetallicTextureRed: boolean;
  107590. /**
  107591. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107592. */
  107593. useAmbientInGrayScale: boolean;
  107594. /**
  107595. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107596. * The material will try to infer what glossiness each pixel should be.
  107597. */
  107598. useAutoMicroSurfaceFromReflectivityMap: boolean;
  107599. /**
  107600. * BJS is using an harcoded light falloff based on a manually sets up range.
  107601. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107602. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107603. */
  107604. get usePhysicalLightFalloff(): boolean;
  107605. /**
  107606. * BJS is using an harcoded light falloff based on a manually sets up range.
  107607. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107608. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107609. */
  107610. set usePhysicalLightFalloff(value: boolean);
  107611. /**
  107612. * In order to support the falloff compatibility with gltf, a special mode has been added
  107613. * to reproduce the gltf light falloff.
  107614. */
  107615. get useGLTFLightFalloff(): boolean;
  107616. /**
  107617. * In order to support the falloff compatibility with gltf, a special mode has been added
  107618. * to reproduce the gltf light falloff.
  107619. */
  107620. set useGLTFLightFalloff(value: boolean);
  107621. /**
  107622. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107623. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107624. */
  107625. useRadianceOverAlpha: boolean;
  107626. /**
  107627. * Allows using an object space normal map (instead of tangent space).
  107628. */
  107629. useObjectSpaceNormalMap: boolean;
  107630. /**
  107631. * Allows using the bump map in parallax mode.
  107632. */
  107633. useParallax: boolean;
  107634. /**
  107635. * Allows using the bump map in parallax occlusion mode.
  107636. */
  107637. useParallaxOcclusion: boolean;
  107638. /**
  107639. * Controls the scale bias of the parallax mode.
  107640. */
  107641. parallaxScaleBias: number;
  107642. /**
  107643. * If sets to true, disables all the lights affecting the material.
  107644. */
  107645. disableLighting: boolean;
  107646. /**
  107647. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107648. */
  107649. forceIrradianceInFragment: boolean;
  107650. /**
  107651. * Number of Simultaneous lights allowed on the material.
  107652. */
  107653. maxSimultaneousLights: number;
  107654. /**
  107655. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107656. */
  107657. invertNormalMapX: boolean;
  107658. /**
  107659. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107660. */
  107661. invertNormalMapY: boolean;
  107662. /**
  107663. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107664. */
  107665. twoSidedLighting: boolean;
  107666. /**
  107667. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107668. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107669. */
  107670. useAlphaFresnel: boolean;
  107671. /**
  107672. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107673. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107674. */
  107675. useLinearAlphaFresnel: boolean;
  107676. /**
  107677. * Let user defines the brdf lookup texture used for IBL.
  107678. * A default 8bit version is embedded but you could point at :
  107679. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107680. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107681. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107682. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107683. */
  107684. environmentBRDFTexture: Nullable<BaseTexture>;
  107685. /**
  107686. * Force normal to face away from face.
  107687. */
  107688. forceNormalForward: boolean;
  107689. /**
  107690. * Enables specular anti aliasing in the PBR shader.
  107691. * It will both interacts on the Geometry for analytical and IBL lighting.
  107692. * It also prefilter the roughness map based on the bump values.
  107693. */
  107694. enableSpecularAntiAliasing: boolean;
  107695. /**
  107696. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107697. * makes the reflect vector face the model (under horizon).
  107698. */
  107699. useHorizonOcclusion: boolean;
  107700. /**
  107701. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107702. * too much the area relying on ambient texture to define their ambient occlusion.
  107703. */
  107704. useRadianceOcclusion: boolean;
  107705. /**
  107706. * If set to true, no lighting calculations will be applied.
  107707. */
  107708. unlit: boolean;
  107709. /**
  107710. * Gets the image processing configuration used either in this material.
  107711. */
  107712. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107713. /**
  107714. * Sets the Default image processing configuration used either in the this material.
  107715. *
  107716. * If sets to null, the scene one is in use.
  107717. */
  107718. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107719. /**
  107720. * Gets wether the color curves effect is enabled.
  107721. */
  107722. get cameraColorCurvesEnabled(): boolean;
  107723. /**
  107724. * Sets wether the color curves effect is enabled.
  107725. */
  107726. set cameraColorCurvesEnabled(value: boolean);
  107727. /**
  107728. * Gets wether the color grading effect is enabled.
  107729. */
  107730. get cameraColorGradingEnabled(): boolean;
  107731. /**
  107732. * Gets wether the color grading effect is enabled.
  107733. */
  107734. set cameraColorGradingEnabled(value: boolean);
  107735. /**
  107736. * Gets wether tonemapping is enabled or not.
  107737. */
  107738. get cameraToneMappingEnabled(): boolean;
  107739. /**
  107740. * Sets wether tonemapping is enabled or not
  107741. */
  107742. set cameraToneMappingEnabled(value: boolean);
  107743. /**
  107744. * The camera exposure used on this material.
  107745. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107746. * This corresponds to a photographic exposure.
  107747. */
  107748. get cameraExposure(): number;
  107749. /**
  107750. * The camera exposure used on this material.
  107751. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107752. * This corresponds to a photographic exposure.
  107753. */
  107754. set cameraExposure(value: number);
  107755. /**
  107756. * Gets The camera contrast used on this material.
  107757. */
  107758. get cameraContrast(): number;
  107759. /**
  107760. * Sets The camera contrast used on this material.
  107761. */
  107762. set cameraContrast(value: number);
  107763. /**
  107764. * Gets the Color Grading 2D Lookup Texture.
  107765. */
  107766. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107767. /**
  107768. * Sets the Color Grading 2D Lookup Texture.
  107769. */
  107770. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107771. /**
  107772. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107773. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107774. * 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;
  107775. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107776. */
  107777. get cameraColorCurves(): Nullable<ColorCurves>;
  107778. /**
  107779. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107780. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107781. * 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;
  107782. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107783. */
  107784. set cameraColorCurves(value: Nullable<ColorCurves>);
  107785. /**
  107786. * Instantiates a new PBRMaterial instance.
  107787. *
  107788. * @param name The material name
  107789. * @param scene The scene the material will be use in.
  107790. */
  107791. constructor(name: string, scene: Scene);
  107792. /**
  107793. * Returns the name of this material class.
  107794. */
  107795. getClassName(): string;
  107796. /**
  107797. * Makes a duplicate of the current material.
  107798. * @param name - name to use for the new material.
  107799. */
  107800. clone(name: string): PBRMaterial;
  107801. /**
  107802. * Serializes this PBR Material.
  107803. * @returns - An object with the serialized material.
  107804. */
  107805. serialize(): any;
  107806. /**
  107807. * Parses a PBR Material from a serialized object.
  107808. * @param source - Serialized object.
  107809. * @param scene - BJS scene instance.
  107810. * @param rootUrl - url for the scene object
  107811. * @returns - PBRMaterial
  107812. */
  107813. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107814. }
  107815. }
  107816. declare module BABYLON {
  107817. /** @hidden */
  107818. export var mrtFragmentDeclaration: {
  107819. name: string;
  107820. shader: string;
  107821. };
  107822. }
  107823. declare module BABYLON {
  107824. /** @hidden */
  107825. export var geometryPixelShader: {
  107826. name: string;
  107827. shader: string;
  107828. };
  107829. }
  107830. declare module BABYLON {
  107831. /** @hidden */
  107832. export var geometryVertexShader: {
  107833. name: string;
  107834. shader: string;
  107835. };
  107836. }
  107837. declare module BABYLON {
  107838. /** @hidden */
  107839. interface ISavedTransformationMatrix {
  107840. world: Matrix;
  107841. viewProjection: Matrix;
  107842. }
  107843. /**
  107844. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107845. */
  107846. export class GeometryBufferRenderer {
  107847. /**
  107848. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  107849. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  107850. */
  107851. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  107852. /**
  107853. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107854. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107855. */
  107856. static readonly POSITION_TEXTURE_TYPE: number;
  107857. /**
  107858. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107859. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107860. */
  107861. static readonly VELOCITY_TEXTURE_TYPE: number;
  107862. /**
  107863. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  107864. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  107865. */
  107866. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  107867. /**
  107868. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107869. * in order to compute objects velocities when enableVelocity is set to "true"
  107870. * @hidden
  107871. */
  107872. _previousTransformationMatrices: {
  107873. [index: number]: ISavedTransformationMatrix;
  107874. };
  107875. /**
  107876. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  107877. * in order to compute objects velocities when enableVelocity is set to "true"
  107878. * @hidden
  107879. */
  107880. _previousBonesTransformationMatrices: {
  107881. [index: number]: Float32Array;
  107882. };
  107883. /**
  107884. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  107885. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  107886. */
  107887. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  107888. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  107889. renderTransparentMeshes: boolean;
  107890. private _scene;
  107891. private _resizeObserver;
  107892. private _multiRenderTarget;
  107893. private _ratio;
  107894. private _enablePosition;
  107895. private _enableVelocity;
  107896. private _enableReflectivity;
  107897. private _positionIndex;
  107898. private _velocityIndex;
  107899. private _reflectivityIndex;
  107900. private _depthNormalIndex;
  107901. private _linkedWithPrePass;
  107902. private _prePassRenderer;
  107903. private _attachments;
  107904. protected _effect: Effect;
  107905. protected _cachedDefines: string;
  107906. /**
  107907. * @hidden
  107908. * Sets up internal structures to share outputs with PrePassRenderer
  107909. * This method should only be called by the PrePassRenderer itself
  107910. */
  107911. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  107912. /**
  107913. * @hidden
  107914. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  107915. * This method should only be called by the PrePassRenderer itself
  107916. */
  107917. _unlinkPrePassRenderer(): void;
  107918. /**
  107919. * @hidden
  107920. * Resets the geometry buffer layout
  107921. */
  107922. _resetLayout(): void;
  107923. /**
  107924. * @hidden
  107925. * Replaces a texture in the geometry buffer renderer
  107926. * Useful when linking textures of the prepass renderer
  107927. */
  107928. _forceTextureType(geometryBufferType: number, index: number): void;
  107929. /**
  107930. * @hidden
  107931. * Sets texture attachments
  107932. * Useful when linking textures of the prepass renderer
  107933. */
  107934. _setAttachments(attachments: number[]): void;
  107935. /**
  107936. * @hidden
  107937. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  107938. * Useful when linking textures of the prepass renderer
  107939. */
  107940. _linkInternalTexture(internalTexture: InternalTexture): void;
  107941. /**
  107942. * Gets the render list (meshes to be rendered) used in the G buffer.
  107943. */
  107944. get renderList(): Nullable<AbstractMesh[]>;
  107945. /**
  107946. * Set the render list (meshes to be rendered) used in the G buffer.
  107947. */
  107948. set renderList(meshes: Nullable<AbstractMesh[]>);
  107949. /**
  107950. * Gets wether or not G buffer are supported by the running hardware.
  107951. * This requires draw buffer supports
  107952. */
  107953. get isSupported(): boolean;
  107954. /**
  107955. * Returns the index of the given texture type in the G-Buffer textures array
  107956. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  107957. * @returns the index of the given texture type in the G-Buffer textures array
  107958. */
  107959. getTextureIndex(textureType: number): number;
  107960. /**
  107961. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  107962. */
  107963. get enablePosition(): boolean;
  107964. /**
  107965. * Sets whether or not objects positions are enabled for the G buffer.
  107966. */
  107967. set enablePosition(enable: boolean);
  107968. /**
  107969. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  107970. */
  107971. get enableVelocity(): boolean;
  107972. /**
  107973. * Sets wether or not objects velocities are enabled for the G buffer.
  107974. */
  107975. set enableVelocity(enable: boolean);
  107976. /**
  107977. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  107978. */
  107979. get enableReflectivity(): boolean;
  107980. /**
  107981. * Sets wether or not objects roughness are enabled for the G buffer.
  107982. */
  107983. set enableReflectivity(enable: boolean);
  107984. /**
  107985. * Gets the scene associated with the buffer.
  107986. */
  107987. get scene(): Scene;
  107988. /**
  107989. * Gets the ratio used by the buffer during its creation.
  107990. * How big is the buffer related to the main canvas.
  107991. */
  107992. get ratio(): number;
  107993. /** @hidden */
  107994. static _SceneComponentInitialization: (scene: Scene) => void;
  107995. /**
  107996. * Creates a new G Buffer for the scene
  107997. * @param scene The scene the buffer belongs to
  107998. * @param ratio How big is the buffer related to the main canvas.
  107999. */
  108000. constructor(scene: Scene, ratio?: number);
  108001. /**
  108002. * Checks wether everything is ready to render a submesh to the G buffer.
  108003. * @param subMesh the submesh to check readiness for
  108004. * @param useInstances is the mesh drawn using instance or not
  108005. * @returns true if ready otherwise false
  108006. */
  108007. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108008. /**
  108009. * Gets the current underlying G Buffer.
  108010. * @returns the buffer
  108011. */
  108012. getGBuffer(): MultiRenderTarget;
  108013. /**
  108014. * Gets the number of samples used to render the buffer (anti aliasing).
  108015. */
  108016. get samples(): number;
  108017. /**
  108018. * Sets the number of samples used to render the buffer (anti aliasing).
  108019. */
  108020. set samples(value: number);
  108021. /**
  108022. * Disposes the renderer and frees up associated resources.
  108023. */
  108024. dispose(): void;
  108025. private _assignRenderTargetIndices;
  108026. protected _createRenderTargets(): void;
  108027. private _copyBonesTransformationMatrices;
  108028. }
  108029. }
  108030. declare module BABYLON {
  108031. /**
  108032. * Renders a pre pass of the scene
  108033. * This means every mesh in the scene will be rendered to a render target texture
  108034. * And then this texture will be composited to the rendering canvas with post processes
  108035. * It is necessary for effects like subsurface scattering or deferred shading
  108036. */
  108037. export class PrePassRenderer {
  108038. /** @hidden */
  108039. static _SceneComponentInitialization: (scene: Scene) => void;
  108040. private _textureFormats;
  108041. /**
  108042. * To save performance, we can excluded skinned meshes from the prepass
  108043. */
  108044. excludedSkinnedMesh: AbstractMesh[];
  108045. /**
  108046. * Force material to be excluded from the prepass
  108047. * Can be useful when `useGeometryBufferFallback` is set to `true`
  108048. * and you don't want a material to show in the effect.
  108049. */
  108050. excludedMaterials: Material[];
  108051. private _textureIndices;
  108052. private _scene;
  108053. private _engine;
  108054. private _isDirty;
  108055. /**
  108056. * Number of textures in the multi render target texture where the scene is directly rendered
  108057. */
  108058. mrtCount: number;
  108059. /**
  108060. * The render target where the scene is directly rendered
  108061. */
  108062. prePassRT: MultiRenderTarget;
  108063. private _multiRenderAttachments;
  108064. private _defaultAttachments;
  108065. private _clearAttachments;
  108066. private _postProcesses;
  108067. private readonly _clearColor;
  108068. /**
  108069. * Image processing post process for composition
  108070. */
  108071. imageProcessingPostProcess: ImageProcessingPostProcess;
  108072. /**
  108073. * Configuration for prepass effects
  108074. */
  108075. private _effectConfigurations;
  108076. private _mrtFormats;
  108077. private _mrtLayout;
  108078. private _enabled;
  108079. /**
  108080. * Indicates if the prepass is enabled
  108081. */
  108082. get enabled(): boolean;
  108083. /**
  108084. * How many samples are used for MSAA of the scene render target
  108085. */
  108086. get samples(): number;
  108087. set samples(n: number);
  108088. private _geometryBuffer;
  108089. private _useGeometryBufferFallback;
  108090. /**
  108091. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  108092. */
  108093. get useGeometryBufferFallback(): boolean;
  108094. set useGeometryBufferFallback(value: boolean);
  108095. /**
  108096. * Instanciates a prepass renderer
  108097. * @param scene The scene
  108098. */
  108099. constructor(scene: Scene);
  108100. private _initializeAttachments;
  108101. private _createCompositionEffect;
  108102. /**
  108103. * Indicates if rendering a prepass is supported
  108104. */
  108105. get isSupported(): boolean;
  108106. /**
  108107. * Sets the proper output textures to draw in the engine.
  108108. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108109. * @param subMesh Submesh on which the effect is applied
  108110. */
  108111. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108112. /**
  108113. * @hidden
  108114. */
  108115. _beforeCameraDraw(): void;
  108116. /**
  108117. * @hidden
  108118. */
  108119. _afterCameraDraw(): void;
  108120. private _checkRTSize;
  108121. private _bindFrameBuffer;
  108122. /**
  108123. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  108124. */
  108125. clear(): void;
  108126. private _setState;
  108127. private _updateGeometryBufferLayout;
  108128. /**
  108129. * Adds an effect configuration to the prepass.
  108130. * If an effect has already been added, it won't add it twice and will return the configuration
  108131. * already present.
  108132. * @param cfg the effect configuration
  108133. * @return the effect configuration now used by the prepass
  108134. */
  108135. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108136. /**
  108137. * Returns the index of a texture in the multi render target texture array.
  108138. * @param type Texture type
  108139. * @return The index
  108140. */
  108141. getIndex(type: number): number;
  108142. private _enable;
  108143. private _disable;
  108144. private _resetLayout;
  108145. private _resetPostProcessChain;
  108146. private _bindPostProcessChain;
  108147. /**
  108148. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108149. */
  108150. markAsDirty(): void;
  108151. /**
  108152. * Enables a texture on the MultiRenderTarget for prepass
  108153. */
  108154. private _enableTextures;
  108155. private _update;
  108156. private _markAllMaterialsAsPrePassDirty;
  108157. /**
  108158. * Disposes the prepass renderer.
  108159. */
  108160. dispose(): void;
  108161. }
  108162. }
  108163. declare module BABYLON {
  108164. /**
  108165. * Size options for a post process
  108166. */
  108167. export type PostProcessOptions = {
  108168. width: number;
  108169. height: number;
  108170. };
  108171. /**
  108172. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108173. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108174. */
  108175. export class PostProcess {
  108176. /**
  108177. * Gets or sets the unique id of the post process
  108178. */
  108179. uniqueId: number;
  108180. /** Name of the PostProcess. */
  108181. name: string;
  108182. /**
  108183. * Width of the texture to apply the post process on
  108184. */
  108185. width: number;
  108186. /**
  108187. * Height of the texture to apply the post process on
  108188. */
  108189. height: number;
  108190. /**
  108191. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108192. */
  108193. nodeMaterialSource: Nullable<NodeMaterial>;
  108194. /**
  108195. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108196. * @hidden
  108197. */
  108198. _outputTexture: Nullable<InternalTexture>;
  108199. /**
  108200. * Sampling mode used by the shader
  108201. * See https://doc.babylonjs.com/classes/3.1/texture
  108202. */
  108203. renderTargetSamplingMode: number;
  108204. /**
  108205. * Clear color to use when screen clearing
  108206. */
  108207. clearColor: Color4;
  108208. /**
  108209. * If the buffer needs to be cleared before applying the post process. (default: true)
  108210. * Should be set to false if shader will overwrite all previous pixels.
  108211. */
  108212. autoClear: boolean;
  108213. /**
  108214. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108215. */
  108216. alphaMode: number;
  108217. /**
  108218. * Sets the setAlphaBlendConstants of the babylon engine
  108219. */
  108220. alphaConstants: Color4;
  108221. /**
  108222. * Animations to be used for the post processing
  108223. */
  108224. animations: Animation[];
  108225. /**
  108226. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108227. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108228. */
  108229. enablePixelPerfectMode: boolean;
  108230. /**
  108231. * Force the postprocess to be applied without taking in account viewport
  108232. */
  108233. forceFullscreenViewport: boolean;
  108234. /**
  108235. * List of inspectable custom properties (used by the Inspector)
  108236. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108237. */
  108238. inspectableCustomProperties: IInspectable[];
  108239. /**
  108240. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108241. *
  108242. * | Value | Type | Description |
  108243. * | ----- | ----------------------------------- | ----------- |
  108244. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108245. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108246. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108247. *
  108248. */
  108249. scaleMode: number;
  108250. /**
  108251. * Force textures to be a power of two (default: false)
  108252. */
  108253. alwaysForcePOT: boolean;
  108254. private _samples;
  108255. /**
  108256. * Number of sample textures (default: 1)
  108257. */
  108258. get samples(): number;
  108259. set samples(n: number);
  108260. /**
  108261. * Modify the scale of the post process to be the same as the viewport (default: false)
  108262. */
  108263. adaptScaleToCurrentViewport: boolean;
  108264. private _camera;
  108265. protected _scene: Scene;
  108266. private _engine;
  108267. private _options;
  108268. private _reusable;
  108269. private _textureType;
  108270. private _textureFormat;
  108271. /**
  108272. * Smart array of input and output textures for the post process.
  108273. * @hidden
  108274. */
  108275. _textures: SmartArray<InternalTexture>;
  108276. /**
  108277. * The index in _textures that corresponds to the output texture.
  108278. * @hidden
  108279. */
  108280. _currentRenderTextureInd: number;
  108281. private _effect;
  108282. private _samplers;
  108283. private _fragmentUrl;
  108284. private _vertexUrl;
  108285. private _parameters;
  108286. private _scaleRatio;
  108287. protected _indexParameters: any;
  108288. private _shareOutputWithPostProcess;
  108289. private _texelSize;
  108290. private _forcedOutputTexture;
  108291. /**
  108292. * Prepass configuration in case this post process needs a texture from prepass
  108293. * @hidden
  108294. */
  108295. _prePassEffectConfiguration: PrePassEffectConfiguration;
  108296. /**
  108297. * Returns the fragment url or shader name used in the post process.
  108298. * @returns the fragment url or name in the shader store.
  108299. */
  108300. getEffectName(): string;
  108301. /**
  108302. * An event triggered when the postprocess is activated.
  108303. */
  108304. onActivateObservable: Observable<Camera>;
  108305. private _onActivateObserver;
  108306. /**
  108307. * A function that is added to the onActivateObservable
  108308. */
  108309. set onActivate(callback: Nullable<(camera: Camera) => void>);
  108310. /**
  108311. * An event triggered when the postprocess changes its size.
  108312. */
  108313. onSizeChangedObservable: Observable<PostProcess>;
  108314. private _onSizeChangedObserver;
  108315. /**
  108316. * A function that is added to the onSizeChangedObservable
  108317. */
  108318. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  108319. /**
  108320. * An event triggered when the postprocess applies its effect.
  108321. */
  108322. onApplyObservable: Observable<Effect>;
  108323. private _onApplyObserver;
  108324. /**
  108325. * A function that is added to the onApplyObservable
  108326. */
  108327. set onApply(callback: (effect: Effect) => void);
  108328. /**
  108329. * An event triggered before rendering the postprocess
  108330. */
  108331. onBeforeRenderObservable: Observable<Effect>;
  108332. private _onBeforeRenderObserver;
  108333. /**
  108334. * A function that is added to the onBeforeRenderObservable
  108335. */
  108336. set onBeforeRender(callback: (effect: Effect) => void);
  108337. /**
  108338. * An event triggered after rendering the postprocess
  108339. */
  108340. onAfterRenderObservable: Observable<Effect>;
  108341. private _onAfterRenderObserver;
  108342. /**
  108343. * A function that is added to the onAfterRenderObservable
  108344. */
  108345. set onAfterRender(callback: (efect: Effect) => void);
  108346. /**
  108347. * 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
  108348. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  108349. */
  108350. get inputTexture(): InternalTexture;
  108351. set inputTexture(value: InternalTexture);
  108352. /**
  108353. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  108354. * the only way to unset it is to use this function to restore its internal state
  108355. */
  108356. restoreDefaultInputTexture(): void;
  108357. /**
  108358. * Gets the camera which post process is applied to.
  108359. * @returns The camera the post process is applied to.
  108360. */
  108361. getCamera(): Camera;
  108362. /**
  108363. * Gets the texel size of the postprocess.
  108364. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  108365. */
  108366. get texelSize(): Vector2;
  108367. /**
  108368. * Creates a new instance PostProcess
  108369. * @param name The name of the PostProcess.
  108370. * @param fragmentUrl The url of the fragment shader to be used.
  108371. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  108372. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  108373. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108374. * @param camera The camera to apply the render pass to.
  108375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108376. * @param engine The engine which the post process will be applied. (default: current engine)
  108377. * @param reusable If the post process can be reused on the same frame. (default: false)
  108378. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  108379. * @param textureType Type of textures used when performing the post process. (default: 0)
  108380. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  108381. * @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
  108382. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  108383. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  108384. */
  108385. 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);
  108386. /**
  108387. * Gets a string identifying the name of the class
  108388. * @returns "PostProcess" string
  108389. */
  108390. getClassName(): string;
  108391. /**
  108392. * Gets the engine which this post process belongs to.
  108393. * @returns The engine the post process was enabled with.
  108394. */
  108395. getEngine(): Engine;
  108396. /**
  108397. * The effect that is created when initializing the post process.
  108398. * @returns The created effect corresponding the the postprocess.
  108399. */
  108400. getEffect(): Effect;
  108401. /**
  108402. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  108403. * @param postProcess The post process to share the output with.
  108404. * @returns This post process.
  108405. */
  108406. shareOutputWith(postProcess: PostProcess): PostProcess;
  108407. /**
  108408. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  108409. * This should be called if the post process that shares output with this post process is disabled/disposed.
  108410. */
  108411. useOwnOutput(): void;
  108412. /**
  108413. * Updates the effect with the current post process compile time values and recompiles the shader.
  108414. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108415. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108416. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108417. * @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
  108418. * @param onCompiled Called when the shader has been compiled.
  108419. * @param onError Called if there is an error when compiling a shader.
  108420. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  108421. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  108422. */
  108423. 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;
  108424. /**
  108425. * The post process is reusable if it can be used multiple times within one frame.
  108426. * @returns If the post process is reusable
  108427. */
  108428. isReusable(): boolean;
  108429. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  108430. markTextureDirty(): void;
  108431. /**
  108432. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  108433. * 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.
  108434. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  108435. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  108436. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  108437. * @returns The target texture that was bound to be written to.
  108438. */
  108439. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  108440. /**
  108441. * If the post process is supported.
  108442. */
  108443. get isSupported(): boolean;
  108444. /**
  108445. * The aspect ratio of the output texture.
  108446. */
  108447. get aspectRatio(): number;
  108448. /**
  108449. * Get a value indicating if the post-process is ready to be used
  108450. * @returns true if the post-process is ready (shader is compiled)
  108451. */
  108452. isReady(): boolean;
  108453. /**
  108454. * Binds all textures and uniforms to the shader, this will be run on every pass.
  108455. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  108456. */
  108457. apply(): Nullable<Effect>;
  108458. private _disposeTextures;
  108459. /**
  108460. * Sets the required values to the prepass renderer.
  108461. * @param prePassRenderer defines the prepass renderer to setup.
  108462. * @returns true if the pre pass is needed.
  108463. */
  108464. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108465. /**
  108466. * Disposes the post process.
  108467. * @param camera The camera to dispose the post process on.
  108468. */
  108469. dispose(camera?: Camera): void;
  108470. /**
  108471. * Serializes the particle system to a JSON object
  108472. * @returns the JSON object
  108473. */
  108474. serialize(): any;
  108475. /**
  108476. * Creates a material from parsed material data
  108477. * @param parsedPostProcess defines parsed post process data
  108478. * @param scene defines the hosting scene
  108479. * @param rootUrl defines the root URL to use to load textures
  108480. * @returns a new post process
  108481. */
  108482. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  108483. }
  108484. }
  108485. declare module BABYLON {
  108486. /** @hidden */
  108487. export var kernelBlurVaryingDeclaration: {
  108488. name: string;
  108489. shader: string;
  108490. };
  108491. }
  108492. declare module BABYLON {
  108493. /** @hidden */
  108494. export var kernelBlurFragment: {
  108495. name: string;
  108496. shader: string;
  108497. };
  108498. }
  108499. declare module BABYLON {
  108500. /** @hidden */
  108501. export var kernelBlurFragment2: {
  108502. name: string;
  108503. shader: string;
  108504. };
  108505. }
  108506. declare module BABYLON {
  108507. /** @hidden */
  108508. export var kernelBlurPixelShader: {
  108509. name: string;
  108510. shader: string;
  108511. };
  108512. }
  108513. declare module BABYLON {
  108514. /** @hidden */
  108515. export var kernelBlurVertex: {
  108516. name: string;
  108517. shader: string;
  108518. };
  108519. }
  108520. declare module BABYLON {
  108521. /** @hidden */
  108522. export var kernelBlurVertexShader: {
  108523. name: string;
  108524. shader: string;
  108525. };
  108526. }
  108527. declare module BABYLON {
  108528. /**
  108529. * The Blur Post Process which blurs an image based on a kernel and direction.
  108530. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  108531. */
  108532. export class BlurPostProcess extends PostProcess {
  108533. private blockCompilation;
  108534. protected _kernel: number;
  108535. protected _idealKernel: number;
  108536. protected _packedFloat: boolean;
  108537. private _staticDefines;
  108538. /** The direction in which to blur the image. */
  108539. direction: Vector2;
  108540. /**
  108541. * Sets the length in pixels of the blur sample region
  108542. */
  108543. set kernel(v: number);
  108544. /**
  108545. * Gets the length in pixels of the blur sample region
  108546. */
  108547. get kernel(): number;
  108548. /**
  108549. * Sets wether or not the blur needs to unpack/repack floats
  108550. */
  108551. set packedFloat(v: boolean);
  108552. /**
  108553. * Gets wether or not the blur is unpacking/repacking floats
  108554. */
  108555. get packedFloat(): boolean;
  108556. /**
  108557. * Gets a string identifying the name of the class
  108558. * @returns "BlurPostProcess" string
  108559. */
  108560. getClassName(): string;
  108561. /**
  108562. * Creates a new instance BlurPostProcess
  108563. * @param name The name of the effect.
  108564. * @param direction The direction in which to blur the image.
  108565. * @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.
  108566. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108567. * @param camera The camera to apply the render pass to.
  108568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108569. * @param engine The engine which the post process will be applied. (default: current engine)
  108570. * @param reusable If the post process can be reused on the same frame. (default: false)
  108571. * @param textureType Type of textures used when performing the post process. (default: 0)
  108572. * @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)
  108573. */
  108574. 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);
  108575. /**
  108576. * Updates the effect with the current post process compile time values and recompiles the shader.
  108577. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108578. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108579. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108580. * @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
  108581. * @param onCompiled Called when the shader has been compiled.
  108582. * @param onError Called if there is an error when compiling a shader.
  108583. */
  108584. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108585. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108586. /**
  108587. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  108588. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  108589. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  108590. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  108591. * The gaps between physical kernels are compensated for in the weighting of the samples
  108592. * @param idealKernel Ideal blur kernel.
  108593. * @return Nearest best kernel.
  108594. */
  108595. protected _nearestBestKernel(idealKernel: number): number;
  108596. /**
  108597. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  108598. * @param x The point on the Gaussian distribution to sample.
  108599. * @return the value of the Gaussian function at x.
  108600. */
  108601. protected _gaussianWeight(x: number): number;
  108602. /**
  108603. * Generates a string that can be used as a floating point number in GLSL.
  108604. * @param x Value to print.
  108605. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  108606. * @return GLSL float string.
  108607. */
  108608. protected _glslFloat(x: number, decimalFigures?: number): string;
  108609. /** @hidden */
  108610. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  108611. }
  108612. }
  108613. declare module BABYLON {
  108614. /**
  108615. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108616. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108617. * You can then easily use it as a reflectionTexture on a flat surface.
  108618. * In case the surface is not a plane, please consider relying on reflection probes.
  108619. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108620. */
  108621. export class MirrorTexture extends RenderTargetTexture {
  108622. private scene;
  108623. /**
  108624. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  108625. * 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.
  108626. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108627. */
  108628. mirrorPlane: Plane;
  108629. /**
  108630. * Define the blur ratio used to blur the reflection if needed.
  108631. */
  108632. set blurRatio(value: number);
  108633. get blurRatio(): number;
  108634. /**
  108635. * Define the adaptive blur kernel used to blur the reflection if needed.
  108636. * This will autocompute the closest best match for the `blurKernel`
  108637. */
  108638. set adaptiveBlurKernel(value: number);
  108639. /**
  108640. * Define the blur kernel used to blur the reflection if needed.
  108641. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108642. */
  108643. set blurKernel(value: number);
  108644. /**
  108645. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108646. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108647. */
  108648. set blurKernelX(value: number);
  108649. get blurKernelX(): number;
  108650. /**
  108651. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108652. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108653. */
  108654. set blurKernelY(value: number);
  108655. get blurKernelY(): number;
  108656. private _autoComputeBlurKernel;
  108657. protected _onRatioRescale(): void;
  108658. private _updateGammaSpace;
  108659. private _imageProcessingConfigChangeObserver;
  108660. private _transformMatrix;
  108661. private _mirrorMatrix;
  108662. private _savedViewMatrix;
  108663. private _blurX;
  108664. private _blurY;
  108665. private _adaptiveBlurKernel;
  108666. private _blurKernelX;
  108667. private _blurKernelY;
  108668. private _blurRatio;
  108669. /**
  108670. * Instantiates a Mirror Texture.
  108671. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108672. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108673. * You can then easily use it as a reflectionTexture on a flat surface.
  108674. * In case the surface is not a plane, please consider relying on reflection probes.
  108675. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108676. * @param name
  108677. * @param size
  108678. * @param scene
  108679. * @param generateMipMaps
  108680. * @param type
  108681. * @param samplingMode
  108682. * @param generateDepthBuffer
  108683. */
  108684. constructor(name: string, size: number | {
  108685. width: number;
  108686. height: number;
  108687. } | {
  108688. ratio: number;
  108689. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108690. private _preparePostProcesses;
  108691. /**
  108692. * Clone the mirror texture.
  108693. * @returns the cloned texture
  108694. */
  108695. clone(): MirrorTexture;
  108696. /**
  108697. * Serialize the texture to a JSON representation you could use in Parse later on
  108698. * @returns the serialized JSON representation
  108699. */
  108700. serialize(): any;
  108701. /**
  108702. * Dispose the texture and release its associated resources.
  108703. */
  108704. dispose(): void;
  108705. }
  108706. }
  108707. declare module BABYLON {
  108708. /**
  108709. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108710. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108711. */
  108712. export class Texture extends BaseTexture {
  108713. /**
  108714. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108715. */
  108716. static SerializeBuffers: boolean;
  108717. /** @hidden */
  108718. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108719. /** @hidden */
  108720. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108721. /** @hidden */
  108722. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108723. /** nearest is mag = nearest and min = nearest and mip = linear */
  108724. static readonly NEAREST_SAMPLINGMODE: number;
  108725. /** nearest is mag = nearest and min = nearest and mip = linear */
  108726. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108727. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108728. static readonly BILINEAR_SAMPLINGMODE: number;
  108729. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108730. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108731. /** Trilinear is mag = linear and min = linear and mip = linear */
  108732. static readonly TRILINEAR_SAMPLINGMODE: number;
  108733. /** Trilinear is mag = linear and min = linear and mip = linear */
  108734. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108735. /** mag = nearest and min = nearest and mip = nearest */
  108736. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108737. /** mag = nearest and min = linear and mip = nearest */
  108738. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108739. /** mag = nearest and min = linear and mip = linear */
  108740. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108741. /** mag = nearest and min = linear and mip = none */
  108742. static readonly NEAREST_LINEAR: number;
  108743. /** mag = nearest and min = nearest and mip = none */
  108744. static readonly NEAREST_NEAREST: number;
  108745. /** mag = linear and min = nearest and mip = nearest */
  108746. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108747. /** mag = linear and min = nearest and mip = linear */
  108748. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108749. /** mag = linear and min = linear and mip = none */
  108750. static readonly LINEAR_LINEAR: number;
  108751. /** mag = linear and min = nearest and mip = none */
  108752. static readonly LINEAR_NEAREST: number;
  108753. /** Explicit coordinates mode */
  108754. static readonly EXPLICIT_MODE: number;
  108755. /** Spherical coordinates mode */
  108756. static readonly SPHERICAL_MODE: number;
  108757. /** Planar coordinates mode */
  108758. static readonly PLANAR_MODE: number;
  108759. /** Cubic coordinates mode */
  108760. static readonly CUBIC_MODE: number;
  108761. /** Projection coordinates mode */
  108762. static readonly PROJECTION_MODE: number;
  108763. /** Inverse Cubic coordinates mode */
  108764. static readonly SKYBOX_MODE: number;
  108765. /** Inverse Cubic coordinates mode */
  108766. static readonly INVCUBIC_MODE: number;
  108767. /** Equirectangular coordinates mode */
  108768. static readonly EQUIRECTANGULAR_MODE: number;
  108769. /** Equirectangular Fixed coordinates mode */
  108770. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108771. /** Equirectangular Fixed Mirrored coordinates mode */
  108772. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108773. /** Texture is not repeating outside of 0..1 UVs */
  108774. static readonly CLAMP_ADDRESSMODE: number;
  108775. /** Texture is repeating outside of 0..1 UVs */
  108776. static readonly WRAP_ADDRESSMODE: number;
  108777. /** Texture is repeating and mirrored */
  108778. static readonly MIRROR_ADDRESSMODE: number;
  108779. /**
  108780. * 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
  108781. */
  108782. static UseSerializedUrlIfAny: boolean;
  108783. /**
  108784. * Define the url of the texture.
  108785. */
  108786. url: Nullable<string>;
  108787. /**
  108788. * Define an offset on the texture to offset the u coordinates of the UVs
  108789. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108790. */
  108791. uOffset: number;
  108792. /**
  108793. * Define an offset on the texture to offset the v coordinates of the UVs
  108794. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108795. */
  108796. vOffset: number;
  108797. /**
  108798. * Define an offset on the texture to scale the u coordinates of the UVs
  108799. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108800. */
  108801. uScale: number;
  108802. /**
  108803. * Define an offset on the texture to scale the v coordinates of the UVs
  108804. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108805. */
  108806. vScale: number;
  108807. /**
  108808. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108809. * @see https://doc.babylonjs.com/how_to/more_materials
  108810. */
  108811. uAng: number;
  108812. /**
  108813. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108814. * @see https://doc.babylonjs.com/how_to/more_materials
  108815. */
  108816. vAng: number;
  108817. /**
  108818. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108819. * @see https://doc.babylonjs.com/how_to/more_materials
  108820. */
  108821. wAng: number;
  108822. /**
  108823. * Defines the center of rotation (U)
  108824. */
  108825. uRotationCenter: number;
  108826. /**
  108827. * Defines the center of rotation (V)
  108828. */
  108829. vRotationCenter: number;
  108830. /**
  108831. * Defines the center of rotation (W)
  108832. */
  108833. wRotationCenter: number;
  108834. /**
  108835. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108836. */
  108837. homogeneousRotationInUVTransform: boolean;
  108838. /**
  108839. * Are mip maps generated for this texture or not.
  108840. */
  108841. get noMipmap(): boolean;
  108842. /**
  108843. * List of inspectable custom properties (used by the Inspector)
  108844. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108845. */
  108846. inspectableCustomProperties: Nullable<IInspectable[]>;
  108847. private _noMipmap;
  108848. /** @hidden */
  108849. _invertY: boolean;
  108850. private _rowGenerationMatrix;
  108851. private _cachedTextureMatrix;
  108852. private _projectionModeMatrix;
  108853. private _t0;
  108854. private _t1;
  108855. private _t2;
  108856. private _cachedUOffset;
  108857. private _cachedVOffset;
  108858. private _cachedUScale;
  108859. private _cachedVScale;
  108860. private _cachedUAng;
  108861. private _cachedVAng;
  108862. private _cachedWAng;
  108863. private _cachedProjectionMatrixId;
  108864. private _cachedURotationCenter;
  108865. private _cachedVRotationCenter;
  108866. private _cachedWRotationCenter;
  108867. private _cachedHomogeneousRotationInUVTransform;
  108868. private _cachedCoordinatesMode;
  108869. /** @hidden */
  108870. protected _initialSamplingMode: number;
  108871. /** @hidden */
  108872. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108873. private _deleteBuffer;
  108874. protected _format: Nullable<number>;
  108875. private _delayedOnLoad;
  108876. private _delayedOnError;
  108877. private _mimeType?;
  108878. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  108879. get mimeType(): string | undefined;
  108880. /**
  108881. * Observable triggered once the texture has been loaded.
  108882. */
  108883. onLoadObservable: Observable<Texture>;
  108884. protected _isBlocking: boolean;
  108885. /**
  108886. * Is the texture preventing material to render while loading.
  108887. * If false, a default texture will be used instead of the loading one during the preparation step.
  108888. */
  108889. set isBlocking(value: boolean);
  108890. get isBlocking(): boolean;
  108891. /**
  108892. * Get the current sampling mode associated with the texture.
  108893. */
  108894. get samplingMode(): number;
  108895. /**
  108896. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  108897. */
  108898. get invertY(): boolean;
  108899. /**
  108900. * Instantiates a new texture.
  108901. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108902. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108903. * @param url defines the url of the picture to load as a texture
  108904. * @param sceneOrEngine defines the scene or engine the texture will belong to
  108905. * @param noMipmap defines if the texture will require mip maps or not
  108906. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  108907. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108908. * @param onLoad defines a callback triggered when the texture has been loaded
  108909. * @param onError defines a callback triggered when an error occurred during the loading session
  108910. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  108911. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  108912. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108913. * @param mimeType defines an optional mime type information
  108914. */
  108915. 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);
  108916. /**
  108917. * Update the url (and optional buffer) of this texture if url was null during construction.
  108918. * @param url the url of the texture
  108919. * @param buffer the buffer of the texture (defaults to null)
  108920. * @param onLoad callback called when the texture is loaded (defaults to null)
  108921. */
  108922. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  108923. /**
  108924. * Finish the loading sequence of a texture flagged as delayed load.
  108925. * @hidden
  108926. */
  108927. delayLoad(): void;
  108928. private _prepareRowForTextureGeneration;
  108929. /**
  108930. * Checks if the texture has the same transform matrix than another texture
  108931. * @param texture texture to check against
  108932. * @returns true if the transforms are the same, else false
  108933. */
  108934. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  108935. /**
  108936. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  108937. * @returns the transform matrix of the texture.
  108938. */
  108939. getTextureMatrix(uBase?: number): Matrix;
  108940. /**
  108941. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  108942. * @returns The reflection texture transform
  108943. */
  108944. getReflectionTextureMatrix(): Matrix;
  108945. /**
  108946. * Clones the texture.
  108947. * @returns the cloned texture
  108948. */
  108949. clone(): Texture;
  108950. /**
  108951. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  108952. * @returns The JSON representation of the texture
  108953. */
  108954. serialize(): any;
  108955. /**
  108956. * Get the current class name of the texture useful for serialization or dynamic coding.
  108957. * @returns "Texture"
  108958. */
  108959. getClassName(): string;
  108960. /**
  108961. * Dispose the texture and release its associated resources.
  108962. */
  108963. dispose(): void;
  108964. /**
  108965. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  108966. * @param parsedTexture Define the JSON representation of the texture
  108967. * @param scene Define the scene the parsed texture should be instantiated in
  108968. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108969. * @returns The parsed texture if successful
  108970. */
  108971. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  108972. /**
  108973. * Creates a texture from its base 64 representation.
  108974. * @param data Define the base64 payload without the data: prefix
  108975. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108976. * @param scene Define the scene the texture should belong to
  108977. * @param noMipmap Forces the texture to not create mip map information if true
  108978. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108979. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108980. * @param onLoad define a callback triggered when the texture has been loaded
  108981. * @param onError define a callback triggered when an error occurred during the loading session
  108982. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108983. * @returns the created texture
  108984. */
  108985. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  108986. /**
  108987. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  108988. * @param data Define the base64 payload without the data: prefix
  108989. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108990. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  108991. * @param scene Define the scene the texture should belong to
  108992. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  108993. * @param noMipmap Forces the texture to not create mip map information if true
  108994. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108995. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108996. * @param onLoad define a callback triggered when the texture has been loaded
  108997. * @param onError define a callback triggered when an error occurred during the loading session
  108998. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108999. * @returns the created texture
  109000. */
  109001. 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;
  109002. }
  109003. }
  109004. declare module BABYLON {
  109005. /**
  109006. * PostProcessManager is used to manage one or more post processes or post process pipelines
  109007. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109008. */
  109009. export class PostProcessManager {
  109010. private _scene;
  109011. private _indexBuffer;
  109012. private _vertexBuffers;
  109013. /**
  109014. * Creates a new instance PostProcess
  109015. * @param scene The scene that the post process is associated with.
  109016. */
  109017. constructor(scene: Scene);
  109018. private _prepareBuffers;
  109019. private _buildIndexBuffer;
  109020. /**
  109021. * Rebuilds the vertex buffers of the manager.
  109022. * @hidden
  109023. */
  109024. _rebuild(): void;
  109025. /**
  109026. * Prepares a frame to be run through a post process.
  109027. * @param sourceTexture The input texture to the post procesess. (default: null)
  109028. * @param postProcesses An array of post processes to be run. (default: null)
  109029. * @returns True if the post processes were able to be run.
  109030. * @hidden
  109031. */
  109032. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  109033. /**
  109034. * Manually render a set of post processes to a texture.
  109035. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  109036. * @param postProcesses An array of post processes to be run.
  109037. * @param targetTexture The target texture to render to.
  109038. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  109039. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  109040. * @param lodLevel defines which lod of the texture to render to
  109041. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  109042. */
  109043. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  109044. /**
  109045. * Finalize the result of the output of the postprocesses.
  109046. * @param doNotPresent If true the result will not be displayed to the screen.
  109047. * @param targetTexture The target texture to render to.
  109048. * @param faceIndex The index of the face to bind the target texture to.
  109049. * @param postProcesses The array of post processes to render.
  109050. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  109051. * @hidden
  109052. */
  109053. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  109054. /**
  109055. * Disposes of the post process manager.
  109056. */
  109057. dispose(): void;
  109058. }
  109059. }
  109060. declare module BABYLON {
  109061. /**
  109062. * This Helps creating a texture that will be created from a camera in your scene.
  109063. * It is basically a dynamic texture that could be used to create special effects for instance.
  109064. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  109065. */
  109066. export class RenderTargetTexture extends Texture {
  109067. /**
  109068. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  109069. */
  109070. static readonly REFRESHRATE_RENDER_ONCE: number;
  109071. /**
  109072. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  109073. */
  109074. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  109075. /**
  109076. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  109077. * the central point of your effect and can save a lot of performances.
  109078. */
  109079. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  109080. /**
  109081. * Use this predicate to dynamically define the list of mesh you want to render.
  109082. * If set, the renderList property will be overwritten.
  109083. */
  109084. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  109085. private _renderList;
  109086. /**
  109087. * Use this list to define the list of mesh you want to render.
  109088. */
  109089. get renderList(): Nullable<Array<AbstractMesh>>;
  109090. set renderList(value: Nullable<Array<AbstractMesh>>);
  109091. /**
  109092. * Use this function to overload the renderList array at rendering time.
  109093. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  109094. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  109095. * the cube (if the RTT is a cube, else layerOrFace=0).
  109096. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  109097. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  109098. * hold dummy elements!
  109099. */
  109100. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  109101. private _hookArray;
  109102. /**
  109103. * Define if particles should be rendered in your texture.
  109104. */
  109105. renderParticles: boolean;
  109106. /**
  109107. * Define if sprites should be rendered in your texture.
  109108. */
  109109. renderSprites: boolean;
  109110. /**
  109111. * Define the camera used to render the texture.
  109112. */
  109113. activeCamera: Nullable<Camera>;
  109114. /**
  109115. * Override the mesh isReady function with your own one.
  109116. */
  109117. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  109118. /**
  109119. * Override the render function of the texture with your own one.
  109120. */
  109121. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  109122. /**
  109123. * Define if camera post processes should be use while rendering the texture.
  109124. */
  109125. useCameraPostProcesses: boolean;
  109126. /**
  109127. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  109128. */
  109129. ignoreCameraViewport: boolean;
  109130. private _postProcessManager;
  109131. private _postProcesses;
  109132. private _resizeObserver;
  109133. /**
  109134. * An event triggered when the texture is unbind.
  109135. */
  109136. onBeforeBindObservable: Observable<RenderTargetTexture>;
  109137. /**
  109138. * An event triggered when the texture is unbind.
  109139. */
  109140. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  109141. private _onAfterUnbindObserver;
  109142. /**
  109143. * Set a after unbind callback in the texture.
  109144. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109145. */
  109146. set onAfterUnbind(callback: () => void);
  109147. /**
  109148. * An event triggered before rendering the texture
  109149. */
  109150. onBeforeRenderObservable: Observable<number>;
  109151. private _onBeforeRenderObserver;
  109152. /**
  109153. * Set a before render callback in the texture.
  109154. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109155. */
  109156. set onBeforeRender(callback: (faceIndex: number) => void);
  109157. /**
  109158. * An event triggered after rendering the texture
  109159. */
  109160. onAfterRenderObservable: Observable<number>;
  109161. private _onAfterRenderObserver;
  109162. /**
  109163. * Set a after render callback in the texture.
  109164. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109165. */
  109166. set onAfterRender(callback: (faceIndex: number) => void);
  109167. /**
  109168. * An event triggered after the texture clear
  109169. */
  109170. onClearObservable: Observable<Engine>;
  109171. private _onClearObserver;
  109172. /**
  109173. * Set a clear callback in the texture.
  109174. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  109175. */
  109176. set onClear(callback: (Engine: Engine) => void);
  109177. /**
  109178. * An event triggered when the texture is resized.
  109179. */
  109180. onResizeObservable: Observable<RenderTargetTexture>;
  109181. /**
  109182. * Define the clear color of the Render Target if it should be different from the scene.
  109183. */
  109184. clearColor: Color4;
  109185. protected _size: number | {
  109186. width: number;
  109187. height: number;
  109188. layers?: number;
  109189. };
  109190. protected _initialSizeParameter: number | {
  109191. width: number;
  109192. height: number;
  109193. } | {
  109194. ratio: number;
  109195. };
  109196. protected _sizeRatio: Nullable<number>;
  109197. /** @hidden */
  109198. _generateMipMaps: boolean;
  109199. protected _renderingManager: RenderingManager;
  109200. /** @hidden */
  109201. _waitingRenderList?: string[];
  109202. protected _doNotChangeAspectRatio: boolean;
  109203. protected _currentRefreshId: number;
  109204. protected _refreshRate: number;
  109205. protected _textureMatrix: Matrix;
  109206. protected _samples: number;
  109207. protected _renderTargetOptions: RenderTargetCreationOptions;
  109208. /**
  109209. * Gets render target creation options that were used.
  109210. */
  109211. get renderTargetOptions(): RenderTargetCreationOptions;
  109212. protected _onRatioRescale(): void;
  109213. /**
  109214. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  109215. * It must define where the camera used to render the texture is set
  109216. */
  109217. boundingBoxPosition: Vector3;
  109218. private _boundingBoxSize;
  109219. /**
  109220. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  109221. * When defined, the cubemap will switch to local mode
  109222. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  109223. * @example https://www.babylonjs-playground.com/#RNASML
  109224. */
  109225. set boundingBoxSize(value: Vector3);
  109226. get boundingBoxSize(): Vector3;
  109227. /**
  109228. * In case the RTT has been created with a depth texture, get the associated
  109229. * depth texture.
  109230. * Otherwise, return null.
  109231. */
  109232. get depthStencilTexture(): Nullable<InternalTexture>;
  109233. /**
  109234. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  109235. * or used a shadow, depth texture...
  109236. * @param name The friendly name of the texture
  109237. * @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)
  109238. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  109239. * @param generateMipMaps True if mip maps need to be generated after render.
  109240. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  109241. * @param type The type of the buffer in the RTT (int, half float, float...)
  109242. * @param isCube True if a cube texture needs to be created
  109243. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  109244. * @param generateDepthBuffer True to generate a depth buffer
  109245. * @param generateStencilBuffer True to generate a stencil buffer
  109246. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  109247. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  109248. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109249. */
  109250. constructor(name: string, size: number | {
  109251. width: number;
  109252. height: number;
  109253. layers?: number;
  109254. } | {
  109255. ratio: number;
  109256. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  109257. /**
  109258. * Creates a depth stencil texture.
  109259. * This is only available in WebGL 2 or with the depth texture extension available.
  109260. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  109261. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  109262. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  109263. */
  109264. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  109265. private _processSizeParameter;
  109266. /**
  109267. * Define the number of samples to use in case of MSAA.
  109268. * It defaults to one meaning no MSAA has been enabled.
  109269. */
  109270. get samples(): number;
  109271. set samples(value: number);
  109272. /**
  109273. * Resets the refresh counter of the texture and start bak from scratch.
  109274. * Could be useful to regenerate the texture if it is setup to render only once.
  109275. */
  109276. resetRefreshCounter(): void;
  109277. /**
  109278. * Define the refresh rate of the texture or the rendering frequency.
  109279. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  109280. */
  109281. get refreshRate(): number;
  109282. set refreshRate(value: number);
  109283. /**
  109284. * Adds a post process to the render target rendering passes.
  109285. * @param postProcess define the post process to add
  109286. */
  109287. addPostProcess(postProcess: PostProcess): void;
  109288. /**
  109289. * Clear all the post processes attached to the render target
  109290. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  109291. */
  109292. clearPostProcesses(dispose?: boolean): void;
  109293. /**
  109294. * Remove one of the post process from the list of attached post processes to the texture
  109295. * @param postProcess define the post process to remove from the list
  109296. */
  109297. removePostProcess(postProcess: PostProcess): void;
  109298. /** @hidden */
  109299. _shouldRender(): boolean;
  109300. /**
  109301. * Gets the actual render size of the texture.
  109302. * @returns the width of the render size
  109303. */
  109304. getRenderSize(): number;
  109305. /**
  109306. * Gets the actual render width of the texture.
  109307. * @returns the width of the render size
  109308. */
  109309. getRenderWidth(): number;
  109310. /**
  109311. * Gets the actual render height of the texture.
  109312. * @returns the height of the render size
  109313. */
  109314. getRenderHeight(): number;
  109315. /**
  109316. * Gets the actual number of layers of the texture.
  109317. * @returns the number of layers
  109318. */
  109319. getRenderLayers(): number;
  109320. /**
  109321. * Get if the texture can be rescaled or not.
  109322. */
  109323. get canRescale(): boolean;
  109324. /**
  109325. * Resize the texture using a ratio.
  109326. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  109327. */
  109328. scale(ratio: number): void;
  109329. /**
  109330. * Get the texture reflection matrix used to rotate/transform the reflection.
  109331. * @returns the reflection matrix
  109332. */
  109333. getReflectionTextureMatrix(): Matrix;
  109334. /**
  109335. * Resize the texture to a new desired size.
  109336. * Be carrefull as it will recreate all the data in the new texture.
  109337. * @param size Define the new size. It can be:
  109338. * - a number for squared texture,
  109339. * - an object containing { width: number, height: number }
  109340. * - or an object containing a ratio { ratio: number }
  109341. */
  109342. resize(size: number | {
  109343. width: number;
  109344. height: number;
  109345. } | {
  109346. ratio: number;
  109347. }): void;
  109348. private _defaultRenderListPrepared;
  109349. /**
  109350. * Renders all the objects from the render list into the texture.
  109351. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  109352. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  109353. */
  109354. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  109355. private _bestReflectionRenderTargetDimension;
  109356. private _prepareRenderingManager;
  109357. /**
  109358. * @hidden
  109359. * @param faceIndex face index to bind to if this is a cubetexture
  109360. * @param layer defines the index of the texture to bind in the array
  109361. */
  109362. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  109363. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109364. private renderToTarget;
  109365. /**
  109366. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109367. * This allowed control for front to back rendering or reversly depending of the special needs.
  109368. *
  109369. * @param renderingGroupId The rendering group id corresponding to its index
  109370. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109371. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109372. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109373. */
  109374. 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;
  109375. /**
  109376. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109377. *
  109378. * @param renderingGroupId The rendering group id corresponding to its index
  109379. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109380. */
  109381. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  109382. /**
  109383. * Clones the texture.
  109384. * @returns the cloned texture
  109385. */
  109386. clone(): RenderTargetTexture;
  109387. /**
  109388. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109389. * @returns The JSON representation of the texture
  109390. */
  109391. serialize(): any;
  109392. /**
  109393. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  109394. */
  109395. disposeFramebufferObjects(): void;
  109396. /**
  109397. * Dispose the texture and release its associated resources.
  109398. */
  109399. dispose(): void;
  109400. /** @hidden */
  109401. _rebuild(): void;
  109402. /**
  109403. * Clear the info related to rendering groups preventing retention point in material dispose.
  109404. */
  109405. freeRenderingGroups(): void;
  109406. /**
  109407. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  109408. * @returns the view count
  109409. */
  109410. getViewCount(): number;
  109411. }
  109412. }
  109413. declare module BABYLON {
  109414. /**
  109415. * Class used to manipulate GUIDs
  109416. */
  109417. export class GUID {
  109418. /**
  109419. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  109420. * Be aware Math.random() could cause collisions, but:
  109421. * "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"
  109422. * @returns a pseudo random id
  109423. */
  109424. static RandomId(): string;
  109425. }
  109426. }
  109427. declare module BABYLON {
  109428. /**
  109429. * Options to be used when creating a shadow depth material
  109430. */
  109431. export interface IIOptionShadowDepthMaterial {
  109432. /** Variables in the vertex shader code that need to have their names remapped.
  109433. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  109434. * "var_name" should be either: worldPos or vNormalW
  109435. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  109436. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  109437. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  109438. */
  109439. remappedVariables?: string[];
  109440. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  109441. standalone?: boolean;
  109442. }
  109443. /**
  109444. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  109445. */
  109446. export class ShadowDepthWrapper {
  109447. private _scene;
  109448. private _options?;
  109449. private _baseMaterial;
  109450. private _onEffectCreatedObserver;
  109451. private _subMeshToEffect;
  109452. private _subMeshToDepthEffect;
  109453. private _meshes;
  109454. /** @hidden */
  109455. _matriceNames: any;
  109456. /** Gets the standalone status of the wrapper */
  109457. get standalone(): boolean;
  109458. /** Gets the base material the wrapper is built upon */
  109459. get baseMaterial(): Material;
  109460. /**
  109461. * Instantiate a new shadow depth wrapper.
  109462. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  109463. * generate the shadow depth map. For more information, please refer to the documentation:
  109464. * https://doc.babylonjs.com/babylon101/shadows
  109465. * @param baseMaterial Material to wrap
  109466. * @param scene Define the scene the material belongs to
  109467. * @param options Options used to create the wrapper
  109468. */
  109469. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  109470. /**
  109471. * Gets the effect to use to generate the depth map
  109472. * @param subMesh subMesh to get the effect for
  109473. * @param shadowGenerator shadow generator to get the effect for
  109474. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  109475. */
  109476. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  109477. /**
  109478. * Specifies that the submesh is ready to be used for depth rendering
  109479. * @param subMesh submesh to check
  109480. * @param defines the list of defines to take into account when checking the effect
  109481. * @param shadowGenerator combined with subMesh, it defines the effect to check
  109482. * @param useInstances specifies that instances should be used
  109483. * @returns a boolean indicating that the submesh is ready or not
  109484. */
  109485. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  109486. /**
  109487. * Disposes the resources
  109488. */
  109489. dispose(): void;
  109490. private _makeEffect;
  109491. }
  109492. }
  109493. declare module BABYLON {
  109494. /**
  109495. * Options for compiling materials.
  109496. */
  109497. export interface IMaterialCompilationOptions {
  109498. /**
  109499. * Defines whether clip planes are enabled.
  109500. */
  109501. clipPlane: boolean;
  109502. /**
  109503. * Defines whether instances are enabled.
  109504. */
  109505. useInstances: boolean;
  109506. }
  109507. /**
  109508. * Options passed when calling customShaderNameResolve
  109509. */
  109510. export interface ICustomShaderNameResolveOptions {
  109511. /**
  109512. * 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
  109513. */
  109514. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  109515. }
  109516. /**
  109517. * Base class for the main features of a material in Babylon.js
  109518. */
  109519. export class Material implements IAnimatable {
  109520. /**
  109521. * Returns the triangle fill mode
  109522. */
  109523. static readonly TriangleFillMode: number;
  109524. /**
  109525. * Returns the wireframe mode
  109526. */
  109527. static readonly WireFrameFillMode: number;
  109528. /**
  109529. * Returns the point fill mode
  109530. */
  109531. static readonly PointFillMode: number;
  109532. /**
  109533. * Returns the point list draw mode
  109534. */
  109535. static readonly PointListDrawMode: number;
  109536. /**
  109537. * Returns the line list draw mode
  109538. */
  109539. static readonly LineListDrawMode: number;
  109540. /**
  109541. * Returns the line loop draw mode
  109542. */
  109543. static readonly LineLoopDrawMode: number;
  109544. /**
  109545. * Returns the line strip draw mode
  109546. */
  109547. static readonly LineStripDrawMode: number;
  109548. /**
  109549. * Returns the triangle strip draw mode
  109550. */
  109551. static readonly TriangleStripDrawMode: number;
  109552. /**
  109553. * Returns the triangle fan draw mode
  109554. */
  109555. static readonly TriangleFanDrawMode: number;
  109556. /**
  109557. * Stores the clock-wise side orientation
  109558. */
  109559. static readonly ClockWiseSideOrientation: number;
  109560. /**
  109561. * Stores the counter clock-wise side orientation
  109562. */
  109563. static readonly CounterClockWiseSideOrientation: number;
  109564. /**
  109565. * The dirty texture flag value
  109566. */
  109567. static readonly TextureDirtyFlag: number;
  109568. /**
  109569. * The dirty light flag value
  109570. */
  109571. static readonly LightDirtyFlag: number;
  109572. /**
  109573. * The dirty fresnel flag value
  109574. */
  109575. static readonly FresnelDirtyFlag: number;
  109576. /**
  109577. * The dirty attribute flag value
  109578. */
  109579. static readonly AttributesDirtyFlag: number;
  109580. /**
  109581. * The dirty misc flag value
  109582. */
  109583. static readonly MiscDirtyFlag: number;
  109584. /**
  109585. * The dirty prepass flag value
  109586. */
  109587. static readonly PrePassDirtyFlag: number;
  109588. /**
  109589. * The all dirty flag value
  109590. */
  109591. static readonly AllDirtyFlag: number;
  109592. /**
  109593. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109594. */
  109595. static readonly MATERIAL_OPAQUE: number;
  109596. /**
  109597. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109598. */
  109599. static readonly MATERIAL_ALPHATEST: number;
  109600. /**
  109601. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109602. */
  109603. static readonly MATERIAL_ALPHABLEND: number;
  109604. /**
  109605. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109606. * They are also discarded below the alpha cutoff threshold to improve performances.
  109607. */
  109608. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  109609. /**
  109610. * The Whiteout method is used to blend normals.
  109611. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109612. */
  109613. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  109614. /**
  109615. * The Reoriented Normal Mapping method is used to blend normals.
  109616. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109617. */
  109618. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  109619. /**
  109620. * Custom callback helping to override the default shader used in the material.
  109621. */
  109622. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  109623. /**
  109624. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  109625. */
  109626. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  109627. /**
  109628. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  109629. * This means that the material can keep using a previous shader while a new one is being compiled.
  109630. * This is mostly used when shader parallel compilation is supported (true by default)
  109631. */
  109632. allowShaderHotSwapping: boolean;
  109633. /**
  109634. * The ID of the material
  109635. */
  109636. id: string;
  109637. /**
  109638. * Gets or sets the unique id of the material
  109639. */
  109640. uniqueId: number;
  109641. /**
  109642. * The name of the material
  109643. */
  109644. name: string;
  109645. /**
  109646. * Gets or sets user defined metadata
  109647. */
  109648. metadata: any;
  109649. /**
  109650. * For internal use only. Please do not use.
  109651. */
  109652. reservedDataStore: any;
  109653. /**
  109654. * Specifies if the ready state should be checked on each call
  109655. */
  109656. checkReadyOnEveryCall: boolean;
  109657. /**
  109658. * Specifies if the ready state should be checked once
  109659. */
  109660. checkReadyOnlyOnce: boolean;
  109661. /**
  109662. * The state of the material
  109663. */
  109664. state: string;
  109665. /**
  109666. * If the material can be rendered to several textures with MRT extension
  109667. */
  109668. get canRenderToMRT(): boolean;
  109669. /**
  109670. * The alpha value of the material
  109671. */
  109672. protected _alpha: number;
  109673. /**
  109674. * List of inspectable custom properties (used by the Inspector)
  109675. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109676. */
  109677. inspectableCustomProperties: IInspectable[];
  109678. /**
  109679. * Sets the alpha value of the material
  109680. */
  109681. set alpha(value: number);
  109682. /**
  109683. * Gets the alpha value of the material
  109684. */
  109685. get alpha(): number;
  109686. /**
  109687. * Specifies if back face culling is enabled
  109688. */
  109689. protected _backFaceCulling: boolean;
  109690. /**
  109691. * Sets the back-face culling state
  109692. */
  109693. set backFaceCulling(value: boolean);
  109694. /**
  109695. * Gets the back-face culling state
  109696. */
  109697. get backFaceCulling(): boolean;
  109698. /**
  109699. * Stores the value for side orientation
  109700. */
  109701. sideOrientation: number;
  109702. /**
  109703. * Callback triggered when the material is compiled
  109704. */
  109705. onCompiled: Nullable<(effect: Effect) => void>;
  109706. /**
  109707. * Callback triggered when an error occurs
  109708. */
  109709. onError: Nullable<(effect: Effect, errors: string) => void>;
  109710. /**
  109711. * Callback triggered to get the render target textures
  109712. */
  109713. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  109714. /**
  109715. * Gets a boolean indicating that current material needs to register RTT
  109716. */
  109717. get hasRenderTargetTextures(): boolean;
  109718. /**
  109719. * Specifies if the material should be serialized
  109720. */
  109721. doNotSerialize: boolean;
  109722. /**
  109723. * @hidden
  109724. */
  109725. _storeEffectOnSubMeshes: boolean;
  109726. /**
  109727. * Stores the animations for the material
  109728. */
  109729. animations: Nullable<Array<Animation>>;
  109730. /**
  109731. * An event triggered when the material is disposed
  109732. */
  109733. onDisposeObservable: Observable<Material>;
  109734. /**
  109735. * An observer which watches for dispose events
  109736. */
  109737. private _onDisposeObserver;
  109738. private _onUnBindObservable;
  109739. /**
  109740. * Called during a dispose event
  109741. */
  109742. set onDispose(callback: () => void);
  109743. private _onBindObservable;
  109744. /**
  109745. * An event triggered when the material is bound
  109746. */
  109747. get onBindObservable(): Observable<AbstractMesh>;
  109748. /**
  109749. * An observer which watches for bind events
  109750. */
  109751. private _onBindObserver;
  109752. /**
  109753. * Called during a bind event
  109754. */
  109755. set onBind(callback: (Mesh: AbstractMesh) => void);
  109756. /**
  109757. * An event triggered when the material is unbound
  109758. */
  109759. get onUnBindObservable(): Observable<Material>;
  109760. protected _onEffectCreatedObservable: Nullable<Observable<{
  109761. effect: Effect;
  109762. subMesh: Nullable<SubMesh>;
  109763. }>>;
  109764. /**
  109765. * An event triggered when the effect is (re)created
  109766. */
  109767. get onEffectCreatedObservable(): Observable<{
  109768. effect: Effect;
  109769. subMesh: Nullable<SubMesh>;
  109770. }>;
  109771. /**
  109772. * Stores the value of the alpha mode
  109773. */
  109774. private _alphaMode;
  109775. /**
  109776. * Sets the value of the alpha mode.
  109777. *
  109778. * | Value | Type | Description |
  109779. * | --- | --- | --- |
  109780. * | 0 | ALPHA_DISABLE | |
  109781. * | 1 | ALPHA_ADD | |
  109782. * | 2 | ALPHA_COMBINE | |
  109783. * | 3 | ALPHA_SUBTRACT | |
  109784. * | 4 | ALPHA_MULTIPLY | |
  109785. * | 5 | ALPHA_MAXIMIZED | |
  109786. * | 6 | ALPHA_ONEONE | |
  109787. * | 7 | ALPHA_PREMULTIPLIED | |
  109788. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  109789. * | 9 | ALPHA_INTERPOLATE | |
  109790. * | 10 | ALPHA_SCREENMODE | |
  109791. *
  109792. */
  109793. set alphaMode(value: number);
  109794. /**
  109795. * Gets the value of the alpha mode
  109796. */
  109797. get alphaMode(): number;
  109798. /**
  109799. * Stores the state of the need depth pre-pass value
  109800. */
  109801. private _needDepthPrePass;
  109802. /**
  109803. * Sets the need depth pre-pass value
  109804. */
  109805. set needDepthPrePass(value: boolean);
  109806. /**
  109807. * Gets the depth pre-pass value
  109808. */
  109809. get needDepthPrePass(): boolean;
  109810. /**
  109811. * Specifies if depth writing should be disabled
  109812. */
  109813. disableDepthWrite: boolean;
  109814. /**
  109815. * Specifies if color writing should be disabled
  109816. */
  109817. disableColorWrite: boolean;
  109818. /**
  109819. * Specifies if depth writing should be forced
  109820. */
  109821. forceDepthWrite: boolean;
  109822. /**
  109823. * Specifies the depth function that should be used. 0 means the default engine function
  109824. */
  109825. depthFunction: number;
  109826. /**
  109827. * Specifies if there should be a separate pass for culling
  109828. */
  109829. separateCullingPass: boolean;
  109830. /**
  109831. * Stores the state specifing if fog should be enabled
  109832. */
  109833. private _fogEnabled;
  109834. /**
  109835. * Sets the state for enabling fog
  109836. */
  109837. set fogEnabled(value: boolean);
  109838. /**
  109839. * Gets the value of the fog enabled state
  109840. */
  109841. get fogEnabled(): boolean;
  109842. /**
  109843. * Stores the size of points
  109844. */
  109845. pointSize: number;
  109846. /**
  109847. * Stores the z offset value
  109848. */
  109849. zOffset: number;
  109850. get wireframe(): boolean;
  109851. /**
  109852. * Sets the state of wireframe mode
  109853. */
  109854. set wireframe(value: boolean);
  109855. /**
  109856. * Gets the value specifying if point clouds are enabled
  109857. */
  109858. get pointsCloud(): boolean;
  109859. /**
  109860. * Sets the state of point cloud mode
  109861. */
  109862. set pointsCloud(value: boolean);
  109863. /**
  109864. * Gets the material fill mode
  109865. */
  109866. get fillMode(): number;
  109867. /**
  109868. * Sets the material fill mode
  109869. */
  109870. set fillMode(value: number);
  109871. /**
  109872. * @hidden
  109873. * Stores the effects for the material
  109874. */
  109875. _effect: Nullable<Effect>;
  109876. /**
  109877. * Specifies if uniform buffers should be used
  109878. */
  109879. private _useUBO;
  109880. /**
  109881. * Stores a reference to the scene
  109882. */
  109883. private _scene;
  109884. /**
  109885. * Stores the fill mode state
  109886. */
  109887. private _fillMode;
  109888. /**
  109889. * Specifies if the depth write state should be cached
  109890. */
  109891. private _cachedDepthWriteState;
  109892. /**
  109893. * Specifies if the color write state should be cached
  109894. */
  109895. private _cachedColorWriteState;
  109896. /**
  109897. * Specifies if the depth function state should be cached
  109898. */
  109899. private _cachedDepthFunctionState;
  109900. /**
  109901. * Stores the uniform buffer
  109902. */
  109903. protected _uniformBuffer: UniformBuffer;
  109904. /** @hidden */
  109905. _indexInSceneMaterialArray: number;
  109906. /** @hidden */
  109907. meshMap: Nullable<{
  109908. [id: string]: AbstractMesh | undefined;
  109909. }>;
  109910. /**
  109911. * Creates a material instance
  109912. * @param name defines the name of the material
  109913. * @param scene defines the scene to reference
  109914. * @param doNotAdd specifies if the material should be added to the scene
  109915. */
  109916. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  109917. /**
  109918. * Returns a string representation of the current material
  109919. * @param fullDetails defines a boolean indicating which levels of logging is desired
  109920. * @returns a string with material information
  109921. */
  109922. toString(fullDetails?: boolean): string;
  109923. /**
  109924. * Gets the class name of the material
  109925. * @returns a string with the class name of the material
  109926. */
  109927. getClassName(): string;
  109928. /**
  109929. * Specifies if updates for the material been locked
  109930. */
  109931. get isFrozen(): boolean;
  109932. /**
  109933. * Locks updates for the material
  109934. */
  109935. freeze(): void;
  109936. /**
  109937. * Unlocks updates for the material
  109938. */
  109939. unfreeze(): void;
  109940. /**
  109941. * Specifies if the material is ready to be used
  109942. * @param mesh defines the mesh to check
  109943. * @param useInstances specifies if instances should be used
  109944. * @returns a boolean indicating if the material is ready to be used
  109945. */
  109946. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  109947. /**
  109948. * Specifies that the submesh is ready to be used
  109949. * @param mesh defines the mesh to check
  109950. * @param subMesh defines which submesh to check
  109951. * @param useInstances specifies that instances should be used
  109952. * @returns a boolean indicating that the submesh is ready or not
  109953. */
  109954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109955. /**
  109956. * Returns the material effect
  109957. * @returns the effect associated with the material
  109958. */
  109959. getEffect(): Nullable<Effect>;
  109960. /**
  109961. * Returns the current scene
  109962. * @returns a Scene
  109963. */
  109964. getScene(): Scene;
  109965. /**
  109966. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109967. */
  109968. protected _forceAlphaTest: boolean;
  109969. /**
  109970. * The transparency mode of the material.
  109971. */
  109972. protected _transparencyMode: Nullable<number>;
  109973. /**
  109974. * Gets the current transparency mode.
  109975. */
  109976. get transparencyMode(): Nullable<number>;
  109977. /**
  109978. * Sets the transparency mode of the material.
  109979. *
  109980. * | Value | Type | Description |
  109981. * | ----- | ----------------------------------- | ----------- |
  109982. * | 0 | OPAQUE | |
  109983. * | 1 | ALPHATEST | |
  109984. * | 2 | ALPHABLEND | |
  109985. * | 3 | ALPHATESTANDBLEND | |
  109986. *
  109987. */
  109988. set transparencyMode(value: Nullable<number>);
  109989. /**
  109990. * Returns true if alpha blending should be disabled.
  109991. */
  109992. protected get _disableAlphaBlending(): boolean;
  109993. /**
  109994. * Specifies whether or not this material should be rendered in alpha blend mode.
  109995. * @returns a boolean specifying if alpha blending is needed
  109996. */
  109997. needAlphaBlending(): boolean;
  109998. /**
  109999. * Specifies if the mesh will require alpha blending
  110000. * @param mesh defines the mesh to check
  110001. * @returns a boolean specifying if alpha blending is needed for the mesh
  110002. */
  110003. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110004. /**
  110005. * Specifies whether or not this material should be rendered in alpha test mode.
  110006. * @returns a boolean specifying if an alpha test is needed.
  110007. */
  110008. needAlphaTesting(): boolean;
  110009. /**
  110010. * Specifies if material alpha testing should be turned on for the mesh
  110011. * @param mesh defines the mesh to check
  110012. */
  110013. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  110014. /**
  110015. * Gets the texture used for the alpha test
  110016. * @returns the texture to use for alpha testing
  110017. */
  110018. getAlphaTestTexture(): Nullable<BaseTexture>;
  110019. /**
  110020. * Marks the material to indicate that it needs to be re-calculated
  110021. */
  110022. markDirty(): void;
  110023. /** @hidden */
  110024. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  110025. /**
  110026. * Binds the material to the mesh
  110027. * @param world defines the world transformation matrix
  110028. * @param mesh defines the mesh to bind the material to
  110029. */
  110030. bind(world: Matrix, mesh?: Mesh): void;
  110031. /**
  110032. * Binds the submesh to the material
  110033. * @param world defines the world transformation matrix
  110034. * @param mesh defines the mesh containing the submesh
  110035. * @param subMesh defines the submesh to bind the material to
  110036. */
  110037. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110038. /**
  110039. * Binds the world matrix to the material
  110040. * @param world defines the world transformation matrix
  110041. */
  110042. bindOnlyWorldMatrix(world: Matrix): void;
  110043. /**
  110044. * Binds the scene's uniform buffer to the effect.
  110045. * @param effect defines the effect to bind to the scene uniform buffer
  110046. * @param sceneUbo defines the uniform buffer storing scene data
  110047. */
  110048. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  110049. /**
  110050. * Binds the view matrix to the effect
  110051. * @param effect defines the effect to bind the view matrix to
  110052. */
  110053. bindView(effect: Effect): void;
  110054. /**
  110055. * Binds the view projection matrix to the effect
  110056. * @param effect defines the effect to bind the view projection matrix to
  110057. */
  110058. bindViewProjection(effect: Effect): void;
  110059. /**
  110060. * Processes to execute after binding the material to a mesh
  110061. * @param mesh defines the rendered mesh
  110062. */
  110063. protected _afterBind(mesh?: Mesh): void;
  110064. /**
  110065. * Unbinds the material from the mesh
  110066. */
  110067. unbind(): void;
  110068. /**
  110069. * Gets the active textures from the material
  110070. * @returns an array of textures
  110071. */
  110072. getActiveTextures(): BaseTexture[];
  110073. /**
  110074. * Specifies if the material uses a texture
  110075. * @param texture defines the texture to check against the material
  110076. * @returns a boolean specifying if the material uses the texture
  110077. */
  110078. hasTexture(texture: BaseTexture): boolean;
  110079. /**
  110080. * Makes a duplicate of the material, and gives it a new name
  110081. * @param name defines the new name for the duplicated material
  110082. * @returns the cloned material
  110083. */
  110084. clone(name: string): Nullable<Material>;
  110085. /**
  110086. * Gets the meshes bound to the material
  110087. * @returns an array of meshes bound to the material
  110088. */
  110089. getBindedMeshes(): AbstractMesh[];
  110090. /**
  110091. * Force shader compilation
  110092. * @param mesh defines the mesh associated with this material
  110093. * @param onCompiled defines a function to execute once the material is compiled
  110094. * @param options defines the options to configure the compilation
  110095. * @param onError defines a function to execute if the material fails compiling
  110096. */
  110097. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  110098. /**
  110099. * Force shader compilation
  110100. * @param mesh defines the mesh that will use this material
  110101. * @param options defines additional options for compiling the shaders
  110102. * @returns a promise that resolves when the compilation completes
  110103. */
  110104. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  110105. private static readonly _AllDirtyCallBack;
  110106. private static readonly _ImageProcessingDirtyCallBack;
  110107. private static readonly _TextureDirtyCallBack;
  110108. private static readonly _FresnelDirtyCallBack;
  110109. private static readonly _MiscDirtyCallBack;
  110110. private static readonly _PrePassDirtyCallBack;
  110111. private static readonly _LightsDirtyCallBack;
  110112. private static readonly _AttributeDirtyCallBack;
  110113. private static _FresnelAndMiscDirtyCallBack;
  110114. private static _TextureAndMiscDirtyCallBack;
  110115. private static readonly _DirtyCallbackArray;
  110116. private static readonly _RunDirtyCallBacks;
  110117. /**
  110118. * Marks a define in the material to indicate that it needs to be re-computed
  110119. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  110120. */
  110121. markAsDirty(flag: number): void;
  110122. /**
  110123. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  110124. * @param func defines a function which checks material defines against the submeshes
  110125. */
  110126. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  110127. /**
  110128. * Indicates that the scene should check if the rendering now needs a prepass
  110129. */
  110130. protected _markScenePrePassDirty(): void;
  110131. /**
  110132. * Indicates that we need to re-calculated for all submeshes
  110133. */
  110134. protected _markAllSubMeshesAsAllDirty(): void;
  110135. /**
  110136. * Indicates that image processing needs to be re-calculated for all submeshes
  110137. */
  110138. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  110139. /**
  110140. * Indicates that textures need to be re-calculated for all submeshes
  110141. */
  110142. protected _markAllSubMeshesAsTexturesDirty(): void;
  110143. /**
  110144. * Indicates that fresnel needs to be re-calculated for all submeshes
  110145. */
  110146. protected _markAllSubMeshesAsFresnelDirty(): void;
  110147. /**
  110148. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110149. */
  110150. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110151. /**
  110152. * Indicates that lights need to be re-calculated for all submeshes
  110153. */
  110154. protected _markAllSubMeshesAsLightsDirty(): void;
  110155. /**
  110156. * Indicates that attributes need to be re-calculated for all submeshes
  110157. */
  110158. protected _markAllSubMeshesAsAttributesDirty(): void;
  110159. /**
  110160. * Indicates that misc needs to be re-calculated for all submeshes
  110161. */
  110162. protected _markAllSubMeshesAsMiscDirty(): void;
  110163. /**
  110164. * Indicates that prepass needs to be re-calculated for all submeshes
  110165. */
  110166. protected _markAllSubMeshesAsPrePassDirty(): void;
  110167. /**
  110168. * Indicates that textures and misc need to be re-calculated for all submeshes
  110169. */
  110170. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  110171. /**
  110172. * Sets the required values to the prepass renderer.
  110173. * @param prePassRenderer defines the prepass renderer to setup.
  110174. * @returns true if the pre pass is needed.
  110175. */
  110176. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  110177. /**
  110178. * Disposes the material
  110179. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110180. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110181. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  110182. */
  110183. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  110184. /** @hidden */
  110185. private releaseVertexArrayObject;
  110186. /**
  110187. * Serializes this material
  110188. * @returns the serialized material object
  110189. */
  110190. serialize(): any;
  110191. /**
  110192. * Creates a material from parsed material data
  110193. * @param parsedMaterial defines parsed material data
  110194. * @param scene defines the hosting scene
  110195. * @param rootUrl defines the root URL to use to load textures
  110196. * @returns a new material
  110197. */
  110198. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  110199. }
  110200. }
  110201. declare module BABYLON {
  110202. /**
  110203. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110204. * separate meshes. This can be use to improve performances.
  110205. * @see https://doc.babylonjs.com/how_to/multi_materials
  110206. */
  110207. export class MultiMaterial extends Material {
  110208. private _subMaterials;
  110209. /**
  110210. * Gets or Sets the list of Materials used within the multi material.
  110211. * They need to be ordered according to the submeshes order in the associated mesh
  110212. */
  110213. get subMaterials(): Nullable<Material>[];
  110214. set subMaterials(value: Nullable<Material>[]);
  110215. /**
  110216. * Function used to align with Node.getChildren()
  110217. * @returns the list of Materials used within the multi material
  110218. */
  110219. getChildren(): Nullable<Material>[];
  110220. /**
  110221. * Instantiates a new Multi Material
  110222. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110223. * separate meshes. This can be use to improve performances.
  110224. * @see https://doc.babylonjs.com/how_to/multi_materials
  110225. * @param name Define the name in the scene
  110226. * @param scene Define the scene the material belongs to
  110227. */
  110228. constructor(name: string, scene: Scene);
  110229. private _hookArray;
  110230. /**
  110231. * Get one of the submaterial by its index in the submaterials array
  110232. * @param index The index to look the sub material at
  110233. * @returns The Material if the index has been defined
  110234. */
  110235. getSubMaterial(index: number): Nullable<Material>;
  110236. /**
  110237. * Get the list of active textures for the whole sub materials list.
  110238. * @returns All the textures that will be used during the rendering
  110239. */
  110240. getActiveTextures(): BaseTexture[];
  110241. /**
  110242. * Gets the current class name of the material e.g. "MultiMaterial"
  110243. * Mainly use in serialization.
  110244. * @returns the class name
  110245. */
  110246. getClassName(): string;
  110247. /**
  110248. * Checks if the material is ready to render the requested sub mesh
  110249. * @param mesh Define the mesh the submesh belongs to
  110250. * @param subMesh Define the sub mesh to look readyness for
  110251. * @param useInstances Define whether or not the material is used with instances
  110252. * @returns true if ready, otherwise false
  110253. */
  110254. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110255. /**
  110256. * Clones the current material and its related sub materials
  110257. * @param name Define the name of the newly cloned material
  110258. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  110259. * @returns the cloned material
  110260. */
  110261. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  110262. /**
  110263. * Serializes the materials into a JSON representation.
  110264. * @returns the JSON representation
  110265. */
  110266. serialize(): any;
  110267. /**
  110268. * Dispose the material and release its associated resources
  110269. * @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)
  110270. * @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)
  110271. * @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)
  110272. */
  110273. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  110274. /**
  110275. * Creates a MultiMaterial from parsed MultiMaterial data.
  110276. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  110277. * @param scene defines the hosting scene
  110278. * @returns a new MultiMaterial
  110279. */
  110280. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  110281. }
  110282. }
  110283. declare module BABYLON {
  110284. /**
  110285. * Defines a subdivision inside a mesh
  110286. */
  110287. export class SubMesh implements ICullable {
  110288. /** the material index to use */
  110289. materialIndex: number;
  110290. /** vertex index start */
  110291. verticesStart: number;
  110292. /** vertices count */
  110293. verticesCount: number;
  110294. /** index start */
  110295. indexStart: number;
  110296. /** indices count */
  110297. indexCount: number;
  110298. /** @hidden */
  110299. _materialDefines: Nullable<MaterialDefines>;
  110300. /** @hidden */
  110301. _materialEffect: Nullable<Effect>;
  110302. /** @hidden */
  110303. _effectOverride: Nullable<Effect>;
  110304. /**
  110305. * Gets material defines used by the effect associated to the sub mesh
  110306. */
  110307. get materialDefines(): Nullable<MaterialDefines>;
  110308. /**
  110309. * Sets material defines used by the effect associated to the sub mesh
  110310. */
  110311. set materialDefines(defines: Nullable<MaterialDefines>);
  110312. /**
  110313. * Gets associated effect
  110314. */
  110315. get effect(): Nullable<Effect>;
  110316. /**
  110317. * Sets associated effect (effect used to render this submesh)
  110318. * @param effect defines the effect to associate with
  110319. * @param defines defines the set of defines used to compile this effect
  110320. */
  110321. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  110322. /** @hidden */
  110323. _linesIndexCount: number;
  110324. private _mesh;
  110325. private _renderingMesh;
  110326. private _boundingInfo;
  110327. private _linesIndexBuffer;
  110328. /** @hidden */
  110329. _lastColliderWorldVertices: Nullable<Vector3[]>;
  110330. /** @hidden */
  110331. _trianglePlanes: Plane[];
  110332. /** @hidden */
  110333. _lastColliderTransformMatrix: Nullable<Matrix>;
  110334. /** @hidden */
  110335. _renderId: number;
  110336. /** @hidden */
  110337. _alphaIndex: number;
  110338. /** @hidden */
  110339. _distanceToCamera: number;
  110340. /** @hidden */
  110341. _id: number;
  110342. private _currentMaterial;
  110343. /**
  110344. * Add a new submesh to a mesh
  110345. * @param materialIndex defines the material index to use
  110346. * @param verticesStart defines vertex index start
  110347. * @param verticesCount defines vertices count
  110348. * @param indexStart defines index start
  110349. * @param indexCount defines indices count
  110350. * @param mesh defines the parent mesh
  110351. * @param renderingMesh defines an optional rendering mesh
  110352. * @param createBoundingBox defines if bounding box should be created for this submesh
  110353. * @returns the new submesh
  110354. */
  110355. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  110356. /**
  110357. * Creates a new submesh
  110358. * @param materialIndex defines the material index to use
  110359. * @param verticesStart defines vertex index start
  110360. * @param verticesCount defines vertices count
  110361. * @param indexStart defines index start
  110362. * @param indexCount defines indices count
  110363. * @param mesh defines the parent mesh
  110364. * @param renderingMesh defines an optional rendering mesh
  110365. * @param createBoundingBox defines if bounding box should be created for this submesh
  110366. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  110367. */
  110368. constructor(
  110369. /** the material index to use */
  110370. materialIndex: number,
  110371. /** vertex index start */
  110372. verticesStart: number,
  110373. /** vertices count */
  110374. verticesCount: number,
  110375. /** index start */
  110376. indexStart: number,
  110377. /** indices count */
  110378. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  110379. /**
  110380. * Returns true if this submesh covers the entire parent mesh
  110381. * @ignorenaming
  110382. */
  110383. get IsGlobal(): boolean;
  110384. /**
  110385. * Returns the submesh BoudingInfo object
  110386. * @returns current bounding info (or mesh's one if the submesh is global)
  110387. */
  110388. getBoundingInfo(): BoundingInfo;
  110389. /**
  110390. * Sets the submesh BoundingInfo
  110391. * @param boundingInfo defines the new bounding info to use
  110392. * @returns the SubMesh
  110393. */
  110394. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  110395. /**
  110396. * Returns the mesh of the current submesh
  110397. * @return the parent mesh
  110398. */
  110399. getMesh(): AbstractMesh;
  110400. /**
  110401. * Returns the rendering mesh of the submesh
  110402. * @returns the rendering mesh (could be different from parent mesh)
  110403. */
  110404. getRenderingMesh(): Mesh;
  110405. /**
  110406. * Returns the replacement mesh of the submesh
  110407. * @returns the replacement mesh (could be different from parent mesh)
  110408. */
  110409. getReplacementMesh(): Nullable<AbstractMesh>;
  110410. /**
  110411. * Returns the effective mesh of the submesh
  110412. * @returns the effective mesh (could be different from parent mesh)
  110413. */
  110414. getEffectiveMesh(): AbstractMesh;
  110415. /**
  110416. * Returns the submesh material
  110417. * @returns null or the current material
  110418. */
  110419. getMaterial(): Nullable<Material>;
  110420. private _IsMultiMaterial;
  110421. /**
  110422. * Sets a new updated BoundingInfo object to the submesh
  110423. * @param data defines an optional position array to use to determine the bounding info
  110424. * @returns the SubMesh
  110425. */
  110426. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  110427. /** @hidden */
  110428. _checkCollision(collider: Collider): boolean;
  110429. /**
  110430. * Updates the submesh BoundingInfo
  110431. * @param world defines the world matrix to use to update the bounding info
  110432. * @returns the submesh
  110433. */
  110434. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  110435. /**
  110436. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  110437. * @param frustumPlanes defines the frustum planes
  110438. * @returns true if the submesh is intersecting with the frustum
  110439. */
  110440. isInFrustum(frustumPlanes: Plane[]): boolean;
  110441. /**
  110442. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  110443. * @param frustumPlanes defines the frustum planes
  110444. * @returns true if the submesh is inside the frustum
  110445. */
  110446. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  110447. /**
  110448. * Renders the submesh
  110449. * @param enableAlphaMode defines if alpha needs to be used
  110450. * @returns the submesh
  110451. */
  110452. render(enableAlphaMode: boolean): SubMesh;
  110453. /**
  110454. * @hidden
  110455. */
  110456. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  110457. /**
  110458. * Checks if the submesh intersects with a ray
  110459. * @param ray defines the ray to test
  110460. * @returns true is the passed ray intersects the submesh bounding box
  110461. */
  110462. canIntersects(ray: Ray): boolean;
  110463. /**
  110464. * Intersects current submesh with a ray
  110465. * @param ray defines the ray to test
  110466. * @param positions defines mesh's positions array
  110467. * @param indices defines mesh's indices array
  110468. * @param fastCheck defines if the first intersection will be used (and not the closest)
  110469. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110470. * @returns intersection info or null if no intersection
  110471. */
  110472. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  110473. /** @hidden */
  110474. private _intersectLines;
  110475. /** @hidden */
  110476. private _intersectUnIndexedLines;
  110477. /** @hidden */
  110478. private _intersectTriangles;
  110479. /** @hidden */
  110480. private _intersectUnIndexedTriangles;
  110481. /** @hidden */
  110482. _rebuild(): void;
  110483. /**
  110484. * Creates a new submesh from the passed mesh
  110485. * @param newMesh defines the new hosting mesh
  110486. * @param newRenderingMesh defines an optional rendering mesh
  110487. * @returns the new submesh
  110488. */
  110489. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  110490. /**
  110491. * Release associated resources
  110492. */
  110493. dispose(): void;
  110494. /**
  110495. * Gets the class name
  110496. * @returns the string "SubMesh".
  110497. */
  110498. getClassName(): string;
  110499. /**
  110500. * Creates a new submesh from indices data
  110501. * @param materialIndex the index of the main mesh material
  110502. * @param startIndex the index where to start the copy in the mesh indices array
  110503. * @param indexCount the number of indices to copy then from the startIndex
  110504. * @param mesh the main mesh to create the submesh from
  110505. * @param renderingMesh the optional rendering mesh
  110506. * @returns a new submesh
  110507. */
  110508. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  110509. }
  110510. }
  110511. declare module BABYLON {
  110512. /**
  110513. * Class used to represent data loading progression
  110514. */
  110515. export class SceneLoaderFlags {
  110516. private static _ForceFullSceneLoadingForIncremental;
  110517. private static _ShowLoadingScreen;
  110518. private static _CleanBoneMatrixWeights;
  110519. private static _loggingLevel;
  110520. /**
  110521. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110522. */
  110523. static get ForceFullSceneLoadingForIncremental(): boolean;
  110524. static set ForceFullSceneLoadingForIncremental(value: boolean);
  110525. /**
  110526. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110527. */
  110528. static get ShowLoadingScreen(): boolean;
  110529. static set ShowLoadingScreen(value: boolean);
  110530. /**
  110531. * Defines the current logging level (while loading the scene)
  110532. * @ignorenaming
  110533. */
  110534. static get loggingLevel(): number;
  110535. static set loggingLevel(value: number);
  110536. /**
  110537. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110538. */
  110539. static get CleanBoneMatrixWeights(): boolean;
  110540. static set CleanBoneMatrixWeights(value: boolean);
  110541. }
  110542. }
  110543. declare module BABYLON {
  110544. /**
  110545. * Class used to store geometry data (vertex buffers + index buffer)
  110546. */
  110547. export class Geometry implements IGetSetVerticesData {
  110548. /**
  110549. * Gets or sets the ID of the geometry
  110550. */
  110551. id: string;
  110552. /**
  110553. * Gets or sets the unique ID of the geometry
  110554. */
  110555. uniqueId: number;
  110556. /**
  110557. * Gets the delay loading state of the geometry (none by default which means not delayed)
  110558. */
  110559. delayLoadState: number;
  110560. /**
  110561. * Gets the file containing the data to load when running in delay load state
  110562. */
  110563. delayLoadingFile: Nullable<string>;
  110564. /**
  110565. * Callback called when the geometry is updated
  110566. */
  110567. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  110568. private _scene;
  110569. private _engine;
  110570. private _meshes;
  110571. private _totalVertices;
  110572. /** @hidden */
  110573. _indices: IndicesArray;
  110574. /** @hidden */
  110575. _vertexBuffers: {
  110576. [key: string]: VertexBuffer;
  110577. };
  110578. private _isDisposed;
  110579. private _extend;
  110580. private _boundingBias;
  110581. /** @hidden */
  110582. _delayInfo: Array<string>;
  110583. private _indexBuffer;
  110584. private _indexBufferIsUpdatable;
  110585. /** @hidden */
  110586. _boundingInfo: Nullable<BoundingInfo>;
  110587. /** @hidden */
  110588. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  110589. /** @hidden */
  110590. _softwareSkinningFrameId: number;
  110591. private _vertexArrayObjects;
  110592. private _updatable;
  110593. /** @hidden */
  110594. _positions: Nullable<Vector3[]>;
  110595. /**
  110596. * 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
  110597. */
  110598. get boundingBias(): Vector2;
  110599. /**
  110600. * 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
  110601. */
  110602. set boundingBias(value: Vector2);
  110603. /**
  110604. * Static function used to attach a new empty geometry to a mesh
  110605. * @param mesh defines the mesh to attach the geometry to
  110606. * @returns the new Geometry
  110607. */
  110608. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  110609. /** Get the list of meshes using this geometry */
  110610. get meshes(): Mesh[];
  110611. /**
  110612. * 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
  110613. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  110614. */
  110615. useBoundingInfoFromGeometry: boolean;
  110616. /**
  110617. * Creates a new geometry
  110618. * @param id defines the unique ID
  110619. * @param scene defines the hosting scene
  110620. * @param vertexData defines the VertexData used to get geometry data
  110621. * @param updatable defines if geometry must be updatable (false by default)
  110622. * @param mesh defines the mesh that will be associated with the geometry
  110623. */
  110624. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  110625. /**
  110626. * Gets the current extend of the geometry
  110627. */
  110628. get extend(): {
  110629. minimum: Vector3;
  110630. maximum: Vector3;
  110631. };
  110632. /**
  110633. * Gets the hosting scene
  110634. * @returns the hosting Scene
  110635. */
  110636. getScene(): Scene;
  110637. /**
  110638. * Gets the hosting engine
  110639. * @returns the hosting Engine
  110640. */
  110641. getEngine(): Engine;
  110642. /**
  110643. * Defines if the geometry is ready to use
  110644. * @returns true if the geometry is ready to be used
  110645. */
  110646. isReady(): boolean;
  110647. /**
  110648. * Gets a value indicating that the geometry should not be serialized
  110649. */
  110650. get doNotSerialize(): boolean;
  110651. /** @hidden */
  110652. _rebuild(): void;
  110653. /**
  110654. * Affects all geometry data in one call
  110655. * @param vertexData defines the geometry data
  110656. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  110657. */
  110658. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  110659. /**
  110660. * Set specific vertex data
  110661. * @param kind defines the data kind (Position, normal, etc...)
  110662. * @param data defines the vertex data to use
  110663. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110664. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110665. */
  110666. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  110667. /**
  110668. * Removes a specific vertex data
  110669. * @param kind defines the data kind (Position, normal, etc...)
  110670. */
  110671. removeVerticesData(kind: string): void;
  110672. /**
  110673. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  110674. * @param buffer defines the vertex buffer to use
  110675. * @param totalVertices defines the total number of vertices for position kind (could be null)
  110676. */
  110677. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  110678. /**
  110679. * Update a specific vertex buffer
  110680. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  110681. * It will do nothing if the buffer is not updatable
  110682. * @param kind defines the data kind (Position, normal, etc...)
  110683. * @param data defines the data to use
  110684. * @param offset defines the offset in the target buffer where to store the data
  110685. * @param useBytes set to true if the offset is in bytes
  110686. */
  110687. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  110688. /**
  110689. * Update a specific vertex buffer
  110690. * This function will create a new buffer if the current one is not updatable
  110691. * @param kind defines the data kind (Position, normal, etc...)
  110692. * @param data defines the data to use
  110693. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  110694. */
  110695. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  110696. private _updateBoundingInfo;
  110697. /** @hidden */
  110698. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  110699. /**
  110700. * Gets total number of vertices
  110701. * @returns the total number of vertices
  110702. */
  110703. getTotalVertices(): number;
  110704. /**
  110705. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110706. * @param kind defines the data kind (Position, normal, etc...)
  110707. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110708. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110709. * @returns a float array containing vertex data
  110710. */
  110711. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110712. /**
  110713. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  110714. * @param kind defines the data kind (Position, normal, etc...)
  110715. * @returns true if the vertex buffer with the specified kind is updatable
  110716. */
  110717. isVertexBufferUpdatable(kind: string): boolean;
  110718. /**
  110719. * Gets a specific vertex buffer
  110720. * @param kind defines the data kind (Position, normal, etc...)
  110721. * @returns a VertexBuffer
  110722. */
  110723. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  110724. /**
  110725. * Returns all vertex buffers
  110726. * @return an object holding all vertex buffers indexed by kind
  110727. */
  110728. getVertexBuffers(): Nullable<{
  110729. [key: string]: VertexBuffer;
  110730. }>;
  110731. /**
  110732. * Gets a boolean indicating if specific vertex buffer is present
  110733. * @param kind defines the data kind (Position, normal, etc...)
  110734. * @returns true if data is present
  110735. */
  110736. isVerticesDataPresent(kind: string): boolean;
  110737. /**
  110738. * Gets a list of all attached data kinds (Position, normal, etc...)
  110739. * @returns a list of string containing all kinds
  110740. */
  110741. getVerticesDataKinds(): string[];
  110742. /**
  110743. * Update index buffer
  110744. * @param indices defines the indices to store in the index buffer
  110745. * @param offset defines the offset in the target buffer where to store the data
  110746. * @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)
  110747. */
  110748. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  110749. /**
  110750. * Creates a new index buffer
  110751. * @param indices defines the indices to store in the index buffer
  110752. * @param totalVertices defines the total number of vertices (could be null)
  110753. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110754. */
  110755. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  110756. /**
  110757. * Return the total number of indices
  110758. * @returns the total number of indices
  110759. */
  110760. getTotalIndices(): number;
  110761. /**
  110762. * Gets the index buffer array
  110763. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110764. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110765. * @returns the index buffer array
  110766. */
  110767. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110768. /**
  110769. * Gets the index buffer
  110770. * @return the index buffer
  110771. */
  110772. getIndexBuffer(): Nullable<DataBuffer>;
  110773. /** @hidden */
  110774. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  110775. /**
  110776. * Release the associated resources for a specific mesh
  110777. * @param mesh defines the source mesh
  110778. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  110779. */
  110780. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  110781. /**
  110782. * Apply current geometry to a given mesh
  110783. * @param mesh defines the mesh to apply geometry to
  110784. */
  110785. applyToMesh(mesh: Mesh): void;
  110786. private _updateExtend;
  110787. private _applyToMesh;
  110788. private notifyUpdate;
  110789. /**
  110790. * Load the geometry if it was flagged as delay loaded
  110791. * @param scene defines the hosting scene
  110792. * @param onLoaded defines a callback called when the geometry is loaded
  110793. */
  110794. load(scene: Scene, onLoaded?: () => void): void;
  110795. private _queueLoad;
  110796. /**
  110797. * Invert the geometry to move from a right handed system to a left handed one.
  110798. */
  110799. toLeftHanded(): void;
  110800. /** @hidden */
  110801. _resetPointsArrayCache(): void;
  110802. /** @hidden */
  110803. _generatePointsArray(): boolean;
  110804. /**
  110805. * Gets a value indicating if the geometry is disposed
  110806. * @returns true if the geometry was disposed
  110807. */
  110808. isDisposed(): boolean;
  110809. private _disposeVertexArrayObjects;
  110810. /**
  110811. * Free all associated resources
  110812. */
  110813. dispose(): void;
  110814. /**
  110815. * Clone the current geometry into a new geometry
  110816. * @param id defines the unique ID of the new geometry
  110817. * @returns a new geometry object
  110818. */
  110819. copy(id: string): Geometry;
  110820. /**
  110821. * Serialize the current geometry info (and not the vertices data) into a JSON object
  110822. * @return a JSON representation of the current geometry data (without the vertices data)
  110823. */
  110824. serialize(): any;
  110825. private toNumberArray;
  110826. /**
  110827. * Serialize all vertices data into a JSON oject
  110828. * @returns a JSON representation of the current geometry data
  110829. */
  110830. serializeVerticeData(): any;
  110831. /**
  110832. * Extracts a clone of a mesh geometry
  110833. * @param mesh defines the source mesh
  110834. * @param id defines the unique ID of the new geometry object
  110835. * @returns the new geometry object
  110836. */
  110837. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  110838. /**
  110839. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  110840. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110841. * Be aware Math.random() could cause collisions, but:
  110842. * "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"
  110843. * @returns a string containing a new GUID
  110844. */
  110845. static RandomId(): string;
  110846. /** @hidden */
  110847. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  110848. private static _CleanMatricesWeights;
  110849. /**
  110850. * Create a new geometry from persisted data (Using .babylon file format)
  110851. * @param parsedVertexData defines the persisted data
  110852. * @param scene defines the hosting scene
  110853. * @param rootUrl defines the root url to use to load assets (like delayed data)
  110854. * @returns the new geometry object
  110855. */
  110856. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  110857. }
  110858. }
  110859. declare module BABYLON {
  110860. /**
  110861. * Define an interface for all classes that will get and set the data on vertices
  110862. */
  110863. export interface IGetSetVerticesData {
  110864. /**
  110865. * Gets a boolean indicating if specific vertex data is present
  110866. * @param kind defines the vertex data kind to use
  110867. * @returns true is data kind is present
  110868. */
  110869. isVerticesDataPresent(kind: string): boolean;
  110870. /**
  110871. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110872. * @param kind defines the data kind (Position, normal, etc...)
  110873. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110874. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110875. * @returns a float array containing vertex data
  110876. */
  110877. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110878. /**
  110879. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  110880. * @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.
  110881. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110882. * @returns the indices array or an empty array if the mesh has no geometry
  110883. */
  110884. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110885. /**
  110886. * Set specific vertex data
  110887. * @param kind defines the data kind (Position, normal, etc...)
  110888. * @param data defines the vertex data to use
  110889. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110890. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110891. */
  110892. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  110893. /**
  110894. * Update a specific associated vertex buffer
  110895. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  110896. * - VertexBuffer.PositionKind
  110897. * - VertexBuffer.UVKind
  110898. * - VertexBuffer.UV2Kind
  110899. * - VertexBuffer.UV3Kind
  110900. * - VertexBuffer.UV4Kind
  110901. * - VertexBuffer.UV5Kind
  110902. * - VertexBuffer.UV6Kind
  110903. * - VertexBuffer.ColorKind
  110904. * - VertexBuffer.MatricesIndicesKind
  110905. * - VertexBuffer.MatricesIndicesExtraKind
  110906. * - VertexBuffer.MatricesWeightsKind
  110907. * - VertexBuffer.MatricesWeightsExtraKind
  110908. * @param data defines the data source
  110909. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  110910. * @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)
  110911. */
  110912. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  110913. /**
  110914. * Creates a new index buffer
  110915. * @param indices defines the indices to store in the index buffer
  110916. * @param totalVertices defines the total number of vertices (could be null)
  110917. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110918. */
  110919. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  110920. }
  110921. /**
  110922. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  110923. */
  110924. export class VertexData {
  110925. /**
  110926. * Mesh side orientation : usually the external or front surface
  110927. */
  110928. static readonly FRONTSIDE: number;
  110929. /**
  110930. * Mesh side orientation : usually the internal or back surface
  110931. */
  110932. static readonly BACKSIDE: number;
  110933. /**
  110934. * Mesh side orientation : both internal and external or front and back surfaces
  110935. */
  110936. static readonly DOUBLESIDE: number;
  110937. /**
  110938. * Mesh side orientation : by default, `FRONTSIDE`
  110939. */
  110940. static readonly DEFAULTSIDE: number;
  110941. /**
  110942. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  110943. */
  110944. positions: Nullable<FloatArray>;
  110945. /**
  110946. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  110947. */
  110948. normals: Nullable<FloatArray>;
  110949. /**
  110950. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  110951. */
  110952. tangents: Nullable<FloatArray>;
  110953. /**
  110954. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110955. */
  110956. uvs: Nullable<FloatArray>;
  110957. /**
  110958. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110959. */
  110960. uvs2: Nullable<FloatArray>;
  110961. /**
  110962. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110963. */
  110964. uvs3: Nullable<FloatArray>;
  110965. /**
  110966. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110967. */
  110968. uvs4: Nullable<FloatArray>;
  110969. /**
  110970. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110971. */
  110972. uvs5: Nullable<FloatArray>;
  110973. /**
  110974. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110975. */
  110976. uvs6: Nullable<FloatArray>;
  110977. /**
  110978. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  110979. */
  110980. colors: Nullable<FloatArray>;
  110981. /**
  110982. * 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).
  110983. */
  110984. matricesIndices: Nullable<FloatArray>;
  110985. /**
  110986. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  110987. */
  110988. matricesWeights: Nullable<FloatArray>;
  110989. /**
  110990. * An array extending the number of possible indices
  110991. */
  110992. matricesIndicesExtra: Nullable<FloatArray>;
  110993. /**
  110994. * An array extending the number of possible weights when the number of indices is extended
  110995. */
  110996. matricesWeightsExtra: Nullable<FloatArray>;
  110997. /**
  110998. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  110999. */
  111000. indices: Nullable<IndicesArray>;
  111001. /**
  111002. * Uses the passed data array to set the set the values for the specified kind of data
  111003. * @param data a linear array of floating numbers
  111004. * @param kind the type of data that is being set, eg positions, colors etc
  111005. */
  111006. set(data: FloatArray, kind: string): void;
  111007. /**
  111008. * Associates the vertexData to the passed Mesh.
  111009. * Sets it as updatable or not (default `false`)
  111010. * @param mesh the mesh the vertexData is applied to
  111011. * @param updatable when used and having the value true allows new data to update the vertexData
  111012. * @returns the VertexData
  111013. */
  111014. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  111015. /**
  111016. * Associates the vertexData to the passed Geometry.
  111017. * Sets it as updatable or not (default `false`)
  111018. * @param geometry the geometry the vertexData is applied to
  111019. * @param updatable when used and having the value true allows new data to update the vertexData
  111020. * @returns VertexData
  111021. */
  111022. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  111023. /**
  111024. * Updates the associated mesh
  111025. * @param mesh the mesh to be updated
  111026. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111027. * @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
  111028. * @returns VertexData
  111029. */
  111030. updateMesh(mesh: Mesh): VertexData;
  111031. /**
  111032. * Updates the associated geometry
  111033. * @param geometry the geometry to be updated
  111034. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111035. * @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
  111036. * @returns VertexData.
  111037. */
  111038. updateGeometry(geometry: Geometry): VertexData;
  111039. private _applyTo;
  111040. private _update;
  111041. /**
  111042. * Transforms each position and each normal of the vertexData according to the passed Matrix
  111043. * @param matrix the transforming matrix
  111044. * @returns the VertexData
  111045. */
  111046. transform(matrix: Matrix): VertexData;
  111047. /**
  111048. * Merges the passed VertexData into the current one
  111049. * @param other the VertexData to be merged into the current one
  111050. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  111051. * @returns the modified VertexData
  111052. */
  111053. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  111054. private _mergeElement;
  111055. private _validate;
  111056. /**
  111057. * Serializes the VertexData
  111058. * @returns a serialized object
  111059. */
  111060. serialize(): any;
  111061. /**
  111062. * Extracts the vertexData from a mesh
  111063. * @param mesh the mesh from which to extract the VertexData
  111064. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  111065. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111066. * @returns the object VertexData associated to the passed mesh
  111067. */
  111068. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111069. /**
  111070. * Extracts the vertexData from the geometry
  111071. * @param geometry the geometry from which to extract the VertexData
  111072. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  111073. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111074. * @returns the object VertexData associated to the passed mesh
  111075. */
  111076. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111077. private static _ExtractFrom;
  111078. /**
  111079. * Creates the VertexData for a Ribbon
  111080. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  111081. * * pathArray array of paths, each of which an array of successive Vector3
  111082. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  111083. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  111084. * * 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
  111085. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111086. * * 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)
  111087. * * 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)
  111088. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  111089. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  111090. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  111091. * @returns the VertexData of the ribbon
  111092. */
  111093. static CreateRibbon(options: {
  111094. pathArray: Vector3[][];
  111095. closeArray?: boolean;
  111096. closePath?: boolean;
  111097. offset?: number;
  111098. sideOrientation?: number;
  111099. frontUVs?: Vector4;
  111100. backUVs?: Vector4;
  111101. invertUV?: boolean;
  111102. uvs?: Vector2[];
  111103. colors?: Color4[];
  111104. }): VertexData;
  111105. /**
  111106. * Creates the VertexData for a box
  111107. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111108. * * size sets the width, height and depth of the box to the value of size, optional default 1
  111109. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  111110. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  111111. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  111112. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111113. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111114. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111115. * * 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)
  111116. * * 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)
  111117. * @returns the VertexData of the box
  111118. */
  111119. static CreateBox(options: {
  111120. size?: number;
  111121. width?: number;
  111122. height?: number;
  111123. depth?: number;
  111124. faceUV?: Vector4[];
  111125. faceColors?: Color4[];
  111126. sideOrientation?: number;
  111127. frontUVs?: Vector4;
  111128. backUVs?: Vector4;
  111129. }): VertexData;
  111130. /**
  111131. * Creates the VertexData for a tiled box
  111132. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111133. * * faceTiles sets the pattern, tile size and number of tiles for a face
  111134. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111135. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111137. * @returns the VertexData of the box
  111138. */
  111139. static CreateTiledBox(options: {
  111140. pattern?: number;
  111141. width?: number;
  111142. height?: number;
  111143. depth?: number;
  111144. tileSize?: number;
  111145. tileWidth?: number;
  111146. tileHeight?: number;
  111147. alignHorizontal?: number;
  111148. alignVertical?: number;
  111149. faceUV?: Vector4[];
  111150. faceColors?: Color4[];
  111151. sideOrientation?: number;
  111152. }): VertexData;
  111153. /**
  111154. * Creates the VertexData for a tiled plane
  111155. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111156. * * pattern a limited pattern arrangement depending on the number
  111157. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111158. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111159. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111160. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111161. * * 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)
  111162. * * 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)
  111163. * @returns the VertexData of the tiled plane
  111164. */
  111165. static CreateTiledPlane(options: {
  111166. pattern?: number;
  111167. tileSize?: number;
  111168. tileWidth?: number;
  111169. tileHeight?: number;
  111170. size?: number;
  111171. width?: number;
  111172. height?: number;
  111173. alignHorizontal?: number;
  111174. alignVertical?: number;
  111175. sideOrientation?: number;
  111176. frontUVs?: Vector4;
  111177. backUVs?: Vector4;
  111178. }): VertexData;
  111179. /**
  111180. * Creates the VertexData for an ellipsoid, defaults to a sphere
  111181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111182. * * segments sets the number of horizontal strips optional, default 32
  111183. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  111184. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  111185. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  111186. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  111187. * * 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
  111188. * * 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
  111189. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111190. * * 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)
  111191. * * 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)
  111192. * @returns the VertexData of the ellipsoid
  111193. */
  111194. static CreateSphere(options: {
  111195. segments?: number;
  111196. diameter?: number;
  111197. diameterX?: number;
  111198. diameterY?: number;
  111199. diameterZ?: number;
  111200. arc?: number;
  111201. slice?: number;
  111202. sideOrientation?: number;
  111203. frontUVs?: Vector4;
  111204. backUVs?: Vector4;
  111205. }): VertexData;
  111206. /**
  111207. * Creates the VertexData for a cylinder, cone or prism
  111208. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111209. * * height sets the height (y direction) of the cylinder, optional, default 2
  111210. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  111211. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  111212. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  111213. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111214. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  111215. * * 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
  111216. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111217. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111218. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  111219. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  111220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111221. * * 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)
  111222. * * 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)
  111223. * @returns the VertexData of the cylinder, cone or prism
  111224. */
  111225. static CreateCylinder(options: {
  111226. height?: number;
  111227. diameterTop?: number;
  111228. diameterBottom?: number;
  111229. diameter?: number;
  111230. tessellation?: number;
  111231. subdivisions?: number;
  111232. arc?: number;
  111233. faceColors?: Color4[];
  111234. faceUV?: Vector4[];
  111235. hasRings?: boolean;
  111236. enclose?: boolean;
  111237. sideOrientation?: number;
  111238. frontUVs?: Vector4;
  111239. backUVs?: Vector4;
  111240. }): VertexData;
  111241. /**
  111242. * Creates the VertexData for a torus
  111243. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111244. * * diameter the diameter of the torus, optional default 1
  111245. * * thickness the diameter of the tube forming the torus, optional default 0.5
  111246. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111247. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111248. * * 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)
  111249. * * 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)
  111250. * @returns the VertexData of the torus
  111251. */
  111252. static CreateTorus(options: {
  111253. diameter?: number;
  111254. thickness?: number;
  111255. tessellation?: number;
  111256. sideOrientation?: number;
  111257. frontUVs?: Vector4;
  111258. backUVs?: Vector4;
  111259. }): VertexData;
  111260. /**
  111261. * Creates the VertexData of the LineSystem
  111262. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  111263. * - lines an array of lines, each line being an array of successive Vector3
  111264. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  111265. * @returns the VertexData of the LineSystem
  111266. */
  111267. static CreateLineSystem(options: {
  111268. lines: Vector3[][];
  111269. colors?: Nullable<Color4[][]>;
  111270. }): VertexData;
  111271. /**
  111272. * Create the VertexData for a DashedLines
  111273. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  111274. * - points an array successive Vector3
  111275. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  111276. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  111277. * - dashNb the intended total number of dashes, optional, default 200
  111278. * @returns the VertexData for the DashedLines
  111279. */
  111280. static CreateDashedLines(options: {
  111281. points: Vector3[];
  111282. dashSize?: number;
  111283. gapSize?: number;
  111284. dashNb?: number;
  111285. }): VertexData;
  111286. /**
  111287. * Creates the VertexData for a Ground
  111288. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111289. * - width the width (x direction) of the ground, optional, default 1
  111290. * - height the height (z direction) of the ground, optional, default 1
  111291. * - subdivisions the number of subdivisions per side, optional, default 1
  111292. * @returns the VertexData of the Ground
  111293. */
  111294. static CreateGround(options: {
  111295. width?: number;
  111296. height?: number;
  111297. subdivisions?: number;
  111298. subdivisionsX?: number;
  111299. subdivisionsY?: number;
  111300. }): VertexData;
  111301. /**
  111302. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  111303. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111304. * * xmin the ground minimum X coordinate, optional, default -1
  111305. * * zmin the ground minimum Z coordinate, optional, default -1
  111306. * * xmax the ground maximum X coordinate, optional, default 1
  111307. * * zmax the ground maximum Z coordinate, optional, default 1
  111308. * * 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}
  111309. * * 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}
  111310. * @returns the VertexData of the TiledGround
  111311. */
  111312. static CreateTiledGround(options: {
  111313. xmin: number;
  111314. zmin: number;
  111315. xmax: number;
  111316. zmax: number;
  111317. subdivisions?: {
  111318. w: number;
  111319. h: number;
  111320. };
  111321. precision?: {
  111322. w: number;
  111323. h: number;
  111324. };
  111325. }): VertexData;
  111326. /**
  111327. * Creates the VertexData of the Ground designed from a heightmap
  111328. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  111329. * * width the width (x direction) of the ground
  111330. * * height the height (z direction) of the ground
  111331. * * subdivisions the number of subdivisions per side
  111332. * * minHeight the minimum altitude on the ground, optional, default 0
  111333. * * maxHeight the maximum altitude on the ground, optional default 1
  111334. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  111335. * * buffer the array holding the image color data
  111336. * * bufferWidth the width of image
  111337. * * bufferHeight the height of image
  111338. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  111339. * @returns the VertexData of the Ground designed from a heightmap
  111340. */
  111341. static CreateGroundFromHeightMap(options: {
  111342. width: number;
  111343. height: number;
  111344. subdivisions: number;
  111345. minHeight: number;
  111346. maxHeight: number;
  111347. colorFilter: Color3;
  111348. buffer: Uint8Array;
  111349. bufferWidth: number;
  111350. bufferHeight: number;
  111351. alphaFilter: number;
  111352. }): VertexData;
  111353. /**
  111354. * Creates the VertexData for a Plane
  111355. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  111356. * * size sets the width and height of the plane to the value of size, optional default 1
  111357. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  111358. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  111359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111360. * * 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)
  111361. * * 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)
  111362. * @returns the VertexData of the box
  111363. */
  111364. static CreatePlane(options: {
  111365. size?: number;
  111366. width?: number;
  111367. height?: number;
  111368. sideOrientation?: number;
  111369. frontUVs?: Vector4;
  111370. backUVs?: Vector4;
  111371. }): VertexData;
  111372. /**
  111373. * Creates the VertexData of the Disc or regular Polygon
  111374. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  111375. * * radius the radius of the disc, optional default 0.5
  111376. * * tessellation the number of polygon sides, optional, default 64
  111377. * * 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
  111378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111379. * * 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)
  111380. * * 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)
  111381. * @returns the VertexData of the box
  111382. */
  111383. static CreateDisc(options: {
  111384. radius?: number;
  111385. tessellation?: number;
  111386. arc?: number;
  111387. sideOrientation?: number;
  111388. frontUVs?: Vector4;
  111389. backUVs?: Vector4;
  111390. }): VertexData;
  111391. /**
  111392. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  111393. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  111394. * @param polygon a mesh built from polygonTriangulation.build()
  111395. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111396. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111397. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111398. * @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)
  111399. * @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)
  111400. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  111401. * @returns the VertexData of the Polygon
  111402. */
  111403. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  111404. /**
  111405. * Creates the VertexData of the IcoSphere
  111406. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  111407. * * radius the radius of the IcoSphere, optional default 1
  111408. * * radiusX allows stretching in the x direction, optional, default radius
  111409. * * radiusY allows stretching in the y direction, optional, default radius
  111410. * * radiusZ allows stretching in the z direction, optional, default radius
  111411. * * flat when true creates a flat shaded mesh, optional, default true
  111412. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111414. * * 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)
  111415. * * 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)
  111416. * @returns the VertexData of the IcoSphere
  111417. */
  111418. static CreateIcoSphere(options: {
  111419. radius?: number;
  111420. radiusX?: number;
  111421. radiusY?: number;
  111422. radiusZ?: number;
  111423. flat?: boolean;
  111424. subdivisions?: number;
  111425. sideOrientation?: number;
  111426. frontUVs?: Vector4;
  111427. backUVs?: Vector4;
  111428. }): VertexData;
  111429. /**
  111430. * Creates the VertexData for a Polyhedron
  111431. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  111432. * * type provided types are:
  111433. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  111434. * * 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)
  111435. * * size the size of the IcoSphere, optional default 1
  111436. * * sizeX allows stretching in the x direction, optional, default size
  111437. * * sizeY allows stretching in the y direction, optional, default size
  111438. * * sizeZ allows stretching in the z direction, optional, default size
  111439. * * 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
  111440. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111441. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111442. * * flat when true creates a flat shaded mesh, optional, default true
  111443. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111445. * * 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)
  111446. * * 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)
  111447. * @returns the VertexData of the Polyhedron
  111448. */
  111449. static CreatePolyhedron(options: {
  111450. type?: number;
  111451. size?: number;
  111452. sizeX?: number;
  111453. sizeY?: number;
  111454. sizeZ?: number;
  111455. custom?: any;
  111456. faceUV?: Vector4[];
  111457. faceColors?: Color4[];
  111458. flat?: boolean;
  111459. sideOrientation?: number;
  111460. frontUVs?: Vector4;
  111461. backUVs?: Vector4;
  111462. }): VertexData;
  111463. /**
  111464. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  111465. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  111466. * @returns the VertexData of the Capsule
  111467. */
  111468. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  111469. /**
  111470. * Creates the VertexData for a TorusKnot
  111471. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  111472. * * radius the radius of the torus knot, optional, default 2
  111473. * * tube the thickness of the tube, optional, default 0.5
  111474. * * radialSegments the number of sides on each tube segments, optional, default 32
  111475. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  111476. * * p the number of windings around the z axis, optional, default 2
  111477. * * q the number of windings around the x axis, optional, default 3
  111478. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111479. * * 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)
  111480. * * 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)
  111481. * @returns the VertexData of the Torus Knot
  111482. */
  111483. static CreateTorusKnot(options: {
  111484. radius?: number;
  111485. tube?: number;
  111486. radialSegments?: number;
  111487. tubularSegments?: number;
  111488. p?: number;
  111489. q?: number;
  111490. sideOrientation?: number;
  111491. frontUVs?: Vector4;
  111492. backUVs?: Vector4;
  111493. }): VertexData;
  111494. /**
  111495. * Compute normals for given positions and indices
  111496. * @param positions an array of vertex positions, [...., x, y, z, ......]
  111497. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  111498. * @param normals an array of vertex normals, [...., x, y, z, ......]
  111499. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  111500. * * facetNormals : optional array of facet normals (vector3)
  111501. * * facetPositions : optional array of facet positions (vector3)
  111502. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  111503. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  111504. * * bInfo : optional bounding info, required for facetPartitioning computation
  111505. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  111506. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  111507. * * useRightHandedSystem: optional boolean to for right handed system computation
  111508. * * depthSort : optional boolean to enable the facet depth sort computation
  111509. * * distanceTo : optional Vector3 to compute the facet depth from this location
  111510. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  111511. */
  111512. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  111513. facetNormals?: any;
  111514. facetPositions?: any;
  111515. facetPartitioning?: any;
  111516. ratio?: number;
  111517. bInfo?: any;
  111518. bbSize?: Vector3;
  111519. subDiv?: any;
  111520. useRightHandedSystem?: boolean;
  111521. depthSort?: boolean;
  111522. distanceTo?: Vector3;
  111523. depthSortedFacets?: any;
  111524. }): void;
  111525. /** @hidden */
  111526. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  111527. /**
  111528. * Applies VertexData created from the imported parameters to the geometry
  111529. * @param parsedVertexData the parsed data from an imported file
  111530. * @param geometry the geometry to apply the VertexData to
  111531. */
  111532. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  111533. }
  111534. }
  111535. declare module BABYLON {
  111536. /**
  111537. * Defines a target to use with MorphTargetManager
  111538. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111539. */
  111540. export class MorphTarget implements IAnimatable {
  111541. /** defines the name of the target */
  111542. name: string;
  111543. /**
  111544. * Gets or sets the list of animations
  111545. */
  111546. animations: Animation[];
  111547. private _scene;
  111548. private _positions;
  111549. private _normals;
  111550. private _tangents;
  111551. private _uvs;
  111552. private _influence;
  111553. private _uniqueId;
  111554. /**
  111555. * Observable raised when the influence changes
  111556. */
  111557. onInfluenceChanged: Observable<boolean>;
  111558. /** @hidden */
  111559. _onDataLayoutChanged: Observable<void>;
  111560. /**
  111561. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  111562. */
  111563. get influence(): number;
  111564. set influence(influence: number);
  111565. /**
  111566. * Gets or sets the id of the morph Target
  111567. */
  111568. id: string;
  111569. private _animationPropertiesOverride;
  111570. /**
  111571. * Gets or sets the animation properties override
  111572. */
  111573. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111574. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111575. /**
  111576. * Creates a new MorphTarget
  111577. * @param name defines the name of the target
  111578. * @param influence defines the influence to use
  111579. * @param scene defines the scene the morphtarget belongs to
  111580. */
  111581. constructor(
  111582. /** defines the name of the target */
  111583. name: string, influence?: number, scene?: Nullable<Scene>);
  111584. /**
  111585. * Gets the unique ID of this manager
  111586. */
  111587. get uniqueId(): number;
  111588. /**
  111589. * Gets a boolean defining if the target contains position data
  111590. */
  111591. get hasPositions(): boolean;
  111592. /**
  111593. * Gets a boolean defining if the target contains normal data
  111594. */
  111595. get hasNormals(): boolean;
  111596. /**
  111597. * Gets a boolean defining if the target contains tangent data
  111598. */
  111599. get hasTangents(): boolean;
  111600. /**
  111601. * Gets a boolean defining if the target contains texture coordinates data
  111602. */
  111603. get hasUVs(): boolean;
  111604. /**
  111605. * Affects position data to this target
  111606. * @param data defines the position data to use
  111607. */
  111608. setPositions(data: Nullable<FloatArray>): void;
  111609. /**
  111610. * Gets the position data stored in this target
  111611. * @returns a FloatArray containing the position data (or null if not present)
  111612. */
  111613. getPositions(): Nullable<FloatArray>;
  111614. /**
  111615. * Affects normal data to this target
  111616. * @param data defines the normal data to use
  111617. */
  111618. setNormals(data: Nullable<FloatArray>): void;
  111619. /**
  111620. * Gets the normal data stored in this target
  111621. * @returns a FloatArray containing the normal data (or null if not present)
  111622. */
  111623. getNormals(): Nullable<FloatArray>;
  111624. /**
  111625. * Affects tangent data to this target
  111626. * @param data defines the tangent data to use
  111627. */
  111628. setTangents(data: Nullable<FloatArray>): void;
  111629. /**
  111630. * Gets the tangent data stored in this target
  111631. * @returns a FloatArray containing the tangent data (or null if not present)
  111632. */
  111633. getTangents(): Nullable<FloatArray>;
  111634. /**
  111635. * Affects texture coordinates data to this target
  111636. * @param data defines the texture coordinates data to use
  111637. */
  111638. setUVs(data: Nullable<FloatArray>): void;
  111639. /**
  111640. * Gets the texture coordinates data stored in this target
  111641. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  111642. */
  111643. getUVs(): Nullable<FloatArray>;
  111644. /**
  111645. * Clone the current target
  111646. * @returns a new MorphTarget
  111647. */
  111648. clone(): MorphTarget;
  111649. /**
  111650. * Serializes the current target into a Serialization object
  111651. * @returns the serialized object
  111652. */
  111653. serialize(): any;
  111654. /**
  111655. * Returns the string "MorphTarget"
  111656. * @returns "MorphTarget"
  111657. */
  111658. getClassName(): string;
  111659. /**
  111660. * Creates a new target from serialized data
  111661. * @param serializationObject defines the serialized data to use
  111662. * @returns a new MorphTarget
  111663. */
  111664. static Parse(serializationObject: any): MorphTarget;
  111665. /**
  111666. * Creates a MorphTarget from mesh data
  111667. * @param mesh defines the source mesh
  111668. * @param name defines the name to use for the new target
  111669. * @param influence defines the influence to attach to the target
  111670. * @returns a new MorphTarget
  111671. */
  111672. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  111673. }
  111674. }
  111675. declare module BABYLON {
  111676. /**
  111677. * This class is used to deform meshes using morphing between different targets
  111678. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111679. */
  111680. export class MorphTargetManager {
  111681. private _targets;
  111682. private _targetInfluenceChangedObservers;
  111683. private _targetDataLayoutChangedObservers;
  111684. private _activeTargets;
  111685. private _scene;
  111686. private _influences;
  111687. private _supportsNormals;
  111688. private _supportsTangents;
  111689. private _supportsUVs;
  111690. private _vertexCount;
  111691. private _uniqueId;
  111692. private _tempInfluences;
  111693. /**
  111694. * Gets or sets a boolean indicating if normals must be morphed
  111695. */
  111696. enableNormalMorphing: boolean;
  111697. /**
  111698. * Gets or sets a boolean indicating if tangents must be morphed
  111699. */
  111700. enableTangentMorphing: boolean;
  111701. /**
  111702. * Gets or sets a boolean indicating if UV must be morphed
  111703. */
  111704. enableUVMorphing: boolean;
  111705. /**
  111706. * Creates a new MorphTargetManager
  111707. * @param scene defines the current scene
  111708. */
  111709. constructor(scene?: Nullable<Scene>);
  111710. /**
  111711. * Gets the unique ID of this manager
  111712. */
  111713. get uniqueId(): number;
  111714. /**
  111715. * Gets the number of vertices handled by this manager
  111716. */
  111717. get vertexCount(): number;
  111718. /**
  111719. * Gets a boolean indicating if this manager supports morphing of normals
  111720. */
  111721. get supportsNormals(): boolean;
  111722. /**
  111723. * Gets a boolean indicating if this manager supports morphing of tangents
  111724. */
  111725. get supportsTangents(): boolean;
  111726. /**
  111727. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  111728. */
  111729. get supportsUVs(): boolean;
  111730. /**
  111731. * Gets the number of targets stored in this manager
  111732. */
  111733. get numTargets(): number;
  111734. /**
  111735. * Gets the number of influencers (ie. the number of targets with influences > 0)
  111736. */
  111737. get numInfluencers(): number;
  111738. /**
  111739. * Gets the list of influences (one per target)
  111740. */
  111741. get influences(): Float32Array;
  111742. /**
  111743. * Gets the active target at specified index. An active target is a target with an influence > 0
  111744. * @param index defines the index to check
  111745. * @returns the requested target
  111746. */
  111747. getActiveTarget(index: number): MorphTarget;
  111748. /**
  111749. * Gets the target at specified index
  111750. * @param index defines the index to check
  111751. * @returns the requested target
  111752. */
  111753. getTarget(index: number): MorphTarget;
  111754. /**
  111755. * Add a new target to this manager
  111756. * @param target defines the target to add
  111757. */
  111758. addTarget(target: MorphTarget): void;
  111759. /**
  111760. * Removes a target from the manager
  111761. * @param target defines the target to remove
  111762. */
  111763. removeTarget(target: MorphTarget): void;
  111764. /**
  111765. * Clone the current manager
  111766. * @returns a new MorphTargetManager
  111767. */
  111768. clone(): MorphTargetManager;
  111769. /**
  111770. * Serializes the current manager into a Serialization object
  111771. * @returns the serialized object
  111772. */
  111773. serialize(): any;
  111774. private _syncActiveTargets;
  111775. /**
  111776. * Syncrhonize the targets with all the meshes using this morph target manager
  111777. */
  111778. synchronize(): void;
  111779. /**
  111780. * Creates a new MorphTargetManager from serialized data
  111781. * @param serializationObject defines the serialized data
  111782. * @param scene defines the hosting scene
  111783. * @returns the new MorphTargetManager
  111784. */
  111785. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  111786. }
  111787. }
  111788. declare module BABYLON {
  111789. /**
  111790. * Class used to represent a specific level of detail of a mesh
  111791. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  111792. */
  111793. export class MeshLODLevel {
  111794. /** Defines the distance where this level should start being displayed */
  111795. distance: number;
  111796. /** Defines the mesh to use to render this level */
  111797. mesh: Nullable<Mesh>;
  111798. /**
  111799. * Creates a new LOD level
  111800. * @param distance defines the distance where this level should star being displayed
  111801. * @param mesh defines the mesh to use to render this level
  111802. */
  111803. constructor(
  111804. /** Defines the distance where this level should start being displayed */
  111805. distance: number,
  111806. /** Defines the mesh to use to render this level */
  111807. mesh: Nullable<Mesh>);
  111808. }
  111809. }
  111810. declare module BABYLON {
  111811. /**
  111812. * Helper class used to generate a canvas to manipulate images
  111813. */
  111814. export class CanvasGenerator {
  111815. /**
  111816. * Create a new canvas (or offscreen canvas depending on the context)
  111817. * @param width defines the expected width
  111818. * @param height defines the expected height
  111819. * @return a new canvas or offscreen canvas
  111820. */
  111821. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  111822. }
  111823. }
  111824. declare module BABYLON {
  111825. /**
  111826. * Mesh representing the gorund
  111827. */
  111828. export class GroundMesh extends Mesh {
  111829. /** If octree should be generated */
  111830. generateOctree: boolean;
  111831. private _heightQuads;
  111832. /** @hidden */
  111833. _subdivisionsX: number;
  111834. /** @hidden */
  111835. _subdivisionsY: number;
  111836. /** @hidden */
  111837. _width: number;
  111838. /** @hidden */
  111839. _height: number;
  111840. /** @hidden */
  111841. _minX: number;
  111842. /** @hidden */
  111843. _maxX: number;
  111844. /** @hidden */
  111845. _minZ: number;
  111846. /** @hidden */
  111847. _maxZ: number;
  111848. constructor(name: string, scene: Scene);
  111849. /**
  111850. * "GroundMesh"
  111851. * @returns "GroundMesh"
  111852. */
  111853. getClassName(): string;
  111854. /**
  111855. * The minimum of x and y subdivisions
  111856. */
  111857. get subdivisions(): number;
  111858. /**
  111859. * X subdivisions
  111860. */
  111861. get subdivisionsX(): number;
  111862. /**
  111863. * Y subdivisions
  111864. */
  111865. get subdivisionsY(): number;
  111866. /**
  111867. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  111868. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111869. * @param chunksCount the number of subdivisions for x and y
  111870. * @param octreeBlocksSize (Default: 32)
  111871. */
  111872. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  111873. /**
  111874. * Returns a height (y) value in the Worl system :
  111875. * the ground altitude at the coordinates (x, z) expressed in the World system.
  111876. * @param x x coordinate
  111877. * @param z z coordinate
  111878. * @returns the ground y position if (x, z) are outside the ground surface.
  111879. */
  111880. getHeightAtCoordinates(x: number, z: number): number;
  111881. /**
  111882. * Returns a normalized vector (Vector3) orthogonal to the ground
  111883. * at the ground coordinates (x, z) expressed in the World system.
  111884. * @param x x coordinate
  111885. * @param z z coordinate
  111886. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  111887. */
  111888. getNormalAtCoordinates(x: number, z: number): Vector3;
  111889. /**
  111890. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  111891. * at the ground coordinates (x, z) expressed in the World system.
  111892. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  111893. * @param x x coordinate
  111894. * @param z z coordinate
  111895. * @param ref vector to store the result
  111896. * @returns the GroundMesh.
  111897. */
  111898. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  111899. /**
  111900. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  111901. * if the ground has been updated.
  111902. * This can be used in the render loop.
  111903. * @returns the GroundMesh.
  111904. */
  111905. updateCoordinateHeights(): GroundMesh;
  111906. private _getFacetAt;
  111907. private _initHeightQuads;
  111908. private _computeHeightQuads;
  111909. /**
  111910. * Serializes this ground mesh
  111911. * @param serializationObject object to write serialization to
  111912. */
  111913. serialize(serializationObject: any): void;
  111914. /**
  111915. * Parses a serialized ground mesh
  111916. * @param parsedMesh the serialized mesh
  111917. * @param scene the scene to create the ground mesh in
  111918. * @returns the created ground mesh
  111919. */
  111920. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  111921. }
  111922. }
  111923. declare module BABYLON {
  111924. /**
  111925. * Interface for Physics-Joint data
  111926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111927. */
  111928. export interface PhysicsJointData {
  111929. /**
  111930. * The main pivot of the joint
  111931. */
  111932. mainPivot?: Vector3;
  111933. /**
  111934. * The connected pivot of the joint
  111935. */
  111936. connectedPivot?: Vector3;
  111937. /**
  111938. * The main axis of the joint
  111939. */
  111940. mainAxis?: Vector3;
  111941. /**
  111942. * The connected axis of the joint
  111943. */
  111944. connectedAxis?: Vector3;
  111945. /**
  111946. * The collision of the joint
  111947. */
  111948. collision?: boolean;
  111949. /**
  111950. * Native Oimo/Cannon/Energy data
  111951. */
  111952. nativeParams?: any;
  111953. }
  111954. /**
  111955. * This is a holder class for the physics joint created by the physics plugin
  111956. * It holds a set of functions to control the underlying joint
  111957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111958. */
  111959. export class PhysicsJoint {
  111960. /**
  111961. * The type of the physics joint
  111962. */
  111963. type: number;
  111964. /**
  111965. * The data for the physics joint
  111966. */
  111967. jointData: PhysicsJointData;
  111968. private _physicsJoint;
  111969. protected _physicsPlugin: IPhysicsEnginePlugin;
  111970. /**
  111971. * Initializes the physics joint
  111972. * @param type The type of the physics joint
  111973. * @param jointData The data for the physics joint
  111974. */
  111975. constructor(
  111976. /**
  111977. * The type of the physics joint
  111978. */
  111979. type: number,
  111980. /**
  111981. * The data for the physics joint
  111982. */
  111983. jointData: PhysicsJointData);
  111984. /**
  111985. * Gets the physics joint
  111986. */
  111987. get physicsJoint(): any;
  111988. /**
  111989. * Sets the physics joint
  111990. */
  111991. set physicsJoint(newJoint: any);
  111992. /**
  111993. * Sets the physics plugin
  111994. */
  111995. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  111996. /**
  111997. * Execute a function that is physics-plugin specific.
  111998. * @param {Function} func the function that will be executed.
  111999. * It accepts two parameters: the physics world and the physics joint
  112000. */
  112001. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112002. /**
  112003. * Distance-Joint type
  112004. */
  112005. static DistanceJoint: number;
  112006. /**
  112007. * Hinge-Joint type
  112008. */
  112009. static HingeJoint: number;
  112010. /**
  112011. * Ball-and-Socket joint type
  112012. */
  112013. static BallAndSocketJoint: number;
  112014. /**
  112015. * Wheel-Joint type
  112016. */
  112017. static WheelJoint: number;
  112018. /**
  112019. * Slider-Joint type
  112020. */
  112021. static SliderJoint: number;
  112022. /**
  112023. * Prismatic-Joint type
  112024. */
  112025. static PrismaticJoint: number;
  112026. /**
  112027. * Universal-Joint type
  112028. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112029. */
  112030. static UniversalJoint: number;
  112031. /**
  112032. * Hinge-Joint 2 type
  112033. */
  112034. static Hinge2Joint: number;
  112035. /**
  112036. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112037. */
  112038. static PointToPointJoint: number;
  112039. /**
  112040. * Spring-Joint type
  112041. */
  112042. static SpringJoint: number;
  112043. /**
  112044. * Lock-Joint type
  112045. */
  112046. static LockJoint: number;
  112047. }
  112048. /**
  112049. * A class representing a physics distance joint
  112050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112051. */
  112052. export class DistanceJoint extends PhysicsJoint {
  112053. /**
  112054. *
  112055. * @param jointData The data for the Distance-Joint
  112056. */
  112057. constructor(jointData: DistanceJointData);
  112058. /**
  112059. * Update the predefined distance.
  112060. * @param maxDistance The maximum preferred distance
  112061. * @param minDistance The minimum preferred distance
  112062. */
  112063. updateDistance(maxDistance: number, minDistance?: number): void;
  112064. }
  112065. /**
  112066. * Represents a Motor-Enabled Joint
  112067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112068. */
  112069. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112070. /**
  112071. * Initializes the Motor-Enabled Joint
  112072. * @param type The type of the joint
  112073. * @param jointData The physica joint data for the joint
  112074. */
  112075. constructor(type: number, jointData: PhysicsJointData);
  112076. /**
  112077. * Set the motor values.
  112078. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112079. * @param force the force to apply
  112080. * @param maxForce max force for this motor.
  112081. */
  112082. setMotor(force?: number, maxForce?: number): void;
  112083. /**
  112084. * Set the motor's limits.
  112085. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112086. * @param upperLimit The upper limit of the motor
  112087. * @param lowerLimit The lower limit of the motor
  112088. */
  112089. setLimit(upperLimit: number, lowerLimit?: number): void;
  112090. }
  112091. /**
  112092. * This class represents a single physics Hinge-Joint
  112093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112094. */
  112095. export class HingeJoint extends MotorEnabledJoint {
  112096. /**
  112097. * Initializes the Hinge-Joint
  112098. * @param jointData The joint data for the Hinge-Joint
  112099. */
  112100. constructor(jointData: PhysicsJointData);
  112101. /**
  112102. * Set the motor values.
  112103. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112104. * @param {number} force the force to apply
  112105. * @param {number} maxForce max force for this motor.
  112106. */
  112107. setMotor(force?: number, maxForce?: number): void;
  112108. /**
  112109. * Set the motor's limits.
  112110. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112111. * @param upperLimit The upper limit of the motor
  112112. * @param lowerLimit The lower limit of the motor
  112113. */
  112114. setLimit(upperLimit: number, lowerLimit?: number): void;
  112115. }
  112116. /**
  112117. * This class represents a dual hinge physics joint (same as wheel joint)
  112118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112119. */
  112120. export class Hinge2Joint extends MotorEnabledJoint {
  112121. /**
  112122. * Initializes the Hinge2-Joint
  112123. * @param jointData The joint data for the Hinge2-Joint
  112124. */
  112125. constructor(jointData: PhysicsJointData);
  112126. /**
  112127. * Set the motor values.
  112128. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112129. * @param {number} targetSpeed the speed the motor is to reach
  112130. * @param {number} maxForce max force for this motor.
  112131. * @param {motorIndex} the motor's index, 0 or 1.
  112132. */
  112133. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112134. /**
  112135. * Set the motor limits.
  112136. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112137. * @param {number} upperLimit the upper limit
  112138. * @param {number} lowerLimit lower limit
  112139. * @param {motorIndex} the motor's index, 0 or 1.
  112140. */
  112141. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112142. }
  112143. /**
  112144. * Interface for a motor enabled joint
  112145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112146. */
  112147. export interface IMotorEnabledJoint {
  112148. /**
  112149. * Physics joint
  112150. */
  112151. physicsJoint: any;
  112152. /**
  112153. * Sets the motor of the motor-enabled joint
  112154. * @param force The force of the motor
  112155. * @param maxForce The maximum force of the motor
  112156. * @param motorIndex The index of the motor
  112157. */
  112158. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112159. /**
  112160. * Sets the limit of the motor
  112161. * @param upperLimit The upper limit of the motor
  112162. * @param lowerLimit The lower limit of the motor
  112163. * @param motorIndex The index of the motor
  112164. */
  112165. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112166. }
  112167. /**
  112168. * Joint data for a Distance-Joint
  112169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112170. */
  112171. export interface DistanceJointData extends PhysicsJointData {
  112172. /**
  112173. * Max distance the 2 joint objects can be apart
  112174. */
  112175. maxDistance: number;
  112176. }
  112177. /**
  112178. * Joint data from a spring joint
  112179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112180. */
  112181. export interface SpringJointData extends PhysicsJointData {
  112182. /**
  112183. * Length of the spring
  112184. */
  112185. length: number;
  112186. /**
  112187. * Stiffness of the spring
  112188. */
  112189. stiffness: number;
  112190. /**
  112191. * Damping of the spring
  112192. */
  112193. damping: number;
  112194. /** this callback will be called when applying the force to the impostors. */
  112195. forceApplicationCallback: () => void;
  112196. }
  112197. }
  112198. declare module BABYLON {
  112199. /**
  112200. * Holds the data for the raycast result
  112201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112202. */
  112203. export class PhysicsRaycastResult {
  112204. private _hasHit;
  112205. private _hitDistance;
  112206. private _hitNormalWorld;
  112207. private _hitPointWorld;
  112208. private _rayFromWorld;
  112209. private _rayToWorld;
  112210. /**
  112211. * Gets if there was a hit
  112212. */
  112213. get hasHit(): boolean;
  112214. /**
  112215. * Gets the distance from the hit
  112216. */
  112217. get hitDistance(): number;
  112218. /**
  112219. * Gets the hit normal/direction in the world
  112220. */
  112221. get hitNormalWorld(): Vector3;
  112222. /**
  112223. * Gets the hit point in the world
  112224. */
  112225. get hitPointWorld(): Vector3;
  112226. /**
  112227. * Gets the ray "start point" of the ray in the world
  112228. */
  112229. get rayFromWorld(): Vector3;
  112230. /**
  112231. * Gets the ray "end point" of the ray in the world
  112232. */
  112233. get rayToWorld(): Vector3;
  112234. /**
  112235. * Sets the hit data (normal & point in world space)
  112236. * @param hitNormalWorld defines the normal in world space
  112237. * @param hitPointWorld defines the point in world space
  112238. */
  112239. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112240. /**
  112241. * Sets the distance from the start point to the hit point
  112242. * @param distance
  112243. */
  112244. setHitDistance(distance: number): void;
  112245. /**
  112246. * Calculates the distance manually
  112247. */
  112248. calculateHitDistance(): void;
  112249. /**
  112250. * Resets all the values to default
  112251. * @param from The from point on world space
  112252. * @param to The to point on world space
  112253. */
  112254. reset(from?: Vector3, to?: Vector3): void;
  112255. }
  112256. /**
  112257. * Interface for the size containing width and height
  112258. */
  112259. interface IXYZ {
  112260. /**
  112261. * X
  112262. */
  112263. x: number;
  112264. /**
  112265. * Y
  112266. */
  112267. y: number;
  112268. /**
  112269. * Z
  112270. */
  112271. z: number;
  112272. }
  112273. }
  112274. declare module BABYLON {
  112275. /**
  112276. * Interface used to describe a physics joint
  112277. */
  112278. export interface PhysicsImpostorJoint {
  112279. /** Defines the main impostor to which the joint is linked */
  112280. mainImpostor: PhysicsImpostor;
  112281. /** Defines the impostor that is connected to the main impostor using this joint */
  112282. connectedImpostor: PhysicsImpostor;
  112283. /** Defines the joint itself */
  112284. joint: PhysicsJoint;
  112285. }
  112286. /** @hidden */
  112287. export interface IPhysicsEnginePlugin {
  112288. world: any;
  112289. name: string;
  112290. setGravity(gravity: Vector3): void;
  112291. setTimeStep(timeStep: number): void;
  112292. getTimeStep(): number;
  112293. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112294. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112295. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112296. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112297. removePhysicsBody(impostor: PhysicsImpostor): void;
  112298. generateJoint(joint: PhysicsImpostorJoint): void;
  112299. removeJoint(joint: PhysicsImpostorJoint): void;
  112300. isSupported(): boolean;
  112301. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112302. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112303. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112304. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112305. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112306. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112307. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112308. getBodyMass(impostor: PhysicsImpostor): number;
  112309. getBodyFriction(impostor: PhysicsImpostor): number;
  112310. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112311. getBodyRestitution(impostor: PhysicsImpostor): number;
  112312. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112313. getBodyPressure?(impostor: PhysicsImpostor): number;
  112314. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  112315. getBodyStiffness?(impostor: PhysicsImpostor): number;
  112316. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  112317. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  112318. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  112319. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  112320. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  112321. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112322. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112323. sleepBody(impostor: PhysicsImpostor): void;
  112324. wakeUpBody(impostor: PhysicsImpostor): void;
  112325. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112326. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112327. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  112328. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112329. getRadius(impostor: PhysicsImpostor): number;
  112330. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112331. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112332. dispose(): void;
  112333. }
  112334. /**
  112335. * Interface used to define a physics engine
  112336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112337. */
  112338. export interface IPhysicsEngine {
  112339. /**
  112340. * Gets the gravity vector used by the simulation
  112341. */
  112342. gravity: Vector3;
  112343. /**
  112344. * Sets the gravity vector used by the simulation
  112345. * @param gravity defines the gravity vector to use
  112346. */
  112347. setGravity(gravity: Vector3): void;
  112348. /**
  112349. * Set the time step of the physics engine.
  112350. * Default is 1/60.
  112351. * To slow it down, enter 1/600 for example.
  112352. * To speed it up, 1/30
  112353. * @param newTimeStep the new timestep to apply to this world.
  112354. */
  112355. setTimeStep(newTimeStep: number): void;
  112356. /**
  112357. * Get the time step of the physics engine.
  112358. * @returns the current time step
  112359. */
  112360. getTimeStep(): number;
  112361. /**
  112362. * Set the sub time step of the physics engine.
  112363. * Default is 0 meaning there is no sub steps
  112364. * To increase physics resolution precision, set a small value (like 1 ms)
  112365. * @param subTimeStep defines the new sub timestep used for physics resolution.
  112366. */
  112367. setSubTimeStep(subTimeStep: number): void;
  112368. /**
  112369. * Get the sub time step of the physics engine.
  112370. * @returns the current sub time step
  112371. */
  112372. getSubTimeStep(): number;
  112373. /**
  112374. * Release all resources
  112375. */
  112376. dispose(): void;
  112377. /**
  112378. * Gets the name of the current physics plugin
  112379. * @returns the name of the plugin
  112380. */
  112381. getPhysicsPluginName(): string;
  112382. /**
  112383. * Adding a new impostor for the impostor tracking.
  112384. * This will be done by the impostor itself.
  112385. * @param impostor the impostor to add
  112386. */
  112387. addImpostor(impostor: PhysicsImpostor): void;
  112388. /**
  112389. * Remove an impostor from the engine.
  112390. * This impostor and its mesh will not longer be updated by the physics engine.
  112391. * @param impostor the impostor to remove
  112392. */
  112393. removeImpostor(impostor: PhysicsImpostor): void;
  112394. /**
  112395. * Add a joint to the physics engine
  112396. * @param mainImpostor defines the main impostor to which the joint is added.
  112397. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112398. * @param joint defines the joint that will connect both impostors.
  112399. */
  112400. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112401. /**
  112402. * Removes a joint from the simulation
  112403. * @param mainImpostor defines the impostor used with the joint
  112404. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112405. * @param joint defines the joint to remove
  112406. */
  112407. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112408. /**
  112409. * Gets the current plugin used to run the simulation
  112410. * @returns current plugin
  112411. */
  112412. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112413. /**
  112414. * Gets the list of physic impostors
  112415. * @returns an array of PhysicsImpostor
  112416. */
  112417. getImpostors(): Array<PhysicsImpostor>;
  112418. /**
  112419. * Gets the impostor for a physics enabled object
  112420. * @param object defines the object impersonated by the impostor
  112421. * @returns the PhysicsImpostor or null if not found
  112422. */
  112423. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112424. /**
  112425. * Gets the impostor for a physics body object
  112426. * @param body defines physics body used by the impostor
  112427. * @returns the PhysicsImpostor or null if not found
  112428. */
  112429. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112430. /**
  112431. * Does a raycast in the physics world
  112432. * @param from when should the ray start?
  112433. * @param to when should the ray end?
  112434. * @returns PhysicsRaycastResult
  112435. */
  112436. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112437. /**
  112438. * Called by the scene. No need to call it.
  112439. * @param delta defines the timespam between frames
  112440. */
  112441. _step(delta: number): void;
  112442. }
  112443. }
  112444. declare module BABYLON {
  112445. /**
  112446. * The interface for the physics imposter parameters
  112447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112448. */
  112449. export interface PhysicsImpostorParameters {
  112450. /**
  112451. * The mass of the physics imposter
  112452. */
  112453. mass: number;
  112454. /**
  112455. * The friction of the physics imposter
  112456. */
  112457. friction?: number;
  112458. /**
  112459. * The coefficient of restitution of the physics imposter
  112460. */
  112461. restitution?: number;
  112462. /**
  112463. * The native options of the physics imposter
  112464. */
  112465. nativeOptions?: any;
  112466. /**
  112467. * Specifies if the parent should be ignored
  112468. */
  112469. ignoreParent?: boolean;
  112470. /**
  112471. * Specifies if bi-directional transformations should be disabled
  112472. */
  112473. disableBidirectionalTransformation?: boolean;
  112474. /**
  112475. * The pressure inside the physics imposter, soft object only
  112476. */
  112477. pressure?: number;
  112478. /**
  112479. * The stiffness the physics imposter, soft object only
  112480. */
  112481. stiffness?: number;
  112482. /**
  112483. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  112484. */
  112485. velocityIterations?: number;
  112486. /**
  112487. * The number of iterations used in maintaining consistent vertex positions, soft object only
  112488. */
  112489. positionIterations?: number;
  112490. /**
  112491. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  112492. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  112493. * Add to fix multiple points
  112494. */
  112495. fixedPoints?: number;
  112496. /**
  112497. * The collision margin around a soft object
  112498. */
  112499. margin?: number;
  112500. /**
  112501. * The collision margin around a soft object
  112502. */
  112503. damping?: number;
  112504. /**
  112505. * The path for a rope based on an extrusion
  112506. */
  112507. path?: any;
  112508. /**
  112509. * The shape of an extrusion used for a rope based on an extrusion
  112510. */
  112511. shape?: any;
  112512. }
  112513. /**
  112514. * Interface for a physics-enabled object
  112515. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112516. */
  112517. export interface IPhysicsEnabledObject {
  112518. /**
  112519. * The position of the physics-enabled object
  112520. */
  112521. position: Vector3;
  112522. /**
  112523. * The rotation of the physics-enabled object
  112524. */
  112525. rotationQuaternion: Nullable<Quaternion>;
  112526. /**
  112527. * The scale of the physics-enabled object
  112528. */
  112529. scaling: Vector3;
  112530. /**
  112531. * The rotation of the physics-enabled object
  112532. */
  112533. rotation?: Vector3;
  112534. /**
  112535. * The parent of the physics-enabled object
  112536. */
  112537. parent?: any;
  112538. /**
  112539. * The bounding info of the physics-enabled object
  112540. * @returns The bounding info of the physics-enabled object
  112541. */
  112542. getBoundingInfo(): BoundingInfo;
  112543. /**
  112544. * Computes the world matrix
  112545. * @param force Specifies if the world matrix should be computed by force
  112546. * @returns A world matrix
  112547. */
  112548. computeWorldMatrix(force: boolean): Matrix;
  112549. /**
  112550. * Gets the world matrix
  112551. * @returns A world matrix
  112552. */
  112553. getWorldMatrix?(): Matrix;
  112554. /**
  112555. * Gets the child meshes
  112556. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  112557. * @returns An array of abstract meshes
  112558. */
  112559. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  112560. /**
  112561. * Gets the vertex data
  112562. * @param kind The type of vertex data
  112563. * @returns A nullable array of numbers, or a float32 array
  112564. */
  112565. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  112566. /**
  112567. * Gets the indices from the mesh
  112568. * @returns A nullable array of index arrays
  112569. */
  112570. getIndices?(): Nullable<IndicesArray>;
  112571. /**
  112572. * Gets the scene from the mesh
  112573. * @returns the indices array or null
  112574. */
  112575. getScene?(): Scene;
  112576. /**
  112577. * Gets the absolute position from the mesh
  112578. * @returns the absolute position
  112579. */
  112580. getAbsolutePosition(): Vector3;
  112581. /**
  112582. * Gets the absolute pivot point from the mesh
  112583. * @returns the absolute pivot point
  112584. */
  112585. getAbsolutePivotPoint(): Vector3;
  112586. /**
  112587. * Rotates the mesh
  112588. * @param axis The axis of rotation
  112589. * @param amount The amount of rotation
  112590. * @param space The space of the rotation
  112591. * @returns The rotation transform node
  112592. */
  112593. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  112594. /**
  112595. * Translates the mesh
  112596. * @param axis The axis of translation
  112597. * @param distance The distance of translation
  112598. * @param space The space of the translation
  112599. * @returns The transform node
  112600. */
  112601. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  112602. /**
  112603. * Sets the absolute position of the mesh
  112604. * @param absolutePosition The absolute position of the mesh
  112605. * @returns The transform node
  112606. */
  112607. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  112608. /**
  112609. * Gets the class name of the mesh
  112610. * @returns The class name
  112611. */
  112612. getClassName(): string;
  112613. }
  112614. /**
  112615. * Represents a physics imposter
  112616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112617. */
  112618. export class PhysicsImpostor {
  112619. /**
  112620. * The physics-enabled object used as the physics imposter
  112621. */
  112622. object: IPhysicsEnabledObject;
  112623. /**
  112624. * The type of the physics imposter
  112625. */
  112626. type: number;
  112627. private _options;
  112628. private _scene?;
  112629. /**
  112630. * The default object size of the imposter
  112631. */
  112632. static DEFAULT_OBJECT_SIZE: Vector3;
  112633. /**
  112634. * The identity quaternion of the imposter
  112635. */
  112636. static IDENTITY_QUATERNION: Quaternion;
  112637. /** @hidden */
  112638. _pluginData: any;
  112639. private _physicsEngine;
  112640. private _physicsBody;
  112641. private _bodyUpdateRequired;
  112642. private _onBeforePhysicsStepCallbacks;
  112643. private _onAfterPhysicsStepCallbacks;
  112644. /** @hidden */
  112645. _onPhysicsCollideCallbacks: Array<{
  112646. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  112647. otherImpostors: Array<PhysicsImpostor>;
  112648. }>;
  112649. private _deltaPosition;
  112650. private _deltaRotation;
  112651. private _deltaRotationConjugated;
  112652. /** @hidden */
  112653. _isFromLine: boolean;
  112654. private _parent;
  112655. private _isDisposed;
  112656. private static _tmpVecs;
  112657. private static _tmpQuat;
  112658. /**
  112659. * Specifies if the physics imposter is disposed
  112660. */
  112661. get isDisposed(): boolean;
  112662. /**
  112663. * Gets the mass of the physics imposter
  112664. */
  112665. get mass(): number;
  112666. set mass(value: number);
  112667. /**
  112668. * Gets the coefficient of friction
  112669. */
  112670. get friction(): number;
  112671. /**
  112672. * Sets the coefficient of friction
  112673. */
  112674. set friction(value: number);
  112675. /**
  112676. * Gets the coefficient of restitution
  112677. */
  112678. get restitution(): number;
  112679. /**
  112680. * Sets the coefficient of restitution
  112681. */
  112682. set restitution(value: number);
  112683. /**
  112684. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  112685. */
  112686. get pressure(): number;
  112687. /**
  112688. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  112689. */
  112690. set pressure(value: number);
  112691. /**
  112692. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112693. */
  112694. get stiffness(): number;
  112695. /**
  112696. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112697. */
  112698. set stiffness(value: number);
  112699. /**
  112700. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112701. */
  112702. get velocityIterations(): number;
  112703. /**
  112704. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112705. */
  112706. set velocityIterations(value: number);
  112707. /**
  112708. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112709. */
  112710. get positionIterations(): number;
  112711. /**
  112712. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112713. */
  112714. set positionIterations(value: number);
  112715. /**
  112716. * The unique id of the physics imposter
  112717. * set by the physics engine when adding this impostor to the array
  112718. */
  112719. uniqueId: number;
  112720. /**
  112721. * @hidden
  112722. */
  112723. soft: boolean;
  112724. /**
  112725. * @hidden
  112726. */
  112727. segments: number;
  112728. private _joints;
  112729. /**
  112730. * Initializes the physics imposter
  112731. * @param object The physics-enabled object used as the physics imposter
  112732. * @param type The type of the physics imposter
  112733. * @param _options The options for the physics imposter
  112734. * @param _scene The Babylon scene
  112735. */
  112736. constructor(
  112737. /**
  112738. * The physics-enabled object used as the physics imposter
  112739. */
  112740. object: IPhysicsEnabledObject,
  112741. /**
  112742. * The type of the physics imposter
  112743. */
  112744. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  112745. /**
  112746. * This function will completly initialize this impostor.
  112747. * It will create a new body - but only if this mesh has no parent.
  112748. * If it has, this impostor will not be used other than to define the impostor
  112749. * of the child mesh.
  112750. * @hidden
  112751. */
  112752. _init(): void;
  112753. private _getPhysicsParent;
  112754. /**
  112755. * Should a new body be generated.
  112756. * @returns boolean specifying if body initialization is required
  112757. */
  112758. isBodyInitRequired(): boolean;
  112759. /**
  112760. * Sets the updated scaling
  112761. * @param updated Specifies if the scaling is updated
  112762. */
  112763. setScalingUpdated(): void;
  112764. /**
  112765. * Force a regeneration of this or the parent's impostor's body.
  112766. * Use under cautious - This will remove all joints already implemented.
  112767. */
  112768. forceUpdate(): void;
  112769. /**
  112770. * Gets the body that holds this impostor. Either its own, or its parent.
  112771. */
  112772. get physicsBody(): any;
  112773. /**
  112774. * Get the parent of the physics imposter
  112775. * @returns Physics imposter or null
  112776. */
  112777. get parent(): Nullable<PhysicsImpostor>;
  112778. /**
  112779. * Sets the parent of the physics imposter
  112780. */
  112781. set parent(value: Nullable<PhysicsImpostor>);
  112782. /**
  112783. * Set the physics body. Used mainly by the physics engine/plugin
  112784. */
  112785. set physicsBody(physicsBody: any);
  112786. /**
  112787. * Resets the update flags
  112788. */
  112789. resetUpdateFlags(): void;
  112790. /**
  112791. * Gets the object extend size
  112792. * @returns the object extend size
  112793. */
  112794. getObjectExtendSize(): Vector3;
  112795. /**
  112796. * Gets the object center
  112797. * @returns The object center
  112798. */
  112799. getObjectCenter(): Vector3;
  112800. /**
  112801. * Get a specific parameter from the options parameters
  112802. * @param paramName The object parameter name
  112803. * @returns The object parameter
  112804. */
  112805. getParam(paramName: string): any;
  112806. /**
  112807. * Sets a specific parameter in the options given to the physics plugin
  112808. * @param paramName The parameter name
  112809. * @param value The value of the parameter
  112810. */
  112811. setParam(paramName: string, value: number): void;
  112812. /**
  112813. * Specifically change the body's mass option. Won't recreate the physics body object
  112814. * @param mass The mass of the physics imposter
  112815. */
  112816. setMass(mass: number): void;
  112817. /**
  112818. * Gets the linear velocity
  112819. * @returns linear velocity or null
  112820. */
  112821. getLinearVelocity(): Nullable<Vector3>;
  112822. /**
  112823. * Sets the linear velocity
  112824. * @param velocity linear velocity or null
  112825. */
  112826. setLinearVelocity(velocity: Nullable<Vector3>): void;
  112827. /**
  112828. * Gets the angular velocity
  112829. * @returns angular velocity or null
  112830. */
  112831. getAngularVelocity(): Nullable<Vector3>;
  112832. /**
  112833. * Sets the angular velocity
  112834. * @param velocity The velocity or null
  112835. */
  112836. setAngularVelocity(velocity: Nullable<Vector3>): void;
  112837. /**
  112838. * Execute a function with the physics plugin native code
  112839. * Provide a function the will have two variables - the world object and the physics body object
  112840. * @param func The function to execute with the physics plugin native code
  112841. */
  112842. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  112843. /**
  112844. * Register a function that will be executed before the physics world is stepping forward
  112845. * @param func The function to execute before the physics world is stepped forward
  112846. */
  112847. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112848. /**
  112849. * Unregister a function that will be executed before the physics world is stepping forward
  112850. * @param func The function to execute before the physics world is stepped forward
  112851. */
  112852. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112853. /**
  112854. * Register a function that will be executed after the physics step
  112855. * @param func The function to execute after physics step
  112856. */
  112857. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112858. /**
  112859. * Unregisters a function that will be executed after the physics step
  112860. * @param func The function to execute after physics step
  112861. */
  112862. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112863. /**
  112864. * register a function that will be executed when this impostor collides against a different body
  112865. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  112866. * @param func Callback that is executed on collision
  112867. */
  112868. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  112869. /**
  112870. * Unregisters the physics imposter on contact
  112871. * @param collideAgainst The physics object to collide against
  112872. * @param func Callback to execute on collision
  112873. */
  112874. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  112875. private _tmpQuat;
  112876. private _tmpQuat2;
  112877. /**
  112878. * Get the parent rotation
  112879. * @returns The parent rotation
  112880. */
  112881. getParentsRotation(): Quaternion;
  112882. /**
  112883. * this function is executed by the physics engine.
  112884. */
  112885. beforeStep: () => void;
  112886. /**
  112887. * this function is executed by the physics engine
  112888. */
  112889. afterStep: () => void;
  112890. /**
  112891. * Legacy collision detection event support
  112892. */
  112893. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  112894. /**
  112895. * event and body object due to cannon's event-based architecture.
  112896. */
  112897. onCollide: (e: {
  112898. body: any;
  112899. }) => void;
  112900. /**
  112901. * Apply a force
  112902. * @param force The force to apply
  112903. * @param contactPoint The contact point for the force
  112904. * @returns The physics imposter
  112905. */
  112906. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  112907. /**
  112908. * Apply an impulse
  112909. * @param force The impulse force
  112910. * @param contactPoint The contact point for the impulse force
  112911. * @returns The physics imposter
  112912. */
  112913. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  112914. /**
  112915. * A help function to create a joint
  112916. * @param otherImpostor A physics imposter used to create a joint
  112917. * @param jointType The type of joint
  112918. * @param jointData The data for the joint
  112919. * @returns The physics imposter
  112920. */
  112921. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  112922. /**
  112923. * Add a joint to this impostor with a different impostor
  112924. * @param otherImpostor A physics imposter used to add a joint
  112925. * @param joint The joint to add
  112926. * @returns The physics imposter
  112927. */
  112928. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  112929. /**
  112930. * Add an anchor to a cloth impostor
  112931. * @param otherImpostor rigid impostor to anchor to
  112932. * @param width ratio across width from 0 to 1
  112933. * @param height ratio up height from 0 to 1
  112934. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112935. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  112936. * @returns impostor the soft imposter
  112937. */
  112938. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  112939. /**
  112940. * Add a hook to a rope impostor
  112941. * @param otherImpostor rigid impostor to anchor to
  112942. * @param length ratio across rope from 0 to 1
  112943. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  112944. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112945. * @returns impostor the rope imposter
  112946. */
  112947. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  112948. /**
  112949. * Will keep this body still, in a sleep mode.
  112950. * @returns the physics imposter
  112951. */
  112952. sleep(): PhysicsImpostor;
  112953. /**
  112954. * Wake the body up.
  112955. * @returns The physics imposter
  112956. */
  112957. wakeUp(): PhysicsImpostor;
  112958. /**
  112959. * Clones the physics imposter
  112960. * @param newObject The physics imposter clones to this physics-enabled object
  112961. * @returns A nullable physics imposter
  112962. */
  112963. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112964. /**
  112965. * Disposes the physics imposter
  112966. */
  112967. dispose(): void;
  112968. /**
  112969. * Sets the delta position
  112970. * @param position The delta position amount
  112971. */
  112972. setDeltaPosition(position: Vector3): void;
  112973. /**
  112974. * Sets the delta rotation
  112975. * @param rotation The delta rotation amount
  112976. */
  112977. setDeltaRotation(rotation: Quaternion): void;
  112978. /**
  112979. * Gets the box size of the physics imposter and stores the result in the input parameter
  112980. * @param result Stores the box size
  112981. * @returns The physics imposter
  112982. */
  112983. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  112984. /**
  112985. * Gets the radius of the physics imposter
  112986. * @returns Radius of the physics imposter
  112987. */
  112988. getRadius(): number;
  112989. /**
  112990. * Sync a bone with this impostor
  112991. * @param bone The bone to sync to the impostor.
  112992. * @param boneMesh The mesh that the bone is influencing.
  112993. * @param jointPivot The pivot of the joint / bone in local space.
  112994. * @param distToJoint Optional distance from the impostor to the joint.
  112995. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112996. */
  112997. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  112998. /**
  112999. * Sync impostor to a bone
  113000. * @param bone The bone that the impostor will be synced to.
  113001. * @param boneMesh The mesh that the bone is influencing.
  113002. * @param jointPivot The pivot of the joint / bone in local space.
  113003. * @param distToJoint Optional distance from the impostor to the joint.
  113004. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113005. * @param boneAxis Optional vector3 axis the bone is aligned with
  113006. */
  113007. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113008. /**
  113009. * No-Imposter type
  113010. */
  113011. static NoImpostor: number;
  113012. /**
  113013. * Sphere-Imposter type
  113014. */
  113015. static SphereImpostor: number;
  113016. /**
  113017. * Box-Imposter type
  113018. */
  113019. static BoxImpostor: number;
  113020. /**
  113021. * Plane-Imposter type
  113022. */
  113023. static PlaneImpostor: number;
  113024. /**
  113025. * Mesh-imposter type
  113026. */
  113027. static MeshImpostor: number;
  113028. /**
  113029. * Capsule-Impostor type (Ammo.js plugin only)
  113030. */
  113031. static CapsuleImpostor: number;
  113032. /**
  113033. * Cylinder-Imposter type
  113034. */
  113035. static CylinderImpostor: number;
  113036. /**
  113037. * Particle-Imposter type
  113038. */
  113039. static ParticleImpostor: number;
  113040. /**
  113041. * Heightmap-Imposter type
  113042. */
  113043. static HeightmapImpostor: number;
  113044. /**
  113045. * ConvexHull-Impostor type (Ammo.js plugin only)
  113046. */
  113047. static ConvexHullImpostor: number;
  113048. /**
  113049. * Custom-Imposter type (Ammo.js plugin only)
  113050. */
  113051. static CustomImpostor: number;
  113052. /**
  113053. * Rope-Imposter type
  113054. */
  113055. static RopeImpostor: number;
  113056. /**
  113057. * Cloth-Imposter type
  113058. */
  113059. static ClothImpostor: number;
  113060. /**
  113061. * Softbody-Imposter type
  113062. */
  113063. static SoftbodyImpostor: number;
  113064. }
  113065. }
  113066. declare module BABYLON {
  113067. /**
  113068. * @hidden
  113069. **/
  113070. export class _CreationDataStorage {
  113071. closePath?: boolean;
  113072. closeArray?: boolean;
  113073. idx: number[];
  113074. dashSize: number;
  113075. gapSize: number;
  113076. path3D: Path3D;
  113077. pathArray: Vector3[][];
  113078. arc: number;
  113079. radius: number;
  113080. cap: number;
  113081. tessellation: number;
  113082. }
  113083. /**
  113084. * @hidden
  113085. **/
  113086. class _InstanceDataStorage {
  113087. visibleInstances: any;
  113088. batchCache: _InstancesBatch;
  113089. instancesBufferSize: number;
  113090. instancesBuffer: Nullable<Buffer>;
  113091. instancesData: Float32Array;
  113092. overridenInstanceCount: number;
  113093. isFrozen: boolean;
  113094. previousBatch: Nullable<_InstancesBatch>;
  113095. hardwareInstancedRendering: boolean;
  113096. sideOrientation: number;
  113097. manualUpdate: boolean;
  113098. previousRenderId: number;
  113099. }
  113100. /**
  113101. * @hidden
  113102. **/
  113103. export class _InstancesBatch {
  113104. mustReturn: boolean;
  113105. visibleInstances: Nullable<InstancedMesh[]>[];
  113106. renderSelf: boolean[];
  113107. hardwareInstancedRendering: boolean[];
  113108. }
  113109. /**
  113110. * @hidden
  113111. **/
  113112. class _ThinInstanceDataStorage {
  113113. instancesCount: number;
  113114. matrixBuffer: Nullable<Buffer>;
  113115. matrixBufferSize: number;
  113116. matrixData: Nullable<Float32Array>;
  113117. boundingVectors: Array<Vector3>;
  113118. worldMatrices: Nullable<Matrix[]>;
  113119. }
  113120. /**
  113121. * Class used to represent renderable models
  113122. */
  113123. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113124. /**
  113125. * Mesh side orientation : usually the external or front surface
  113126. */
  113127. static readonly FRONTSIDE: number;
  113128. /**
  113129. * Mesh side orientation : usually the internal or back surface
  113130. */
  113131. static readonly BACKSIDE: number;
  113132. /**
  113133. * Mesh side orientation : both internal and external or front and back surfaces
  113134. */
  113135. static readonly DOUBLESIDE: number;
  113136. /**
  113137. * Mesh side orientation : by default, `FRONTSIDE`
  113138. */
  113139. static readonly DEFAULTSIDE: number;
  113140. /**
  113141. * Mesh cap setting : no cap
  113142. */
  113143. static readonly NO_CAP: number;
  113144. /**
  113145. * Mesh cap setting : one cap at the beginning of the mesh
  113146. */
  113147. static readonly CAP_START: number;
  113148. /**
  113149. * Mesh cap setting : one cap at the end of the mesh
  113150. */
  113151. static readonly CAP_END: number;
  113152. /**
  113153. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113154. */
  113155. static readonly CAP_ALL: number;
  113156. /**
  113157. * Mesh pattern setting : no flip or rotate
  113158. */
  113159. static readonly NO_FLIP: number;
  113160. /**
  113161. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113162. */
  113163. static readonly FLIP_TILE: number;
  113164. /**
  113165. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113166. */
  113167. static readonly ROTATE_TILE: number;
  113168. /**
  113169. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113170. */
  113171. static readonly FLIP_ROW: number;
  113172. /**
  113173. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113174. */
  113175. static readonly ROTATE_ROW: number;
  113176. /**
  113177. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113178. */
  113179. static readonly FLIP_N_ROTATE_TILE: number;
  113180. /**
  113181. * Mesh pattern setting : rotate pattern and rotate
  113182. */
  113183. static readonly FLIP_N_ROTATE_ROW: number;
  113184. /**
  113185. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113186. */
  113187. static readonly CENTER: number;
  113188. /**
  113189. * Mesh tile positioning : part tiles on left
  113190. */
  113191. static readonly LEFT: number;
  113192. /**
  113193. * Mesh tile positioning : part tiles on right
  113194. */
  113195. static readonly RIGHT: number;
  113196. /**
  113197. * Mesh tile positioning : part tiles on top
  113198. */
  113199. static readonly TOP: number;
  113200. /**
  113201. * Mesh tile positioning : part tiles on bottom
  113202. */
  113203. static readonly BOTTOM: number;
  113204. /**
  113205. * Gets the default side orientation.
  113206. * @param orientation the orientation to value to attempt to get
  113207. * @returns the default orientation
  113208. * @hidden
  113209. */
  113210. static _GetDefaultSideOrientation(orientation?: number): number;
  113211. private _internalMeshDataInfo;
  113212. get computeBonesUsingShaders(): boolean;
  113213. set computeBonesUsingShaders(value: boolean);
  113214. /**
  113215. * An event triggered before rendering the mesh
  113216. */
  113217. get onBeforeRenderObservable(): Observable<Mesh>;
  113218. /**
  113219. * An event triggered before binding the mesh
  113220. */
  113221. get onBeforeBindObservable(): Observable<Mesh>;
  113222. /**
  113223. * An event triggered after rendering the mesh
  113224. */
  113225. get onAfterRenderObservable(): Observable<Mesh>;
  113226. /**
  113227. * An event triggered before drawing the mesh
  113228. */
  113229. get onBeforeDrawObservable(): Observable<Mesh>;
  113230. private _onBeforeDrawObserver;
  113231. /**
  113232. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113233. */
  113234. set onBeforeDraw(callback: () => void);
  113235. get hasInstances(): boolean;
  113236. get hasThinInstances(): boolean;
  113237. /**
  113238. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113239. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113240. */
  113241. delayLoadState: number;
  113242. /**
  113243. * Gets the list of instances created from this mesh
  113244. * it is not supposed to be modified manually.
  113245. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113246. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113247. */
  113248. instances: InstancedMesh[];
  113249. /**
  113250. * Gets the file containing delay loading data for this mesh
  113251. */
  113252. delayLoadingFile: string;
  113253. /** @hidden */
  113254. _binaryInfo: any;
  113255. /**
  113256. * User defined function used to change how LOD level selection is done
  113257. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113258. */
  113259. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113260. /**
  113261. * Gets or sets the morph target manager
  113262. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113263. */
  113264. get morphTargetManager(): Nullable<MorphTargetManager>;
  113265. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113266. /** @hidden */
  113267. _creationDataStorage: Nullable<_CreationDataStorage>;
  113268. /** @hidden */
  113269. _geometry: Nullable<Geometry>;
  113270. /** @hidden */
  113271. _delayInfo: Array<string>;
  113272. /** @hidden */
  113273. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  113274. /** @hidden */
  113275. _instanceDataStorage: _InstanceDataStorage;
  113276. /** @hidden */
  113277. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  113278. private _effectiveMaterial;
  113279. /** @hidden */
  113280. _shouldGenerateFlatShading: boolean;
  113281. /** @hidden */
  113282. _originalBuilderSideOrientation: number;
  113283. /**
  113284. * Use this property to change the original side orientation defined at construction time
  113285. */
  113286. overrideMaterialSideOrientation: Nullable<number>;
  113287. /**
  113288. * Gets the source mesh (the one used to clone this one from)
  113289. */
  113290. get source(): Nullable<Mesh>;
  113291. /**
  113292. * Gets the list of clones of this mesh
  113293. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  113294. * Note that useClonedMeshMap=true is the default setting
  113295. */
  113296. get cloneMeshMap(): Nullable<{
  113297. [id: string]: Mesh | undefined;
  113298. }>;
  113299. /**
  113300. * Gets or sets a boolean indicating that this mesh does not use index buffer
  113301. */
  113302. get isUnIndexed(): boolean;
  113303. set isUnIndexed(value: boolean);
  113304. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  113305. get worldMatrixInstancedBuffer(): Float32Array;
  113306. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  113307. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  113308. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  113309. /**
  113310. * @constructor
  113311. * @param name The value used by scene.getMeshByName() to do a lookup.
  113312. * @param scene The scene to add this mesh to.
  113313. * @param parent The parent of this mesh, if it has one
  113314. * @param source An optional Mesh from which geometry is shared, cloned.
  113315. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113316. * When false, achieved by calling a clone(), also passing False.
  113317. * This will make creation of children, recursive.
  113318. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  113319. */
  113320. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  113321. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  113322. doNotInstantiate: boolean;
  113323. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  113324. /**
  113325. * Gets the class name
  113326. * @returns the string "Mesh".
  113327. */
  113328. getClassName(): string;
  113329. /** @hidden */
  113330. get _isMesh(): boolean;
  113331. /**
  113332. * Returns a description of this mesh
  113333. * @param fullDetails define if full details about this mesh must be used
  113334. * @returns a descriptive string representing this mesh
  113335. */
  113336. toString(fullDetails?: boolean): string;
  113337. /** @hidden */
  113338. _unBindEffect(): void;
  113339. /**
  113340. * Gets a boolean indicating if this mesh has LOD
  113341. */
  113342. get hasLODLevels(): boolean;
  113343. /**
  113344. * Gets the list of MeshLODLevel associated with the current mesh
  113345. * @returns an array of MeshLODLevel
  113346. */
  113347. getLODLevels(): MeshLODLevel[];
  113348. private _sortLODLevels;
  113349. /**
  113350. * Add a mesh as LOD level triggered at the given distance.
  113351. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113352. * @param distance The distance from the center of the object to show this level
  113353. * @param mesh The mesh to be added as LOD level (can be null)
  113354. * @return This mesh (for chaining)
  113355. */
  113356. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  113357. /**
  113358. * Returns the LOD level mesh at the passed distance or null if not found.
  113359. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113360. * @param distance The distance from the center of the object to show this level
  113361. * @returns a Mesh or `null`
  113362. */
  113363. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  113364. /**
  113365. * Remove a mesh from the LOD array
  113366. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113367. * @param mesh defines the mesh to be removed
  113368. * @return This mesh (for chaining)
  113369. */
  113370. removeLODLevel(mesh: Mesh): Mesh;
  113371. /**
  113372. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  113373. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113374. * @param camera defines the camera to use to compute distance
  113375. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  113376. * @return This mesh (for chaining)
  113377. */
  113378. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  113379. /**
  113380. * Gets the mesh internal Geometry object
  113381. */
  113382. get geometry(): Nullable<Geometry>;
  113383. /**
  113384. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  113385. * @returns the total number of vertices
  113386. */
  113387. getTotalVertices(): number;
  113388. /**
  113389. * Returns the content of an associated vertex buffer
  113390. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113391. * - VertexBuffer.PositionKind
  113392. * - VertexBuffer.UVKind
  113393. * - VertexBuffer.UV2Kind
  113394. * - VertexBuffer.UV3Kind
  113395. * - VertexBuffer.UV4Kind
  113396. * - VertexBuffer.UV5Kind
  113397. * - VertexBuffer.UV6Kind
  113398. * - VertexBuffer.ColorKind
  113399. * - VertexBuffer.MatricesIndicesKind
  113400. * - VertexBuffer.MatricesIndicesExtraKind
  113401. * - VertexBuffer.MatricesWeightsKind
  113402. * - VertexBuffer.MatricesWeightsExtraKind
  113403. * @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
  113404. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  113405. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  113406. */
  113407. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  113408. /**
  113409. * Returns the mesh VertexBuffer object from the requested `kind`
  113410. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113411. * - VertexBuffer.PositionKind
  113412. * - VertexBuffer.NormalKind
  113413. * - VertexBuffer.UVKind
  113414. * - VertexBuffer.UV2Kind
  113415. * - VertexBuffer.UV3Kind
  113416. * - VertexBuffer.UV4Kind
  113417. * - VertexBuffer.UV5Kind
  113418. * - VertexBuffer.UV6Kind
  113419. * - VertexBuffer.ColorKind
  113420. * - VertexBuffer.MatricesIndicesKind
  113421. * - VertexBuffer.MatricesIndicesExtraKind
  113422. * - VertexBuffer.MatricesWeightsKind
  113423. * - VertexBuffer.MatricesWeightsExtraKind
  113424. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  113425. */
  113426. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  113427. /**
  113428. * Tests if a specific vertex buffer is associated with this mesh
  113429. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113430. * - VertexBuffer.PositionKind
  113431. * - VertexBuffer.NormalKind
  113432. * - VertexBuffer.UVKind
  113433. * - VertexBuffer.UV2Kind
  113434. * - VertexBuffer.UV3Kind
  113435. * - VertexBuffer.UV4Kind
  113436. * - VertexBuffer.UV5Kind
  113437. * - VertexBuffer.UV6Kind
  113438. * - VertexBuffer.ColorKind
  113439. * - VertexBuffer.MatricesIndicesKind
  113440. * - VertexBuffer.MatricesIndicesExtraKind
  113441. * - VertexBuffer.MatricesWeightsKind
  113442. * - VertexBuffer.MatricesWeightsExtraKind
  113443. * @returns a boolean
  113444. */
  113445. isVerticesDataPresent(kind: string): boolean;
  113446. /**
  113447. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  113448. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113449. * - VertexBuffer.PositionKind
  113450. * - VertexBuffer.UVKind
  113451. * - VertexBuffer.UV2Kind
  113452. * - VertexBuffer.UV3Kind
  113453. * - VertexBuffer.UV4Kind
  113454. * - VertexBuffer.UV5Kind
  113455. * - VertexBuffer.UV6Kind
  113456. * - VertexBuffer.ColorKind
  113457. * - VertexBuffer.MatricesIndicesKind
  113458. * - VertexBuffer.MatricesIndicesExtraKind
  113459. * - VertexBuffer.MatricesWeightsKind
  113460. * - VertexBuffer.MatricesWeightsExtraKind
  113461. * @returns a boolean
  113462. */
  113463. isVertexBufferUpdatable(kind: string): boolean;
  113464. /**
  113465. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  113466. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113467. * - VertexBuffer.PositionKind
  113468. * - VertexBuffer.NormalKind
  113469. * - VertexBuffer.UVKind
  113470. * - VertexBuffer.UV2Kind
  113471. * - VertexBuffer.UV3Kind
  113472. * - VertexBuffer.UV4Kind
  113473. * - VertexBuffer.UV5Kind
  113474. * - VertexBuffer.UV6Kind
  113475. * - VertexBuffer.ColorKind
  113476. * - VertexBuffer.MatricesIndicesKind
  113477. * - VertexBuffer.MatricesIndicesExtraKind
  113478. * - VertexBuffer.MatricesWeightsKind
  113479. * - VertexBuffer.MatricesWeightsExtraKind
  113480. * @returns an array of strings
  113481. */
  113482. getVerticesDataKinds(): string[];
  113483. /**
  113484. * Returns a positive integer : the total number of indices in this mesh geometry.
  113485. * @returns the numner of indices or zero if the mesh has no geometry.
  113486. */
  113487. getTotalIndices(): number;
  113488. /**
  113489. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113490. * @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.
  113491. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  113492. * @returns the indices array or an empty array if the mesh has no geometry
  113493. */
  113494. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  113495. get isBlocked(): boolean;
  113496. /**
  113497. * Determine if the current mesh is ready to be rendered
  113498. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113499. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  113500. * @returns true if all associated assets are ready (material, textures, shaders)
  113501. */
  113502. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  113503. /**
  113504. * 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.
  113505. */
  113506. get areNormalsFrozen(): boolean;
  113507. /**
  113508. * 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.
  113509. * @returns the current mesh
  113510. */
  113511. freezeNormals(): Mesh;
  113512. /**
  113513. * 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
  113514. * @returns the current mesh
  113515. */
  113516. unfreezeNormals(): Mesh;
  113517. /**
  113518. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  113519. */
  113520. set overridenInstanceCount(count: number);
  113521. /** @hidden */
  113522. _preActivate(): Mesh;
  113523. /** @hidden */
  113524. _preActivateForIntermediateRendering(renderId: number): Mesh;
  113525. /** @hidden */
  113526. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  113527. protected _afterComputeWorldMatrix(): void;
  113528. /** @hidden */
  113529. _postActivate(): void;
  113530. /**
  113531. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113532. * This means the mesh underlying bounding box and sphere are recomputed.
  113533. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113534. * @returns the current mesh
  113535. */
  113536. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  113537. /** @hidden */
  113538. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  113539. /**
  113540. * This function will subdivide the mesh into multiple submeshes
  113541. * @param count defines the expected number of submeshes
  113542. */
  113543. subdivide(count: number): void;
  113544. /**
  113545. * Copy a FloatArray into a specific associated vertex buffer
  113546. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113547. * - VertexBuffer.PositionKind
  113548. * - VertexBuffer.UVKind
  113549. * - VertexBuffer.UV2Kind
  113550. * - VertexBuffer.UV3Kind
  113551. * - VertexBuffer.UV4Kind
  113552. * - VertexBuffer.UV5Kind
  113553. * - VertexBuffer.UV6Kind
  113554. * - VertexBuffer.ColorKind
  113555. * - VertexBuffer.MatricesIndicesKind
  113556. * - VertexBuffer.MatricesIndicesExtraKind
  113557. * - VertexBuffer.MatricesWeightsKind
  113558. * - VertexBuffer.MatricesWeightsExtraKind
  113559. * @param data defines the data source
  113560. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113561. * @param stride defines the data stride size (can be null)
  113562. * @returns the current mesh
  113563. */
  113564. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113565. /**
  113566. * Delete a vertex buffer associated with this mesh
  113567. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  113568. * - VertexBuffer.PositionKind
  113569. * - VertexBuffer.UVKind
  113570. * - VertexBuffer.UV2Kind
  113571. * - VertexBuffer.UV3Kind
  113572. * - VertexBuffer.UV4Kind
  113573. * - VertexBuffer.UV5Kind
  113574. * - VertexBuffer.UV6Kind
  113575. * - VertexBuffer.ColorKind
  113576. * - VertexBuffer.MatricesIndicesKind
  113577. * - VertexBuffer.MatricesIndicesExtraKind
  113578. * - VertexBuffer.MatricesWeightsKind
  113579. * - VertexBuffer.MatricesWeightsExtraKind
  113580. */
  113581. removeVerticesData(kind: string): void;
  113582. /**
  113583. * Flags an associated vertex buffer as updatable
  113584. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  113585. * - VertexBuffer.PositionKind
  113586. * - VertexBuffer.UVKind
  113587. * - VertexBuffer.UV2Kind
  113588. * - VertexBuffer.UV3Kind
  113589. * - VertexBuffer.UV4Kind
  113590. * - VertexBuffer.UV5Kind
  113591. * - VertexBuffer.UV6Kind
  113592. * - VertexBuffer.ColorKind
  113593. * - VertexBuffer.MatricesIndicesKind
  113594. * - VertexBuffer.MatricesIndicesExtraKind
  113595. * - VertexBuffer.MatricesWeightsKind
  113596. * - VertexBuffer.MatricesWeightsExtraKind
  113597. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113598. */
  113599. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  113600. /**
  113601. * Sets the mesh global Vertex Buffer
  113602. * @param buffer defines the buffer to use
  113603. * @returns the current mesh
  113604. */
  113605. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  113606. /**
  113607. * Update a specific associated vertex buffer
  113608. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113609. * - VertexBuffer.PositionKind
  113610. * - VertexBuffer.UVKind
  113611. * - VertexBuffer.UV2Kind
  113612. * - VertexBuffer.UV3Kind
  113613. * - VertexBuffer.UV4Kind
  113614. * - VertexBuffer.UV5Kind
  113615. * - VertexBuffer.UV6Kind
  113616. * - VertexBuffer.ColorKind
  113617. * - VertexBuffer.MatricesIndicesKind
  113618. * - VertexBuffer.MatricesIndicesExtraKind
  113619. * - VertexBuffer.MatricesWeightsKind
  113620. * - VertexBuffer.MatricesWeightsExtraKind
  113621. * @param data defines the data source
  113622. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  113623. * @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)
  113624. * @returns the current mesh
  113625. */
  113626. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  113627. /**
  113628. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  113629. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  113630. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  113631. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  113632. * @returns the current mesh
  113633. */
  113634. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  113635. /**
  113636. * Creates a un-shared specific occurence of the geometry for the mesh.
  113637. * @returns the current mesh
  113638. */
  113639. makeGeometryUnique(): Mesh;
  113640. /**
  113641. * Set the index buffer of this mesh
  113642. * @param indices defines the source data
  113643. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  113644. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  113645. * @returns the current mesh
  113646. */
  113647. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  113648. /**
  113649. * Update the current index buffer
  113650. * @param indices defines the source data
  113651. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113652. * @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)
  113653. * @returns the current mesh
  113654. */
  113655. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113656. /**
  113657. * Invert the geometry to move from a right handed system to a left handed one.
  113658. * @returns the current mesh
  113659. */
  113660. toLeftHanded(): Mesh;
  113661. /** @hidden */
  113662. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113663. /** @hidden */
  113664. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113665. /**
  113666. * Registers for this mesh a javascript function called just before the rendering process
  113667. * @param func defines the function to call before rendering this mesh
  113668. * @returns the current mesh
  113669. */
  113670. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113671. /**
  113672. * Disposes a previously registered javascript function called before the rendering
  113673. * @param func defines the function to remove
  113674. * @returns the current mesh
  113675. */
  113676. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113677. /**
  113678. * Registers for this mesh a javascript function called just after the rendering is complete
  113679. * @param func defines the function to call after rendering this mesh
  113680. * @returns the current mesh
  113681. */
  113682. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113683. /**
  113684. * Disposes a previously registered javascript function called after the rendering.
  113685. * @param func defines the function to remove
  113686. * @returns the current mesh
  113687. */
  113688. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113689. /** @hidden */
  113690. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  113691. /** @hidden */
  113692. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  113693. /** @hidden */
  113694. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  113695. /** @hidden */
  113696. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  113697. /** @hidden */
  113698. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  113699. /** @hidden */
  113700. _rebuild(): void;
  113701. /** @hidden */
  113702. _freeze(): void;
  113703. /** @hidden */
  113704. _unFreeze(): void;
  113705. /**
  113706. * 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
  113707. * @param subMesh defines the subMesh to render
  113708. * @param enableAlphaMode defines if alpha mode can be changed
  113709. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  113710. * @returns the current mesh
  113711. */
  113712. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  113713. private _onBeforeDraw;
  113714. /**
  113715. * Renormalize the mesh and patch it up if there are no weights
  113716. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  113717. * However in the case of zero weights then we set just a single influence to 1.
  113718. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  113719. */
  113720. cleanMatrixWeights(): void;
  113721. private normalizeSkinFourWeights;
  113722. private normalizeSkinWeightsAndExtra;
  113723. /**
  113724. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  113725. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  113726. * the user know there was an issue with importing the mesh
  113727. * @returns a validation object with skinned, valid and report string
  113728. */
  113729. validateSkinning(): {
  113730. skinned: boolean;
  113731. valid: boolean;
  113732. report: string;
  113733. };
  113734. /** @hidden */
  113735. _checkDelayState(): Mesh;
  113736. private _queueLoad;
  113737. /**
  113738. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  113739. * A mesh is in the frustum if its bounding box intersects the frustum
  113740. * @param frustumPlanes defines the frustum to test
  113741. * @returns true if the mesh is in the frustum planes
  113742. */
  113743. isInFrustum(frustumPlanes: Plane[]): boolean;
  113744. /**
  113745. * Sets the mesh material by the material or multiMaterial `id` property
  113746. * @param id is a string identifying the material or the multiMaterial
  113747. * @returns the current mesh
  113748. */
  113749. setMaterialByID(id: string): Mesh;
  113750. /**
  113751. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  113752. * @returns an array of IAnimatable
  113753. */
  113754. getAnimatables(): IAnimatable[];
  113755. /**
  113756. * Modifies the mesh geometry according to the passed transformation matrix.
  113757. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  113758. * The mesh normals are modified using the same transformation.
  113759. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113760. * @param transform defines the transform matrix to use
  113761. * @see https://doc.babylonjs.com/resources/baking_transformations
  113762. * @returns the current mesh
  113763. */
  113764. bakeTransformIntoVertices(transform: Matrix): Mesh;
  113765. /**
  113766. * Modifies the mesh geometry according to its own current World Matrix.
  113767. * The mesh World Matrix is then reset.
  113768. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  113769. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113770. * @see https://doc.babylonjs.com/resources/baking_transformations
  113771. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  113772. * @returns the current mesh
  113773. */
  113774. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  113775. /** @hidden */
  113776. get _positions(): Nullable<Vector3[]>;
  113777. /** @hidden */
  113778. _resetPointsArrayCache(): Mesh;
  113779. /** @hidden */
  113780. _generatePointsArray(): boolean;
  113781. /**
  113782. * Returns a new Mesh object generated from the current mesh properties.
  113783. * This method must not get confused with createInstance()
  113784. * @param name is a string, the name given to the new mesh
  113785. * @param newParent can be any Node object (default `null`)
  113786. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  113787. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  113788. * @returns a new mesh
  113789. */
  113790. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  113791. /**
  113792. * Releases resources associated with this mesh.
  113793. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113794. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113795. */
  113796. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113797. /** @hidden */
  113798. _disposeInstanceSpecificData(): void;
  113799. /** @hidden */
  113800. _disposeThinInstanceSpecificData(): void;
  113801. /**
  113802. * Modifies the mesh geometry according to a displacement map.
  113803. * 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.
  113804. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113805. * @param url is a string, the URL from the image file is to be downloaded.
  113806. * @param minHeight is the lower limit of the displacement.
  113807. * @param maxHeight is the upper limit of the displacement.
  113808. * @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.
  113809. * @param uvOffset is an optional vector2 used to offset UV.
  113810. * @param uvScale is an optional vector2 used to scale UV.
  113811. * @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.
  113812. * @returns the Mesh.
  113813. */
  113814. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113815. /**
  113816. * Modifies the mesh geometry according to a displacementMap buffer.
  113817. * 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.
  113818. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113819. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  113820. * @param heightMapWidth is the width of the buffer image.
  113821. * @param heightMapHeight is the height of the buffer image.
  113822. * @param minHeight is the lower limit of the displacement.
  113823. * @param maxHeight is the upper limit of the displacement.
  113824. * @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.
  113825. * @param uvOffset is an optional vector2 used to offset UV.
  113826. * @param uvScale is an optional vector2 used to scale UV.
  113827. * @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.
  113828. * @returns the Mesh.
  113829. */
  113830. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113831. /**
  113832. * Modify the mesh to get a flat shading rendering.
  113833. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  113834. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  113835. * @returns current mesh
  113836. */
  113837. convertToFlatShadedMesh(): Mesh;
  113838. /**
  113839. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  113840. * In other words, more vertices, no more indices and a single bigger VBO.
  113841. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  113842. * @returns current mesh
  113843. */
  113844. convertToUnIndexedMesh(): Mesh;
  113845. /**
  113846. * Inverses facet orientations.
  113847. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113848. * @param flipNormals will also inverts the normals
  113849. * @returns current mesh
  113850. */
  113851. flipFaces(flipNormals?: boolean): Mesh;
  113852. /**
  113853. * Increase the number of facets and hence vertices in a mesh
  113854. * Vertex normals are interpolated from existing vertex normals
  113855. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113856. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  113857. */
  113858. increaseVertices(numberPerEdge: number): void;
  113859. /**
  113860. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  113861. * This will undo any application of covertToFlatShadedMesh
  113862. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113863. */
  113864. forceSharedVertices(): void;
  113865. /** @hidden */
  113866. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  113867. /** @hidden */
  113868. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  113869. /**
  113870. * Creates a new InstancedMesh object from the mesh model.
  113871. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113872. * @param name defines the name of the new instance
  113873. * @returns a new InstancedMesh
  113874. */
  113875. createInstance(name: string): InstancedMesh;
  113876. /**
  113877. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  113878. * After this call, all the mesh instances have the same submeshes than the current mesh.
  113879. * @returns the current mesh
  113880. */
  113881. synchronizeInstances(): Mesh;
  113882. /**
  113883. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  113884. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  113885. * This should be used together with the simplification to avoid disappearing triangles.
  113886. * @param successCallback an optional success callback to be called after the optimization finished.
  113887. * @returns the current mesh
  113888. */
  113889. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  113890. /**
  113891. * Serialize current mesh
  113892. * @param serializationObject defines the object which will receive the serialization data
  113893. */
  113894. serialize(serializationObject: any): void;
  113895. /** @hidden */
  113896. _syncGeometryWithMorphTargetManager(): void;
  113897. /** @hidden */
  113898. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  113899. /**
  113900. * Returns a new Mesh object parsed from the source provided.
  113901. * @param parsedMesh is the source
  113902. * @param scene defines the hosting scene
  113903. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  113904. * @returns a new Mesh
  113905. */
  113906. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  113907. /**
  113908. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  113909. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113910. * @param name defines the name of the mesh to create
  113911. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  113912. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  113913. * @param closePath creates a seam between the first and the last points of each path of the path array
  113914. * @param offset is taken in account only if the `pathArray` is containing a single path
  113915. * @param scene defines the hosting scene
  113916. * @param updatable defines if the mesh must be flagged as updatable
  113917. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113918. * @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)
  113919. * @returns a new Mesh
  113920. */
  113921. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  113922. /**
  113923. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  113924. * @param name defines the name of the mesh to create
  113925. * @param radius sets the radius size (float) of the polygon (default 0.5)
  113926. * @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
  113927. * @param scene defines the hosting scene
  113928. * @param updatable defines if the mesh must be flagged as updatable
  113929. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113930. * @returns a new Mesh
  113931. */
  113932. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  113933. /**
  113934. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  113935. * @param name defines the name of the mesh to create
  113936. * @param size sets the size (float) of each box side (default 1)
  113937. * @param scene defines the hosting scene
  113938. * @param updatable defines if the mesh must be flagged as updatable
  113939. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113940. * @returns a new Mesh
  113941. */
  113942. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  113943. /**
  113944. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  113945. * @param name defines the name of the mesh to create
  113946. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  113947. * @param diameter sets the diameter size (float) of the sphere (default 1)
  113948. * @param scene defines the hosting scene
  113949. * @param updatable defines if the mesh must be flagged as updatable
  113950. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113951. * @returns a new Mesh
  113952. */
  113953. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113954. /**
  113955. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  113956. * @param name defines the name of the mesh to create
  113957. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  113958. * @param diameter sets the diameter size (float) of the sphere (default 1)
  113959. * @param scene defines the hosting scene
  113960. * @returns a new Mesh
  113961. */
  113962. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  113963. /**
  113964. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  113965. * @param name defines the name of the mesh to create
  113966. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  113967. * @param diameterTop set the top cap diameter (floats, default 1)
  113968. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  113969. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  113970. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  113971. * @param scene defines the hosting scene
  113972. * @param updatable defines if the mesh must be flagged as updatable
  113973. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113974. * @returns a new Mesh
  113975. */
  113976. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  113977. /**
  113978. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  113979. * @param name defines the name of the mesh to create
  113980. * @param diameter sets the diameter size (float) of the torus (default 1)
  113981. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  113982. * @param tessellation sets the number of torus sides (postive integer, default 16)
  113983. * @param scene defines the hosting scene
  113984. * @param updatable defines if the mesh must be flagged as updatable
  113985. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113986. * @returns a new Mesh
  113987. */
  113988. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113989. /**
  113990. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  113991. * @param name defines the name of the mesh to create
  113992. * @param radius sets the global radius size (float) of the torus knot (default 2)
  113993. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  113994. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  113995. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  113996. * @param p the number of windings on X axis (positive integers, default 2)
  113997. * @param q the number of windings on Y axis (positive integers, default 3)
  113998. * @param scene defines the hosting scene
  113999. * @param updatable defines if the mesh must be flagged as updatable
  114000. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114001. * @returns a new Mesh
  114002. */
  114003. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114004. /**
  114005. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114006. * @param name defines the name of the mesh to create
  114007. * @param points is an array successive Vector3
  114008. * @param scene defines the hosting scene
  114009. * @param updatable defines if the mesh must be flagged as updatable
  114010. * @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).
  114011. * @returns a new Mesh
  114012. */
  114013. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114014. /**
  114015. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114016. * @param name defines the name of the mesh to create
  114017. * @param points is an array successive Vector3
  114018. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114019. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114020. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114021. * @param scene defines the hosting scene
  114022. * @param updatable defines if the mesh must be flagged as updatable
  114023. * @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)
  114024. * @returns a new Mesh
  114025. */
  114026. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114027. /**
  114028. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114029. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114030. * 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.
  114031. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114032. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114033. * Remember you can only change the shape positions, not their number when updating a polygon.
  114034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114035. * @param name defines the name of the mesh to create
  114036. * @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
  114037. * @param scene defines the hosting scene
  114038. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114039. * @param updatable defines if the mesh must be flagged as updatable
  114040. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114041. * @param earcutInjection can be used to inject your own earcut reference
  114042. * @returns a new Mesh
  114043. */
  114044. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114045. /**
  114046. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114047. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114048. * @param name defines the name of the mesh to create
  114049. * @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
  114050. * @param depth defines the height of extrusion
  114051. * @param scene defines the hosting scene
  114052. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114053. * @param updatable defines if the mesh must be flagged as updatable
  114054. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114055. * @param earcutInjection can be used to inject your own earcut reference
  114056. * @returns a new Mesh
  114057. */
  114058. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114059. /**
  114060. * Creates an extruded shape mesh.
  114061. * 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
  114062. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114063. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114064. * @param name defines the name of the mesh to create
  114065. * @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
  114066. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114067. * @param scale is the value to scale the shape
  114068. * @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
  114069. * @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
  114070. * @param scene defines the hosting scene
  114071. * @param updatable defines if the mesh must be flagged as updatable
  114072. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114073. * @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)
  114074. * @returns a new Mesh
  114075. */
  114076. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114077. /**
  114078. * Creates an custom extruded shape mesh.
  114079. * The custom extrusion is a parametric shape.
  114080. * It has no predefined shape. Its final shape will depend on the input parameters.
  114081. * Please consider using the same method from the MeshBuilder class instead
  114082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114083. * @param name defines the name of the mesh to create
  114084. * @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
  114085. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114086. * @param scaleFunction is a custom Javascript function called on each path point
  114087. * @param rotationFunction is a custom Javascript function called on each path point
  114088. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114089. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114090. * @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
  114091. * @param scene defines the hosting scene
  114092. * @param updatable defines if the mesh must be flagged as updatable
  114093. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114094. * @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)
  114095. * @returns a new Mesh
  114096. */
  114097. 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;
  114098. /**
  114099. * Creates lathe mesh.
  114100. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114101. * Please consider using the same method from the MeshBuilder class instead
  114102. * @param name defines the name of the mesh to create
  114103. * @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
  114104. * @param radius is the radius value of the lathe
  114105. * @param tessellation is the side number of the lathe.
  114106. * @param scene defines the hosting scene
  114107. * @param updatable defines if the mesh must be flagged as updatable
  114108. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114109. * @returns a new Mesh
  114110. */
  114111. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114112. /**
  114113. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114114. * @param name defines the name of the mesh to create
  114115. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114116. * @param scene defines the hosting scene
  114117. * @param updatable defines if the mesh must be flagged as updatable
  114118. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114119. * @returns a new Mesh
  114120. */
  114121. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114122. /**
  114123. * Creates a ground mesh.
  114124. * Please consider using the same method from the MeshBuilder class instead
  114125. * @param name defines the name of the mesh to create
  114126. * @param width set the width of the ground
  114127. * @param height set the height of the ground
  114128. * @param subdivisions sets the number of subdivisions per side
  114129. * @param scene defines the hosting scene
  114130. * @param updatable defines if the mesh must be flagged as updatable
  114131. * @returns a new Mesh
  114132. */
  114133. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114134. /**
  114135. * Creates a tiled ground mesh.
  114136. * Please consider using the same method from the MeshBuilder class instead
  114137. * @param name defines the name of the mesh to create
  114138. * @param xmin set the ground minimum X coordinate
  114139. * @param zmin set the ground minimum Y coordinate
  114140. * @param xmax set the ground maximum X coordinate
  114141. * @param zmax set the ground maximum Z coordinate
  114142. * @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
  114143. * @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
  114144. * @param scene defines the hosting scene
  114145. * @param updatable defines if the mesh must be flagged as updatable
  114146. * @returns a new Mesh
  114147. */
  114148. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114149. w: number;
  114150. h: number;
  114151. }, precision: {
  114152. w: number;
  114153. h: number;
  114154. }, scene: Scene, updatable?: boolean): Mesh;
  114155. /**
  114156. * Creates a ground mesh from a height map.
  114157. * Please consider using the same method from the MeshBuilder class instead
  114158. * @see https://doc.babylonjs.com/babylon101/height_map
  114159. * @param name defines the name of the mesh to create
  114160. * @param url sets the URL of the height map image resource
  114161. * @param width set the ground width size
  114162. * @param height set the ground height size
  114163. * @param subdivisions sets the number of subdivision per side
  114164. * @param minHeight is the minimum altitude on the ground
  114165. * @param maxHeight is the maximum altitude on the ground
  114166. * @param scene defines the hosting scene
  114167. * @param updatable defines if the mesh must be flagged as updatable
  114168. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114169. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114170. * @returns a new Mesh
  114171. */
  114172. 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;
  114173. /**
  114174. * Creates a tube mesh.
  114175. * The tube is a parametric shape.
  114176. * It has no predefined shape. Its final shape will depend on the input parameters.
  114177. * Please consider using the same method from the MeshBuilder class instead
  114178. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114179. * @param name defines the name of the mesh to create
  114180. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114181. * @param radius sets the tube radius size
  114182. * @param tessellation is the number of sides on the tubular surface
  114183. * @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
  114184. * @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
  114185. * @param scene defines the hosting scene
  114186. * @param updatable defines if the mesh must be flagged as updatable
  114187. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114188. * @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)
  114189. * @returns a new Mesh
  114190. */
  114191. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114192. (i: number, distance: number): number;
  114193. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114194. /**
  114195. * Creates a polyhedron mesh.
  114196. * Please consider using the same method from the MeshBuilder class instead.
  114197. * * 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
  114198. * * The parameter `size` (positive float, default 1) sets the polygon size
  114199. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114200. * * 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`
  114201. * * 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
  114202. * * 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)`)
  114203. * * 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
  114204. * * 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
  114205. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114208. * @param name defines the name of the mesh to create
  114209. * @param options defines the options used to create the mesh
  114210. * @param scene defines the hosting scene
  114211. * @returns a new Mesh
  114212. */
  114213. static CreatePolyhedron(name: string, options: {
  114214. type?: number;
  114215. size?: number;
  114216. sizeX?: number;
  114217. sizeY?: number;
  114218. sizeZ?: number;
  114219. custom?: any;
  114220. faceUV?: Vector4[];
  114221. faceColors?: Color4[];
  114222. updatable?: boolean;
  114223. sideOrientation?: number;
  114224. }, scene: Scene): Mesh;
  114225. /**
  114226. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114227. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114228. * * 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`)
  114229. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114230. * * 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
  114231. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114234. * @param name defines the name of the mesh
  114235. * @param options defines the options used to create the mesh
  114236. * @param scene defines the hosting scene
  114237. * @returns a new Mesh
  114238. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114239. */
  114240. static CreateIcoSphere(name: string, options: {
  114241. radius?: number;
  114242. flat?: boolean;
  114243. subdivisions?: number;
  114244. sideOrientation?: number;
  114245. updatable?: boolean;
  114246. }, scene: Scene): Mesh;
  114247. /**
  114248. * Creates a decal mesh.
  114249. * Please consider using the same method from the MeshBuilder class instead.
  114250. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114251. * @param name defines the name of the mesh
  114252. * @param sourceMesh defines the mesh receiving the decal
  114253. * @param position sets the position of the decal in world coordinates
  114254. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114255. * @param size sets the decal scaling
  114256. * @param angle sets the angle to rotate the decal
  114257. * @returns a new Mesh
  114258. */
  114259. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114260. /** Creates a Capsule Mesh
  114261. * @param name defines the name of the mesh.
  114262. * @param options the constructors options used to shape the mesh.
  114263. * @param scene defines the scene the mesh is scoped to.
  114264. * @returns the capsule mesh
  114265. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114266. */
  114267. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114268. /**
  114269. * Prepare internal position array for software CPU skinning
  114270. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114271. */
  114272. setPositionsForCPUSkinning(): Float32Array;
  114273. /**
  114274. * Prepare internal normal array for software CPU skinning
  114275. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  114276. */
  114277. setNormalsForCPUSkinning(): Float32Array;
  114278. /**
  114279. * Updates the vertex buffer by applying transformation from the bones
  114280. * @param skeleton defines the skeleton to apply to current mesh
  114281. * @returns the current mesh
  114282. */
  114283. applySkeleton(skeleton: Skeleton): Mesh;
  114284. /**
  114285. * 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
  114286. * @param meshes defines the list of meshes to scan
  114287. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  114288. */
  114289. static MinMax(meshes: AbstractMesh[]): {
  114290. min: Vector3;
  114291. max: Vector3;
  114292. };
  114293. /**
  114294. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  114295. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  114296. * @returns a vector3
  114297. */
  114298. static Center(meshesOrMinMaxVector: {
  114299. min: Vector3;
  114300. max: Vector3;
  114301. } | AbstractMesh[]): Vector3;
  114302. /**
  114303. * Merge the array of meshes into a single mesh for performance reasons.
  114304. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  114305. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  114306. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  114307. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  114308. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  114309. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  114310. * @returns a new mesh
  114311. */
  114312. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  114313. /** @hidden */
  114314. addInstance(instance: InstancedMesh): void;
  114315. /** @hidden */
  114316. removeInstance(instance: InstancedMesh): void;
  114317. }
  114318. }
  114319. declare module BABYLON {
  114320. /**
  114321. * This is the base class of all the camera used in the application.
  114322. * @see https://doc.babylonjs.com/features/cameras
  114323. */
  114324. export class Camera extends Node {
  114325. /** @hidden */
  114326. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  114327. /**
  114328. * This is the default projection mode used by the cameras.
  114329. * It helps recreating a feeling of perspective and better appreciate depth.
  114330. * This is the best way to simulate real life cameras.
  114331. */
  114332. static readonly PERSPECTIVE_CAMERA: number;
  114333. /**
  114334. * This helps creating camera with an orthographic mode.
  114335. * 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.
  114336. */
  114337. static readonly ORTHOGRAPHIC_CAMERA: number;
  114338. /**
  114339. * This is the default FOV mode for perspective cameras.
  114340. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  114341. */
  114342. static readonly FOVMODE_VERTICAL_FIXED: number;
  114343. /**
  114344. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  114345. */
  114346. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  114347. /**
  114348. * This specifies ther is no need for a camera rig.
  114349. * Basically only one eye is rendered corresponding to the camera.
  114350. */
  114351. static readonly RIG_MODE_NONE: number;
  114352. /**
  114353. * Simulates a camera Rig with one blue eye and one red eye.
  114354. * This can be use with 3d blue and red glasses.
  114355. */
  114356. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  114357. /**
  114358. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  114359. */
  114360. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  114361. /**
  114362. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  114363. */
  114364. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  114365. /**
  114366. * Defines that both eyes of the camera will be rendered over under each other.
  114367. */
  114368. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  114369. /**
  114370. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  114371. */
  114372. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  114373. /**
  114374. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  114375. */
  114376. static readonly RIG_MODE_VR: number;
  114377. /**
  114378. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  114379. */
  114380. static readonly RIG_MODE_WEBVR: number;
  114381. /**
  114382. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  114383. */
  114384. static readonly RIG_MODE_CUSTOM: number;
  114385. /**
  114386. * Defines if by default attaching controls should prevent the default javascript event to continue.
  114387. */
  114388. static ForceAttachControlToAlwaysPreventDefault: boolean;
  114389. /**
  114390. * Define the input manager associated with the camera.
  114391. */
  114392. inputs: CameraInputsManager<Camera>;
  114393. /** @hidden */
  114394. _position: Vector3;
  114395. /**
  114396. * Define the current local position of the camera in the scene
  114397. */
  114398. get position(): Vector3;
  114399. set position(newPosition: Vector3);
  114400. protected _upVector: Vector3;
  114401. /**
  114402. * The vector the camera should consider as up.
  114403. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  114404. */
  114405. set upVector(vec: Vector3);
  114406. get upVector(): Vector3;
  114407. /**
  114408. * Define the current limit on the left side for an orthographic camera
  114409. * In scene unit
  114410. */
  114411. orthoLeft: Nullable<number>;
  114412. /**
  114413. * Define the current limit on the right side for an orthographic camera
  114414. * In scene unit
  114415. */
  114416. orthoRight: Nullable<number>;
  114417. /**
  114418. * Define the current limit on the bottom side for an orthographic camera
  114419. * In scene unit
  114420. */
  114421. orthoBottom: Nullable<number>;
  114422. /**
  114423. * Define the current limit on the top side for an orthographic camera
  114424. * In scene unit
  114425. */
  114426. orthoTop: Nullable<number>;
  114427. /**
  114428. * Field Of View is set in Radians. (default is 0.8)
  114429. */
  114430. fov: number;
  114431. /**
  114432. * Define the minimum distance the camera can see from.
  114433. * This is important to note that the depth buffer are not infinite and the closer it starts
  114434. * the more your scene might encounter depth fighting issue.
  114435. */
  114436. minZ: number;
  114437. /**
  114438. * Define the maximum distance the camera can see to.
  114439. * This is important to note that the depth buffer are not infinite and the further it end
  114440. * the more your scene might encounter depth fighting issue.
  114441. */
  114442. maxZ: number;
  114443. /**
  114444. * Define the default inertia of the camera.
  114445. * This helps giving a smooth feeling to the camera movement.
  114446. */
  114447. inertia: number;
  114448. /**
  114449. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  114450. */
  114451. mode: number;
  114452. /**
  114453. * Define whether the camera is intermediate.
  114454. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  114455. */
  114456. isIntermediate: boolean;
  114457. /**
  114458. * Define the viewport of the camera.
  114459. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  114460. */
  114461. viewport: Viewport;
  114462. /**
  114463. * Restricts the camera to viewing objects with the same layerMask.
  114464. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  114465. */
  114466. layerMask: number;
  114467. /**
  114468. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  114469. */
  114470. fovMode: number;
  114471. /**
  114472. * Rig mode of the camera.
  114473. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  114474. * This is normally controlled byt the camera themselves as internal use.
  114475. */
  114476. cameraRigMode: number;
  114477. /**
  114478. * Defines the distance between both "eyes" in case of a RIG
  114479. */
  114480. interaxialDistance: number;
  114481. /**
  114482. * Defines if stereoscopic rendering is done side by side or over under.
  114483. */
  114484. isStereoscopicSideBySide: boolean;
  114485. /**
  114486. * 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
  114487. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  114488. * else in the scene. (Eg. security camera)
  114489. *
  114490. * 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)
  114491. */
  114492. customRenderTargets: RenderTargetTexture[];
  114493. /**
  114494. * When set, the camera will render to this render target instead of the default canvas
  114495. *
  114496. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  114497. */
  114498. outputRenderTarget: Nullable<RenderTargetTexture>;
  114499. /**
  114500. * Observable triggered when the camera view matrix has changed.
  114501. */
  114502. onViewMatrixChangedObservable: Observable<Camera>;
  114503. /**
  114504. * Observable triggered when the camera Projection matrix has changed.
  114505. */
  114506. onProjectionMatrixChangedObservable: Observable<Camera>;
  114507. /**
  114508. * Observable triggered when the inputs have been processed.
  114509. */
  114510. onAfterCheckInputsObservable: Observable<Camera>;
  114511. /**
  114512. * Observable triggered when reset has been called and applied to the camera.
  114513. */
  114514. onRestoreStateObservable: Observable<Camera>;
  114515. /**
  114516. * Is this camera a part of a rig system?
  114517. */
  114518. isRigCamera: boolean;
  114519. /**
  114520. * If isRigCamera set to true this will be set with the parent camera.
  114521. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  114522. */
  114523. rigParent?: Camera;
  114524. /** @hidden */
  114525. _cameraRigParams: any;
  114526. /** @hidden */
  114527. _rigCameras: Camera[];
  114528. /** @hidden */
  114529. _rigPostProcess: Nullable<PostProcess>;
  114530. protected _webvrViewMatrix: Matrix;
  114531. /** @hidden */
  114532. _skipRendering: boolean;
  114533. /** @hidden */
  114534. _projectionMatrix: Matrix;
  114535. /** @hidden */
  114536. _postProcesses: Nullable<PostProcess>[];
  114537. /** @hidden */
  114538. _activeMeshes: SmartArray<AbstractMesh>;
  114539. protected _globalPosition: Vector3;
  114540. /** @hidden */
  114541. _computedViewMatrix: Matrix;
  114542. private _doNotComputeProjectionMatrix;
  114543. private _transformMatrix;
  114544. private _frustumPlanes;
  114545. private _refreshFrustumPlanes;
  114546. private _storedFov;
  114547. private _stateStored;
  114548. /**
  114549. * Instantiates a new camera object.
  114550. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  114551. * @see https://doc.babylonjs.com/features/cameras
  114552. * @param name Defines the name of the camera in the scene
  114553. * @param position Defines the position of the camera
  114554. * @param scene Defines the scene the camera belongs too
  114555. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  114556. */
  114557. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114558. /**
  114559. * Store current camera state (fov, position, etc..)
  114560. * @returns the camera
  114561. */
  114562. storeState(): Camera;
  114563. /**
  114564. * Restores the camera state values if it has been stored. You must call storeState() first
  114565. */
  114566. protected _restoreStateValues(): boolean;
  114567. /**
  114568. * Restored camera state. You must call storeState() first.
  114569. * @returns true if restored and false otherwise
  114570. */
  114571. restoreState(): boolean;
  114572. /**
  114573. * Gets the class name of the camera.
  114574. * @returns the class name
  114575. */
  114576. getClassName(): string;
  114577. /** @hidden */
  114578. readonly _isCamera: boolean;
  114579. /**
  114580. * Gets a string representation of the camera useful for debug purpose.
  114581. * @param fullDetails Defines that a more verboe level of logging is required
  114582. * @returns the string representation
  114583. */
  114584. toString(fullDetails?: boolean): string;
  114585. /**
  114586. * Gets the current world space position of the camera.
  114587. */
  114588. get globalPosition(): Vector3;
  114589. /**
  114590. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  114591. * @returns the active meshe list
  114592. */
  114593. getActiveMeshes(): SmartArray<AbstractMesh>;
  114594. /**
  114595. * Check whether a mesh is part of the current active mesh list of the camera
  114596. * @param mesh Defines the mesh to check
  114597. * @returns true if active, false otherwise
  114598. */
  114599. isActiveMesh(mesh: Mesh): boolean;
  114600. /**
  114601. * Is this camera ready to be used/rendered
  114602. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  114603. * @return true if the camera is ready
  114604. */
  114605. isReady(completeCheck?: boolean): boolean;
  114606. /** @hidden */
  114607. _initCache(): void;
  114608. /** @hidden */
  114609. _updateCache(ignoreParentClass?: boolean): void;
  114610. /** @hidden */
  114611. _isSynchronized(): boolean;
  114612. /** @hidden */
  114613. _isSynchronizedViewMatrix(): boolean;
  114614. /** @hidden */
  114615. _isSynchronizedProjectionMatrix(): boolean;
  114616. /**
  114617. * Attach the input controls to a specific dom element to get the input from.
  114618. * @param element Defines the element the controls should be listened from
  114619. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114620. */
  114621. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114622. /**
  114623. * Detach the current controls from the specified dom element.
  114624. * @param element Defines the element to stop listening the inputs from
  114625. */
  114626. detachControl(element: HTMLElement): void;
  114627. /**
  114628. * Update the camera state according to the different inputs gathered during the frame.
  114629. */
  114630. update(): void;
  114631. /** @hidden */
  114632. _checkInputs(): void;
  114633. /** @hidden */
  114634. get rigCameras(): Camera[];
  114635. /**
  114636. * Gets the post process used by the rig cameras
  114637. */
  114638. get rigPostProcess(): Nullable<PostProcess>;
  114639. /**
  114640. * Internal, gets the first post proces.
  114641. * @returns the first post process to be run on this camera.
  114642. */
  114643. _getFirstPostProcess(): Nullable<PostProcess>;
  114644. private _cascadePostProcessesToRigCams;
  114645. /**
  114646. * Attach a post process to the camera.
  114647. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114648. * @param postProcess The post process to attach to the camera
  114649. * @param insertAt The position of the post process in case several of them are in use in the scene
  114650. * @returns the position the post process has been inserted at
  114651. */
  114652. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  114653. /**
  114654. * Detach a post process to the camera.
  114655. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114656. * @param postProcess The post process to detach from the camera
  114657. */
  114658. detachPostProcess(postProcess: PostProcess): void;
  114659. /**
  114660. * Gets the current world matrix of the camera
  114661. */
  114662. getWorldMatrix(): Matrix;
  114663. /** @hidden */
  114664. _getViewMatrix(): Matrix;
  114665. /**
  114666. * Gets the current view matrix of the camera.
  114667. * @param force forces the camera to recompute the matrix without looking at the cached state
  114668. * @returns the view matrix
  114669. */
  114670. getViewMatrix(force?: boolean): Matrix;
  114671. /**
  114672. * Freeze the projection matrix.
  114673. * It will prevent the cache check of the camera projection compute and can speed up perf
  114674. * if no parameter of the camera are meant to change
  114675. * @param projection Defines manually a projection if necessary
  114676. */
  114677. freezeProjectionMatrix(projection?: Matrix): void;
  114678. /**
  114679. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  114680. */
  114681. unfreezeProjectionMatrix(): void;
  114682. /**
  114683. * Gets the current projection matrix of the camera.
  114684. * @param force forces the camera to recompute the matrix without looking at the cached state
  114685. * @returns the projection matrix
  114686. */
  114687. getProjectionMatrix(force?: boolean): Matrix;
  114688. /**
  114689. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  114690. * @returns a Matrix
  114691. */
  114692. getTransformationMatrix(): Matrix;
  114693. private _updateFrustumPlanes;
  114694. /**
  114695. * Checks if a cullable object (mesh...) is in the camera frustum
  114696. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  114697. * @param target The object to check
  114698. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  114699. * @returns true if the object is in frustum otherwise false
  114700. */
  114701. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  114702. /**
  114703. * Checks if a cullable object (mesh...) is in the camera frustum
  114704. * Unlike isInFrustum this cheks the full bounding box
  114705. * @param target The object to check
  114706. * @returns true if the object is in frustum otherwise false
  114707. */
  114708. isCompletelyInFrustum(target: ICullable): boolean;
  114709. /**
  114710. * Gets a ray in the forward direction from the camera.
  114711. * @param length Defines the length of the ray to create
  114712. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114713. * @param origin Defines the start point of the ray which defaults to the camera position
  114714. * @returns the forward ray
  114715. */
  114716. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114717. /**
  114718. * Gets a ray in the forward direction from the camera.
  114719. * @param refRay the ray to (re)use when setting the values
  114720. * @param length Defines the length of the ray to create
  114721. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114722. * @param origin Defines the start point of the ray which defaults to the camera position
  114723. * @returns the forward ray
  114724. */
  114725. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114726. /**
  114727. * Releases resources associated with this node.
  114728. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114729. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114730. */
  114731. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114732. /** @hidden */
  114733. _isLeftCamera: boolean;
  114734. /**
  114735. * Gets the left camera of a rig setup in case of Rigged Camera
  114736. */
  114737. get isLeftCamera(): boolean;
  114738. /** @hidden */
  114739. _isRightCamera: boolean;
  114740. /**
  114741. * Gets the right camera of a rig setup in case of Rigged Camera
  114742. */
  114743. get isRightCamera(): boolean;
  114744. /**
  114745. * Gets the left camera of a rig setup in case of Rigged Camera
  114746. */
  114747. get leftCamera(): Nullable<FreeCamera>;
  114748. /**
  114749. * Gets the right camera of a rig setup in case of Rigged Camera
  114750. */
  114751. get rightCamera(): Nullable<FreeCamera>;
  114752. /**
  114753. * Gets the left camera target of a rig setup in case of Rigged Camera
  114754. * @returns the target position
  114755. */
  114756. getLeftTarget(): Nullable<Vector3>;
  114757. /**
  114758. * Gets the right camera target of a rig setup in case of Rigged Camera
  114759. * @returns the target position
  114760. */
  114761. getRightTarget(): Nullable<Vector3>;
  114762. /**
  114763. * @hidden
  114764. */
  114765. setCameraRigMode(mode: number, rigParams: any): void;
  114766. /** @hidden */
  114767. static _setStereoscopicRigMode(camera: Camera): void;
  114768. /** @hidden */
  114769. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  114770. /** @hidden */
  114771. static _setVRRigMode(camera: Camera, rigParams: any): void;
  114772. /** @hidden */
  114773. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  114774. /** @hidden */
  114775. _getVRProjectionMatrix(): Matrix;
  114776. protected _updateCameraRotationMatrix(): void;
  114777. protected _updateWebVRCameraRotationMatrix(): void;
  114778. /**
  114779. * This function MUST be overwritten by the different WebVR cameras available.
  114780. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114781. * @hidden
  114782. */
  114783. _getWebVRProjectionMatrix(): Matrix;
  114784. /**
  114785. * This function MUST be overwritten by the different WebVR cameras available.
  114786. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114787. * @hidden
  114788. */
  114789. _getWebVRViewMatrix(): Matrix;
  114790. /** @hidden */
  114791. setCameraRigParameter(name: string, value: any): void;
  114792. /**
  114793. * needs to be overridden by children so sub has required properties to be copied
  114794. * @hidden
  114795. */
  114796. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  114797. /**
  114798. * May need to be overridden by children
  114799. * @hidden
  114800. */
  114801. _updateRigCameras(): void;
  114802. /** @hidden */
  114803. _setupInputs(): void;
  114804. /**
  114805. * Serialiaze the camera setup to a json represention
  114806. * @returns the JSON representation
  114807. */
  114808. serialize(): any;
  114809. /**
  114810. * Clones the current camera.
  114811. * @param name The cloned camera name
  114812. * @returns the cloned camera
  114813. */
  114814. clone(name: string): Camera;
  114815. /**
  114816. * Gets the direction of the camera relative to a given local axis.
  114817. * @param localAxis Defines the reference axis to provide a relative direction.
  114818. * @return the direction
  114819. */
  114820. getDirection(localAxis: Vector3): Vector3;
  114821. /**
  114822. * Returns the current camera absolute rotation
  114823. */
  114824. get absoluteRotation(): Quaternion;
  114825. /**
  114826. * Gets the direction of the camera relative to a given local axis into a passed vector.
  114827. * @param localAxis Defines the reference axis to provide a relative direction.
  114828. * @param result Defines the vector to store the result in
  114829. */
  114830. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  114831. /**
  114832. * Gets a camera constructor for a given camera type
  114833. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  114834. * @param name The name of the camera the result will be able to instantiate
  114835. * @param scene The scene the result will construct the camera in
  114836. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  114837. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  114838. * @returns a factory method to construc the camera
  114839. */
  114840. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  114841. /**
  114842. * Compute the world matrix of the camera.
  114843. * @returns the camera world matrix
  114844. */
  114845. computeWorldMatrix(): Matrix;
  114846. /**
  114847. * Parse a JSON and creates the camera from the parsed information
  114848. * @param parsedCamera The JSON to parse
  114849. * @param scene The scene to instantiate the camera in
  114850. * @returns the newly constructed camera
  114851. */
  114852. static Parse(parsedCamera: any, scene: Scene): Camera;
  114853. }
  114854. }
  114855. declare module BABYLON {
  114856. /**
  114857. * Class containing static functions to help procedurally build meshes
  114858. */
  114859. export class DiscBuilder {
  114860. /**
  114861. * Creates a plane polygonal mesh. By default, this is a disc
  114862. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114863. * * 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
  114864. * * 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
  114865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114868. * @param name defines the name of the mesh
  114869. * @param options defines the options used to create the mesh
  114870. * @param scene defines the hosting scene
  114871. * @returns the plane polygonal mesh
  114872. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  114873. */
  114874. static CreateDisc(name: string, options: {
  114875. radius?: number;
  114876. tessellation?: number;
  114877. arc?: number;
  114878. updatable?: boolean;
  114879. sideOrientation?: number;
  114880. frontUVs?: Vector4;
  114881. backUVs?: Vector4;
  114882. }, scene?: Nullable<Scene>): Mesh;
  114883. }
  114884. }
  114885. declare module BABYLON {
  114886. /**
  114887. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  114888. *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.
  114889. * The SPS is also a particle system. It provides some methods to manage the particles.
  114890. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  114891. *
  114892. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  114893. */
  114894. export class SolidParticleSystem implements IDisposable {
  114895. /**
  114896. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  114897. * Example : var p = SPS.particles[i];
  114898. */
  114899. particles: SolidParticle[];
  114900. /**
  114901. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  114902. */
  114903. nbParticles: number;
  114904. /**
  114905. * If the particles must ever face the camera (default false). Useful for planar particles.
  114906. */
  114907. billboard: boolean;
  114908. /**
  114909. * Recompute normals when adding a shape
  114910. */
  114911. recomputeNormals: boolean;
  114912. /**
  114913. * This a counter ofr your own usage. It's not set by any SPS functions.
  114914. */
  114915. counter: number;
  114916. /**
  114917. * The SPS name. This name is also given to the underlying mesh.
  114918. */
  114919. name: string;
  114920. /**
  114921. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  114922. */
  114923. mesh: Mesh;
  114924. /**
  114925. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  114926. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  114927. */
  114928. vars: any;
  114929. /**
  114930. * This array is populated when the SPS is set as 'pickable'.
  114931. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  114932. * Each element of this array is an object `{idx: int, faceId: int}`.
  114933. * `idx` is the picked particle index in the `SPS.particles` array
  114934. * `faceId` is the picked face index counted within this particle.
  114935. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  114936. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  114937. * Use the method SPS.pickedParticle(pickingInfo) instead.
  114938. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  114939. */
  114940. pickedParticles: {
  114941. idx: number;
  114942. faceId: number;
  114943. }[];
  114944. /**
  114945. * This array is populated when the SPS is set as 'pickable'
  114946. * Each key of this array is a submesh index.
  114947. * Each element of this array is a second array defined like this :
  114948. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  114949. * Each element of this second array is an object `{idx: int, faceId: int}`.
  114950. * `idx` is the picked particle index in the `SPS.particles` array
  114951. * `faceId` is the picked face index counted within this particle.
  114952. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  114953. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  114954. */
  114955. pickedBySubMesh: {
  114956. idx: number;
  114957. faceId: number;
  114958. }[][];
  114959. /**
  114960. * This array is populated when `enableDepthSort` is set to true.
  114961. * Each element of this array is an instance of the class DepthSortedParticle.
  114962. */
  114963. depthSortedParticles: DepthSortedParticle[];
  114964. /**
  114965. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  114966. * @hidden
  114967. */
  114968. _bSphereOnly: boolean;
  114969. /**
  114970. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  114971. * @hidden
  114972. */
  114973. _bSphereRadiusFactor: number;
  114974. private _scene;
  114975. private _positions;
  114976. private _indices;
  114977. private _normals;
  114978. private _colors;
  114979. private _uvs;
  114980. private _indices32;
  114981. private _positions32;
  114982. private _normals32;
  114983. private _fixedNormal32;
  114984. private _colors32;
  114985. private _uvs32;
  114986. private _index;
  114987. private _updatable;
  114988. private _pickable;
  114989. private _isVisibilityBoxLocked;
  114990. private _alwaysVisible;
  114991. private _depthSort;
  114992. private _expandable;
  114993. private _shapeCounter;
  114994. private _copy;
  114995. private _color;
  114996. private _computeParticleColor;
  114997. private _computeParticleTexture;
  114998. private _computeParticleRotation;
  114999. private _computeParticleVertex;
  115000. private _computeBoundingBox;
  115001. private _depthSortParticles;
  115002. private _camera;
  115003. private _mustUnrotateFixedNormals;
  115004. private _particlesIntersect;
  115005. private _needs32Bits;
  115006. private _isNotBuilt;
  115007. private _lastParticleId;
  115008. private _idxOfId;
  115009. private _multimaterialEnabled;
  115010. private _useModelMaterial;
  115011. private _indicesByMaterial;
  115012. private _materialIndexes;
  115013. private _depthSortFunction;
  115014. private _materialSortFunction;
  115015. private _materials;
  115016. private _multimaterial;
  115017. private _materialIndexesById;
  115018. private _defaultMaterial;
  115019. private _autoUpdateSubMeshes;
  115020. private _tmpVertex;
  115021. /**
  115022. * Creates a SPS (Solid Particle System) object.
  115023. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115024. * @param scene (Scene) is the scene in which the SPS is added.
  115025. * @param options defines the options of the sps e.g.
  115026. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115027. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115028. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115029. * * 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.
  115030. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115031. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115032. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115033. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115034. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115035. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115036. */
  115037. constructor(name: string, scene: Scene, options?: {
  115038. updatable?: boolean;
  115039. isPickable?: boolean;
  115040. enableDepthSort?: boolean;
  115041. particleIntersection?: boolean;
  115042. boundingSphereOnly?: boolean;
  115043. bSphereRadiusFactor?: number;
  115044. expandable?: boolean;
  115045. useModelMaterial?: boolean;
  115046. enableMultiMaterial?: boolean;
  115047. });
  115048. /**
  115049. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115050. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115051. * @returns the created mesh
  115052. */
  115053. buildMesh(): Mesh;
  115054. /**
  115055. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115056. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115057. * Thus the particles generated from `digest()` have their property `position` set yet.
  115058. * @param mesh ( Mesh ) is the mesh to be digested
  115059. * @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
  115060. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115061. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115062. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115063. * @returns the current SPS
  115064. */
  115065. digest(mesh: Mesh, options?: {
  115066. facetNb?: number;
  115067. number?: number;
  115068. delta?: number;
  115069. storage?: [];
  115070. }): SolidParticleSystem;
  115071. /**
  115072. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115073. * @hidden
  115074. */
  115075. private _unrotateFixedNormals;
  115076. /**
  115077. * Resets the temporary working copy particle
  115078. * @hidden
  115079. */
  115080. private _resetCopy;
  115081. /**
  115082. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115083. * @param p the current index in the positions array to be updated
  115084. * @param ind the current index in the indices array
  115085. * @param shape a Vector3 array, the shape geometry
  115086. * @param positions the positions array to be updated
  115087. * @param meshInd the shape indices array
  115088. * @param indices the indices array to be updated
  115089. * @param meshUV the shape uv array
  115090. * @param uvs the uv array to be updated
  115091. * @param meshCol the shape color array
  115092. * @param colors the color array to be updated
  115093. * @param meshNor the shape normals array
  115094. * @param normals the normals array to be updated
  115095. * @param idx the particle index
  115096. * @param idxInShape the particle index in its shape
  115097. * @param options the addShape() method passed options
  115098. * @model the particle model
  115099. * @hidden
  115100. */
  115101. private _meshBuilder;
  115102. /**
  115103. * Returns a shape Vector3 array from positions float array
  115104. * @param positions float array
  115105. * @returns a vector3 array
  115106. * @hidden
  115107. */
  115108. private _posToShape;
  115109. /**
  115110. * Returns a shapeUV array from a float uvs (array deep copy)
  115111. * @param uvs as a float array
  115112. * @returns a shapeUV array
  115113. * @hidden
  115114. */
  115115. private _uvsToShapeUV;
  115116. /**
  115117. * Adds a new particle object in the particles array
  115118. * @param idx particle index in particles array
  115119. * @param id particle id
  115120. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115121. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115122. * @param model particle ModelShape object
  115123. * @param shapeId model shape identifier
  115124. * @param idxInShape index of the particle in the current model
  115125. * @param bInfo model bounding info object
  115126. * @param storage target storage array, if any
  115127. * @hidden
  115128. */
  115129. private _addParticle;
  115130. /**
  115131. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115132. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115133. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115134. * @param nb (positive integer) the number of particles to be created from this model
  115135. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115136. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115137. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115138. * @returns the number of shapes in the system
  115139. */
  115140. addShape(mesh: Mesh, nb: number, options?: {
  115141. positionFunction?: any;
  115142. vertexFunction?: any;
  115143. storage?: [];
  115144. }): number;
  115145. /**
  115146. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115147. * @hidden
  115148. */
  115149. private _rebuildParticle;
  115150. /**
  115151. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115152. * @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.
  115153. * @returns the SPS.
  115154. */
  115155. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115156. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115157. * Returns an array with the removed particles.
  115158. * 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.
  115159. * The SPS can't be empty so at least one particle needs to remain in place.
  115160. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115161. * @param start index of the first particle to remove
  115162. * @param end index of the last particle to remove (included)
  115163. * @returns an array populated with the removed particles
  115164. */
  115165. removeParticles(start: number, end: number): SolidParticle[];
  115166. /**
  115167. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115168. * @param solidParticleArray an array populated with Solid Particles objects
  115169. * @returns the SPS
  115170. */
  115171. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115172. /**
  115173. * Creates a new particle and modifies the SPS mesh geometry :
  115174. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115175. * - calls _addParticle() to populate the particle array
  115176. * factorized code from addShape() and insertParticlesFromArray()
  115177. * @param idx particle index in the particles array
  115178. * @param i particle index in its shape
  115179. * @param modelShape particle ModelShape object
  115180. * @param shape shape vertex array
  115181. * @param meshInd shape indices array
  115182. * @param meshUV shape uv array
  115183. * @param meshCol shape color array
  115184. * @param meshNor shape normals array
  115185. * @param bbInfo shape bounding info
  115186. * @param storage target particle storage
  115187. * @options addShape() passed options
  115188. * @hidden
  115189. */
  115190. private _insertNewParticle;
  115191. /**
  115192. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115193. * This method calls `updateParticle()` for each particle of the SPS.
  115194. * For an animated SPS, it is usually called within the render loop.
  115195. * 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.
  115196. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115197. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115198. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115199. * @returns the SPS.
  115200. */
  115201. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115202. /**
  115203. * Disposes the SPS.
  115204. */
  115205. dispose(): void;
  115206. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115207. * idx is the particle index in the SPS
  115208. * faceId is the picked face index counted within this particle.
  115209. * Returns null if the pickInfo can't identify a picked particle.
  115210. * @param pickingInfo (PickingInfo object)
  115211. * @returns {idx: number, faceId: number} or null
  115212. */
  115213. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115214. idx: number;
  115215. faceId: number;
  115216. }>;
  115217. /**
  115218. * Returns a SolidParticle object from its identifier : particle.id
  115219. * @param id (integer) the particle Id
  115220. * @returns the searched particle or null if not found in the SPS.
  115221. */
  115222. getParticleById(id: number): Nullable<SolidParticle>;
  115223. /**
  115224. * Returns a new array populated with the particles having the passed shapeId.
  115225. * @param shapeId (integer) the shape identifier
  115226. * @returns a new solid particle array
  115227. */
  115228. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115229. /**
  115230. * Populates the passed array "ref" with the particles having the passed shapeId.
  115231. * @param shapeId the shape identifier
  115232. * @returns the SPS
  115233. * @param ref
  115234. */
  115235. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115236. /**
  115237. * Computes the required SubMeshes according the materials assigned to the particles.
  115238. * @returns the solid particle system.
  115239. * Does nothing if called before the SPS mesh is built.
  115240. */
  115241. computeSubMeshes(): SolidParticleSystem;
  115242. /**
  115243. * Sorts the solid particles by material when MultiMaterial is enabled.
  115244. * Updates the indices32 array.
  115245. * Updates the indicesByMaterial array.
  115246. * Updates the mesh indices array.
  115247. * @returns the SPS
  115248. * @hidden
  115249. */
  115250. private _sortParticlesByMaterial;
  115251. /**
  115252. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115253. * @hidden
  115254. */
  115255. private _setMaterialIndexesById;
  115256. /**
  115257. * Returns an array with unique values of Materials from the passed array
  115258. * @param array the material array to be checked and filtered
  115259. * @hidden
  115260. */
  115261. private _filterUniqueMaterialId;
  115262. /**
  115263. * Sets a new Standard Material as _defaultMaterial if not already set.
  115264. * @hidden
  115265. */
  115266. private _setDefaultMaterial;
  115267. /**
  115268. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  115269. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115270. * @returns the SPS.
  115271. */
  115272. refreshVisibleSize(): SolidParticleSystem;
  115273. /**
  115274. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  115275. * @param size the size (float) of the visibility box
  115276. * note : this doesn't lock the SPS mesh bounding box.
  115277. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115278. */
  115279. setVisibilityBox(size: number): void;
  115280. /**
  115281. * Gets whether the SPS as always visible or not
  115282. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115283. */
  115284. get isAlwaysVisible(): boolean;
  115285. /**
  115286. * Sets the SPS as always visible or not
  115287. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115288. */
  115289. set isAlwaysVisible(val: boolean);
  115290. /**
  115291. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115292. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115293. */
  115294. set isVisibilityBoxLocked(val: boolean);
  115295. /**
  115296. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115297. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115298. */
  115299. get isVisibilityBoxLocked(): boolean;
  115300. /**
  115301. * Tells to `setParticles()` to compute the particle rotations or not.
  115302. * Default value : true. The SPS is faster when it's set to false.
  115303. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115304. */
  115305. set computeParticleRotation(val: boolean);
  115306. /**
  115307. * Tells to `setParticles()` to compute the particle colors or not.
  115308. * Default value : true. The SPS is faster when it's set to false.
  115309. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115310. */
  115311. set computeParticleColor(val: boolean);
  115312. set computeParticleTexture(val: boolean);
  115313. /**
  115314. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  115315. * Default value : false. The SPS is faster when it's set to false.
  115316. * Note : the particle custom vertex positions aren't stored values.
  115317. */
  115318. set computeParticleVertex(val: boolean);
  115319. /**
  115320. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  115321. */
  115322. set computeBoundingBox(val: boolean);
  115323. /**
  115324. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  115325. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115326. * Default : `true`
  115327. */
  115328. set depthSortParticles(val: boolean);
  115329. /**
  115330. * Gets if `setParticles()` computes the particle rotations or not.
  115331. * Default value : true. The SPS is faster when it's set to false.
  115332. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115333. */
  115334. get computeParticleRotation(): boolean;
  115335. /**
  115336. * Gets if `setParticles()` computes the particle colors or not.
  115337. * Default value : true. The SPS is faster when it's set to false.
  115338. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115339. */
  115340. get computeParticleColor(): boolean;
  115341. /**
  115342. * Gets if `setParticles()` computes the particle textures or not.
  115343. * Default value : true. The SPS is faster when it's set to false.
  115344. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  115345. */
  115346. get computeParticleTexture(): boolean;
  115347. /**
  115348. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  115349. * Default value : false. The SPS is faster when it's set to false.
  115350. * Note : the particle custom vertex positions aren't stored values.
  115351. */
  115352. get computeParticleVertex(): boolean;
  115353. /**
  115354. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  115355. */
  115356. get computeBoundingBox(): boolean;
  115357. /**
  115358. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  115359. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115360. * Default : `true`
  115361. */
  115362. get depthSortParticles(): boolean;
  115363. /**
  115364. * Gets if the SPS is created as expandable at construction time.
  115365. * Default : `false`
  115366. */
  115367. get expandable(): boolean;
  115368. /**
  115369. * Gets if the SPS supports the Multi Materials
  115370. */
  115371. get multimaterialEnabled(): boolean;
  115372. /**
  115373. * Gets if the SPS uses the model materials for its own multimaterial.
  115374. */
  115375. get useModelMaterial(): boolean;
  115376. /**
  115377. * The SPS used material array.
  115378. */
  115379. get materials(): Material[];
  115380. /**
  115381. * Sets the SPS MultiMaterial from the passed materials.
  115382. * Note : the passed array is internally copied and not used then by reference.
  115383. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  115384. */
  115385. setMultiMaterial(materials: Material[]): void;
  115386. /**
  115387. * The SPS computed multimaterial object
  115388. */
  115389. get multimaterial(): MultiMaterial;
  115390. set multimaterial(mm: MultiMaterial);
  115391. /**
  115392. * If the subMeshes must be updated on the next call to setParticles()
  115393. */
  115394. get autoUpdateSubMeshes(): boolean;
  115395. set autoUpdateSubMeshes(val: boolean);
  115396. /**
  115397. * This function does nothing. It may be overwritten to set all the particle first values.
  115398. * The SPS doesn't call this function, you may have to call it by your own.
  115399. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115400. */
  115401. initParticles(): void;
  115402. /**
  115403. * This function does nothing. It may be overwritten to recycle a particle.
  115404. * The SPS doesn't call this function, you may have to call it by your own.
  115405. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115406. * @param particle The particle to recycle
  115407. * @returns the recycled particle
  115408. */
  115409. recycleParticle(particle: SolidParticle): SolidParticle;
  115410. /**
  115411. * Updates a particle : this function should be overwritten by the user.
  115412. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  115413. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115414. * @example : just set a particle position or velocity and recycle conditions
  115415. * @param particle The particle to update
  115416. * @returns the updated particle
  115417. */
  115418. updateParticle(particle: SolidParticle): SolidParticle;
  115419. /**
  115420. * Updates a vertex of a particle : it can be overwritten by the user.
  115421. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  115422. * @param particle the current particle
  115423. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  115424. * @param pt the index of the current vertex in the particle shape
  115425. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  115426. * @example : just set a vertex particle position or color
  115427. * @returns the sps
  115428. */
  115429. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  115430. /**
  115431. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  115432. * This does nothing and may be overwritten by the user.
  115433. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115434. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115435. * @param update the boolean update value actually passed to setParticles()
  115436. */
  115437. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115438. /**
  115439. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  115440. * This will be passed three parameters.
  115441. * This does nothing and may be overwritten by the user.
  115442. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115443. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115444. * @param update the boolean update value actually passed to setParticles()
  115445. */
  115446. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115447. }
  115448. }
  115449. declare module BABYLON {
  115450. /**
  115451. * Represents one particle of a solid particle system.
  115452. */
  115453. export class SolidParticle {
  115454. /**
  115455. * particle global index
  115456. */
  115457. idx: number;
  115458. /**
  115459. * particle identifier
  115460. */
  115461. id: number;
  115462. /**
  115463. * The color of the particle
  115464. */
  115465. color: Nullable<Color4>;
  115466. /**
  115467. * The world space position of the particle.
  115468. */
  115469. position: Vector3;
  115470. /**
  115471. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  115472. */
  115473. rotation: Vector3;
  115474. /**
  115475. * The world space rotation quaternion of the particle.
  115476. */
  115477. rotationQuaternion: Nullable<Quaternion>;
  115478. /**
  115479. * The scaling of the particle.
  115480. */
  115481. scaling: Vector3;
  115482. /**
  115483. * The uvs of the particle.
  115484. */
  115485. uvs: Vector4;
  115486. /**
  115487. * The current speed of the particle.
  115488. */
  115489. velocity: Vector3;
  115490. /**
  115491. * The pivot point in the particle local space.
  115492. */
  115493. pivot: Vector3;
  115494. /**
  115495. * Must the particle be translated from its pivot point in its local space ?
  115496. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  115497. * Default : false
  115498. */
  115499. translateFromPivot: boolean;
  115500. /**
  115501. * Is the particle active or not ?
  115502. */
  115503. alive: boolean;
  115504. /**
  115505. * Is the particle visible or not ?
  115506. */
  115507. isVisible: boolean;
  115508. /**
  115509. * Index of this particle in the global "positions" array (Internal use)
  115510. * @hidden
  115511. */
  115512. _pos: number;
  115513. /**
  115514. * @hidden Index of this particle in the global "indices" array (Internal use)
  115515. */
  115516. _ind: number;
  115517. /**
  115518. * @hidden ModelShape of this particle (Internal use)
  115519. */
  115520. _model: ModelShape;
  115521. /**
  115522. * ModelShape id of this particle
  115523. */
  115524. shapeId: number;
  115525. /**
  115526. * Index of the particle in its shape id
  115527. */
  115528. idxInShape: number;
  115529. /**
  115530. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  115531. */
  115532. _modelBoundingInfo: BoundingInfo;
  115533. /**
  115534. * @hidden Particle BoundingInfo object (Internal use)
  115535. */
  115536. _boundingInfo: BoundingInfo;
  115537. /**
  115538. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  115539. */
  115540. _sps: SolidParticleSystem;
  115541. /**
  115542. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  115543. */
  115544. _stillInvisible: boolean;
  115545. /**
  115546. * @hidden Last computed particle rotation matrix
  115547. */
  115548. _rotationMatrix: number[];
  115549. /**
  115550. * Parent particle Id, if any.
  115551. * Default null.
  115552. */
  115553. parentId: Nullable<number>;
  115554. /**
  115555. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  115556. */
  115557. materialIndex: Nullable<number>;
  115558. /**
  115559. * Custom object or properties.
  115560. */
  115561. props: Nullable<any>;
  115562. /**
  115563. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  115564. * The possible values are :
  115565. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115566. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115567. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115568. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115569. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115570. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  115571. * */
  115572. cullingStrategy: number;
  115573. /**
  115574. * @hidden Internal global position in the SPS.
  115575. */
  115576. _globalPosition: Vector3;
  115577. /**
  115578. * Creates a Solid Particle object.
  115579. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  115580. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  115581. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  115582. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  115583. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  115584. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  115585. * @param shapeId (integer) is the model shape identifier in the SPS.
  115586. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  115587. * @param sps defines the sps it is associated to
  115588. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  115589. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  115590. */
  115591. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  115592. /**
  115593. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  115594. * @param target the particle target
  115595. * @returns the current particle
  115596. */
  115597. copyToRef(target: SolidParticle): SolidParticle;
  115598. /**
  115599. * Legacy support, changed scale to scaling
  115600. */
  115601. get scale(): Vector3;
  115602. /**
  115603. * Legacy support, changed scale to scaling
  115604. */
  115605. set scale(scale: Vector3);
  115606. /**
  115607. * Legacy support, changed quaternion to rotationQuaternion
  115608. */
  115609. get quaternion(): Nullable<Quaternion>;
  115610. /**
  115611. * Legacy support, changed quaternion to rotationQuaternion
  115612. */
  115613. set quaternion(q: Nullable<Quaternion>);
  115614. /**
  115615. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  115616. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  115617. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  115618. * @returns true if it intersects
  115619. */
  115620. intersectsMesh(target: Mesh | SolidParticle): boolean;
  115621. /**
  115622. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  115623. * A particle is in the frustum if its bounding box intersects the frustum
  115624. * @param frustumPlanes defines the frustum to test
  115625. * @returns true if the particle is in the frustum planes
  115626. */
  115627. isInFrustum(frustumPlanes: Plane[]): boolean;
  115628. /**
  115629. * get the rotation matrix of the particle
  115630. * @hidden
  115631. */
  115632. getRotationMatrix(m: Matrix): void;
  115633. }
  115634. /**
  115635. * Represents the shape of the model used by one particle of a solid particle system.
  115636. * SPS internal tool, don't use it manually.
  115637. */
  115638. export class ModelShape {
  115639. /**
  115640. * The shape id
  115641. * @hidden
  115642. */
  115643. shapeID: number;
  115644. /**
  115645. * flat array of model positions (internal use)
  115646. * @hidden
  115647. */
  115648. _shape: Vector3[];
  115649. /**
  115650. * flat array of model UVs (internal use)
  115651. * @hidden
  115652. */
  115653. _shapeUV: number[];
  115654. /**
  115655. * color array of the model
  115656. * @hidden
  115657. */
  115658. _shapeColors: number[];
  115659. /**
  115660. * indices array of the model
  115661. * @hidden
  115662. */
  115663. _indices: number[];
  115664. /**
  115665. * normals array of the model
  115666. * @hidden
  115667. */
  115668. _normals: number[];
  115669. /**
  115670. * length of the shape in the model indices array (internal use)
  115671. * @hidden
  115672. */
  115673. _indicesLength: number;
  115674. /**
  115675. * Custom position function (internal use)
  115676. * @hidden
  115677. */
  115678. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  115679. /**
  115680. * Custom vertex function (internal use)
  115681. * @hidden
  115682. */
  115683. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  115684. /**
  115685. * Model material (internal use)
  115686. * @hidden
  115687. */
  115688. _material: Nullable<Material>;
  115689. /**
  115690. * 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.
  115691. * SPS internal tool, don't use it manually.
  115692. * @hidden
  115693. */
  115694. 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>);
  115695. }
  115696. /**
  115697. * Represents a Depth Sorted Particle in the solid particle system.
  115698. * @hidden
  115699. */
  115700. export class DepthSortedParticle {
  115701. /**
  115702. * Particle index
  115703. */
  115704. idx: number;
  115705. /**
  115706. * Index of the particle in the "indices" array
  115707. */
  115708. ind: number;
  115709. /**
  115710. * Length of the particle shape in the "indices" array
  115711. */
  115712. indicesLength: number;
  115713. /**
  115714. * Squared distance from the particle to the camera
  115715. */
  115716. sqDistance: number;
  115717. /**
  115718. * Material index when used with MultiMaterials
  115719. */
  115720. materialIndex: number;
  115721. /**
  115722. * Creates a new sorted particle
  115723. * @param materialIndex
  115724. */
  115725. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  115726. }
  115727. /**
  115728. * Represents a solid particle vertex
  115729. */
  115730. export class SolidParticleVertex {
  115731. /**
  115732. * Vertex position
  115733. */
  115734. position: Vector3;
  115735. /**
  115736. * Vertex color
  115737. */
  115738. color: Color4;
  115739. /**
  115740. * Vertex UV
  115741. */
  115742. uv: Vector2;
  115743. /**
  115744. * Creates a new solid particle vertex
  115745. */
  115746. constructor();
  115747. /** Vertex x coordinate */
  115748. get x(): number;
  115749. set x(val: number);
  115750. /** Vertex y coordinate */
  115751. get y(): number;
  115752. set y(val: number);
  115753. /** Vertex z coordinate */
  115754. get z(): number;
  115755. set z(val: number);
  115756. }
  115757. }
  115758. declare module BABYLON {
  115759. /**
  115760. * @hidden
  115761. */
  115762. export class _MeshCollisionData {
  115763. _checkCollisions: boolean;
  115764. _collisionMask: number;
  115765. _collisionGroup: number;
  115766. _surroundingMeshes: Nullable<AbstractMesh[]>;
  115767. _collider: Nullable<Collider>;
  115768. _oldPositionForCollisions: Vector3;
  115769. _diffPositionForCollisions: Vector3;
  115770. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  115771. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  115772. _collisionResponse: boolean;
  115773. }
  115774. }
  115775. declare module BABYLON {
  115776. /** @hidden */
  115777. class _FacetDataStorage {
  115778. facetPositions: Vector3[];
  115779. facetNormals: Vector3[];
  115780. facetPartitioning: number[][];
  115781. facetNb: number;
  115782. partitioningSubdivisions: number;
  115783. partitioningBBoxRatio: number;
  115784. facetDataEnabled: boolean;
  115785. facetParameters: any;
  115786. bbSize: Vector3;
  115787. subDiv: {
  115788. max: number;
  115789. X: number;
  115790. Y: number;
  115791. Z: number;
  115792. };
  115793. facetDepthSort: boolean;
  115794. facetDepthSortEnabled: boolean;
  115795. depthSortedIndices: IndicesArray;
  115796. depthSortedFacets: {
  115797. ind: number;
  115798. sqDistance: number;
  115799. }[];
  115800. facetDepthSortFunction: (f1: {
  115801. ind: number;
  115802. sqDistance: number;
  115803. }, f2: {
  115804. ind: number;
  115805. sqDistance: number;
  115806. }) => number;
  115807. facetDepthSortFrom: Vector3;
  115808. facetDepthSortOrigin: Vector3;
  115809. invertedMatrix: Matrix;
  115810. }
  115811. /**
  115812. * @hidden
  115813. **/
  115814. class _InternalAbstractMeshDataInfo {
  115815. _hasVertexAlpha: boolean;
  115816. _useVertexColors: boolean;
  115817. _numBoneInfluencers: number;
  115818. _applyFog: boolean;
  115819. _receiveShadows: boolean;
  115820. _facetData: _FacetDataStorage;
  115821. _visibility: number;
  115822. _skeleton: Nullable<Skeleton>;
  115823. _layerMask: number;
  115824. _computeBonesUsingShaders: boolean;
  115825. _isActive: boolean;
  115826. _onlyForInstances: boolean;
  115827. _isActiveIntermediate: boolean;
  115828. _onlyForInstancesIntermediate: boolean;
  115829. _actAsRegularMesh: boolean;
  115830. }
  115831. /**
  115832. * Class used to store all common mesh properties
  115833. */
  115834. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  115835. /** No occlusion */
  115836. static OCCLUSION_TYPE_NONE: number;
  115837. /** Occlusion set to optimisitic */
  115838. static OCCLUSION_TYPE_OPTIMISTIC: number;
  115839. /** Occlusion set to strict */
  115840. static OCCLUSION_TYPE_STRICT: number;
  115841. /** Use an accurante occlusion algorithm */
  115842. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  115843. /** Use a conservative occlusion algorithm */
  115844. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  115845. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  115846. * Test order :
  115847. * Is the bounding sphere outside the frustum ?
  115848. * If not, are the bounding box vertices outside the frustum ?
  115849. * It not, then the cullable object is in the frustum.
  115850. */
  115851. static readonly CULLINGSTRATEGY_STANDARD: number;
  115852. /** Culling strategy : Bounding Sphere Only.
  115853. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  115854. * It's also less accurate than the standard because some not visible objects can still be selected.
  115855. * Test : is the bounding sphere outside the frustum ?
  115856. * If not, then the cullable object is in the frustum.
  115857. */
  115858. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  115859. /** Culling strategy : Optimistic Inclusion.
  115860. * This in an inclusion test first, then the standard exclusion test.
  115861. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  115862. * 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.
  115863. * Anyway, it's as accurate as the standard strategy.
  115864. * Test :
  115865. * Is the cullable object bounding sphere center in the frustum ?
  115866. * If not, apply the default culling strategy.
  115867. */
  115868. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  115869. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  115870. * This in an inclusion test first, then the bounding sphere only exclusion test.
  115871. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  115872. * 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.
  115873. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  115874. * Test :
  115875. * Is the cullable object bounding sphere center in the frustum ?
  115876. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  115877. */
  115878. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  115879. /**
  115880. * No billboard
  115881. */
  115882. static get BILLBOARDMODE_NONE(): number;
  115883. /** Billboard on X axis */
  115884. static get BILLBOARDMODE_X(): number;
  115885. /** Billboard on Y axis */
  115886. static get BILLBOARDMODE_Y(): number;
  115887. /** Billboard on Z axis */
  115888. static get BILLBOARDMODE_Z(): number;
  115889. /** Billboard on all axes */
  115890. static get BILLBOARDMODE_ALL(): number;
  115891. /** Billboard on using position instead of orientation */
  115892. static get BILLBOARDMODE_USE_POSITION(): number;
  115893. /** @hidden */
  115894. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  115895. /**
  115896. * The culling strategy to use to check whether the mesh must be rendered or not.
  115897. * This value can be changed at any time and will be used on the next render mesh selection.
  115898. * The possible values are :
  115899. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115900. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115901. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115902. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115903. * Please read each static variable documentation to get details about the culling process.
  115904. * */
  115905. cullingStrategy: number;
  115906. /**
  115907. * Gets the number of facets in the mesh
  115908. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  115909. */
  115910. get facetNb(): number;
  115911. /**
  115912. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  115913. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  115914. */
  115915. get partitioningSubdivisions(): number;
  115916. set partitioningSubdivisions(nb: number);
  115917. /**
  115918. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  115919. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  115920. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  115921. */
  115922. get partitioningBBoxRatio(): number;
  115923. set partitioningBBoxRatio(ratio: number);
  115924. /**
  115925. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  115926. * Works only for updatable meshes.
  115927. * Doesn't work with multi-materials
  115928. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  115929. */
  115930. get mustDepthSortFacets(): boolean;
  115931. set mustDepthSortFacets(sort: boolean);
  115932. /**
  115933. * The location (Vector3) where the facet depth sort must be computed from.
  115934. * By default, the active camera position.
  115935. * Used only when facet depth sort is enabled
  115936. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  115937. */
  115938. get facetDepthSortFrom(): Vector3;
  115939. set facetDepthSortFrom(location: Vector3);
  115940. /**
  115941. * gets a boolean indicating if facetData is enabled
  115942. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  115943. */
  115944. get isFacetDataEnabled(): boolean;
  115945. /** @hidden */
  115946. _updateNonUniformScalingState(value: boolean): boolean;
  115947. /**
  115948. * An event triggered when this mesh collides with another one
  115949. */
  115950. onCollideObservable: Observable<AbstractMesh>;
  115951. /** Set a function to call when this mesh collides with another one */
  115952. set onCollide(callback: () => void);
  115953. /**
  115954. * An event triggered when the collision's position changes
  115955. */
  115956. onCollisionPositionChangeObservable: Observable<Vector3>;
  115957. /** Set a function to call when the collision's position changes */
  115958. set onCollisionPositionChange(callback: () => void);
  115959. /**
  115960. * An event triggered when material is changed
  115961. */
  115962. onMaterialChangedObservable: Observable<AbstractMesh>;
  115963. /**
  115964. * Gets or sets the orientation for POV movement & rotation
  115965. */
  115966. definedFacingForward: boolean;
  115967. /** @hidden */
  115968. _occlusionQuery: Nullable<WebGLQuery>;
  115969. /** @hidden */
  115970. _renderingGroup: Nullable<RenderingGroup>;
  115971. /**
  115972. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  115973. */
  115974. get visibility(): number;
  115975. /**
  115976. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  115977. */
  115978. set visibility(value: number);
  115979. /** Gets or sets the alpha index used to sort transparent meshes
  115980. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  115981. */
  115982. alphaIndex: number;
  115983. /**
  115984. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  115985. */
  115986. isVisible: boolean;
  115987. /**
  115988. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  115989. */
  115990. isPickable: boolean;
  115991. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  115992. showSubMeshesBoundingBox: boolean;
  115993. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  115994. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115995. */
  115996. isBlocker: boolean;
  115997. /**
  115998. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  115999. */
  116000. enablePointerMoveEvents: boolean;
  116001. private _renderingGroupId;
  116002. /**
  116003. * Specifies the rendering group id for this mesh (0 by default)
  116004. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116005. */
  116006. get renderingGroupId(): number;
  116007. set renderingGroupId(value: number);
  116008. private _material;
  116009. /** Gets or sets current material */
  116010. get material(): Nullable<Material>;
  116011. set material(value: Nullable<Material>);
  116012. /**
  116013. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116014. * @see https://doc.babylonjs.com/babylon101/shadows
  116015. */
  116016. get receiveShadows(): boolean;
  116017. set receiveShadows(value: boolean);
  116018. /** Defines color to use when rendering outline */
  116019. outlineColor: Color3;
  116020. /** Define width to use when rendering outline */
  116021. outlineWidth: number;
  116022. /** Defines color to use when rendering overlay */
  116023. overlayColor: Color3;
  116024. /** Defines alpha to use when rendering overlay */
  116025. overlayAlpha: number;
  116026. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116027. get hasVertexAlpha(): boolean;
  116028. set hasVertexAlpha(value: boolean);
  116029. /** 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) */
  116030. get useVertexColors(): boolean;
  116031. set useVertexColors(value: boolean);
  116032. /**
  116033. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116034. */
  116035. get computeBonesUsingShaders(): boolean;
  116036. set computeBonesUsingShaders(value: boolean);
  116037. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116038. get numBoneInfluencers(): number;
  116039. set numBoneInfluencers(value: number);
  116040. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116041. get applyFog(): boolean;
  116042. set applyFog(value: boolean);
  116043. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116044. useOctreeForRenderingSelection: boolean;
  116045. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116046. useOctreeForPicking: boolean;
  116047. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116048. useOctreeForCollisions: boolean;
  116049. /**
  116050. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116051. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116052. */
  116053. get layerMask(): number;
  116054. set layerMask(value: number);
  116055. /**
  116056. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116057. */
  116058. alwaysSelectAsActiveMesh: boolean;
  116059. /**
  116060. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116061. */
  116062. doNotSyncBoundingInfo: boolean;
  116063. /**
  116064. * Gets or sets the current action manager
  116065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116066. */
  116067. actionManager: Nullable<AbstractActionManager>;
  116068. private _meshCollisionData;
  116069. /**
  116070. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116071. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116072. */
  116073. ellipsoid: Vector3;
  116074. /**
  116075. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116076. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116077. */
  116078. ellipsoidOffset: Vector3;
  116079. /**
  116080. * Gets or sets a collision mask used to mask collisions (default is -1).
  116081. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116082. */
  116083. get collisionMask(): number;
  116084. set collisionMask(mask: number);
  116085. /**
  116086. * Gets or sets a collision response flag (default is true).
  116087. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116088. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116089. * to respond to the collision.
  116090. */
  116091. get collisionResponse(): boolean;
  116092. set collisionResponse(response: boolean);
  116093. /**
  116094. * Gets or sets the current collision group mask (-1 by default).
  116095. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116096. */
  116097. get collisionGroup(): number;
  116098. set collisionGroup(mask: number);
  116099. /**
  116100. * Gets or sets current surrounding meshes (null by default).
  116101. *
  116102. * By default collision detection is tested against every mesh in the scene.
  116103. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116104. * meshes will be tested for the collision.
  116105. *
  116106. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116107. */
  116108. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116109. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116110. /**
  116111. * Defines edge width used when edgesRenderer is enabled
  116112. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116113. */
  116114. edgesWidth: number;
  116115. /**
  116116. * Defines edge color used when edgesRenderer is enabled
  116117. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116118. */
  116119. edgesColor: Color4;
  116120. /** @hidden */
  116121. _edgesRenderer: Nullable<IEdgesRenderer>;
  116122. /** @hidden */
  116123. _masterMesh: Nullable<AbstractMesh>;
  116124. /** @hidden */
  116125. _boundingInfo: Nullable<BoundingInfo>;
  116126. /** @hidden */
  116127. _renderId: number;
  116128. /**
  116129. * Gets or sets the list of subMeshes
  116130. * @see https://doc.babylonjs.com/how_to/multi_materials
  116131. */
  116132. subMeshes: SubMesh[];
  116133. /** @hidden */
  116134. _intersectionsInProgress: AbstractMesh[];
  116135. /** @hidden */
  116136. _unIndexed: boolean;
  116137. /** @hidden */
  116138. _lightSources: Light[];
  116139. /** Gets the list of lights affecting that mesh */
  116140. get lightSources(): Light[];
  116141. /** @hidden */
  116142. get _positions(): Nullable<Vector3[]>;
  116143. /** @hidden */
  116144. _waitingData: {
  116145. lods: Nullable<any>;
  116146. actions: Nullable<any>;
  116147. freezeWorldMatrix: Nullable<boolean>;
  116148. };
  116149. /** @hidden */
  116150. _bonesTransformMatrices: Nullable<Float32Array>;
  116151. /** @hidden */
  116152. _transformMatrixTexture: Nullable<RawTexture>;
  116153. /**
  116154. * Gets or sets a skeleton to apply skining transformations
  116155. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116156. */
  116157. set skeleton(value: Nullable<Skeleton>);
  116158. get skeleton(): Nullable<Skeleton>;
  116159. /**
  116160. * An event triggered when the mesh is rebuilt.
  116161. */
  116162. onRebuildObservable: Observable<AbstractMesh>;
  116163. /**
  116164. * Creates a new AbstractMesh
  116165. * @param name defines the name of the mesh
  116166. * @param scene defines the hosting scene
  116167. */
  116168. constructor(name: string, scene?: Nullable<Scene>);
  116169. /**
  116170. * Returns the string "AbstractMesh"
  116171. * @returns "AbstractMesh"
  116172. */
  116173. getClassName(): string;
  116174. /**
  116175. * Gets a string representation of the current mesh
  116176. * @param fullDetails defines a boolean indicating if full details must be included
  116177. * @returns a string representation of the current mesh
  116178. */
  116179. toString(fullDetails?: boolean): string;
  116180. /**
  116181. * @hidden
  116182. */
  116183. protected _getEffectiveParent(): Nullable<Node>;
  116184. /** @hidden */
  116185. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116186. /** @hidden */
  116187. _rebuild(): void;
  116188. /** @hidden */
  116189. _resyncLightSources(): void;
  116190. /** @hidden */
  116191. _resyncLightSource(light: Light): void;
  116192. /** @hidden */
  116193. _unBindEffect(): void;
  116194. /** @hidden */
  116195. _removeLightSource(light: Light, dispose: boolean): void;
  116196. private _markSubMeshesAsDirty;
  116197. /** @hidden */
  116198. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116199. /** @hidden */
  116200. _markSubMeshesAsAttributesDirty(): void;
  116201. /** @hidden */
  116202. _markSubMeshesAsMiscDirty(): void;
  116203. /**
  116204. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116205. */
  116206. get scaling(): Vector3;
  116207. set scaling(newScaling: Vector3);
  116208. /**
  116209. * Returns true if the mesh is blocked. Implemented by child classes
  116210. */
  116211. get isBlocked(): boolean;
  116212. /**
  116213. * Returns the mesh itself by default. Implemented by child classes
  116214. * @param camera defines the camera to use to pick the right LOD level
  116215. * @returns the currentAbstractMesh
  116216. */
  116217. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116218. /**
  116219. * Returns 0 by default. Implemented by child classes
  116220. * @returns an integer
  116221. */
  116222. getTotalVertices(): number;
  116223. /**
  116224. * Returns a positive integer : the total number of indices in this mesh geometry.
  116225. * @returns the numner of indices or zero if the mesh has no geometry.
  116226. */
  116227. getTotalIndices(): number;
  116228. /**
  116229. * Returns null by default. Implemented by child classes
  116230. * @returns null
  116231. */
  116232. getIndices(): Nullable<IndicesArray>;
  116233. /**
  116234. * Returns the array of the requested vertex data kind. Implemented by child classes
  116235. * @param kind defines the vertex data kind to use
  116236. * @returns null
  116237. */
  116238. getVerticesData(kind: string): Nullable<FloatArray>;
  116239. /**
  116240. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116241. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116242. * Note that a new underlying VertexBuffer object is created each call.
  116243. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116244. * @param kind defines vertex data kind:
  116245. * * VertexBuffer.PositionKind
  116246. * * VertexBuffer.UVKind
  116247. * * VertexBuffer.UV2Kind
  116248. * * VertexBuffer.UV3Kind
  116249. * * VertexBuffer.UV4Kind
  116250. * * VertexBuffer.UV5Kind
  116251. * * VertexBuffer.UV6Kind
  116252. * * VertexBuffer.ColorKind
  116253. * * VertexBuffer.MatricesIndicesKind
  116254. * * VertexBuffer.MatricesIndicesExtraKind
  116255. * * VertexBuffer.MatricesWeightsKind
  116256. * * VertexBuffer.MatricesWeightsExtraKind
  116257. * @param data defines the data source
  116258. * @param updatable defines if the data must be flagged as updatable (or static)
  116259. * @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
  116260. * @returns the current mesh
  116261. */
  116262. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  116263. /**
  116264. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  116265. * If the mesh has no geometry, it is simply returned as it is.
  116266. * @param kind defines vertex data kind:
  116267. * * VertexBuffer.PositionKind
  116268. * * VertexBuffer.UVKind
  116269. * * VertexBuffer.UV2Kind
  116270. * * VertexBuffer.UV3Kind
  116271. * * VertexBuffer.UV4Kind
  116272. * * VertexBuffer.UV5Kind
  116273. * * VertexBuffer.UV6Kind
  116274. * * VertexBuffer.ColorKind
  116275. * * VertexBuffer.MatricesIndicesKind
  116276. * * VertexBuffer.MatricesIndicesExtraKind
  116277. * * VertexBuffer.MatricesWeightsKind
  116278. * * VertexBuffer.MatricesWeightsExtraKind
  116279. * @param data defines the data source
  116280. * @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
  116281. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  116282. * @returns the current mesh
  116283. */
  116284. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  116285. /**
  116286. * Sets the mesh indices,
  116287. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  116288. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  116289. * @param totalVertices Defines the total number of vertices
  116290. * @returns the current mesh
  116291. */
  116292. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  116293. /**
  116294. * Gets a boolean indicating if specific vertex data is present
  116295. * @param kind defines the vertex data kind to use
  116296. * @returns true is data kind is present
  116297. */
  116298. isVerticesDataPresent(kind: string): boolean;
  116299. /**
  116300. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  116301. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  116302. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  116303. * @returns a BoundingInfo
  116304. */
  116305. getBoundingInfo(): BoundingInfo;
  116306. /**
  116307. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  116308. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  116309. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  116310. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  116311. * @returns the current mesh
  116312. */
  116313. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  116314. /**
  116315. * Overwrite the current bounding info
  116316. * @param boundingInfo defines the new bounding info
  116317. * @returns the current mesh
  116318. */
  116319. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  116320. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  116321. get useBones(): boolean;
  116322. /** @hidden */
  116323. _preActivate(): void;
  116324. /** @hidden */
  116325. _preActivateForIntermediateRendering(renderId: number): void;
  116326. /** @hidden */
  116327. _activate(renderId: number, intermediateRendering: boolean): boolean;
  116328. /** @hidden */
  116329. _postActivate(): void;
  116330. /** @hidden */
  116331. _freeze(): void;
  116332. /** @hidden */
  116333. _unFreeze(): void;
  116334. /**
  116335. * Gets the current world matrix
  116336. * @returns a Matrix
  116337. */
  116338. getWorldMatrix(): Matrix;
  116339. /** @hidden */
  116340. _getWorldMatrixDeterminant(): number;
  116341. /**
  116342. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  116343. */
  116344. get isAnInstance(): boolean;
  116345. /**
  116346. * Gets a boolean indicating if this mesh has instances
  116347. */
  116348. get hasInstances(): boolean;
  116349. /**
  116350. * Gets a boolean indicating if this mesh has thin instances
  116351. */
  116352. get hasThinInstances(): boolean;
  116353. /**
  116354. * Perform relative position change from the point of view of behind the front of the mesh.
  116355. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116356. * Supports definition of mesh facing forward or backward
  116357. * @param amountRight defines the distance on the right axis
  116358. * @param amountUp defines the distance on the up axis
  116359. * @param amountForward defines the distance on the forward axis
  116360. * @returns the current mesh
  116361. */
  116362. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  116363. /**
  116364. * Calculate relative position change from the point of view of behind the front of the mesh.
  116365. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116366. * Supports definition of mesh facing forward or backward
  116367. * @param amountRight defines the distance on the right axis
  116368. * @param amountUp defines the distance on the up axis
  116369. * @param amountForward defines the distance on the forward axis
  116370. * @returns the new displacement vector
  116371. */
  116372. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  116373. /**
  116374. * Perform relative rotation change from the point of view of behind the front of the mesh.
  116375. * Supports definition of mesh facing forward or backward
  116376. * @param flipBack defines the flip
  116377. * @param twirlClockwise defines the twirl
  116378. * @param tiltRight defines the tilt
  116379. * @returns the current mesh
  116380. */
  116381. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  116382. /**
  116383. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  116384. * Supports definition of mesh facing forward or backward.
  116385. * @param flipBack defines the flip
  116386. * @param twirlClockwise defines the twirl
  116387. * @param tiltRight defines the tilt
  116388. * @returns the new rotation vector
  116389. */
  116390. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  116391. /**
  116392. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  116393. * This means the mesh underlying bounding box and sphere are recomputed.
  116394. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  116395. * @returns the current mesh
  116396. */
  116397. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  116398. /** @hidden */
  116399. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  116400. /** @hidden */
  116401. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  116402. /** @hidden */
  116403. _updateBoundingInfo(): AbstractMesh;
  116404. /** @hidden */
  116405. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  116406. /** @hidden */
  116407. protected _afterComputeWorldMatrix(): void;
  116408. /** @hidden */
  116409. get _effectiveMesh(): AbstractMesh;
  116410. /**
  116411. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  116412. * A mesh is in the frustum if its bounding box intersects the frustum
  116413. * @param frustumPlanes defines the frustum to test
  116414. * @returns true if the mesh is in the frustum planes
  116415. */
  116416. isInFrustum(frustumPlanes: Plane[]): boolean;
  116417. /**
  116418. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  116419. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  116420. * @param frustumPlanes defines the frustum to test
  116421. * @returns true if the mesh is completely in the frustum planes
  116422. */
  116423. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  116424. /**
  116425. * True if the mesh intersects another mesh or a SolidParticle object
  116426. * @param mesh defines a target mesh or SolidParticle to test
  116427. * @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)
  116428. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  116429. * @returns true if there is an intersection
  116430. */
  116431. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  116432. /**
  116433. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  116434. * @param point defines the point to test
  116435. * @returns true if there is an intersection
  116436. */
  116437. intersectsPoint(point: Vector3): boolean;
  116438. /**
  116439. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  116440. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116441. */
  116442. get checkCollisions(): boolean;
  116443. set checkCollisions(collisionEnabled: boolean);
  116444. /**
  116445. * Gets Collider object used to compute collisions (not physics)
  116446. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116447. */
  116448. get collider(): Nullable<Collider>;
  116449. /**
  116450. * Move the mesh using collision engine
  116451. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116452. * @param displacement defines the requested displacement vector
  116453. * @returns the current mesh
  116454. */
  116455. moveWithCollisions(displacement: Vector3): AbstractMesh;
  116456. private _onCollisionPositionChange;
  116457. /** @hidden */
  116458. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  116459. /** @hidden */
  116460. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  116461. /** @hidden */
  116462. _checkCollision(collider: Collider): AbstractMesh;
  116463. /** @hidden */
  116464. _generatePointsArray(): boolean;
  116465. /**
  116466. * Checks if the passed Ray intersects with the mesh
  116467. * @param ray defines the ray to use
  116468. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  116469. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116470. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  116471. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  116472. * @returns the picking info
  116473. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  116474. */
  116475. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  116476. /**
  116477. * Clones the current mesh
  116478. * @param name defines the mesh name
  116479. * @param newParent defines the new mesh parent
  116480. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  116481. * @returns the new mesh
  116482. */
  116483. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  116484. /**
  116485. * Disposes all the submeshes of the current meshnp
  116486. * @returns the current mesh
  116487. */
  116488. releaseSubMeshes(): AbstractMesh;
  116489. /**
  116490. * Releases resources associated with this abstract mesh.
  116491. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116492. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116493. */
  116494. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116495. /**
  116496. * Adds the passed mesh as a child to the current mesh
  116497. * @param mesh defines the child mesh
  116498. * @returns the current mesh
  116499. */
  116500. addChild(mesh: AbstractMesh): AbstractMesh;
  116501. /**
  116502. * Removes the passed mesh from the current mesh children list
  116503. * @param mesh defines the child mesh
  116504. * @returns the current mesh
  116505. */
  116506. removeChild(mesh: AbstractMesh): AbstractMesh;
  116507. /** @hidden */
  116508. private _initFacetData;
  116509. /**
  116510. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  116511. * This method can be called within the render loop.
  116512. * 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
  116513. * @returns the current mesh
  116514. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116515. */
  116516. updateFacetData(): AbstractMesh;
  116517. /**
  116518. * Returns the facetLocalNormals array.
  116519. * The normals are expressed in the mesh local spac
  116520. * @returns an array of Vector3
  116521. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116522. */
  116523. getFacetLocalNormals(): Vector3[];
  116524. /**
  116525. * Returns the facetLocalPositions array.
  116526. * The facet positions are expressed in the mesh local space
  116527. * @returns an array of Vector3
  116528. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116529. */
  116530. getFacetLocalPositions(): Vector3[];
  116531. /**
  116532. * Returns the facetLocalPartioning array
  116533. * @returns an array of array of numbers
  116534. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116535. */
  116536. getFacetLocalPartitioning(): number[][];
  116537. /**
  116538. * Returns the i-th facet position in the world system.
  116539. * This method allocates a new Vector3 per call
  116540. * @param i defines the facet index
  116541. * @returns a new Vector3
  116542. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116543. */
  116544. getFacetPosition(i: number): Vector3;
  116545. /**
  116546. * Sets the reference Vector3 with the i-th facet position in the world system
  116547. * @param i defines the facet index
  116548. * @param ref defines the target vector
  116549. * @returns the current mesh
  116550. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116551. */
  116552. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  116553. /**
  116554. * Returns the i-th facet normal in the world system.
  116555. * This method allocates a new Vector3 per call
  116556. * @param i defines the facet index
  116557. * @returns a new Vector3
  116558. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116559. */
  116560. getFacetNormal(i: number): Vector3;
  116561. /**
  116562. * Sets the reference Vector3 with the i-th facet normal in the world system
  116563. * @param i defines the facet index
  116564. * @param ref defines the target vector
  116565. * @returns the current mesh
  116566. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116567. */
  116568. getFacetNormalToRef(i: number, ref: Vector3): this;
  116569. /**
  116570. * 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)
  116571. * @param x defines x coordinate
  116572. * @param y defines y coordinate
  116573. * @param z defines z coordinate
  116574. * @returns the array of facet indexes
  116575. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116576. */
  116577. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  116578. /**
  116579. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  116580. * @param projected sets as the (x,y,z) world projection on the facet
  116581. * @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
  116582. * @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
  116583. * @param x defines x coordinate
  116584. * @param y defines y coordinate
  116585. * @param z defines z coordinate
  116586. * @returns the face index if found (or null instead)
  116587. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116588. */
  116589. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116590. /**
  116591. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  116592. * @param projected sets as the (x,y,z) local projection on the facet
  116593. * @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
  116594. * @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
  116595. * @param x defines x coordinate
  116596. * @param y defines y coordinate
  116597. * @param z defines z coordinate
  116598. * @returns the face index if found (or null instead)
  116599. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116600. */
  116601. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116602. /**
  116603. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  116604. * @returns the parameters
  116605. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116606. */
  116607. getFacetDataParameters(): any;
  116608. /**
  116609. * Disables the feature FacetData and frees the related memory
  116610. * @returns the current mesh
  116611. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116612. */
  116613. disableFacetData(): AbstractMesh;
  116614. /**
  116615. * Updates the AbstractMesh indices array
  116616. * @param indices defines the data source
  116617. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  116618. * @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)
  116619. * @returns the current mesh
  116620. */
  116621. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  116622. /**
  116623. * Creates new normals data for the mesh
  116624. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  116625. * @returns the current mesh
  116626. */
  116627. createNormals(updatable: boolean): AbstractMesh;
  116628. /**
  116629. * Align the mesh with a normal
  116630. * @param normal defines the normal to use
  116631. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  116632. * @returns the current mesh
  116633. */
  116634. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  116635. /** @hidden */
  116636. _checkOcclusionQuery(): boolean;
  116637. /**
  116638. * Disables the mesh edge rendering mode
  116639. * @returns the currentAbstractMesh
  116640. */
  116641. disableEdgesRendering(): AbstractMesh;
  116642. /**
  116643. * Enables the edge rendering mode on the mesh.
  116644. * This mode makes the mesh edges visible
  116645. * @param epsilon defines the maximal distance between two angles to detect a face
  116646. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  116647. * @returns the currentAbstractMesh
  116648. * @see https://www.babylonjs-playground.com/#19O9TU#0
  116649. */
  116650. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  116651. /**
  116652. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  116653. * @returns an array of particle systems in the scene that use the mesh as an emitter
  116654. */
  116655. getConnectedParticleSystems(): IParticleSystem[];
  116656. }
  116657. }
  116658. declare module BABYLON {
  116659. /**
  116660. * Interface used to define ActionEvent
  116661. */
  116662. export interface IActionEvent {
  116663. /** The mesh or sprite that triggered the action */
  116664. source: any;
  116665. /** The X mouse cursor position at the time of the event */
  116666. pointerX: number;
  116667. /** The Y mouse cursor position at the time of the event */
  116668. pointerY: number;
  116669. /** The mesh that is currently pointed at (can be null) */
  116670. meshUnderPointer: Nullable<AbstractMesh>;
  116671. /** the original (browser) event that triggered the ActionEvent */
  116672. sourceEvent?: any;
  116673. /** additional data for the event */
  116674. additionalData?: any;
  116675. }
  116676. /**
  116677. * ActionEvent is the event being sent when an action is triggered.
  116678. */
  116679. export class ActionEvent implements IActionEvent {
  116680. /** The mesh or sprite that triggered the action */
  116681. source: any;
  116682. /** The X mouse cursor position at the time of the event */
  116683. pointerX: number;
  116684. /** The Y mouse cursor position at the time of the event */
  116685. pointerY: number;
  116686. /** The mesh that is currently pointed at (can be null) */
  116687. meshUnderPointer: Nullable<AbstractMesh>;
  116688. /** the original (browser) event that triggered the ActionEvent */
  116689. sourceEvent?: any;
  116690. /** additional data for the event */
  116691. additionalData?: any;
  116692. /**
  116693. * Creates a new ActionEvent
  116694. * @param source The mesh or sprite that triggered the action
  116695. * @param pointerX The X mouse cursor position at the time of the event
  116696. * @param pointerY The Y mouse cursor position at the time of the event
  116697. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  116698. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  116699. * @param additionalData additional data for the event
  116700. */
  116701. constructor(
  116702. /** The mesh or sprite that triggered the action */
  116703. source: any,
  116704. /** The X mouse cursor position at the time of the event */
  116705. pointerX: number,
  116706. /** The Y mouse cursor position at the time of the event */
  116707. pointerY: number,
  116708. /** The mesh that is currently pointed at (can be null) */
  116709. meshUnderPointer: Nullable<AbstractMesh>,
  116710. /** the original (browser) event that triggered the ActionEvent */
  116711. sourceEvent?: any,
  116712. /** additional data for the event */
  116713. additionalData?: any);
  116714. /**
  116715. * Helper function to auto-create an ActionEvent from a source mesh.
  116716. * @param source The source mesh that triggered the event
  116717. * @param evt The original (browser) event
  116718. * @param additionalData additional data for the event
  116719. * @returns the new ActionEvent
  116720. */
  116721. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  116722. /**
  116723. * Helper function to auto-create an ActionEvent from a source sprite
  116724. * @param source The source sprite that triggered the event
  116725. * @param scene Scene associated with the sprite
  116726. * @param evt The original (browser) event
  116727. * @param additionalData additional data for the event
  116728. * @returns the new ActionEvent
  116729. */
  116730. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  116731. /**
  116732. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  116733. * @param scene the scene where the event occurred
  116734. * @param evt The original (browser) event
  116735. * @returns the new ActionEvent
  116736. */
  116737. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  116738. /**
  116739. * Helper function to auto-create an ActionEvent from a primitive
  116740. * @param prim defines the target primitive
  116741. * @param pointerPos defines the pointer position
  116742. * @param evt The original (browser) event
  116743. * @param additionalData additional data for the event
  116744. * @returns the new ActionEvent
  116745. */
  116746. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  116747. }
  116748. }
  116749. declare module BABYLON {
  116750. /**
  116751. * Abstract class used to decouple action Manager from scene and meshes.
  116752. * Do not instantiate.
  116753. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116754. */
  116755. export abstract class AbstractActionManager implements IDisposable {
  116756. /** Gets the list of active triggers */
  116757. static Triggers: {
  116758. [key: string]: number;
  116759. };
  116760. /** Gets the cursor to use when hovering items */
  116761. hoverCursor: string;
  116762. /** Gets the list of actions */
  116763. actions: IAction[];
  116764. /**
  116765. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  116766. */
  116767. isRecursive: boolean;
  116768. /**
  116769. * Releases all associated resources
  116770. */
  116771. abstract dispose(): void;
  116772. /**
  116773. * Does this action manager has pointer triggers
  116774. */
  116775. abstract get hasPointerTriggers(): boolean;
  116776. /**
  116777. * Does this action manager has pick triggers
  116778. */
  116779. abstract get hasPickTriggers(): boolean;
  116780. /**
  116781. * Process a specific trigger
  116782. * @param trigger defines the trigger to process
  116783. * @param evt defines the event details to be processed
  116784. */
  116785. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  116786. /**
  116787. * Does this action manager handles actions of any of the given triggers
  116788. * @param triggers defines the triggers to be tested
  116789. * @return a boolean indicating whether one (or more) of the triggers is handled
  116790. */
  116791. abstract hasSpecificTriggers(triggers: number[]): boolean;
  116792. /**
  116793. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  116794. * speed.
  116795. * @param triggerA defines the trigger to be tested
  116796. * @param triggerB defines the trigger to be tested
  116797. * @return a boolean indicating whether one (or more) of the triggers is handled
  116798. */
  116799. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  116800. /**
  116801. * Does this action manager handles actions of a given trigger
  116802. * @param trigger defines the trigger to be tested
  116803. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  116804. * @return whether the trigger is handled
  116805. */
  116806. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  116807. /**
  116808. * Serialize this manager to a JSON object
  116809. * @param name defines the property name to store this manager
  116810. * @returns a JSON representation of this manager
  116811. */
  116812. abstract serialize(name: string): any;
  116813. /**
  116814. * Registers an action to this action manager
  116815. * @param action defines the action to be registered
  116816. * @return the action amended (prepared) after registration
  116817. */
  116818. abstract registerAction(action: IAction): Nullable<IAction>;
  116819. /**
  116820. * Unregisters an action to this action manager
  116821. * @param action defines the action to be unregistered
  116822. * @return a boolean indicating whether the action has been unregistered
  116823. */
  116824. abstract unregisterAction(action: IAction): Boolean;
  116825. /**
  116826. * Does exist one action manager with at least one trigger
  116827. **/
  116828. static get HasTriggers(): boolean;
  116829. /**
  116830. * Does exist one action manager with at least one pick trigger
  116831. **/
  116832. static get HasPickTriggers(): boolean;
  116833. /**
  116834. * Does exist one action manager that handles actions of a given trigger
  116835. * @param trigger defines the trigger to be tested
  116836. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  116837. **/
  116838. static HasSpecificTrigger(trigger: number): boolean;
  116839. }
  116840. }
  116841. declare module BABYLON {
  116842. /**
  116843. * Defines how a node can be built from a string name.
  116844. */
  116845. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  116846. /**
  116847. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  116848. */
  116849. export class Node implements IBehaviorAware<Node> {
  116850. /** @hidden */
  116851. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  116852. private static _NodeConstructors;
  116853. /**
  116854. * Add a new node constructor
  116855. * @param type defines the type name of the node to construct
  116856. * @param constructorFunc defines the constructor function
  116857. */
  116858. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  116859. /**
  116860. * Returns a node constructor based on type name
  116861. * @param type defines the type name
  116862. * @param name defines the new node name
  116863. * @param scene defines the hosting scene
  116864. * @param options defines optional options to transmit to constructors
  116865. * @returns the new constructor or null
  116866. */
  116867. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  116868. /**
  116869. * Gets or sets the name of the node
  116870. */
  116871. name: string;
  116872. /**
  116873. * Gets or sets the id of the node
  116874. */
  116875. id: string;
  116876. /**
  116877. * Gets or sets the unique id of the node
  116878. */
  116879. uniqueId: number;
  116880. /**
  116881. * Gets or sets a string used to store user defined state for the node
  116882. */
  116883. state: string;
  116884. /**
  116885. * Gets or sets an object used to store user defined information for the node
  116886. */
  116887. metadata: any;
  116888. /**
  116889. * For internal use only. Please do not use.
  116890. */
  116891. reservedDataStore: any;
  116892. /**
  116893. * List of inspectable custom properties (used by the Inspector)
  116894. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  116895. */
  116896. inspectableCustomProperties: IInspectable[];
  116897. private _doNotSerialize;
  116898. /**
  116899. * Gets or sets a boolean used to define if the node must be serialized
  116900. */
  116901. get doNotSerialize(): boolean;
  116902. set doNotSerialize(value: boolean);
  116903. /** @hidden */
  116904. _isDisposed: boolean;
  116905. /**
  116906. * Gets a list of Animations associated with the node
  116907. */
  116908. animations: Animation[];
  116909. protected _ranges: {
  116910. [name: string]: Nullable<AnimationRange>;
  116911. };
  116912. /**
  116913. * Callback raised when the node is ready to be used
  116914. */
  116915. onReady: Nullable<(node: Node) => void>;
  116916. private _isEnabled;
  116917. private _isParentEnabled;
  116918. private _isReady;
  116919. /** @hidden */
  116920. _currentRenderId: number;
  116921. private _parentUpdateId;
  116922. /** @hidden */
  116923. _childUpdateId: number;
  116924. /** @hidden */
  116925. _waitingParentId: Nullable<string>;
  116926. /** @hidden */
  116927. _scene: Scene;
  116928. /** @hidden */
  116929. _cache: any;
  116930. private _parentNode;
  116931. private _children;
  116932. /** @hidden */
  116933. _worldMatrix: Matrix;
  116934. /** @hidden */
  116935. _worldMatrixDeterminant: number;
  116936. /** @hidden */
  116937. _worldMatrixDeterminantIsDirty: boolean;
  116938. /** @hidden */
  116939. private _sceneRootNodesIndex;
  116940. /**
  116941. * Gets a boolean indicating if the node has been disposed
  116942. * @returns true if the node was disposed
  116943. */
  116944. isDisposed(): boolean;
  116945. /**
  116946. * Gets or sets the parent of the node (without keeping the current position in the scene)
  116947. * @see https://doc.babylonjs.com/how_to/parenting
  116948. */
  116949. set parent(parent: Nullable<Node>);
  116950. get parent(): Nullable<Node>;
  116951. /** @hidden */
  116952. _addToSceneRootNodes(): void;
  116953. /** @hidden */
  116954. _removeFromSceneRootNodes(): void;
  116955. private _animationPropertiesOverride;
  116956. /**
  116957. * Gets or sets the animation properties override
  116958. */
  116959. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116960. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116961. /**
  116962. * Gets a string identifying the name of the class
  116963. * @returns "Node" string
  116964. */
  116965. getClassName(): string;
  116966. /** @hidden */
  116967. readonly _isNode: boolean;
  116968. /**
  116969. * An event triggered when the mesh is disposed
  116970. */
  116971. onDisposeObservable: Observable<Node>;
  116972. private _onDisposeObserver;
  116973. /**
  116974. * Sets a callback that will be raised when the node will be disposed
  116975. */
  116976. set onDispose(callback: () => void);
  116977. /**
  116978. * Creates a new Node
  116979. * @param name the name and id to be given to this node
  116980. * @param scene the scene this node will be added to
  116981. */
  116982. constructor(name: string, scene?: Nullable<Scene>);
  116983. /**
  116984. * Gets the scene of the node
  116985. * @returns a scene
  116986. */
  116987. getScene(): Scene;
  116988. /**
  116989. * Gets the engine of the node
  116990. * @returns a Engine
  116991. */
  116992. getEngine(): Engine;
  116993. private _behaviors;
  116994. /**
  116995. * Attach a behavior to the node
  116996. * @see https://doc.babylonjs.com/features/behaviour
  116997. * @param behavior defines the behavior to attach
  116998. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  116999. * @returns the current Node
  117000. */
  117001. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117002. /**
  117003. * Remove an attached behavior
  117004. * @see https://doc.babylonjs.com/features/behaviour
  117005. * @param behavior defines the behavior to attach
  117006. * @returns the current Node
  117007. */
  117008. removeBehavior(behavior: Behavior<Node>): Node;
  117009. /**
  117010. * Gets the list of attached behaviors
  117011. * @see https://doc.babylonjs.com/features/behaviour
  117012. */
  117013. get behaviors(): Behavior<Node>[];
  117014. /**
  117015. * Gets an attached behavior by name
  117016. * @param name defines the name of the behavior to look for
  117017. * @see https://doc.babylonjs.com/features/behaviour
  117018. * @returns null if behavior was not found else the requested behavior
  117019. */
  117020. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117021. /**
  117022. * Returns the latest update of the World matrix
  117023. * @returns a Matrix
  117024. */
  117025. getWorldMatrix(): Matrix;
  117026. /** @hidden */
  117027. _getWorldMatrixDeterminant(): number;
  117028. /**
  117029. * Returns directly the latest state of the mesh World matrix.
  117030. * A Matrix is returned.
  117031. */
  117032. get worldMatrixFromCache(): Matrix;
  117033. /** @hidden */
  117034. _initCache(): void;
  117035. /** @hidden */
  117036. updateCache(force?: boolean): void;
  117037. /** @hidden */
  117038. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117039. /** @hidden */
  117040. _updateCache(ignoreParentClass?: boolean): void;
  117041. /** @hidden */
  117042. _isSynchronized(): boolean;
  117043. /** @hidden */
  117044. _markSyncedWithParent(): void;
  117045. /** @hidden */
  117046. isSynchronizedWithParent(): boolean;
  117047. /** @hidden */
  117048. isSynchronized(): boolean;
  117049. /**
  117050. * Is this node ready to be used/rendered
  117051. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117052. * @return true if the node is ready
  117053. */
  117054. isReady(completeCheck?: boolean): boolean;
  117055. /**
  117056. * Is this node enabled?
  117057. * 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
  117058. * @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
  117059. * @return whether this node (and its parent) is enabled
  117060. */
  117061. isEnabled(checkAncestors?: boolean): boolean;
  117062. /** @hidden */
  117063. protected _syncParentEnabledState(): void;
  117064. /**
  117065. * Set the enabled state of this node
  117066. * @param value defines the new enabled state
  117067. */
  117068. setEnabled(value: boolean): void;
  117069. /**
  117070. * Is this node a descendant of the given node?
  117071. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117072. * @param ancestor defines the parent node to inspect
  117073. * @returns a boolean indicating if this node is a descendant of the given node
  117074. */
  117075. isDescendantOf(ancestor: Node): boolean;
  117076. /** @hidden */
  117077. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117078. /**
  117079. * Will return all nodes that have this node as ascendant
  117080. * @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
  117081. * @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
  117082. * @return all children nodes of all types
  117083. */
  117084. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117085. /**
  117086. * Get all child-meshes of this node
  117087. * @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)
  117088. * @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
  117089. * @returns an array of AbstractMesh
  117090. */
  117091. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117092. /**
  117093. * Get all direct children of this node
  117094. * @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
  117095. * @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)
  117096. * @returns an array of Node
  117097. */
  117098. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117099. /** @hidden */
  117100. _setReady(state: boolean): void;
  117101. /**
  117102. * Get an animation by name
  117103. * @param name defines the name of the animation to look for
  117104. * @returns null if not found else the requested animation
  117105. */
  117106. getAnimationByName(name: string): Nullable<Animation>;
  117107. /**
  117108. * Creates an animation range for this node
  117109. * @param name defines the name of the range
  117110. * @param from defines the starting key
  117111. * @param to defines the end key
  117112. */
  117113. createAnimationRange(name: string, from: number, to: number): void;
  117114. /**
  117115. * Delete a specific animation range
  117116. * @param name defines the name of the range to delete
  117117. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117118. */
  117119. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117120. /**
  117121. * Get an animation range by name
  117122. * @param name defines the name of the animation range to look for
  117123. * @returns null if not found else the requested animation range
  117124. */
  117125. getAnimationRange(name: string): Nullable<AnimationRange>;
  117126. /**
  117127. * Gets the list of all animation ranges defined on this node
  117128. * @returns an array
  117129. */
  117130. getAnimationRanges(): Nullable<AnimationRange>[];
  117131. /**
  117132. * Will start the animation sequence
  117133. * @param name defines the range frames for animation sequence
  117134. * @param loop defines if the animation should loop (false by default)
  117135. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117136. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117137. * @returns the object created for this animation. If range does not exist, it will return null
  117138. */
  117139. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117140. /**
  117141. * Serialize animation ranges into a JSON compatible object
  117142. * @returns serialization object
  117143. */
  117144. serializeAnimationRanges(): any;
  117145. /**
  117146. * Computes the world matrix of the node
  117147. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117148. * @returns the world matrix
  117149. */
  117150. computeWorldMatrix(force?: boolean): Matrix;
  117151. /**
  117152. * Releases resources associated with this node.
  117153. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117154. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117155. */
  117156. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117157. /**
  117158. * Parse animation range data from a serialization object and store them into a given node
  117159. * @param node defines where to store the animation ranges
  117160. * @param parsedNode defines the serialization object to read data from
  117161. * @param scene defines the hosting scene
  117162. */
  117163. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117164. /**
  117165. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117166. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117167. * @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
  117168. * @returns the new bounding vectors
  117169. */
  117170. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117171. min: Vector3;
  117172. max: Vector3;
  117173. };
  117174. }
  117175. }
  117176. declare module BABYLON {
  117177. /**
  117178. * @hidden
  117179. */
  117180. export class _IAnimationState {
  117181. key: number;
  117182. repeatCount: number;
  117183. workValue?: any;
  117184. loopMode?: number;
  117185. offsetValue?: any;
  117186. highLimitValue?: any;
  117187. }
  117188. /**
  117189. * Class used to store any kind of animation
  117190. */
  117191. export class Animation {
  117192. /**Name of the animation */
  117193. name: string;
  117194. /**Property to animate */
  117195. targetProperty: string;
  117196. /**The frames per second of the animation */
  117197. framePerSecond: number;
  117198. /**The data type of the animation */
  117199. dataType: number;
  117200. /**The loop mode of the animation */
  117201. loopMode?: number | undefined;
  117202. /**Specifies if blending should be enabled */
  117203. enableBlending?: boolean | undefined;
  117204. /**
  117205. * Use matrix interpolation instead of using direct key value when animating matrices
  117206. */
  117207. static AllowMatricesInterpolation: boolean;
  117208. /**
  117209. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117210. */
  117211. static AllowMatrixDecomposeForInterpolation: boolean;
  117212. /** Define the Url to load snippets */
  117213. static SnippetUrl: string;
  117214. /** Snippet ID if the animation was created from the snippet server */
  117215. snippetId: string;
  117216. /**
  117217. * Stores the key frames of the animation
  117218. */
  117219. private _keys;
  117220. /**
  117221. * Stores the easing function of the animation
  117222. */
  117223. private _easingFunction;
  117224. /**
  117225. * @hidden Internal use only
  117226. */
  117227. _runtimeAnimations: RuntimeAnimation[];
  117228. /**
  117229. * The set of event that will be linked to this animation
  117230. */
  117231. private _events;
  117232. /**
  117233. * Stores an array of target property paths
  117234. */
  117235. targetPropertyPath: string[];
  117236. /**
  117237. * Stores the blending speed of the animation
  117238. */
  117239. blendingSpeed: number;
  117240. /**
  117241. * Stores the animation ranges for the animation
  117242. */
  117243. private _ranges;
  117244. /**
  117245. * @hidden Internal use
  117246. */
  117247. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117248. /**
  117249. * Sets up an animation
  117250. * @param property The property to animate
  117251. * @param animationType The animation type to apply
  117252. * @param framePerSecond The frames per second of the animation
  117253. * @param easingFunction The easing function used in the animation
  117254. * @returns The created animation
  117255. */
  117256. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117257. /**
  117258. * Create and start an animation on a node
  117259. * @param name defines the name of the global animation that will be run on all nodes
  117260. * @param node defines the root node where the animation will take place
  117261. * @param targetProperty defines property to animate
  117262. * @param framePerSecond defines the number of frame per second yo use
  117263. * @param totalFrame defines the number of frames in total
  117264. * @param from defines the initial value
  117265. * @param to defines the final value
  117266. * @param loopMode defines which loop mode you want to use (off by default)
  117267. * @param easingFunction defines the easing function to use (linear by default)
  117268. * @param onAnimationEnd defines the callback to call when animation end
  117269. * @returns the animatable created for this animation
  117270. */
  117271. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117272. /**
  117273. * Create and start an animation on a node and its descendants
  117274. * @param name defines the name of the global animation that will be run on all nodes
  117275. * @param node defines the root node where the animation will take place
  117276. * @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
  117277. * @param targetProperty defines property to animate
  117278. * @param framePerSecond defines the number of frame per second to use
  117279. * @param totalFrame defines the number of frames in total
  117280. * @param from defines the initial value
  117281. * @param to defines the final value
  117282. * @param loopMode defines which loop mode you want to use (off by default)
  117283. * @param easingFunction defines the easing function to use (linear by default)
  117284. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  117285. * @returns the list of animatables created for all nodes
  117286. * @example https://www.babylonjs-playground.com/#MH0VLI
  117287. */
  117288. 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[]>;
  117289. /**
  117290. * Creates a new animation, merges it with the existing animations and starts it
  117291. * @param name Name of the animation
  117292. * @param node Node which contains the scene that begins the animations
  117293. * @param targetProperty Specifies which property to animate
  117294. * @param framePerSecond The frames per second of the animation
  117295. * @param totalFrame The total number of frames
  117296. * @param from The frame at the beginning of the animation
  117297. * @param to The frame at the end of the animation
  117298. * @param loopMode Specifies the loop mode of the animation
  117299. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  117300. * @param onAnimationEnd Callback to run once the animation is complete
  117301. * @returns Nullable animation
  117302. */
  117303. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117304. /**
  117305. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117306. * @param sourceAnimation defines the Animation containing keyframes to convert
  117307. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117308. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  117309. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  117310. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  117311. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  117312. */
  117313. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  117314. /**
  117315. * Transition property of an host to the target Value
  117316. * @param property The property to transition
  117317. * @param targetValue The target Value of the property
  117318. * @param host The object where the property to animate belongs
  117319. * @param scene Scene used to run the animation
  117320. * @param frameRate Framerate (in frame/s) to use
  117321. * @param transition The transition type we want to use
  117322. * @param duration The duration of the animation, in milliseconds
  117323. * @param onAnimationEnd Callback trigger at the end of the animation
  117324. * @returns Nullable animation
  117325. */
  117326. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  117327. /**
  117328. * Return the array of runtime animations currently using this animation
  117329. */
  117330. get runtimeAnimations(): RuntimeAnimation[];
  117331. /**
  117332. * Specifies if any of the runtime animations are currently running
  117333. */
  117334. get hasRunningRuntimeAnimations(): boolean;
  117335. /**
  117336. * Initializes the animation
  117337. * @param name Name of the animation
  117338. * @param targetProperty Property to animate
  117339. * @param framePerSecond The frames per second of the animation
  117340. * @param dataType The data type of the animation
  117341. * @param loopMode The loop mode of the animation
  117342. * @param enableBlending Specifies if blending should be enabled
  117343. */
  117344. constructor(
  117345. /**Name of the animation */
  117346. name: string,
  117347. /**Property to animate */
  117348. targetProperty: string,
  117349. /**The frames per second of the animation */
  117350. framePerSecond: number,
  117351. /**The data type of the animation */
  117352. dataType: number,
  117353. /**The loop mode of the animation */
  117354. loopMode?: number | undefined,
  117355. /**Specifies if blending should be enabled */
  117356. enableBlending?: boolean | undefined);
  117357. /**
  117358. * Converts the animation to a string
  117359. * @param fullDetails support for multiple levels of logging within scene loading
  117360. * @returns String form of the animation
  117361. */
  117362. toString(fullDetails?: boolean): string;
  117363. /**
  117364. * Add an event to this animation
  117365. * @param event Event to add
  117366. */
  117367. addEvent(event: AnimationEvent): void;
  117368. /**
  117369. * Remove all events found at the given frame
  117370. * @param frame The frame to remove events from
  117371. */
  117372. removeEvents(frame: number): void;
  117373. /**
  117374. * Retrieves all the events from the animation
  117375. * @returns Events from the animation
  117376. */
  117377. getEvents(): AnimationEvent[];
  117378. /**
  117379. * Creates an animation range
  117380. * @param name Name of the animation range
  117381. * @param from Starting frame of the animation range
  117382. * @param to Ending frame of the animation
  117383. */
  117384. createRange(name: string, from: number, to: number): void;
  117385. /**
  117386. * Deletes an animation range by name
  117387. * @param name Name of the animation range to delete
  117388. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  117389. */
  117390. deleteRange(name: string, deleteFrames?: boolean): void;
  117391. /**
  117392. * Gets the animation range by name, or null if not defined
  117393. * @param name Name of the animation range
  117394. * @returns Nullable animation range
  117395. */
  117396. getRange(name: string): Nullable<AnimationRange>;
  117397. /**
  117398. * Gets the key frames from the animation
  117399. * @returns The key frames of the animation
  117400. */
  117401. getKeys(): Array<IAnimationKey>;
  117402. /**
  117403. * Gets the highest frame rate of the animation
  117404. * @returns Highest frame rate of the animation
  117405. */
  117406. getHighestFrame(): number;
  117407. /**
  117408. * Gets the easing function of the animation
  117409. * @returns Easing function of the animation
  117410. */
  117411. getEasingFunction(): IEasingFunction;
  117412. /**
  117413. * Sets the easing function of the animation
  117414. * @param easingFunction A custom mathematical formula for animation
  117415. */
  117416. setEasingFunction(easingFunction: EasingFunction): void;
  117417. /**
  117418. * Interpolates a scalar linearly
  117419. * @param startValue Start value of the animation curve
  117420. * @param endValue End value of the animation curve
  117421. * @param gradient Scalar amount to interpolate
  117422. * @returns Interpolated scalar value
  117423. */
  117424. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  117425. /**
  117426. * Interpolates a scalar cubically
  117427. * @param startValue Start value of the animation curve
  117428. * @param outTangent End tangent of the animation
  117429. * @param endValue End value of the animation curve
  117430. * @param inTangent Start tangent of the animation curve
  117431. * @param gradient Scalar amount to interpolate
  117432. * @returns Interpolated scalar value
  117433. */
  117434. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  117435. /**
  117436. * Interpolates a quaternion using a spherical linear interpolation
  117437. * @param startValue Start value of the animation curve
  117438. * @param endValue End value of the animation curve
  117439. * @param gradient Scalar amount to interpolate
  117440. * @returns Interpolated quaternion value
  117441. */
  117442. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  117443. /**
  117444. * Interpolates a quaternion cubically
  117445. * @param startValue Start value of the animation curve
  117446. * @param outTangent End tangent of the animation curve
  117447. * @param endValue End value of the animation curve
  117448. * @param inTangent Start tangent of the animation curve
  117449. * @param gradient Scalar amount to interpolate
  117450. * @returns Interpolated quaternion value
  117451. */
  117452. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  117453. /**
  117454. * Interpolates a Vector3 linearl
  117455. * @param startValue Start value of the animation curve
  117456. * @param endValue End value of the animation curve
  117457. * @param gradient Scalar amount to interpolate
  117458. * @returns Interpolated scalar value
  117459. */
  117460. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  117461. /**
  117462. * Interpolates a Vector3 cubically
  117463. * @param startValue Start value of the animation curve
  117464. * @param outTangent End tangent of the animation
  117465. * @param endValue End value of the animation curve
  117466. * @param inTangent Start tangent of the animation curve
  117467. * @param gradient Scalar amount to interpolate
  117468. * @returns InterpolatedVector3 value
  117469. */
  117470. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  117471. /**
  117472. * Interpolates a Vector2 linearly
  117473. * @param startValue Start value of the animation curve
  117474. * @param endValue End value of the animation curve
  117475. * @param gradient Scalar amount to interpolate
  117476. * @returns Interpolated Vector2 value
  117477. */
  117478. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  117479. /**
  117480. * Interpolates a Vector2 cubically
  117481. * @param startValue Start value of the animation curve
  117482. * @param outTangent End tangent of the animation
  117483. * @param endValue End value of the animation curve
  117484. * @param inTangent Start tangent of the animation curve
  117485. * @param gradient Scalar amount to interpolate
  117486. * @returns Interpolated Vector2 value
  117487. */
  117488. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  117489. /**
  117490. * Interpolates a size linearly
  117491. * @param startValue Start value of the animation curve
  117492. * @param endValue End value of the animation curve
  117493. * @param gradient Scalar amount to interpolate
  117494. * @returns Interpolated Size value
  117495. */
  117496. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  117497. /**
  117498. * Interpolates a Color3 linearly
  117499. * @param startValue Start value of the animation curve
  117500. * @param endValue End value of the animation curve
  117501. * @param gradient Scalar amount to interpolate
  117502. * @returns Interpolated Color3 value
  117503. */
  117504. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  117505. /**
  117506. * Interpolates a Color4 linearly
  117507. * @param startValue Start value of the animation curve
  117508. * @param endValue End value of the animation curve
  117509. * @param gradient Scalar amount to interpolate
  117510. * @returns Interpolated Color3 value
  117511. */
  117512. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  117513. /**
  117514. * @hidden Internal use only
  117515. */
  117516. _getKeyValue(value: any): any;
  117517. /**
  117518. * @hidden Internal use only
  117519. */
  117520. _interpolate(currentFrame: number, state: _IAnimationState): any;
  117521. /**
  117522. * Defines the function to use to interpolate matrices
  117523. * @param startValue defines the start matrix
  117524. * @param endValue defines the end matrix
  117525. * @param gradient defines the gradient between both matrices
  117526. * @param result defines an optional target matrix where to store the interpolation
  117527. * @returns the interpolated matrix
  117528. */
  117529. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  117530. /**
  117531. * Makes a copy of the animation
  117532. * @returns Cloned animation
  117533. */
  117534. clone(): Animation;
  117535. /**
  117536. * Sets the key frames of the animation
  117537. * @param values The animation key frames to set
  117538. */
  117539. setKeys(values: Array<IAnimationKey>): void;
  117540. /**
  117541. * Serializes the animation to an object
  117542. * @returns Serialized object
  117543. */
  117544. serialize(): any;
  117545. /**
  117546. * Float animation type
  117547. */
  117548. static readonly ANIMATIONTYPE_FLOAT: number;
  117549. /**
  117550. * Vector3 animation type
  117551. */
  117552. static readonly ANIMATIONTYPE_VECTOR3: number;
  117553. /**
  117554. * Quaternion animation type
  117555. */
  117556. static readonly ANIMATIONTYPE_QUATERNION: number;
  117557. /**
  117558. * Matrix animation type
  117559. */
  117560. static readonly ANIMATIONTYPE_MATRIX: number;
  117561. /**
  117562. * Color3 animation type
  117563. */
  117564. static readonly ANIMATIONTYPE_COLOR3: number;
  117565. /**
  117566. * Color3 animation type
  117567. */
  117568. static readonly ANIMATIONTYPE_COLOR4: number;
  117569. /**
  117570. * Vector2 animation type
  117571. */
  117572. static readonly ANIMATIONTYPE_VECTOR2: number;
  117573. /**
  117574. * Size animation type
  117575. */
  117576. static readonly ANIMATIONTYPE_SIZE: number;
  117577. /**
  117578. * Relative Loop Mode
  117579. */
  117580. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  117581. /**
  117582. * Cycle Loop Mode
  117583. */
  117584. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  117585. /**
  117586. * Constant Loop Mode
  117587. */
  117588. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  117589. /** @hidden */
  117590. static _UniversalLerp(left: any, right: any, amount: number): any;
  117591. /**
  117592. * Parses an animation object and creates an animation
  117593. * @param parsedAnimation Parsed animation object
  117594. * @returns Animation object
  117595. */
  117596. static Parse(parsedAnimation: any): Animation;
  117597. /**
  117598. * Appends the serialized animations from the source animations
  117599. * @param source Source containing the animations
  117600. * @param destination Target to store the animations
  117601. */
  117602. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117603. /**
  117604. * Creates a new animation or an array of animations from a snippet saved in a remote file
  117605. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  117606. * @param url defines the url to load from
  117607. * @returns a promise that will resolve to the new animation or an array of animations
  117608. */
  117609. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  117610. /**
  117611. * Creates an animation or an array of animations from a snippet saved by the Inspector
  117612. * @param snippetId defines the snippet to load
  117613. * @returns a promise that will resolve to the new animation or a new array of animations
  117614. */
  117615. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  117616. }
  117617. }
  117618. declare module BABYLON {
  117619. /**
  117620. * Interface containing an array of animations
  117621. */
  117622. export interface IAnimatable {
  117623. /**
  117624. * Array of animations
  117625. */
  117626. animations: Nullable<Array<Animation>>;
  117627. }
  117628. }
  117629. declare module BABYLON {
  117630. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  117631. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117632. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117633. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117634. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117635. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117636. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117637. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117638. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117639. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117640. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117641. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117642. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117643. /**
  117644. * Decorator used to define property that can be serialized as reference to a camera
  117645. * @param sourceName defines the name of the property to decorate
  117646. */
  117647. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117648. /**
  117649. * Class used to help serialization objects
  117650. */
  117651. export class SerializationHelper {
  117652. /** @hidden */
  117653. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  117654. /** @hidden */
  117655. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  117656. /** @hidden */
  117657. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  117658. /** @hidden */
  117659. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  117660. /**
  117661. * Appends the serialized animations from the source animations
  117662. * @param source Source containing the animations
  117663. * @param destination Target to store the animations
  117664. */
  117665. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117666. /**
  117667. * Static function used to serialized a specific entity
  117668. * @param entity defines the entity to serialize
  117669. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  117670. * @returns a JSON compatible object representing the serialization of the entity
  117671. */
  117672. static Serialize<T>(entity: T, serializationObject?: any): any;
  117673. /**
  117674. * Creates a new entity from a serialization data object
  117675. * @param creationFunction defines a function used to instanciated the new entity
  117676. * @param source defines the source serialization data
  117677. * @param scene defines the hosting scene
  117678. * @param rootUrl defines the root url for resources
  117679. * @returns a new entity
  117680. */
  117681. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  117682. /**
  117683. * Clones an object
  117684. * @param creationFunction defines the function used to instanciate the new object
  117685. * @param source defines the source object
  117686. * @returns the cloned object
  117687. */
  117688. static Clone<T>(creationFunction: () => T, source: T): T;
  117689. /**
  117690. * Instanciates a new object based on a source one (some data will be shared between both object)
  117691. * @param creationFunction defines the function used to instanciate the new object
  117692. * @param source defines the source object
  117693. * @returns the new object
  117694. */
  117695. static Instanciate<T>(creationFunction: () => T, source: T): T;
  117696. }
  117697. }
  117698. declare module BABYLON {
  117699. /**
  117700. * Base class of all the textures in babylon.
  117701. * It groups all the common properties the materials, post process, lights... might need
  117702. * in order to make a correct use of the texture.
  117703. */
  117704. export class BaseTexture implements IAnimatable {
  117705. /**
  117706. * Default anisotropic filtering level for the application.
  117707. * It is set to 4 as a good tradeoff between perf and quality.
  117708. */
  117709. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  117710. /**
  117711. * Gets or sets the unique id of the texture
  117712. */
  117713. uniqueId: number;
  117714. /**
  117715. * Define the name of the texture.
  117716. */
  117717. name: string;
  117718. /**
  117719. * Gets or sets an object used to store user defined information.
  117720. */
  117721. metadata: any;
  117722. /**
  117723. * For internal use only. Please do not use.
  117724. */
  117725. reservedDataStore: any;
  117726. private _hasAlpha;
  117727. /**
  117728. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  117729. */
  117730. set hasAlpha(value: boolean);
  117731. get hasAlpha(): boolean;
  117732. /**
  117733. * Defines if the alpha value should be determined via the rgb values.
  117734. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  117735. */
  117736. getAlphaFromRGB: boolean;
  117737. /**
  117738. * Intensity or strength of the texture.
  117739. * It is commonly used by materials to fine tune the intensity of the texture
  117740. */
  117741. level: number;
  117742. /**
  117743. * Define the UV chanel to use starting from 0 and defaulting to 0.
  117744. * This is part of the texture as textures usually maps to one uv set.
  117745. */
  117746. coordinatesIndex: number;
  117747. protected _coordinatesMode: number;
  117748. /**
  117749. * How a texture is mapped.
  117750. *
  117751. * | Value | Type | Description |
  117752. * | ----- | ----------------------------------- | ----------- |
  117753. * | 0 | EXPLICIT_MODE | |
  117754. * | 1 | SPHERICAL_MODE | |
  117755. * | 2 | PLANAR_MODE | |
  117756. * | 3 | CUBIC_MODE | |
  117757. * | 4 | PROJECTION_MODE | |
  117758. * | 5 | SKYBOX_MODE | |
  117759. * | 6 | INVCUBIC_MODE | |
  117760. * | 7 | EQUIRECTANGULAR_MODE | |
  117761. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  117762. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  117763. */
  117764. set coordinatesMode(value: number);
  117765. get coordinatesMode(): number;
  117766. private _wrapU;
  117767. /**
  117768. * | Value | Type | Description |
  117769. * | ----- | ------------------ | ----------- |
  117770. * | 0 | CLAMP_ADDRESSMODE | |
  117771. * | 1 | WRAP_ADDRESSMODE | |
  117772. * | 2 | MIRROR_ADDRESSMODE | |
  117773. */
  117774. get wrapU(): number;
  117775. set wrapU(value: number);
  117776. private _wrapV;
  117777. /**
  117778. * | Value | Type | Description |
  117779. * | ----- | ------------------ | ----------- |
  117780. * | 0 | CLAMP_ADDRESSMODE | |
  117781. * | 1 | WRAP_ADDRESSMODE | |
  117782. * | 2 | MIRROR_ADDRESSMODE | |
  117783. */
  117784. get wrapV(): number;
  117785. set wrapV(value: number);
  117786. /**
  117787. * | Value | Type | Description |
  117788. * | ----- | ------------------ | ----------- |
  117789. * | 0 | CLAMP_ADDRESSMODE | |
  117790. * | 1 | WRAP_ADDRESSMODE | |
  117791. * | 2 | MIRROR_ADDRESSMODE | |
  117792. */
  117793. wrapR: number;
  117794. /**
  117795. * With compliant hardware and browser (supporting anisotropic filtering)
  117796. * this defines the level of anisotropic filtering in the texture.
  117797. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  117798. */
  117799. anisotropicFilteringLevel: number;
  117800. /**
  117801. * Define if the texture is a cube texture or if false a 2d texture.
  117802. */
  117803. get isCube(): boolean;
  117804. set isCube(value: boolean);
  117805. /**
  117806. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  117807. */
  117808. get is3D(): boolean;
  117809. set is3D(value: boolean);
  117810. /**
  117811. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  117812. */
  117813. get is2DArray(): boolean;
  117814. set is2DArray(value: boolean);
  117815. private _gammaSpace;
  117816. /**
  117817. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  117818. * HDR texture are usually stored in linear space.
  117819. * This only impacts the PBR and Background materials
  117820. */
  117821. get gammaSpace(): boolean;
  117822. set gammaSpace(gamma: boolean);
  117823. /**
  117824. * Gets or sets whether or not the texture contains RGBD data.
  117825. */
  117826. get isRGBD(): boolean;
  117827. set isRGBD(value: boolean);
  117828. /**
  117829. * Is Z inverted in the texture (useful in a cube texture).
  117830. */
  117831. invertZ: boolean;
  117832. /**
  117833. * Are mip maps generated for this texture or not.
  117834. */
  117835. get noMipmap(): boolean;
  117836. /**
  117837. * @hidden
  117838. */
  117839. lodLevelInAlpha: boolean;
  117840. /**
  117841. * With prefiltered texture, defined the offset used during the prefiltering steps.
  117842. */
  117843. get lodGenerationOffset(): number;
  117844. set lodGenerationOffset(value: number);
  117845. /**
  117846. * With prefiltered texture, defined the scale used during the prefiltering steps.
  117847. */
  117848. get lodGenerationScale(): number;
  117849. set lodGenerationScale(value: number);
  117850. /**
  117851. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  117852. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  117853. * average roughness values.
  117854. */
  117855. get linearSpecularLOD(): boolean;
  117856. set linearSpecularLOD(value: boolean);
  117857. /**
  117858. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  117859. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  117860. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  117861. */
  117862. get irradianceTexture(): Nullable<BaseTexture>;
  117863. set irradianceTexture(value: Nullable<BaseTexture>);
  117864. /**
  117865. * Define if the texture is a render target.
  117866. */
  117867. isRenderTarget: boolean;
  117868. /**
  117869. * Define the unique id of the texture in the scene.
  117870. */
  117871. get uid(): string;
  117872. /** @hidden */
  117873. _prefiltered: boolean;
  117874. /**
  117875. * Return a string representation of the texture.
  117876. * @returns the texture as a string
  117877. */
  117878. toString(): string;
  117879. /**
  117880. * Get the class name of the texture.
  117881. * @returns "BaseTexture"
  117882. */
  117883. getClassName(): string;
  117884. /**
  117885. * Define the list of animation attached to the texture.
  117886. */
  117887. animations: Animation[];
  117888. /**
  117889. * An event triggered when the texture is disposed.
  117890. */
  117891. onDisposeObservable: Observable<BaseTexture>;
  117892. private _onDisposeObserver;
  117893. /**
  117894. * Callback triggered when the texture has been disposed.
  117895. * Kept for back compatibility, you can use the onDisposeObservable instead.
  117896. */
  117897. set onDispose(callback: () => void);
  117898. /**
  117899. * Define the current state of the loading sequence when in delayed load mode.
  117900. */
  117901. delayLoadState: number;
  117902. protected _scene: Nullable<Scene>;
  117903. protected _engine: Nullable<ThinEngine>;
  117904. /** @hidden */
  117905. _texture: Nullable<InternalTexture>;
  117906. private _uid;
  117907. /**
  117908. * Define if the texture is preventinga material to render or not.
  117909. * If not and the texture is not ready, the engine will use a default black texture instead.
  117910. */
  117911. get isBlocking(): boolean;
  117912. /**
  117913. * Instantiates a new BaseTexture.
  117914. * Base class of all the textures in babylon.
  117915. * It groups all the common properties the materials, post process, lights... might need
  117916. * in order to make a correct use of the texture.
  117917. * @param sceneOrEngine Define the scene or engine the texture blongs to
  117918. */
  117919. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  117920. /**
  117921. * Get the scene the texture belongs to.
  117922. * @returns the scene or null if undefined
  117923. */
  117924. getScene(): Nullable<Scene>;
  117925. /** @hidden */
  117926. protected _getEngine(): Nullable<ThinEngine>;
  117927. /**
  117928. * Checks if the texture has the same transform matrix than another texture
  117929. * @param texture texture to check against
  117930. * @returns true if the transforms are the same, else false
  117931. */
  117932. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  117933. /**
  117934. * Get the texture transform matrix used to offset tile the texture for istance.
  117935. * @returns the transformation matrix
  117936. */
  117937. getTextureMatrix(): Matrix;
  117938. /**
  117939. * Get the texture reflection matrix used to rotate/transform the reflection.
  117940. * @returns the reflection matrix
  117941. */
  117942. getReflectionTextureMatrix(): Matrix;
  117943. /**
  117944. * Get the underlying lower level texture from Babylon.
  117945. * @returns the insternal texture
  117946. */
  117947. getInternalTexture(): Nullable<InternalTexture>;
  117948. /**
  117949. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  117950. * @returns true if ready or not blocking
  117951. */
  117952. isReadyOrNotBlocking(): boolean;
  117953. /**
  117954. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  117955. * @returns true if fully ready
  117956. */
  117957. isReady(): boolean;
  117958. private _cachedSize;
  117959. /**
  117960. * Get the size of the texture.
  117961. * @returns the texture size.
  117962. */
  117963. getSize(): ISize;
  117964. /**
  117965. * Get the base size of the texture.
  117966. * It can be different from the size if the texture has been resized for POT for instance
  117967. * @returns the base size
  117968. */
  117969. getBaseSize(): ISize;
  117970. /**
  117971. * Update the sampling mode of the texture.
  117972. * Default is Trilinear mode.
  117973. *
  117974. * | Value | Type | Description |
  117975. * | ----- | ------------------ | ----------- |
  117976. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  117977. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  117978. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  117979. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  117980. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  117981. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  117982. * | 7 | NEAREST_LINEAR | |
  117983. * | 8 | NEAREST_NEAREST | |
  117984. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  117985. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  117986. * | 11 | LINEAR_LINEAR | |
  117987. * | 12 | LINEAR_NEAREST | |
  117988. *
  117989. * > _mag_: magnification filter (close to the viewer)
  117990. * > _min_: minification filter (far from the viewer)
  117991. * > _mip_: filter used between mip map levels
  117992. *@param samplingMode Define the new sampling mode of the texture
  117993. */
  117994. updateSamplingMode(samplingMode: number): void;
  117995. /**
  117996. * Scales the texture if is `canRescale()`
  117997. * @param ratio the resize factor we want to use to rescale
  117998. */
  117999. scale(ratio: number): void;
  118000. /**
  118001. * Get if the texture can rescale.
  118002. */
  118003. get canRescale(): boolean;
  118004. /** @hidden */
  118005. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  118006. /** @hidden */
  118007. _rebuild(): void;
  118008. /**
  118009. * Triggers the load sequence in delayed load mode.
  118010. */
  118011. delayLoad(): void;
  118012. /**
  118013. * Clones the texture.
  118014. * @returns the cloned texture
  118015. */
  118016. clone(): Nullable<BaseTexture>;
  118017. /**
  118018. * Get the texture underlying type (INT, FLOAT...)
  118019. */
  118020. get textureType(): number;
  118021. /**
  118022. * Get the texture underlying format (RGB, RGBA...)
  118023. */
  118024. get textureFormat(): number;
  118025. /**
  118026. * Indicates that textures need to be re-calculated for all materials
  118027. */
  118028. protected _markAllSubMeshesAsTexturesDirty(): void;
  118029. /**
  118030. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  118031. * This will returns an RGBA array buffer containing either in values (0-255) or
  118032. * float values (0-1) depending of the underlying buffer type.
  118033. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  118034. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  118035. * @param buffer defines a user defined buffer to fill with data (can be null)
  118036. * @returns The Array buffer containing the pixels data.
  118037. */
  118038. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  118039. /**
  118040. * Release and destroy the underlying lower level texture aka internalTexture.
  118041. */
  118042. releaseInternalTexture(): void;
  118043. /** @hidden */
  118044. get _lodTextureHigh(): Nullable<BaseTexture>;
  118045. /** @hidden */
  118046. get _lodTextureMid(): Nullable<BaseTexture>;
  118047. /** @hidden */
  118048. get _lodTextureLow(): Nullable<BaseTexture>;
  118049. /**
  118050. * Dispose the texture and release its associated resources.
  118051. */
  118052. dispose(): void;
  118053. /**
  118054. * Serialize the texture into a JSON representation that can be parsed later on.
  118055. * @returns the JSON representation of the texture
  118056. */
  118057. serialize(): any;
  118058. /**
  118059. * Helper function to be called back once a list of texture contains only ready textures.
  118060. * @param textures Define the list of textures to wait for
  118061. * @param callback Define the callback triggered once the entire list will be ready
  118062. */
  118063. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  118064. private static _isScene;
  118065. }
  118066. }
  118067. declare module BABYLON {
  118068. /**
  118069. * Options to be used when creating an effect.
  118070. */
  118071. export interface IEffectCreationOptions {
  118072. /**
  118073. * Atrributes that will be used in the shader.
  118074. */
  118075. attributes: string[];
  118076. /**
  118077. * Uniform varible names that will be set in the shader.
  118078. */
  118079. uniformsNames: string[];
  118080. /**
  118081. * Uniform buffer variable names that will be set in the shader.
  118082. */
  118083. uniformBuffersNames: string[];
  118084. /**
  118085. * Sampler texture variable names that will be set in the shader.
  118086. */
  118087. samplers: string[];
  118088. /**
  118089. * Define statements that will be set in the shader.
  118090. */
  118091. defines: any;
  118092. /**
  118093. * Possible fallbacks for this effect to improve performance when needed.
  118094. */
  118095. fallbacks: Nullable<IEffectFallbacks>;
  118096. /**
  118097. * Callback that will be called when the shader is compiled.
  118098. */
  118099. onCompiled: Nullable<(effect: Effect) => void>;
  118100. /**
  118101. * Callback that will be called if an error occurs during shader compilation.
  118102. */
  118103. onError: Nullable<(effect: Effect, errors: string) => void>;
  118104. /**
  118105. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118106. */
  118107. indexParameters?: any;
  118108. /**
  118109. * Max number of lights that can be used in the shader.
  118110. */
  118111. maxSimultaneousLights?: number;
  118112. /**
  118113. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  118114. */
  118115. transformFeedbackVaryings?: Nullable<string[]>;
  118116. /**
  118117. * 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
  118118. */
  118119. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  118120. /**
  118121. * Is this effect rendering to several color attachments ?
  118122. */
  118123. multiTarget?: boolean;
  118124. }
  118125. /**
  118126. * Effect containing vertex and fragment shader that can be executed on an object.
  118127. */
  118128. export class Effect implements IDisposable {
  118129. /**
  118130. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  118131. */
  118132. static ShadersRepository: string;
  118133. /**
  118134. * Enable logging of the shader code when a compilation error occurs
  118135. */
  118136. static LogShaderCodeOnCompilationError: boolean;
  118137. /**
  118138. * Name of the effect.
  118139. */
  118140. name: any;
  118141. /**
  118142. * String container all the define statements that should be set on the shader.
  118143. */
  118144. defines: string;
  118145. /**
  118146. * Callback that will be called when the shader is compiled.
  118147. */
  118148. onCompiled: Nullable<(effect: Effect) => void>;
  118149. /**
  118150. * Callback that will be called if an error occurs during shader compilation.
  118151. */
  118152. onError: Nullable<(effect: Effect, errors: string) => void>;
  118153. /**
  118154. * Callback that will be called when effect is bound.
  118155. */
  118156. onBind: Nullable<(effect: Effect) => void>;
  118157. /**
  118158. * Unique ID of the effect.
  118159. */
  118160. uniqueId: number;
  118161. /**
  118162. * Observable that will be called when the shader is compiled.
  118163. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118164. */
  118165. onCompileObservable: Observable<Effect>;
  118166. /**
  118167. * Observable that will be called if an error occurs during shader compilation.
  118168. */
  118169. onErrorObservable: Observable<Effect>;
  118170. /** @hidden */
  118171. _onBindObservable: Nullable<Observable<Effect>>;
  118172. /**
  118173. * @hidden
  118174. * Specifies if the effect was previously ready
  118175. */
  118176. _wasPreviouslyReady: boolean;
  118177. /**
  118178. * Observable that will be called when effect is bound.
  118179. */
  118180. get onBindObservable(): Observable<Effect>;
  118181. /** @hidden */
  118182. _bonesComputationForcedToCPU: boolean;
  118183. /** @hidden */
  118184. _multiTarget: boolean;
  118185. private static _uniqueIdSeed;
  118186. private _engine;
  118187. private _uniformBuffersNames;
  118188. private _uniformBuffersNamesList;
  118189. private _uniformsNames;
  118190. private _samplerList;
  118191. private _samplers;
  118192. private _isReady;
  118193. private _compilationError;
  118194. private _allFallbacksProcessed;
  118195. private _attributesNames;
  118196. private _attributes;
  118197. private _attributeLocationByName;
  118198. private _uniforms;
  118199. /**
  118200. * Key for the effect.
  118201. * @hidden
  118202. */
  118203. _key: string;
  118204. private _indexParameters;
  118205. private _fallbacks;
  118206. private _vertexSourceCode;
  118207. private _fragmentSourceCode;
  118208. private _vertexSourceCodeOverride;
  118209. private _fragmentSourceCodeOverride;
  118210. private _transformFeedbackVaryings;
  118211. /**
  118212. * Compiled shader to webGL program.
  118213. * @hidden
  118214. */
  118215. _pipelineContext: Nullable<IPipelineContext>;
  118216. private _valueCache;
  118217. private static _baseCache;
  118218. /**
  118219. * Instantiates an effect.
  118220. * An effect can be used to create/manage/execute vertex and fragment shaders.
  118221. * @param baseName Name of the effect.
  118222. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  118223. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  118224. * @param samplers List of sampler variables that will be passed to the shader.
  118225. * @param engine Engine to be used to render the effect
  118226. * @param defines Define statements to be added to the shader.
  118227. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  118228. * @param onCompiled Callback that will be called when the shader is compiled.
  118229. * @param onError Callback that will be called if an error occurs during shader compilation.
  118230. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118231. */
  118232. 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);
  118233. private _useFinalCode;
  118234. /**
  118235. * Unique key for this effect
  118236. */
  118237. get key(): string;
  118238. /**
  118239. * If the effect has been compiled and prepared.
  118240. * @returns if the effect is compiled and prepared.
  118241. */
  118242. isReady(): boolean;
  118243. private _isReadyInternal;
  118244. /**
  118245. * The engine the effect was initialized with.
  118246. * @returns the engine.
  118247. */
  118248. getEngine(): Engine;
  118249. /**
  118250. * The pipeline context for this effect
  118251. * @returns the associated pipeline context
  118252. */
  118253. getPipelineContext(): Nullable<IPipelineContext>;
  118254. /**
  118255. * The set of names of attribute variables for the shader.
  118256. * @returns An array of attribute names.
  118257. */
  118258. getAttributesNames(): string[];
  118259. /**
  118260. * Returns the attribute at the given index.
  118261. * @param index The index of the attribute.
  118262. * @returns The location of the attribute.
  118263. */
  118264. getAttributeLocation(index: number): number;
  118265. /**
  118266. * Returns the attribute based on the name of the variable.
  118267. * @param name of the attribute to look up.
  118268. * @returns the attribute location.
  118269. */
  118270. getAttributeLocationByName(name: string): number;
  118271. /**
  118272. * The number of attributes.
  118273. * @returns the numnber of attributes.
  118274. */
  118275. getAttributesCount(): number;
  118276. /**
  118277. * Gets the index of a uniform variable.
  118278. * @param uniformName of the uniform to look up.
  118279. * @returns the index.
  118280. */
  118281. getUniformIndex(uniformName: string): number;
  118282. /**
  118283. * Returns the attribute based on the name of the variable.
  118284. * @param uniformName of the uniform to look up.
  118285. * @returns the location of the uniform.
  118286. */
  118287. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  118288. /**
  118289. * Returns an array of sampler variable names
  118290. * @returns The array of sampler variable names.
  118291. */
  118292. getSamplers(): string[];
  118293. /**
  118294. * Returns an array of uniform variable names
  118295. * @returns The array of uniform variable names.
  118296. */
  118297. getUniformNames(): string[];
  118298. /**
  118299. * Returns an array of uniform buffer variable names
  118300. * @returns The array of uniform buffer variable names.
  118301. */
  118302. getUniformBuffersNames(): string[];
  118303. /**
  118304. * Returns the index parameters used to create the effect
  118305. * @returns The index parameters object
  118306. */
  118307. getIndexParameters(): any;
  118308. /**
  118309. * The error from the last compilation.
  118310. * @returns the error string.
  118311. */
  118312. getCompilationError(): string;
  118313. /**
  118314. * Gets a boolean indicating that all fallbacks were used during compilation
  118315. * @returns true if all fallbacks were used
  118316. */
  118317. allFallbacksProcessed(): boolean;
  118318. /**
  118319. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  118320. * @param func The callback to be used.
  118321. */
  118322. executeWhenCompiled(func: (effect: Effect) => void): void;
  118323. private _checkIsReady;
  118324. private _loadShader;
  118325. /**
  118326. * Gets the vertex shader source code of this effect
  118327. */
  118328. get vertexSourceCode(): string;
  118329. /**
  118330. * Gets the fragment shader source code of this effect
  118331. */
  118332. get fragmentSourceCode(): string;
  118333. /**
  118334. * Recompiles the webGL program
  118335. * @param vertexSourceCode The source code for the vertex shader.
  118336. * @param fragmentSourceCode The source code for the fragment shader.
  118337. * @param onCompiled Callback called when completed.
  118338. * @param onError Callback called on error.
  118339. * @hidden
  118340. */
  118341. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  118342. /**
  118343. * Prepares the effect
  118344. * @hidden
  118345. */
  118346. _prepareEffect(): void;
  118347. private _getShaderCodeAndErrorLine;
  118348. private _processCompilationErrors;
  118349. /**
  118350. * Checks if the effect is supported. (Must be called after compilation)
  118351. */
  118352. get isSupported(): boolean;
  118353. /**
  118354. * Binds a texture to the engine to be used as output of the shader.
  118355. * @param channel Name of the output variable.
  118356. * @param texture Texture to bind.
  118357. * @hidden
  118358. */
  118359. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  118360. /**
  118361. * Sets a texture on the engine to be used in the shader.
  118362. * @param channel Name of the sampler variable.
  118363. * @param texture Texture to set.
  118364. */
  118365. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  118366. /**
  118367. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  118368. * @param channel Name of the sampler variable.
  118369. * @param texture Texture to set.
  118370. */
  118371. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  118372. /**
  118373. * Sets an array of textures on the engine to be used in the shader.
  118374. * @param channel Name of the variable.
  118375. * @param textures Textures to set.
  118376. */
  118377. setTextureArray(channel: string, textures: BaseTexture[]): void;
  118378. /**
  118379. * 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)
  118380. * @param channel Name of the sampler variable.
  118381. * @param postProcess Post process to get the input texture from.
  118382. */
  118383. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  118384. /**
  118385. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  118386. * 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)
  118387. * @param channel Name of the sampler variable.
  118388. * @param postProcess Post process to get the output texture from.
  118389. */
  118390. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  118391. /** @hidden */
  118392. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  118393. /** @hidden */
  118394. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  118395. /** @hidden */
  118396. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  118397. /** @hidden */
  118398. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  118399. /**
  118400. * Binds a buffer to a uniform.
  118401. * @param buffer Buffer to bind.
  118402. * @param name Name of the uniform variable to bind to.
  118403. */
  118404. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  118405. /**
  118406. * Binds block to a uniform.
  118407. * @param blockName Name of the block to bind.
  118408. * @param index Index to bind.
  118409. */
  118410. bindUniformBlock(blockName: string, index: number): void;
  118411. /**
  118412. * Sets an interger value on a uniform variable.
  118413. * @param uniformName Name of the variable.
  118414. * @param value Value to be set.
  118415. * @returns this effect.
  118416. */
  118417. setInt(uniformName: string, value: number): Effect;
  118418. /**
  118419. * Sets an int array on a uniform variable.
  118420. * @param uniformName Name of the variable.
  118421. * @param array array to be set.
  118422. * @returns this effect.
  118423. */
  118424. setIntArray(uniformName: string, array: Int32Array): Effect;
  118425. /**
  118426. * 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)
  118427. * @param uniformName Name of the variable.
  118428. * @param array array to be set.
  118429. * @returns this effect.
  118430. */
  118431. setIntArray2(uniformName: string, array: Int32Array): Effect;
  118432. /**
  118433. * 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)
  118434. * @param uniformName Name of the variable.
  118435. * @param array array to be set.
  118436. * @returns this effect.
  118437. */
  118438. setIntArray3(uniformName: string, array: Int32Array): Effect;
  118439. /**
  118440. * 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)
  118441. * @param uniformName Name of the variable.
  118442. * @param array array to be set.
  118443. * @returns this effect.
  118444. */
  118445. setIntArray4(uniformName: string, array: Int32Array): Effect;
  118446. /**
  118447. * Sets an float array on a uniform variable.
  118448. * @param uniformName Name of the variable.
  118449. * @param array array to be set.
  118450. * @returns this effect.
  118451. */
  118452. setFloatArray(uniformName: string, array: Float32Array): Effect;
  118453. /**
  118454. * 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)
  118455. * @param uniformName Name of the variable.
  118456. * @param array array to be set.
  118457. * @returns this effect.
  118458. */
  118459. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  118460. /**
  118461. * 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)
  118462. * @param uniformName Name of the variable.
  118463. * @param array array to be set.
  118464. * @returns this effect.
  118465. */
  118466. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  118467. /**
  118468. * 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)
  118469. * @param uniformName Name of the variable.
  118470. * @param array array to be set.
  118471. * @returns this effect.
  118472. */
  118473. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  118474. /**
  118475. * Sets an array on a uniform variable.
  118476. * @param uniformName Name of the variable.
  118477. * @param array array to be set.
  118478. * @returns this effect.
  118479. */
  118480. setArray(uniformName: string, array: number[]): Effect;
  118481. /**
  118482. * 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)
  118483. * @param uniformName Name of the variable.
  118484. * @param array array to be set.
  118485. * @returns this effect.
  118486. */
  118487. setArray2(uniformName: string, array: number[]): Effect;
  118488. /**
  118489. * 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)
  118490. * @param uniformName Name of the variable.
  118491. * @param array array to be set.
  118492. * @returns this effect.
  118493. */
  118494. setArray3(uniformName: string, array: number[]): Effect;
  118495. /**
  118496. * 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)
  118497. * @param uniformName Name of the variable.
  118498. * @param array array to be set.
  118499. * @returns this effect.
  118500. */
  118501. setArray4(uniformName: string, array: number[]): Effect;
  118502. /**
  118503. * Sets matrices on a uniform variable.
  118504. * @param uniformName Name of the variable.
  118505. * @param matrices matrices to be set.
  118506. * @returns this effect.
  118507. */
  118508. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  118509. /**
  118510. * Sets matrix on a uniform variable.
  118511. * @param uniformName Name of the variable.
  118512. * @param matrix matrix to be set.
  118513. * @returns this effect.
  118514. */
  118515. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  118516. /**
  118517. * 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)
  118518. * @param uniformName Name of the variable.
  118519. * @param matrix matrix to be set.
  118520. * @returns this effect.
  118521. */
  118522. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118523. /**
  118524. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  118525. * @param uniformName Name of the variable.
  118526. * @param matrix matrix to be set.
  118527. * @returns this effect.
  118528. */
  118529. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118530. /**
  118531. * Sets a float on a uniform variable.
  118532. * @param uniformName Name of the variable.
  118533. * @param value value to be set.
  118534. * @returns this effect.
  118535. */
  118536. setFloat(uniformName: string, value: number): Effect;
  118537. /**
  118538. * Sets a boolean on a uniform variable.
  118539. * @param uniformName Name of the variable.
  118540. * @param bool value to be set.
  118541. * @returns this effect.
  118542. */
  118543. setBool(uniformName: string, bool: boolean): Effect;
  118544. /**
  118545. * Sets a Vector2 on a uniform variable.
  118546. * @param uniformName Name of the variable.
  118547. * @param vector2 vector2 to be set.
  118548. * @returns this effect.
  118549. */
  118550. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  118551. /**
  118552. * Sets a float2 on a uniform variable.
  118553. * @param uniformName Name of the variable.
  118554. * @param x First float in float2.
  118555. * @param y Second float in float2.
  118556. * @returns this effect.
  118557. */
  118558. setFloat2(uniformName: string, x: number, y: number): Effect;
  118559. /**
  118560. * Sets a Vector3 on a uniform variable.
  118561. * @param uniformName Name of the variable.
  118562. * @param vector3 Value to be set.
  118563. * @returns this effect.
  118564. */
  118565. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  118566. /**
  118567. * Sets a float3 on a uniform variable.
  118568. * @param uniformName Name of the variable.
  118569. * @param x First float in float3.
  118570. * @param y Second float in float3.
  118571. * @param z Third float in float3.
  118572. * @returns this effect.
  118573. */
  118574. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  118575. /**
  118576. * Sets a Vector4 on a uniform variable.
  118577. * @param uniformName Name of the variable.
  118578. * @param vector4 Value to be set.
  118579. * @returns this effect.
  118580. */
  118581. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  118582. /**
  118583. * Sets a float4 on a uniform variable.
  118584. * @param uniformName Name of the variable.
  118585. * @param x First float in float4.
  118586. * @param y Second float in float4.
  118587. * @param z Third float in float4.
  118588. * @param w Fourth float in float4.
  118589. * @returns this effect.
  118590. */
  118591. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  118592. /**
  118593. * Sets a Color3 on a uniform variable.
  118594. * @param uniformName Name of the variable.
  118595. * @param color3 Value to be set.
  118596. * @returns this effect.
  118597. */
  118598. setColor3(uniformName: string, color3: IColor3Like): Effect;
  118599. /**
  118600. * Sets a Color4 on a uniform variable.
  118601. * @param uniformName Name of the variable.
  118602. * @param color3 Value to be set.
  118603. * @param alpha Alpha value to be set.
  118604. * @returns this effect.
  118605. */
  118606. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  118607. /**
  118608. * Sets a Color4 on a uniform variable
  118609. * @param uniformName defines the name of the variable
  118610. * @param color4 defines the value to be set
  118611. * @returns this effect.
  118612. */
  118613. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  118614. /** Release all associated resources */
  118615. dispose(): void;
  118616. /**
  118617. * This function will add a new shader to the shader store
  118618. * @param name the name of the shader
  118619. * @param pixelShader optional pixel shader content
  118620. * @param vertexShader optional vertex shader content
  118621. */
  118622. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  118623. /**
  118624. * Store of each shader (The can be looked up using effect.key)
  118625. */
  118626. static ShadersStore: {
  118627. [key: string]: string;
  118628. };
  118629. /**
  118630. * Store of each included file for a shader (The can be looked up using effect.key)
  118631. */
  118632. static IncludesShadersStore: {
  118633. [key: string]: string;
  118634. };
  118635. /**
  118636. * Resets the cache of effects.
  118637. */
  118638. static ResetCache(): void;
  118639. }
  118640. }
  118641. declare module BABYLON {
  118642. /**
  118643. * Interface used to describe the capabilities of the engine relatively to the current browser
  118644. */
  118645. export interface EngineCapabilities {
  118646. /** Maximum textures units per fragment shader */
  118647. maxTexturesImageUnits: number;
  118648. /** Maximum texture units per vertex shader */
  118649. maxVertexTextureImageUnits: number;
  118650. /** Maximum textures units in the entire pipeline */
  118651. maxCombinedTexturesImageUnits: number;
  118652. /** Maximum texture size */
  118653. maxTextureSize: number;
  118654. /** Maximum texture samples */
  118655. maxSamples?: number;
  118656. /** Maximum cube texture size */
  118657. maxCubemapTextureSize: number;
  118658. /** Maximum render texture size */
  118659. maxRenderTextureSize: number;
  118660. /** Maximum number of vertex attributes */
  118661. maxVertexAttribs: number;
  118662. /** Maximum number of varyings */
  118663. maxVaryingVectors: number;
  118664. /** Maximum number of uniforms per vertex shader */
  118665. maxVertexUniformVectors: number;
  118666. /** Maximum number of uniforms per fragment shader */
  118667. maxFragmentUniformVectors: number;
  118668. /** Defines if standard derivates (dx/dy) are supported */
  118669. standardDerivatives: boolean;
  118670. /** Defines if s3tc texture compression is supported */
  118671. s3tc?: WEBGL_compressed_texture_s3tc;
  118672. /** Defines if pvrtc texture compression is supported */
  118673. pvrtc: any;
  118674. /** Defines if etc1 texture compression is supported */
  118675. etc1: any;
  118676. /** Defines if etc2 texture compression is supported */
  118677. etc2: any;
  118678. /** Defines if astc texture compression is supported */
  118679. astc: any;
  118680. /** Defines if bptc texture compression is supported */
  118681. bptc: any;
  118682. /** Defines if float textures are supported */
  118683. textureFloat: boolean;
  118684. /** Defines if vertex array objects are supported */
  118685. vertexArrayObject: boolean;
  118686. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  118687. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  118688. /** Gets the maximum level of anisotropy supported */
  118689. maxAnisotropy: number;
  118690. /** Defines if instancing is supported */
  118691. instancedArrays: boolean;
  118692. /** Defines if 32 bits indices are supported */
  118693. uintIndices: boolean;
  118694. /** Defines if high precision shaders are supported */
  118695. highPrecisionShaderSupported: boolean;
  118696. /** Defines if depth reading in the fragment shader is supported */
  118697. fragmentDepthSupported: boolean;
  118698. /** Defines if float texture linear filtering is supported*/
  118699. textureFloatLinearFiltering: boolean;
  118700. /** Defines if rendering to float textures is supported */
  118701. textureFloatRender: boolean;
  118702. /** Defines if half float textures are supported*/
  118703. textureHalfFloat: boolean;
  118704. /** Defines if half float texture linear filtering is supported*/
  118705. textureHalfFloatLinearFiltering: boolean;
  118706. /** Defines if rendering to half float textures is supported */
  118707. textureHalfFloatRender: boolean;
  118708. /** Defines if textureLOD shader command is supported */
  118709. textureLOD: boolean;
  118710. /** Defines if draw buffers extension is supported */
  118711. drawBuffersExtension: boolean;
  118712. /** Defines if depth textures are supported */
  118713. depthTextureExtension: boolean;
  118714. /** Defines if float color buffer are supported */
  118715. colorBufferFloat: boolean;
  118716. /** Gets disjoint timer query extension (null if not supported) */
  118717. timerQuery?: EXT_disjoint_timer_query;
  118718. /** Defines if timestamp can be used with timer query */
  118719. canUseTimestampForTimerQuery: boolean;
  118720. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  118721. multiview?: any;
  118722. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  118723. oculusMultiview?: any;
  118724. /** Function used to let the system compiles shaders in background */
  118725. parallelShaderCompile?: {
  118726. COMPLETION_STATUS_KHR: number;
  118727. };
  118728. /** Max number of texture samples for MSAA */
  118729. maxMSAASamples: number;
  118730. /** Defines if the blend min max extension is supported */
  118731. blendMinMax: boolean;
  118732. }
  118733. }
  118734. declare module BABYLON {
  118735. /**
  118736. * @hidden
  118737. **/
  118738. export class DepthCullingState {
  118739. private _isDepthTestDirty;
  118740. private _isDepthMaskDirty;
  118741. private _isDepthFuncDirty;
  118742. private _isCullFaceDirty;
  118743. private _isCullDirty;
  118744. private _isZOffsetDirty;
  118745. private _isFrontFaceDirty;
  118746. private _depthTest;
  118747. private _depthMask;
  118748. private _depthFunc;
  118749. private _cull;
  118750. private _cullFace;
  118751. private _zOffset;
  118752. private _frontFace;
  118753. /**
  118754. * Initializes the state.
  118755. */
  118756. constructor();
  118757. get isDirty(): boolean;
  118758. get zOffset(): number;
  118759. set zOffset(value: number);
  118760. get cullFace(): Nullable<number>;
  118761. set cullFace(value: Nullable<number>);
  118762. get cull(): Nullable<boolean>;
  118763. set cull(value: Nullable<boolean>);
  118764. get depthFunc(): Nullable<number>;
  118765. set depthFunc(value: Nullable<number>);
  118766. get depthMask(): boolean;
  118767. set depthMask(value: boolean);
  118768. get depthTest(): boolean;
  118769. set depthTest(value: boolean);
  118770. get frontFace(): Nullable<number>;
  118771. set frontFace(value: Nullable<number>);
  118772. reset(): void;
  118773. apply(gl: WebGLRenderingContext): void;
  118774. }
  118775. }
  118776. declare module BABYLON {
  118777. /**
  118778. * @hidden
  118779. **/
  118780. export class StencilState {
  118781. /** 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 */
  118782. static readonly ALWAYS: number;
  118783. /** Passed to stencilOperation to specify that stencil value must be kept */
  118784. static readonly KEEP: number;
  118785. /** Passed to stencilOperation to specify that stencil value must be replaced */
  118786. static readonly REPLACE: number;
  118787. private _isStencilTestDirty;
  118788. private _isStencilMaskDirty;
  118789. private _isStencilFuncDirty;
  118790. private _isStencilOpDirty;
  118791. private _stencilTest;
  118792. private _stencilMask;
  118793. private _stencilFunc;
  118794. private _stencilFuncRef;
  118795. private _stencilFuncMask;
  118796. private _stencilOpStencilFail;
  118797. private _stencilOpDepthFail;
  118798. private _stencilOpStencilDepthPass;
  118799. get isDirty(): boolean;
  118800. get stencilFunc(): number;
  118801. set stencilFunc(value: number);
  118802. get stencilFuncRef(): number;
  118803. set stencilFuncRef(value: number);
  118804. get stencilFuncMask(): number;
  118805. set stencilFuncMask(value: number);
  118806. get stencilOpStencilFail(): number;
  118807. set stencilOpStencilFail(value: number);
  118808. get stencilOpDepthFail(): number;
  118809. set stencilOpDepthFail(value: number);
  118810. get stencilOpStencilDepthPass(): number;
  118811. set stencilOpStencilDepthPass(value: number);
  118812. get stencilMask(): number;
  118813. set stencilMask(value: number);
  118814. get stencilTest(): boolean;
  118815. set stencilTest(value: boolean);
  118816. constructor();
  118817. reset(): void;
  118818. apply(gl: WebGLRenderingContext): void;
  118819. }
  118820. }
  118821. declare module BABYLON {
  118822. /**
  118823. * @hidden
  118824. **/
  118825. export class AlphaState {
  118826. private _isAlphaBlendDirty;
  118827. private _isBlendFunctionParametersDirty;
  118828. private _isBlendEquationParametersDirty;
  118829. private _isBlendConstantsDirty;
  118830. private _alphaBlend;
  118831. private _blendFunctionParameters;
  118832. private _blendEquationParameters;
  118833. private _blendConstants;
  118834. /**
  118835. * Initializes the state.
  118836. */
  118837. constructor();
  118838. get isDirty(): boolean;
  118839. get alphaBlend(): boolean;
  118840. set alphaBlend(value: boolean);
  118841. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  118842. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  118843. setAlphaEquationParameters(rgb: number, alpha: number): void;
  118844. reset(): void;
  118845. apply(gl: WebGLRenderingContext): void;
  118846. }
  118847. }
  118848. declare module BABYLON {
  118849. /** @hidden */
  118850. export class WebGL2ShaderProcessor implements IShaderProcessor {
  118851. attributeProcessor(attribute: string): string;
  118852. varyingProcessor(varying: string, isFragment: boolean): string;
  118853. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  118854. }
  118855. }
  118856. declare module BABYLON {
  118857. /**
  118858. * Interface for attribute information associated with buffer instanciation
  118859. */
  118860. export interface InstancingAttributeInfo {
  118861. /**
  118862. * Name of the GLSL attribute
  118863. * if attribute index is not specified, this is used to retrieve the index from the effect
  118864. */
  118865. attributeName: string;
  118866. /**
  118867. * Index/offset of the attribute in the vertex shader
  118868. * if not specified, this will be computes from the name.
  118869. */
  118870. index?: number;
  118871. /**
  118872. * size of the attribute, 1, 2, 3 or 4
  118873. */
  118874. attributeSize: number;
  118875. /**
  118876. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  118877. */
  118878. offset: number;
  118879. /**
  118880. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  118881. * default to 1
  118882. */
  118883. divisor?: number;
  118884. /**
  118885. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  118886. * default is FLOAT
  118887. */
  118888. attributeType?: number;
  118889. /**
  118890. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  118891. */
  118892. normalized?: boolean;
  118893. }
  118894. }
  118895. declare module BABYLON {
  118896. interface ThinEngine {
  118897. /**
  118898. * Update a video texture
  118899. * @param texture defines the texture to update
  118900. * @param video defines the video element to use
  118901. * @param invertY defines if data must be stored with Y axis inverted
  118902. */
  118903. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  118904. }
  118905. }
  118906. declare module BABYLON {
  118907. interface ThinEngine {
  118908. /**
  118909. * Creates a dynamic texture
  118910. * @param width defines the width of the texture
  118911. * @param height defines the height of the texture
  118912. * @param generateMipMaps defines if the engine should generate the mip levels
  118913. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  118914. * @returns the dynamic texture inside an InternalTexture
  118915. */
  118916. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  118917. /**
  118918. * Update the content of a dynamic texture
  118919. * @param texture defines the texture to update
  118920. * @param canvas defines the canvas containing the source
  118921. * @param invertY defines if data must be stored with Y axis inverted
  118922. * @param premulAlpha defines if alpha is stored as premultiplied
  118923. * @param format defines the format of the data
  118924. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  118925. */
  118926. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  118927. }
  118928. }
  118929. declare module BABYLON {
  118930. /**
  118931. * Settings for finer control over video usage
  118932. */
  118933. export interface VideoTextureSettings {
  118934. /**
  118935. * Applies `autoplay` to video, if specified
  118936. */
  118937. autoPlay?: boolean;
  118938. /**
  118939. * Applies `muted` to video, if specified
  118940. */
  118941. muted?: boolean;
  118942. /**
  118943. * Applies `loop` to video, if specified
  118944. */
  118945. loop?: boolean;
  118946. /**
  118947. * Automatically updates internal texture from video at every frame in the render loop
  118948. */
  118949. autoUpdateTexture: boolean;
  118950. /**
  118951. * Image src displayed during the video loading or until the user interacts with the video.
  118952. */
  118953. poster?: string;
  118954. }
  118955. /**
  118956. * If you want to display a video in your scene, this is the special texture for that.
  118957. * This special texture works similar to other textures, with the exception of a few parameters.
  118958. * @see https://doc.babylonjs.com/how_to/video_texture
  118959. */
  118960. export class VideoTexture extends Texture {
  118961. /**
  118962. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  118963. */
  118964. readonly autoUpdateTexture: boolean;
  118965. /**
  118966. * The video instance used by the texture internally
  118967. */
  118968. readonly video: HTMLVideoElement;
  118969. private _onUserActionRequestedObservable;
  118970. /**
  118971. * Event triggerd when a dom action is required by the user to play the video.
  118972. * This happens due to recent changes in browser policies preventing video to auto start.
  118973. */
  118974. get onUserActionRequestedObservable(): Observable<Texture>;
  118975. private _generateMipMaps;
  118976. private _stillImageCaptured;
  118977. private _displayingPosterTexture;
  118978. private _settings;
  118979. private _createInternalTextureOnEvent;
  118980. private _frameId;
  118981. private _currentSrc;
  118982. /**
  118983. * Creates a video texture.
  118984. * If you want to display a video in your scene, this is the special texture for that.
  118985. * This special texture works similar to other textures, with the exception of a few parameters.
  118986. * @see https://doc.babylonjs.com/how_to/video_texture
  118987. * @param name optional name, will detect from video source, if not defined
  118988. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  118989. * @param scene is obviously the current scene.
  118990. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  118991. * @param invertY is false by default but can be used to invert video on Y axis
  118992. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  118993. * @param settings allows finer control over video usage
  118994. */
  118995. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  118996. private _getName;
  118997. private _getVideo;
  118998. private _createInternalTexture;
  118999. private reset;
  119000. /**
  119001. * @hidden Internal method to initiate `update`.
  119002. */
  119003. _rebuild(): void;
  119004. /**
  119005. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  119006. */
  119007. update(): void;
  119008. /**
  119009. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  119010. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  119011. */
  119012. updateTexture(isVisible: boolean): void;
  119013. protected _updateInternalTexture: () => void;
  119014. /**
  119015. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  119016. * @param url New url.
  119017. */
  119018. updateURL(url: string): void;
  119019. /**
  119020. * Clones the texture.
  119021. * @returns the cloned texture
  119022. */
  119023. clone(): VideoTexture;
  119024. /**
  119025. * Dispose the texture and release its associated resources.
  119026. */
  119027. dispose(): void;
  119028. /**
  119029. * Creates a video texture straight from a stream.
  119030. * @param scene Define the scene the texture should be created in
  119031. * @param stream Define the stream the texture should be created from
  119032. * @returns The created video texture as a promise
  119033. */
  119034. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  119035. /**
  119036. * Creates a video texture straight from your WebCam video feed.
  119037. * @param scene Define the scene the texture should be created in
  119038. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119039. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119040. * @returns The created video texture as a promise
  119041. */
  119042. static CreateFromWebCamAsync(scene: Scene, constraints: {
  119043. minWidth: number;
  119044. maxWidth: number;
  119045. minHeight: number;
  119046. maxHeight: number;
  119047. deviceId: string;
  119048. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  119049. /**
  119050. * Creates a video texture straight from your WebCam video feed.
  119051. * @param scene Define the scene the texture should be created in
  119052. * @param onReady Define a callback to triggered once the texture will be ready
  119053. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119054. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119055. */
  119056. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  119057. minWidth: number;
  119058. maxWidth: number;
  119059. minHeight: number;
  119060. maxHeight: number;
  119061. deviceId: string;
  119062. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  119063. }
  119064. }
  119065. declare module BABYLON {
  119066. /**
  119067. * Defines the interface used by objects working like Scene
  119068. * @hidden
  119069. */
  119070. export interface ISceneLike {
  119071. _addPendingData(data: any): void;
  119072. _removePendingData(data: any): void;
  119073. offlineProvider: IOfflineProvider;
  119074. }
  119075. /**
  119076. * Information about the current host
  119077. */
  119078. export interface HostInformation {
  119079. /**
  119080. * Defines if the current host is a mobile
  119081. */
  119082. isMobile: boolean;
  119083. }
  119084. /** Interface defining initialization parameters for Engine class */
  119085. export interface EngineOptions extends WebGLContextAttributes {
  119086. /**
  119087. * Defines if the engine should no exceed a specified device ratio
  119088. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  119089. */
  119090. limitDeviceRatio?: number;
  119091. /**
  119092. * Defines if webvr should be enabled automatically
  119093. * @see https://doc.babylonjs.com/how_to/webvr_camera
  119094. */
  119095. autoEnableWebVR?: boolean;
  119096. /**
  119097. * Defines if webgl2 should be turned off even if supported
  119098. * @see https://doc.babylonjs.com/features/webgl2
  119099. */
  119100. disableWebGL2Support?: boolean;
  119101. /**
  119102. * Defines if webaudio should be initialized as well
  119103. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119104. */
  119105. audioEngine?: boolean;
  119106. /**
  119107. * Defines if animations should run using a deterministic lock step
  119108. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119109. */
  119110. deterministicLockstep?: boolean;
  119111. /** Defines the maximum steps to use with deterministic lock step mode */
  119112. lockstepMaxSteps?: number;
  119113. /** Defines the seconds between each deterministic lock step */
  119114. timeStep?: number;
  119115. /**
  119116. * Defines that engine should ignore context lost events
  119117. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  119118. */
  119119. doNotHandleContextLost?: boolean;
  119120. /**
  119121. * Defines that engine should ignore modifying touch action attribute and style
  119122. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  119123. */
  119124. doNotHandleTouchAction?: boolean;
  119125. /**
  119126. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  119127. */
  119128. useHighPrecisionFloats?: boolean;
  119129. /**
  119130. * Make the canvas XR Compatible for XR sessions
  119131. */
  119132. xrCompatible?: boolean;
  119133. /**
  119134. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  119135. */
  119136. useHighPrecisionMatrix?: boolean;
  119137. /**
  119138. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  119139. */
  119140. failIfMajorPerformanceCaveat?: boolean;
  119141. }
  119142. /**
  119143. * The base engine class (root of all engines)
  119144. */
  119145. export class ThinEngine {
  119146. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  119147. static ExceptionList: ({
  119148. key: string;
  119149. capture: string;
  119150. captureConstraint: number;
  119151. targets: string[];
  119152. } | {
  119153. key: string;
  119154. capture: null;
  119155. captureConstraint: null;
  119156. targets: string[];
  119157. })[];
  119158. /** @hidden */
  119159. static _TextureLoaders: IInternalTextureLoader[];
  119160. /**
  119161. * Returns the current npm package of the sdk
  119162. */
  119163. static get NpmPackage(): string;
  119164. /**
  119165. * Returns the current version of the framework
  119166. */
  119167. static get Version(): string;
  119168. /**
  119169. * Returns a string describing the current engine
  119170. */
  119171. get description(): string;
  119172. /**
  119173. * Gets or sets the epsilon value used by collision engine
  119174. */
  119175. static CollisionsEpsilon: number;
  119176. /**
  119177. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119178. */
  119179. static get ShadersRepository(): string;
  119180. static set ShadersRepository(value: string);
  119181. /** @hidden */
  119182. _shaderProcessor: IShaderProcessor;
  119183. /**
  119184. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  119185. */
  119186. forcePOTTextures: boolean;
  119187. /**
  119188. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  119189. */
  119190. isFullscreen: boolean;
  119191. /**
  119192. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  119193. */
  119194. cullBackFaces: boolean;
  119195. /**
  119196. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  119197. */
  119198. renderEvenInBackground: boolean;
  119199. /**
  119200. * Gets or sets a boolean indicating that cache can be kept between frames
  119201. */
  119202. preventCacheWipeBetweenFrames: boolean;
  119203. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  119204. validateShaderPrograms: boolean;
  119205. /**
  119206. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  119207. * This can provide greater z depth for distant objects.
  119208. */
  119209. useReverseDepthBuffer: boolean;
  119210. /**
  119211. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  119212. */
  119213. disableUniformBuffers: boolean;
  119214. /** @hidden */
  119215. _uniformBuffers: UniformBuffer[];
  119216. /**
  119217. * Gets a boolean indicating that the engine supports uniform buffers
  119218. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  119219. */
  119220. get supportsUniformBuffers(): boolean;
  119221. /** @hidden */
  119222. _gl: WebGLRenderingContext;
  119223. /** @hidden */
  119224. _webGLVersion: number;
  119225. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  119226. protected _windowIsBackground: boolean;
  119227. protected _creationOptions: EngineOptions;
  119228. protected _highPrecisionShadersAllowed: boolean;
  119229. /** @hidden */
  119230. get _shouldUseHighPrecisionShader(): boolean;
  119231. /**
  119232. * Gets a boolean indicating that only power of 2 textures are supported
  119233. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  119234. */
  119235. get needPOTTextures(): boolean;
  119236. /** @hidden */
  119237. _badOS: boolean;
  119238. /** @hidden */
  119239. _badDesktopOS: boolean;
  119240. private _hardwareScalingLevel;
  119241. /** @hidden */
  119242. _caps: EngineCapabilities;
  119243. private _isStencilEnable;
  119244. private _glVersion;
  119245. private _glRenderer;
  119246. private _glVendor;
  119247. /** @hidden */
  119248. _videoTextureSupported: boolean;
  119249. protected _renderingQueueLaunched: boolean;
  119250. protected _activeRenderLoops: (() => void)[];
  119251. /**
  119252. * Observable signaled when a context lost event is raised
  119253. */
  119254. onContextLostObservable: Observable<ThinEngine>;
  119255. /**
  119256. * Observable signaled when a context restored event is raised
  119257. */
  119258. onContextRestoredObservable: Observable<ThinEngine>;
  119259. private _onContextLost;
  119260. private _onContextRestored;
  119261. protected _contextWasLost: boolean;
  119262. /** @hidden */
  119263. _doNotHandleContextLost: boolean;
  119264. /**
  119265. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  119266. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  119267. */
  119268. get doNotHandleContextLost(): boolean;
  119269. set doNotHandleContextLost(value: boolean);
  119270. /**
  119271. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  119272. */
  119273. disableVertexArrayObjects: boolean;
  119274. /** @hidden */
  119275. protected _colorWrite: boolean;
  119276. /** @hidden */
  119277. protected _colorWriteChanged: boolean;
  119278. /** @hidden */
  119279. protected _depthCullingState: DepthCullingState;
  119280. /** @hidden */
  119281. protected _stencilState: StencilState;
  119282. /** @hidden */
  119283. _alphaState: AlphaState;
  119284. /** @hidden */
  119285. _alphaMode: number;
  119286. /** @hidden */
  119287. _alphaEquation: number;
  119288. /** @hidden */
  119289. _internalTexturesCache: InternalTexture[];
  119290. /** @hidden */
  119291. protected _activeChannel: number;
  119292. private _currentTextureChannel;
  119293. /** @hidden */
  119294. protected _boundTexturesCache: {
  119295. [key: string]: Nullable<InternalTexture>;
  119296. };
  119297. /** @hidden */
  119298. protected _currentEffect: Nullable<Effect>;
  119299. /** @hidden */
  119300. protected _currentProgram: Nullable<WebGLProgram>;
  119301. private _compiledEffects;
  119302. private _vertexAttribArraysEnabled;
  119303. /** @hidden */
  119304. protected _cachedViewport: Nullable<IViewportLike>;
  119305. private _cachedVertexArrayObject;
  119306. /** @hidden */
  119307. protected _cachedVertexBuffers: any;
  119308. /** @hidden */
  119309. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  119310. /** @hidden */
  119311. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  119312. /** @hidden */
  119313. _currentRenderTarget: Nullable<InternalTexture>;
  119314. private _uintIndicesCurrentlySet;
  119315. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  119316. /** @hidden */
  119317. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  119318. /** @hidden */
  119319. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  119320. private _currentBufferPointers;
  119321. private _currentInstanceLocations;
  119322. private _currentInstanceBuffers;
  119323. private _textureUnits;
  119324. /** @hidden */
  119325. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  119326. /** @hidden */
  119327. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  119328. /** @hidden */
  119329. _boundRenderFunction: any;
  119330. private _vaoRecordInProgress;
  119331. private _mustWipeVertexAttributes;
  119332. private _emptyTexture;
  119333. private _emptyCubeTexture;
  119334. private _emptyTexture3D;
  119335. private _emptyTexture2DArray;
  119336. /** @hidden */
  119337. _frameHandler: number;
  119338. private _nextFreeTextureSlots;
  119339. private _maxSimultaneousTextures;
  119340. private _activeRequests;
  119341. /** @hidden */
  119342. _transformTextureUrl: Nullable<(url: string) => string>;
  119343. /**
  119344. * Gets information about the current host
  119345. */
  119346. hostInformation: HostInformation;
  119347. protected get _supportsHardwareTextureRescaling(): boolean;
  119348. private _framebufferDimensionsObject;
  119349. /**
  119350. * sets the object from which width and height will be taken from when getting render width and height
  119351. * Will fallback to the gl object
  119352. * @param dimensions the framebuffer width and height that will be used.
  119353. */
  119354. set framebufferDimensionsObject(dimensions: Nullable<{
  119355. framebufferWidth: number;
  119356. framebufferHeight: number;
  119357. }>);
  119358. /**
  119359. * Gets the current viewport
  119360. */
  119361. get currentViewport(): Nullable<IViewportLike>;
  119362. /**
  119363. * Gets the default empty texture
  119364. */
  119365. get emptyTexture(): InternalTexture;
  119366. /**
  119367. * Gets the default empty 3D texture
  119368. */
  119369. get emptyTexture3D(): InternalTexture;
  119370. /**
  119371. * Gets the default empty 2D array texture
  119372. */
  119373. get emptyTexture2DArray(): InternalTexture;
  119374. /**
  119375. * Gets the default empty cube texture
  119376. */
  119377. get emptyCubeTexture(): InternalTexture;
  119378. /**
  119379. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  119380. */
  119381. readonly premultipliedAlpha: boolean;
  119382. /**
  119383. * Observable event triggered before each texture is initialized
  119384. */
  119385. onBeforeTextureInitObservable: Observable<Texture>;
  119386. /**
  119387. * Creates a new engine
  119388. * @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
  119389. * @param antialias defines enable antialiasing (default: false)
  119390. * @param options defines further options to be sent to the getContext() function
  119391. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  119392. */
  119393. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  119394. private _rebuildInternalTextures;
  119395. private _rebuildEffects;
  119396. /**
  119397. * Gets a boolean indicating if all created effects are ready
  119398. * @returns true if all effects are ready
  119399. */
  119400. areAllEffectsReady(): boolean;
  119401. protected _rebuildBuffers(): void;
  119402. protected _initGLContext(): void;
  119403. /**
  119404. * Gets version of the current webGL context
  119405. */
  119406. get webGLVersion(): number;
  119407. /**
  119408. * Gets a string identifying the name of the class
  119409. * @returns "Engine" string
  119410. */
  119411. getClassName(): string;
  119412. /**
  119413. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  119414. */
  119415. get isStencilEnable(): boolean;
  119416. /** @hidden */
  119417. _prepareWorkingCanvas(): void;
  119418. /**
  119419. * Reset the texture cache to empty state
  119420. */
  119421. resetTextureCache(): void;
  119422. /**
  119423. * Gets an object containing information about the current webGL context
  119424. * @returns an object containing the vender, the renderer and the version of the current webGL context
  119425. */
  119426. getGlInfo(): {
  119427. vendor: string;
  119428. renderer: string;
  119429. version: string;
  119430. };
  119431. /**
  119432. * Defines the hardware scaling level.
  119433. * By default the hardware scaling level is computed from the window device ratio.
  119434. * 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.
  119435. * @param level defines the level to use
  119436. */
  119437. setHardwareScalingLevel(level: number): void;
  119438. /**
  119439. * Gets the current hardware scaling level.
  119440. * By default the hardware scaling level is computed from the window device ratio.
  119441. * 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.
  119442. * @returns a number indicating the current hardware scaling level
  119443. */
  119444. getHardwareScalingLevel(): number;
  119445. /**
  119446. * Gets the list of loaded textures
  119447. * @returns an array containing all loaded textures
  119448. */
  119449. getLoadedTexturesCache(): InternalTexture[];
  119450. /**
  119451. * Gets the object containing all engine capabilities
  119452. * @returns the EngineCapabilities object
  119453. */
  119454. getCaps(): EngineCapabilities;
  119455. /**
  119456. * stop executing a render loop function and remove it from the execution array
  119457. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  119458. */
  119459. stopRenderLoop(renderFunction?: () => void): void;
  119460. /** @hidden */
  119461. _renderLoop(): void;
  119462. /**
  119463. * Gets the HTML canvas attached with the current webGL context
  119464. * @returns a HTML canvas
  119465. */
  119466. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  119467. /**
  119468. * Gets host window
  119469. * @returns the host window object
  119470. */
  119471. getHostWindow(): Nullable<Window>;
  119472. /**
  119473. * Gets the current render width
  119474. * @param useScreen defines if screen size must be used (or the current render target if any)
  119475. * @returns a number defining the current render width
  119476. */
  119477. getRenderWidth(useScreen?: boolean): number;
  119478. /**
  119479. * Gets the current render height
  119480. * @param useScreen defines if screen size must be used (or the current render target if any)
  119481. * @returns a number defining the current render height
  119482. */
  119483. getRenderHeight(useScreen?: boolean): number;
  119484. /**
  119485. * Can be used to override the current requestAnimationFrame requester.
  119486. * @hidden
  119487. */
  119488. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  119489. /**
  119490. * Register and execute a render loop. The engine can have more than one render function
  119491. * @param renderFunction defines the function to continuously execute
  119492. */
  119493. runRenderLoop(renderFunction: () => void): void;
  119494. /**
  119495. * Clear the current render buffer or the current render target (if any is set up)
  119496. * @param color defines the color to use
  119497. * @param backBuffer defines if the back buffer must be cleared
  119498. * @param depth defines if the depth buffer must be cleared
  119499. * @param stencil defines if the stencil buffer must be cleared
  119500. */
  119501. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119502. private _viewportCached;
  119503. /** @hidden */
  119504. _viewport(x: number, y: number, width: number, height: number): void;
  119505. /**
  119506. * Set the WebGL's viewport
  119507. * @param viewport defines the viewport element to be used
  119508. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119509. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119510. */
  119511. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119512. /**
  119513. * Begin a new frame
  119514. */
  119515. beginFrame(): void;
  119516. /**
  119517. * Enf the current frame
  119518. */
  119519. endFrame(): void;
  119520. /**
  119521. * Resize the view according to the canvas' size
  119522. */
  119523. resize(): void;
  119524. /**
  119525. * Force a specific size of the canvas
  119526. * @param width defines the new canvas' width
  119527. * @param height defines the new canvas' height
  119528. * @returns true if the size was changed
  119529. */
  119530. setSize(width: number, height: number): boolean;
  119531. /**
  119532. * Binds the frame buffer to the specified texture.
  119533. * @param texture The texture to render to or null for the default canvas
  119534. * @param faceIndex The face of the texture to render to in case of cube texture
  119535. * @param requiredWidth The width of the target to render to
  119536. * @param requiredHeight The height of the target to render to
  119537. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119538. * @param lodLevel defines the lod level to bind to the frame buffer
  119539. * @param layer defines the 2d array index to bind to frame buffer to
  119540. */
  119541. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  119542. /** @hidden */
  119543. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  119544. /**
  119545. * Unbind the current render target texture from the webGL context
  119546. * @param texture defines the render target texture to unbind
  119547. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119548. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119549. */
  119550. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119551. /**
  119552. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  119553. */
  119554. flushFramebuffer(): void;
  119555. /**
  119556. * Unbind the current render target and bind the default framebuffer
  119557. */
  119558. restoreDefaultFramebuffer(): void;
  119559. /** @hidden */
  119560. protected _resetVertexBufferBinding(): void;
  119561. /**
  119562. * Creates a vertex buffer
  119563. * @param data the data for the vertex buffer
  119564. * @returns the new WebGL static buffer
  119565. */
  119566. createVertexBuffer(data: DataArray): DataBuffer;
  119567. private _createVertexBuffer;
  119568. /**
  119569. * Creates a dynamic vertex buffer
  119570. * @param data the data for the dynamic vertex buffer
  119571. * @returns the new WebGL dynamic buffer
  119572. */
  119573. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  119574. protected _resetIndexBufferBinding(): void;
  119575. /**
  119576. * Creates a new index buffer
  119577. * @param indices defines the content of the index buffer
  119578. * @param updatable defines if the index buffer must be updatable
  119579. * @returns a new webGL buffer
  119580. */
  119581. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  119582. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  119583. /**
  119584. * Bind a webGL buffer to the webGL context
  119585. * @param buffer defines the buffer to bind
  119586. */
  119587. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  119588. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  119589. private bindBuffer;
  119590. /**
  119591. * update the bound buffer with the given data
  119592. * @param data defines the data to update
  119593. */
  119594. updateArrayBuffer(data: Float32Array): void;
  119595. private _vertexAttribPointer;
  119596. /** @hidden */
  119597. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  119598. private _bindVertexBuffersAttributes;
  119599. /**
  119600. * Records a vertex array object
  119601. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119602. * @param vertexBuffers defines the list of vertex buffers to store
  119603. * @param indexBuffer defines the index buffer to store
  119604. * @param effect defines the effect to store
  119605. * @returns the new vertex array object
  119606. */
  119607. recordVertexArrayObject(vertexBuffers: {
  119608. [key: string]: VertexBuffer;
  119609. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  119610. /**
  119611. * Bind a specific vertex array object
  119612. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119613. * @param vertexArrayObject defines the vertex array object to bind
  119614. * @param indexBuffer defines the index buffer to bind
  119615. */
  119616. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  119617. /**
  119618. * Bind webGl buffers directly to the webGL context
  119619. * @param vertexBuffer defines the vertex buffer to bind
  119620. * @param indexBuffer defines the index buffer to bind
  119621. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119622. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119623. * @param effect defines the effect associated with the vertex buffer
  119624. */
  119625. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  119626. private _unbindVertexArrayObject;
  119627. /**
  119628. * Bind a list of vertex buffers to the webGL context
  119629. * @param vertexBuffers defines the list of vertex buffers to bind
  119630. * @param indexBuffer defines the index buffer to bind
  119631. * @param effect defines the effect associated with the vertex buffers
  119632. */
  119633. bindBuffers(vertexBuffers: {
  119634. [key: string]: Nullable<VertexBuffer>;
  119635. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  119636. /**
  119637. * Unbind all instance attributes
  119638. */
  119639. unbindInstanceAttributes(): void;
  119640. /**
  119641. * Release and free the memory of a vertex array object
  119642. * @param vao defines the vertex array object to delete
  119643. */
  119644. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  119645. /** @hidden */
  119646. _releaseBuffer(buffer: DataBuffer): boolean;
  119647. protected _deleteBuffer(buffer: DataBuffer): void;
  119648. /**
  119649. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  119650. * @param instancesBuffer defines the webGL buffer to update and bind
  119651. * @param data defines the data to store in the buffer
  119652. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  119653. */
  119654. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  119655. /**
  119656. * Bind the content of a webGL buffer used with instantiation
  119657. * @param instancesBuffer defines the webGL buffer to bind
  119658. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  119659. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  119660. */
  119661. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  119662. /**
  119663. * Disable the instance attribute corresponding to the name in parameter
  119664. * @param name defines the name of the attribute to disable
  119665. */
  119666. disableInstanceAttributeByName(name: string): void;
  119667. /**
  119668. * Disable the instance attribute corresponding to the location in parameter
  119669. * @param attributeLocation defines the attribute location of the attribute to disable
  119670. */
  119671. disableInstanceAttribute(attributeLocation: number): void;
  119672. /**
  119673. * Disable the attribute corresponding to the location in parameter
  119674. * @param attributeLocation defines the attribute location of the attribute to disable
  119675. */
  119676. disableAttributeByIndex(attributeLocation: number): void;
  119677. /**
  119678. * Send a draw order
  119679. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119680. * @param indexStart defines the starting index
  119681. * @param indexCount defines the number of index to draw
  119682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119683. */
  119684. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119685. /**
  119686. * Draw a list of points
  119687. * @param verticesStart defines the index of first vertex to draw
  119688. * @param verticesCount defines the count of vertices to draw
  119689. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119690. */
  119691. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119692. /**
  119693. * Draw a list of unindexed primitives
  119694. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119695. * @param verticesStart defines the index of first vertex to draw
  119696. * @param verticesCount defines the count of vertices to draw
  119697. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119698. */
  119699. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119700. /**
  119701. * Draw a list of indexed primitives
  119702. * @param fillMode defines the primitive to use
  119703. * @param indexStart defines the starting index
  119704. * @param indexCount defines the number of index to draw
  119705. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119706. */
  119707. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119708. /**
  119709. * Draw a list of unindexed primitives
  119710. * @param fillMode defines the primitive to use
  119711. * @param verticesStart defines the index of first vertex to draw
  119712. * @param verticesCount defines the count of vertices to draw
  119713. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119714. */
  119715. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119716. private _drawMode;
  119717. /** @hidden */
  119718. protected _reportDrawCall(): void;
  119719. /** @hidden */
  119720. _releaseEffect(effect: Effect): void;
  119721. /** @hidden */
  119722. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  119723. /**
  119724. * Create a new effect (used to store vertex/fragment shaders)
  119725. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  119726. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  119727. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  119728. * @param samplers defines an array of string used to represent textures
  119729. * @param defines defines the string containing the defines to use to compile the shaders
  119730. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119731. * @param onCompiled defines a function to call when the effect creation is successful
  119732. * @param onError defines a function to call when the effect creation has failed
  119733. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  119734. * @returns the new Effect
  119735. */
  119736. 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;
  119737. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  119738. private _compileShader;
  119739. private _compileRawShader;
  119740. /** @hidden */
  119741. _getShaderSource(shader: WebGLShader): Nullable<string>;
  119742. /**
  119743. * Directly creates a webGL program
  119744. * @param pipelineContext defines the pipeline context to attach to
  119745. * @param vertexCode defines the vertex shader code to use
  119746. * @param fragmentCode defines the fragment shader code to use
  119747. * @param context defines the webGL context to use (if not set, the current one will be used)
  119748. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119749. * @returns the new webGL program
  119750. */
  119751. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119752. /**
  119753. * Creates a webGL program
  119754. * @param pipelineContext defines the pipeline context to attach to
  119755. * @param vertexCode defines the vertex shader code to use
  119756. * @param fragmentCode defines the fragment shader code to use
  119757. * @param defines defines the string containing the defines to use to compile the shaders
  119758. * @param context defines the webGL context to use (if not set, the current one will be used)
  119759. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119760. * @returns the new webGL program
  119761. */
  119762. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119763. /**
  119764. * Creates a new pipeline context
  119765. * @returns the new pipeline
  119766. */
  119767. createPipelineContext(): IPipelineContext;
  119768. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119769. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  119770. /** @hidden */
  119771. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  119772. /** @hidden */
  119773. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  119774. /** @hidden */
  119775. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  119776. /**
  119777. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119778. * @param pipelineContext defines the pipeline context to use
  119779. * @param uniformsNames defines the list of uniform names
  119780. * @returns an array of webGL uniform locations
  119781. */
  119782. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119783. /**
  119784. * Gets the lsit of active attributes for a given webGL program
  119785. * @param pipelineContext defines the pipeline context to use
  119786. * @param attributesNames defines the list of attribute names to get
  119787. * @returns an array of indices indicating the offset of each attribute
  119788. */
  119789. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119790. /**
  119791. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119792. * @param effect defines the effect to activate
  119793. */
  119794. enableEffect(effect: Nullable<Effect>): void;
  119795. /**
  119796. * Set the value of an uniform to a number (int)
  119797. * @param uniform defines the webGL uniform location where to store the value
  119798. * @param value defines the int number to store
  119799. * @returns true if the value was set
  119800. */
  119801. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119802. /**
  119803. * Set the value of an uniform to an array of int32
  119804. * @param uniform defines the webGL uniform location where to store the value
  119805. * @param array defines the array of int32 to store
  119806. * @returns true if the value was set
  119807. */
  119808. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119809. /**
  119810. * Set the value of an uniform to an array of int32 (stored as vec2)
  119811. * @param uniform defines the webGL uniform location where to store the value
  119812. * @param array defines the array of int32 to store
  119813. * @returns true if the value was set
  119814. */
  119815. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119816. /**
  119817. * Set the value of an uniform to an array of int32 (stored as vec3)
  119818. * @param uniform defines the webGL uniform location where to store the value
  119819. * @param array defines the array of int32 to store
  119820. * @returns true if the value was set
  119821. */
  119822. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119823. /**
  119824. * Set the value of an uniform to an array of int32 (stored as vec4)
  119825. * @param uniform defines the webGL uniform location where to store the value
  119826. * @param array defines the array of int32 to store
  119827. * @returns true if the value was set
  119828. */
  119829. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119830. /**
  119831. * Set the value of an uniform to an array of number
  119832. * @param uniform defines the webGL uniform location where to store the value
  119833. * @param array defines the array of number to store
  119834. * @returns true if the value was set
  119835. */
  119836. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119837. /**
  119838. * Set the value of an uniform to an array of number (stored as vec2)
  119839. * @param uniform defines the webGL uniform location where to store the value
  119840. * @param array defines the array of number to store
  119841. * @returns true if the value was set
  119842. */
  119843. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119844. /**
  119845. * Set the value of an uniform to an array of number (stored as vec3)
  119846. * @param uniform defines the webGL uniform location where to store the value
  119847. * @param array defines the array of number to store
  119848. * @returns true if the value was set
  119849. */
  119850. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119851. /**
  119852. * Set the value of an uniform to an array of number (stored as vec4)
  119853. * @param uniform defines the webGL uniform location where to store the value
  119854. * @param array defines the array of number to store
  119855. * @returns true if the value was set
  119856. */
  119857. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119858. /**
  119859. * Set the value of an uniform to an array of float32 (stored as matrices)
  119860. * @param uniform defines the webGL uniform location where to store the value
  119861. * @param matrices defines the array of float32 to store
  119862. * @returns true if the value was set
  119863. */
  119864. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  119865. /**
  119866. * Set the value of an uniform to a matrix (3x3)
  119867. * @param uniform defines the webGL uniform location where to store the value
  119868. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119869. * @returns true if the value was set
  119870. */
  119871. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119872. /**
  119873. * Set the value of an uniform to a matrix (2x2)
  119874. * @param uniform defines the webGL uniform location where to store the value
  119875. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119876. * @returns true if the value was set
  119877. */
  119878. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119879. /**
  119880. * Set the value of an uniform to a number (float)
  119881. * @param uniform defines the webGL uniform location where to store the value
  119882. * @param value defines the float number to store
  119883. * @returns true if the value was transfered
  119884. */
  119885. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119886. /**
  119887. * Set the value of an uniform to a vec2
  119888. * @param uniform defines the webGL uniform location where to store the value
  119889. * @param x defines the 1st component of the value
  119890. * @param y defines the 2nd component of the value
  119891. * @returns true if the value was set
  119892. */
  119893. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  119894. /**
  119895. * Set the value of an uniform to a vec3
  119896. * @param uniform defines the webGL uniform location where to store the value
  119897. * @param x defines the 1st component of the value
  119898. * @param y defines the 2nd component of the value
  119899. * @param z defines the 3rd component of the value
  119900. * @returns true if the value was set
  119901. */
  119902. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  119903. /**
  119904. * Set the value of an uniform to a vec4
  119905. * @param uniform defines the webGL uniform location where to store the value
  119906. * @param x defines the 1st component of the value
  119907. * @param y defines the 2nd component of the value
  119908. * @param z defines the 3rd component of the value
  119909. * @param w defines the 4th component of the value
  119910. * @returns true if the value was set
  119911. */
  119912. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  119913. /**
  119914. * Apply all cached states (depth, culling, stencil and alpha)
  119915. */
  119916. applyStates(): void;
  119917. /**
  119918. * Enable or disable color writing
  119919. * @param enable defines the state to set
  119920. */
  119921. setColorWrite(enable: boolean): void;
  119922. /**
  119923. * Gets a boolean indicating if color writing is enabled
  119924. * @returns the current color writing state
  119925. */
  119926. getColorWrite(): boolean;
  119927. /**
  119928. * Gets the depth culling state manager
  119929. */
  119930. get depthCullingState(): DepthCullingState;
  119931. /**
  119932. * Gets the alpha state manager
  119933. */
  119934. get alphaState(): AlphaState;
  119935. /**
  119936. * Gets the stencil state manager
  119937. */
  119938. get stencilState(): StencilState;
  119939. /**
  119940. * Clears the list of texture accessible through engine.
  119941. * This can help preventing texture load conflict due to name collision.
  119942. */
  119943. clearInternalTexturesCache(): void;
  119944. /**
  119945. * Force the entire cache to be cleared
  119946. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119947. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119948. */
  119949. wipeCaches(bruteForce?: boolean): void;
  119950. /** @hidden */
  119951. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  119952. min: number;
  119953. mag: number;
  119954. };
  119955. /** @hidden */
  119956. _createTexture(): WebGLTexture;
  119957. /**
  119958. * Usually called from Texture.ts.
  119959. * Passed information to create a WebGLTexture
  119960. * @param url defines a value which contains one of the following:
  119961. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119962. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119963. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119964. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119965. * @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)
  119966. * @param scene needed for loading to the correct scene
  119967. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119968. * @param onLoad optional callback to be called upon successful completion
  119969. * @param onError optional callback to be called upon failure
  119970. * @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
  119971. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119972. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119973. * @param forcedExtension defines the extension to use to pick the right loader
  119974. * @param mimeType defines an optional mime type
  119975. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119976. */
  119977. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  119978. /**
  119979. * Loads an image as an HTMLImageElement.
  119980. * @param input url string, ArrayBuffer, or Blob to load
  119981. * @param onLoad callback called when the image successfully loads
  119982. * @param onError callback called when the image fails to load
  119983. * @param offlineProvider offline provider for caching
  119984. * @param mimeType optional mime type
  119985. * @returns the HTMLImageElement of the loaded image
  119986. * @hidden
  119987. */
  119988. 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>;
  119989. /**
  119990. * @hidden
  119991. */
  119992. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  119993. private _unpackFlipYCached;
  119994. /**
  119995. * In case you are sharing the context with other applications, it might
  119996. * be interested to not cache the unpack flip y state to ensure a consistent
  119997. * value would be set.
  119998. */
  119999. enableUnpackFlipYCached: boolean;
  120000. /** @hidden */
  120001. _unpackFlipY(value: boolean): void;
  120002. /** @hidden */
  120003. _getUnpackAlignement(): number;
  120004. private _getTextureTarget;
  120005. /**
  120006. * Update the sampling mode of a given texture
  120007. * @param samplingMode defines the required sampling mode
  120008. * @param texture defines the texture to update
  120009. * @param generateMipMaps defines whether to generate mipmaps for the texture
  120010. */
  120011. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  120012. /**
  120013. * Update the sampling mode of a given texture
  120014. * @param texture defines the texture to update
  120015. * @param wrapU defines the texture wrap mode of the u coordinates
  120016. * @param wrapV defines the texture wrap mode of the v coordinates
  120017. * @param wrapR defines the texture wrap mode of the r coordinates
  120018. */
  120019. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  120020. /** @hidden */
  120021. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  120022. width: number;
  120023. height: number;
  120024. layers?: number;
  120025. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  120026. /** @hidden */
  120027. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120028. /** @hidden */
  120029. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  120030. /**
  120031. * Update a portion of an internal texture
  120032. * @param texture defines the texture to update
  120033. * @param imageData defines the data to store into the texture
  120034. * @param xOffset defines the x coordinates of the update rectangle
  120035. * @param yOffset defines the y coordinates of the update rectangle
  120036. * @param width defines the width of the update rectangle
  120037. * @param height defines the height of the update rectangle
  120038. * @param faceIndex defines the face index if texture is a cube (0 by default)
  120039. * @param lod defines the lod level to update (0 by default)
  120040. */
  120041. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  120042. /** @hidden */
  120043. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120044. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  120045. private _prepareWebGLTexture;
  120046. /** @hidden */
  120047. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  120048. private _getDepthStencilBuffer;
  120049. /** @hidden */
  120050. _releaseFramebufferObjects(texture: InternalTexture): void;
  120051. /** @hidden */
  120052. _releaseTexture(texture: InternalTexture): void;
  120053. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120054. protected _setProgram(program: WebGLProgram): void;
  120055. protected _boundUniforms: {
  120056. [key: number]: WebGLUniformLocation;
  120057. };
  120058. /**
  120059. * Binds an effect to the webGL context
  120060. * @param effect defines the effect to bind
  120061. */
  120062. bindSamplers(effect: Effect): void;
  120063. private _activateCurrentTexture;
  120064. /** @hidden */
  120065. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  120066. /** @hidden */
  120067. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  120068. /**
  120069. * Unbind all textures from the webGL context
  120070. */
  120071. unbindAllTextures(): void;
  120072. /**
  120073. * Sets a texture to the according uniform.
  120074. * @param channel The texture channel
  120075. * @param uniform The uniform to set
  120076. * @param texture The texture to apply
  120077. */
  120078. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  120079. private _bindSamplerUniformToChannel;
  120080. private _getTextureWrapMode;
  120081. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120082. /**
  120083. * Sets an array of texture to the webGL context
  120084. * @param channel defines the channel where the texture array must be set
  120085. * @param uniform defines the associated uniform location
  120086. * @param textures defines the array of textures to bind
  120087. */
  120088. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  120089. /** @hidden */
  120090. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  120091. private _setTextureParameterFloat;
  120092. private _setTextureParameterInteger;
  120093. /**
  120094. * Unbind all vertex attributes from the webGL context
  120095. */
  120096. unbindAllAttributes(): void;
  120097. /**
  120098. * 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
  120099. */
  120100. releaseEffects(): void;
  120101. /**
  120102. * Dispose and release all associated resources
  120103. */
  120104. dispose(): void;
  120105. /**
  120106. * Attach a new callback raised when context lost event is fired
  120107. * @param callback defines the callback to call
  120108. */
  120109. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120110. /**
  120111. * Attach a new callback raised when context restored event is fired
  120112. * @param callback defines the callback to call
  120113. */
  120114. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120115. /**
  120116. * Get the current error code of the webGL context
  120117. * @returns the error code
  120118. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120119. */
  120120. getError(): number;
  120121. private _canRenderToFloatFramebuffer;
  120122. private _canRenderToHalfFloatFramebuffer;
  120123. private _canRenderToFramebuffer;
  120124. /** @hidden */
  120125. _getWebGLTextureType(type: number): number;
  120126. /** @hidden */
  120127. _getInternalFormat(format: number): number;
  120128. /** @hidden */
  120129. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  120130. /** @hidden */
  120131. _getRGBAMultiSampleBufferFormat(type: number): number;
  120132. /** @hidden */
  120133. _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;
  120134. /**
  120135. * Loads a file from a url
  120136. * @param url url to load
  120137. * @param onSuccess callback called when the file successfully loads
  120138. * @param onProgress callback called while file is loading (if the server supports this mode)
  120139. * @param offlineProvider defines the offline provider for caching
  120140. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  120141. * @param onError callback called when the file fails to load
  120142. * @returns a file request object
  120143. * @hidden
  120144. */
  120145. 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;
  120146. /**
  120147. * Reads pixels from the current frame buffer. Please note that this function can be slow
  120148. * @param x defines the x coordinate of the rectangle where pixels must be read
  120149. * @param y defines the y coordinate of the rectangle where pixels must be read
  120150. * @param width defines the width of the rectangle where pixels must be read
  120151. * @param height defines the height of the rectangle where pixels must be read
  120152. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  120153. * @returns a Uint8Array containing RGBA colors
  120154. */
  120155. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  120156. private static _IsSupported;
  120157. private static _HasMajorPerformanceCaveat;
  120158. /**
  120159. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120160. */
  120161. static get IsSupported(): boolean;
  120162. /**
  120163. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120164. * @returns true if the engine can be created
  120165. * @ignorenaming
  120166. */
  120167. static isSupported(): boolean;
  120168. /**
  120169. * 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)
  120170. */
  120171. static get HasMajorPerformanceCaveat(): boolean;
  120172. /**
  120173. * Find the next highest power of two.
  120174. * @param x Number to start search from.
  120175. * @return Next highest power of two.
  120176. */
  120177. static CeilingPOT(x: number): number;
  120178. /**
  120179. * Find the next lowest power of two.
  120180. * @param x Number to start search from.
  120181. * @return Next lowest power of two.
  120182. */
  120183. static FloorPOT(x: number): number;
  120184. /**
  120185. * Find the nearest power of two.
  120186. * @param x Number to start search from.
  120187. * @return Next nearest power of two.
  120188. */
  120189. static NearestPOT(x: number): number;
  120190. /**
  120191. * Get the closest exponent of two
  120192. * @param value defines the value to approximate
  120193. * @param max defines the maximum value to return
  120194. * @param mode defines how to define the closest value
  120195. * @returns closest exponent of two of the given value
  120196. */
  120197. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  120198. /**
  120199. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  120200. * @param func - the function to be called
  120201. * @param requester - the object that will request the next frame. Falls back to window.
  120202. * @returns frame number
  120203. */
  120204. static QueueNewFrame(func: () => void, requester?: any): number;
  120205. /**
  120206. * Gets host document
  120207. * @returns the host document object
  120208. */
  120209. getHostDocument(): Nullable<Document>;
  120210. }
  120211. }
  120212. declare module BABYLON {
  120213. /**
  120214. * Defines the source of the internal texture
  120215. */
  120216. export enum InternalTextureSource {
  120217. /**
  120218. * The source of the texture data is unknown
  120219. */
  120220. Unknown = 0,
  120221. /**
  120222. * Texture data comes from an URL
  120223. */
  120224. Url = 1,
  120225. /**
  120226. * Texture data is only used for temporary storage
  120227. */
  120228. Temp = 2,
  120229. /**
  120230. * Texture data comes from raw data (ArrayBuffer)
  120231. */
  120232. Raw = 3,
  120233. /**
  120234. * Texture content is dynamic (video or dynamic texture)
  120235. */
  120236. Dynamic = 4,
  120237. /**
  120238. * Texture content is generated by rendering to it
  120239. */
  120240. RenderTarget = 5,
  120241. /**
  120242. * Texture content is part of a multi render target process
  120243. */
  120244. MultiRenderTarget = 6,
  120245. /**
  120246. * Texture data comes from a cube data file
  120247. */
  120248. Cube = 7,
  120249. /**
  120250. * Texture data comes from a raw cube data
  120251. */
  120252. CubeRaw = 8,
  120253. /**
  120254. * Texture data come from a prefiltered cube data file
  120255. */
  120256. CubePrefiltered = 9,
  120257. /**
  120258. * Texture content is raw 3D data
  120259. */
  120260. Raw3D = 10,
  120261. /**
  120262. * Texture content is raw 2D array data
  120263. */
  120264. Raw2DArray = 11,
  120265. /**
  120266. * Texture content is a depth texture
  120267. */
  120268. Depth = 12,
  120269. /**
  120270. * Texture data comes from a raw cube data encoded with RGBD
  120271. */
  120272. CubeRawRGBD = 13
  120273. }
  120274. /**
  120275. * Class used to store data associated with WebGL texture data for the engine
  120276. * This class should not be used directly
  120277. */
  120278. export class InternalTexture {
  120279. /** @hidden */
  120280. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  120281. /**
  120282. * Defines if the texture is ready
  120283. */
  120284. isReady: boolean;
  120285. /**
  120286. * Defines if the texture is a cube texture
  120287. */
  120288. isCube: boolean;
  120289. /**
  120290. * Defines if the texture contains 3D data
  120291. */
  120292. is3D: boolean;
  120293. /**
  120294. * Defines if the texture contains 2D array data
  120295. */
  120296. is2DArray: boolean;
  120297. /**
  120298. * Defines if the texture contains multiview data
  120299. */
  120300. isMultiview: boolean;
  120301. /**
  120302. * Gets the URL used to load this texture
  120303. */
  120304. url: string;
  120305. /**
  120306. * Gets the sampling mode of the texture
  120307. */
  120308. samplingMode: number;
  120309. /**
  120310. * Gets a boolean indicating if the texture needs mipmaps generation
  120311. */
  120312. generateMipMaps: boolean;
  120313. /**
  120314. * Gets the number of samples used by the texture (WebGL2+ only)
  120315. */
  120316. samples: number;
  120317. /**
  120318. * Gets the type of the texture (int, float...)
  120319. */
  120320. type: number;
  120321. /**
  120322. * Gets the format of the texture (RGB, RGBA...)
  120323. */
  120324. format: number;
  120325. /**
  120326. * Observable called when the texture is loaded
  120327. */
  120328. onLoadedObservable: Observable<InternalTexture>;
  120329. /**
  120330. * Gets the width of the texture
  120331. */
  120332. width: number;
  120333. /**
  120334. * Gets the height of the texture
  120335. */
  120336. height: number;
  120337. /**
  120338. * Gets the depth of the texture
  120339. */
  120340. depth: number;
  120341. /**
  120342. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  120343. */
  120344. baseWidth: number;
  120345. /**
  120346. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  120347. */
  120348. baseHeight: number;
  120349. /**
  120350. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  120351. */
  120352. baseDepth: number;
  120353. /**
  120354. * Gets a boolean indicating if the texture is inverted on Y axis
  120355. */
  120356. invertY: boolean;
  120357. /** @hidden */
  120358. _invertVScale: boolean;
  120359. /** @hidden */
  120360. _associatedChannel: number;
  120361. /** @hidden */
  120362. _source: InternalTextureSource;
  120363. /** @hidden */
  120364. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  120365. /** @hidden */
  120366. _bufferView: Nullable<ArrayBufferView>;
  120367. /** @hidden */
  120368. _bufferViewArray: Nullable<ArrayBufferView[]>;
  120369. /** @hidden */
  120370. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  120371. /** @hidden */
  120372. _size: number;
  120373. /** @hidden */
  120374. _extension: string;
  120375. /** @hidden */
  120376. _files: Nullable<string[]>;
  120377. /** @hidden */
  120378. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120379. /** @hidden */
  120380. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120381. /** @hidden */
  120382. _framebuffer: Nullable<WebGLFramebuffer>;
  120383. /** @hidden */
  120384. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  120385. /** @hidden */
  120386. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  120387. /** @hidden */
  120388. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  120389. /** @hidden */
  120390. _attachments: Nullable<number[]>;
  120391. /** @hidden */
  120392. _textureArray: Nullable<InternalTexture[]>;
  120393. /** @hidden */
  120394. _cachedCoordinatesMode: Nullable<number>;
  120395. /** @hidden */
  120396. _cachedWrapU: Nullable<number>;
  120397. /** @hidden */
  120398. _cachedWrapV: Nullable<number>;
  120399. /** @hidden */
  120400. _cachedWrapR: Nullable<number>;
  120401. /** @hidden */
  120402. _cachedAnisotropicFilteringLevel: Nullable<number>;
  120403. /** @hidden */
  120404. _isDisabled: boolean;
  120405. /** @hidden */
  120406. _compression: Nullable<string>;
  120407. /** @hidden */
  120408. _generateStencilBuffer: boolean;
  120409. /** @hidden */
  120410. _generateDepthBuffer: boolean;
  120411. /** @hidden */
  120412. _comparisonFunction: number;
  120413. /** @hidden */
  120414. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  120415. /** @hidden */
  120416. _lodGenerationScale: number;
  120417. /** @hidden */
  120418. _lodGenerationOffset: number;
  120419. /** @hidden */
  120420. _depthStencilTexture: Nullable<InternalTexture>;
  120421. /** @hidden */
  120422. _colorTextureArray: Nullable<WebGLTexture>;
  120423. /** @hidden */
  120424. _depthStencilTextureArray: Nullable<WebGLTexture>;
  120425. /** @hidden */
  120426. _lodTextureHigh: Nullable<BaseTexture>;
  120427. /** @hidden */
  120428. _lodTextureMid: Nullable<BaseTexture>;
  120429. /** @hidden */
  120430. _lodTextureLow: Nullable<BaseTexture>;
  120431. /** @hidden */
  120432. _isRGBD: boolean;
  120433. /** @hidden */
  120434. _linearSpecularLOD: boolean;
  120435. /** @hidden */
  120436. _irradianceTexture: Nullable<BaseTexture>;
  120437. /** @hidden */
  120438. _webGLTexture: Nullable<WebGLTexture>;
  120439. /** @hidden */
  120440. _references: number;
  120441. /** @hidden */
  120442. _gammaSpace: Nullable<boolean>;
  120443. private _engine;
  120444. /**
  120445. * Gets the Engine the texture belongs to.
  120446. * @returns The babylon engine
  120447. */
  120448. getEngine(): ThinEngine;
  120449. /**
  120450. * Gets the data source type of the texture
  120451. */
  120452. get source(): InternalTextureSource;
  120453. /**
  120454. * Creates a new InternalTexture
  120455. * @param engine defines the engine to use
  120456. * @param source defines the type of data that will be used
  120457. * @param delayAllocation if the texture allocation should be delayed (default: false)
  120458. */
  120459. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  120460. /**
  120461. * Increments the number of references (ie. the number of Texture that point to it)
  120462. */
  120463. incrementReferences(): void;
  120464. /**
  120465. * Change the size of the texture (not the size of the content)
  120466. * @param width defines the new width
  120467. * @param height defines the new height
  120468. * @param depth defines the new depth (1 by default)
  120469. */
  120470. updateSize(width: int, height: int, depth?: int): void;
  120471. /** @hidden */
  120472. _rebuild(): void;
  120473. /** @hidden */
  120474. _swapAndDie(target: InternalTexture): void;
  120475. /**
  120476. * Dispose the current allocated resources
  120477. */
  120478. dispose(): void;
  120479. }
  120480. }
  120481. declare module BABYLON {
  120482. /**
  120483. * Class used to work with sound analyzer using fast fourier transform (FFT)
  120484. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120485. */
  120486. export class Analyser {
  120487. /**
  120488. * Gets or sets the smoothing
  120489. * @ignorenaming
  120490. */
  120491. SMOOTHING: number;
  120492. /**
  120493. * Gets or sets the FFT table size
  120494. * @ignorenaming
  120495. */
  120496. FFT_SIZE: number;
  120497. /**
  120498. * Gets or sets the bar graph amplitude
  120499. * @ignorenaming
  120500. */
  120501. BARGRAPHAMPLITUDE: number;
  120502. /**
  120503. * Gets or sets the position of the debug canvas
  120504. * @ignorenaming
  120505. */
  120506. DEBUGCANVASPOS: {
  120507. x: number;
  120508. y: number;
  120509. };
  120510. /**
  120511. * Gets or sets the debug canvas size
  120512. * @ignorenaming
  120513. */
  120514. DEBUGCANVASSIZE: {
  120515. width: number;
  120516. height: number;
  120517. };
  120518. private _byteFreqs;
  120519. private _byteTime;
  120520. private _floatFreqs;
  120521. private _webAudioAnalyser;
  120522. private _debugCanvas;
  120523. private _debugCanvasContext;
  120524. private _scene;
  120525. private _registerFunc;
  120526. private _audioEngine;
  120527. /**
  120528. * Creates a new analyser
  120529. * @param scene defines hosting scene
  120530. */
  120531. constructor(scene: Scene);
  120532. /**
  120533. * Get the number of data values you will have to play with for the visualization
  120534. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  120535. * @returns a number
  120536. */
  120537. getFrequencyBinCount(): number;
  120538. /**
  120539. * Gets the current frequency data as a byte array
  120540. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120541. * @returns a Uint8Array
  120542. */
  120543. getByteFrequencyData(): Uint8Array;
  120544. /**
  120545. * Gets the current waveform as a byte array
  120546. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  120547. * @returns a Uint8Array
  120548. */
  120549. getByteTimeDomainData(): Uint8Array;
  120550. /**
  120551. * Gets the current frequency data as a float array
  120552. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120553. * @returns a Float32Array
  120554. */
  120555. getFloatFrequencyData(): Float32Array;
  120556. /**
  120557. * Renders the debug canvas
  120558. */
  120559. drawDebugCanvas(): void;
  120560. /**
  120561. * Stops rendering the debug canvas and removes it
  120562. */
  120563. stopDebugCanvas(): void;
  120564. /**
  120565. * Connects two audio nodes
  120566. * @param inputAudioNode defines first node to connect
  120567. * @param outputAudioNode defines second node to connect
  120568. */
  120569. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  120570. /**
  120571. * Releases all associated resources
  120572. */
  120573. dispose(): void;
  120574. }
  120575. }
  120576. declare module BABYLON {
  120577. /**
  120578. * This represents an audio engine and it is responsible
  120579. * to play, synchronize and analyse sounds throughout the application.
  120580. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120581. */
  120582. export interface IAudioEngine extends IDisposable {
  120583. /**
  120584. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120585. */
  120586. readonly canUseWebAudio: boolean;
  120587. /**
  120588. * Gets the current AudioContext if available.
  120589. */
  120590. readonly audioContext: Nullable<AudioContext>;
  120591. /**
  120592. * The master gain node defines the global audio volume of your audio engine.
  120593. */
  120594. readonly masterGain: GainNode;
  120595. /**
  120596. * Gets whether or not mp3 are supported by your browser.
  120597. */
  120598. readonly isMP3supported: boolean;
  120599. /**
  120600. * Gets whether or not ogg are supported by your browser.
  120601. */
  120602. readonly isOGGsupported: boolean;
  120603. /**
  120604. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120605. * @ignoreNaming
  120606. */
  120607. WarnedWebAudioUnsupported: boolean;
  120608. /**
  120609. * Defines if the audio engine relies on a custom unlocked button.
  120610. * In this case, the embedded button will not be displayed.
  120611. */
  120612. useCustomUnlockedButton: boolean;
  120613. /**
  120614. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  120615. */
  120616. readonly unlocked: boolean;
  120617. /**
  120618. * Event raised when audio has been unlocked on the browser.
  120619. */
  120620. onAudioUnlockedObservable: Observable<AudioEngine>;
  120621. /**
  120622. * Event raised when audio has been locked on the browser.
  120623. */
  120624. onAudioLockedObservable: Observable<AudioEngine>;
  120625. /**
  120626. * Flags the audio engine in Locked state.
  120627. * This happens due to new browser policies preventing audio to autoplay.
  120628. */
  120629. lock(): void;
  120630. /**
  120631. * Unlocks the audio engine once a user action has been done on the dom.
  120632. * This is helpful to resume play once browser policies have been satisfied.
  120633. */
  120634. unlock(): void;
  120635. /**
  120636. * Gets the global volume sets on the master gain.
  120637. * @returns the global volume if set or -1 otherwise
  120638. */
  120639. getGlobalVolume(): number;
  120640. /**
  120641. * Sets the global volume of your experience (sets on the master gain).
  120642. * @param newVolume Defines the new global volume of the application
  120643. */
  120644. setGlobalVolume(newVolume: number): void;
  120645. /**
  120646. * Connect the audio engine to an audio analyser allowing some amazing
  120647. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120648. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120649. * @param analyser The analyser to connect to the engine
  120650. */
  120651. connectToAnalyser(analyser: Analyser): void;
  120652. }
  120653. /**
  120654. * This represents the default audio engine used in babylon.
  120655. * It is responsible to play, synchronize and analyse sounds throughout the application.
  120656. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120657. */
  120658. export class AudioEngine implements IAudioEngine {
  120659. private _audioContext;
  120660. private _audioContextInitialized;
  120661. private _muteButton;
  120662. private _hostElement;
  120663. /**
  120664. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120665. */
  120666. canUseWebAudio: boolean;
  120667. /**
  120668. * The master gain node defines the global audio volume of your audio engine.
  120669. */
  120670. masterGain: GainNode;
  120671. /**
  120672. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120673. * @ignoreNaming
  120674. */
  120675. WarnedWebAudioUnsupported: boolean;
  120676. /**
  120677. * Gets whether or not mp3 are supported by your browser.
  120678. */
  120679. isMP3supported: boolean;
  120680. /**
  120681. * Gets whether or not ogg are supported by your browser.
  120682. */
  120683. isOGGsupported: boolean;
  120684. /**
  120685. * Gets whether audio has been unlocked on the device.
  120686. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  120687. * a user interaction has happened.
  120688. */
  120689. unlocked: boolean;
  120690. /**
  120691. * Defines if the audio engine relies on a custom unlocked button.
  120692. * In this case, the embedded button will not be displayed.
  120693. */
  120694. useCustomUnlockedButton: boolean;
  120695. /**
  120696. * Event raised when audio has been unlocked on the browser.
  120697. */
  120698. onAudioUnlockedObservable: Observable<AudioEngine>;
  120699. /**
  120700. * Event raised when audio has been locked on the browser.
  120701. */
  120702. onAudioLockedObservable: Observable<AudioEngine>;
  120703. /**
  120704. * Gets the current AudioContext if available.
  120705. */
  120706. get audioContext(): Nullable<AudioContext>;
  120707. private _connectedAnalyser;
  120708. /**
  120709. * Instantiates a new audio engine.
  120710. *
  120711. * There should be only one per page as some browsers restrict the number
  120712. * of audio contexts you can create.
  120713. * @param hostElement defines the host element where to display the mute icon if necessary
  120714. */
  120715. constructor(hostElement?: Nullable<HTMLElement>);
  120716. /**
  120717. * Flags the audio engine in Locked state.
  120718. * This happens due to new browser policies preventing audio to autoplay.
  120719. */
  120720. lock(): void;
  120721. /**
  120722. * Unlocks the audio engine once a user action has been done on the dom.
  120723. * This is helpful to resume play once browser policies have been satisfied.
  120724. */
  120725. unlock(): void;
  120726. private _resumeAudioContext;
  120727. private _initializeAudioContext;
  120728. private _tryToRun;
  120729. private _triggerRunningState;
  120730. private _triggerSuspendedState;
  120731. private _displayMuteButton;
  120732. private _moveButtonToTopLeft;
  120733. private _onResize;
  120734. private _hideMuteButton;
  120735. /**
  120736. * Destroy and release the resources associated with the audio ccontext.
  120737. */
  120738. dispose(): void;
  120739. /**
  120740. * Gets the global volume sets on the master gain.
  120741. * @returns the global volume if set or -1 otherwise
  120742. */
  120743. getGlobalVolume(): number;
  120744. /**
  120745. * Sets the global volume of your experience (sets on the master gain).
  120746. * @param newVolume Defines the new global volume of the application
  120747. */
  120748. setGlobalVolume(newVolume: number): void;
  120749. /**
  120750. * Connect the audio engine to an audio analyser allowing some amazing
  120751. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120752. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120753. * @param analyser The analyser to connect to the engine
  120754. */
  120755. connectToAnalyser(analyser: Analyser): void;
  120756. }
  120757. }
  120758. declare module BABYLON {
  120759. /**
  120760. * Interface used to present a loading screen while loading a scene
  120761. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120762. */
  120763. export interface ILoadingScreen {
  120764. /**
  120765. * Function called to display the loading screen
  120766. */
  120767. displayLoadingUI: () => void;
  120768. /**
  120769. * Function called to hide the loading screen
  120770. */
  120771. hideLoadingUI: () => void;
  120772. /**
  120773. * Gets or sets the color to use for the background
  120774. */
  120775. loadingUIBackgroundColor: string;
  120776. /**
  120777. * Gets or sets the text to display while loading
  120778. */
  120779. loadingUIText: string;
  120780. }
  120781. /**
  120782. * Class used for the default loading screen
  120783. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120784. */
  120785. export class DefaultLoadingScreen implements ILoadingScreen {
  120786. private _renderingCanvas;
  120787. private _loadingText;
  120788. private _loadingDivBackgroundColor;
  120789. private _loadingDiv;
  120790. private _loadingTextDiv;
  120791. /** Gets or sets the logo url to use for the default loading screen */
  120792. static DefaultLogoUrl: string;
  120793. /** Gets or sets the spinner url to use for the default loading screen */
  120794. static DefaultSpinnerUrl: string;
  120795. /**
  120796. * Creates a new default loading screen
  120797. * @param _renderingCanvas defines the canvas used to render the scene
  120798. * @param _loadingText defines the default text to display
  120799. * @param _loadingDivBackgroundColor defines the default background color
  120800. */
  120801. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  120802. /**
  120803. * Function called to display the loading screen
  120804. */
  120805. displayLoadingUI(): void;
  120806. /**
  120807. * Function called to hide the loading screen
  120808. */
  120809. hideLoadingUI(): void;
  120810. /**
  120811. * Gets or sets the text to display while loading
  120812. */
  120813. set loadingUIText(text: string);
  120814. get loadingUIText(): string;
  120815. /**
  120816. * Gets or sets the color to use for the background
  120817. */
  120818. get loadingUIBackgroundColor(): string;
  120819. set loadingUIBackgroundColor(color: string);
  120820. private _resizeLoadingUI;
  120821. }
  120822. }
  120823. declare module BABYLON {
  120824. /**
  120825. * Interface for any object that can request an animation frame
  120826. */
  120827. export interface ICustomAnimationFrameRequester {
  120828. /**
  120829. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  120830. */
  120831. renderFunction?: Function;
  120832. /**
  120833. * Called to request the next frame to render to
  120834. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  120835. */
  120836. requestAnimationFrame: Function;
  120837. /**
  120838. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  120839. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  120840. */
  120841. requestID?: number;
  120842. }
  120843. }
  120844. declare module BABYLON {
  120845. /**
  120846. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  120847. */
  120848. export class PerformanceMonitor {
  120849. private _enabled;
  120850. private _rollingFrameTime;
  120851. private _lastFrameTimeMs;
  120852. /**
  120853. * constructor
  120854. * @param frameSampleSize The number of samples required to saturate the sliding window
  120855. */
  120856. constructor(frameSampleSize?: number);
  120857. /**
  120858. * Samples current frame
  120859. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  120860. */
  120861. sampleFrame(timeMs?: number): void;
  120862. /**
  120863. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120864. */
  120865. get averageFrameTime(): number;
  120866. /**
  120867. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120868. */
  120869. get averageFrameTimeVariance(): number;
  120870. /**
  120871. * Returns the frame time of the most recent frame
  120872. */
  120873. get instantaneousFrameTime(): number;
  120874. /**
  120875. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  120876. */
  120877. get averageFPS(): number;
  120878. /**
  120879. * Returns the average framerate in frames per second using the most recent frame time
  120880. */
  120881. get instantaneousFPS(): number;
  120882. /**
  120883. * Returns true if enough samples have been taken to completely fill the sliding window
  120884. */
  120885. get isSaturated(): boolean;
  120886. /**
  120887. * Enables contributions to the sliding window sample set
  120888. */
  120889. enable(): void;
  120890. /**
  120891. * Disables contributions to the sliding window sample set
  120892. * Samples will not be interpolated over the disabled period
  120893. */
  120894. disable(): void;
  120895. /**
  120896. * Returns true if sampling is enabled
  120897. */
  120898. get isEnabled(): boolean;
  120899. /**
  120900. * Resets performance monitor
  120901. */
  120902. reset(): void;
  120903. }
  120904. /**
  120905. * RollingAverage
  120906. *
  120907. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  120908. */
  120909. export class RollingAverage {
  120910. /**
  120911. * Current average
  120912. */
  120913. average: number;
  120914. /**
  120915. * Current variance
  120916. */
  120917. variance: number;
  120918. protected _samples: Array<number>;
  120919. protected _sampleCount: number;
  120920. protected _pos: number;
  120921. protected _m2: number;
  120922. /**
  120923. * constructor
  120924. * @param length The number of samples required to saturate the sliding window
  120925. */
  120926. constructor(length: number);
  120927. /**
  120928. * Adds a sample to the sample set
  120929. * @param v The sample value
  120930. */
  120931. add(v: number): void;
  120932. /**
  120933. * Returns previously added values or null if outside of history or outside the sliding window domain
  120934. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  120935. * @return Value previously recorded with add() or null if outside of range
  120936. */
  120937. history(i: number): number;
  120938. /**
  120939. * Returns true if enough samples have been taken to completely fill the sliding window
  120940. * @return true if sample-set saturated
  120941. */
  120942. isSaturated(): boolean;
  120943. /**
  120944. * Resets the rolling average (equivalent to 0 samples taken so far)
  120945. */
  120946. reset(): void;
  120947. /**
  120948. * Wraps a value around the sample range boundaries
  120949. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  120950. * @return Wrapped position in sample range
  120951. */
  120952. protected _wrapPosition(i: number): number;
  120953. }
  120954. }
  120955. declare module BABYLON {
  120956. /**
  120957. * This class is used to track a performance counter which is number based.
  120958. * The user has access to many properties which give statistics of different nature.
  120959. *
  120960. * The implementer can track two kinds of Performance Counter: time and count.
  120961. * 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.
  120962. * 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.
  120963. */
  120964. export class PerfCounter {
  120965. /**
  120966. * Gets or sets a global boolean to turn on and off all the counters
  120967. */
  120968. static Enabled: boolean;
  120969. /**
  120970. * Returns the smallest value ever
  120971. */
  120972. get min(): number;
  120973. /**
  120974. * Returns the biggest value ever
  120975. */
  120976. get max(): number;
  120977. /**
  120978. * Returns the average value since the performance counter is running
  120979. */
  120980. get average(): number;
  120981. /**
  120982. * Returns the average value of the last second the counter was monitored
  120983. */
  120984. get lastSecAverage(): number;
  120985. /**
  120986. * Returns the current value
  120987. */
  120988. get current(): number;
  120989. /**
  120990. * Gets the accumulated total
  120991. */
  120992. get total(): number;
  120993. /**
  120994. * Gets the total value count
  120995. */
  120996. get count(): number;
  120997. /**
  120998. * Creates a new counter
  120999. */
  121000. constructor();
  121001. /**
  121002. * Call this method to start monitoring a new frame.
  121003. * 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.
  121004. */
  121005. fetchNewFrame(): void;
  121006. /**
  121007. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  121008. * @param newCount the count value to add to the monitored count
  121009. * @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.
  121010. */
  121011. addCount(newCount: number, fetchResult: boolean): void;
  121012. /**
  121013. * Start monitoring this performance counter
  121014. */
  121015. beginMonitoring(): void;
  121016. /**
  121017. * Compute the time lapsed since the previous beginMonitoring() call.
  121018. * @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
  121019. */
  121020. endMonitoring(newFrame?: boolean): void;
  121021. private _fetchResult;
  121022. private _startMonitoringTime;
  121023. private _min;
  121024. private _max;
  121025. private _average;
  121026. private _current;
  121027. private _totalValueCount;
  121028. private _totalAccumulated;
  121029. private _lastSecAverage;
  121030. private _lastSecAccumulated;
  121031. private _lastSecTime;
  121032. private _lastSecValueCount;
  121033. }
  121034. }
  121035. declare module BABYLON {
  121036. interface ThinEngine {
  121037. /** @hidden */
  121038. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  121039. }
  121040. }
  121041. declare module BABYLON {
  121042. /**
  121043. * Defines the interface used by display changed events
  121044. */
  121045. export interface IDisplayChangedEventArgs {
  121046. /** Gets the vrDisplay object (if any) */
  121047. vrDisplay: Nullable<any>;
  121048. /** Gets a boolean indicating if webVR is supported */
  121049. vrSupported: boolean;
  121050. }
  121051. /**
  121052. * Defines the interface used by objects containing a viewport (like a camera)
  121053. */
  121054. interface IViewportOwnerLike {
  121055. /**
  121056. * Gets or sets the viewport
  121057. */
  121058. viewport: IViewportLike;
  121059. }
  121060. /**
  121061. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  121062. */
  121063. export class Engine extends ThinEngine {
  121064. /** Defines that alpha blending is disabled */
  121065. static readonly ALPHA_DISABLE: number;
  121066. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  121067. static readonly ALPHA_ADD: number;
  121068. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  121069. static readonly ALPHA_COMBINE: number;
  121070. /** Defines that alpha blending to DEST - SRC * DEST */
  121071. static readonly ALPHA_SUBTRACT: number;
  121072. /** Defines that alpha blending to SRC * DEST */
  121073. static readonly ALPHA_MULTIPLY: number;
  121074. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  121075. static readonly ALPHA_MAXIMIZED: number;
  121076. /** Defines that alpha blending to SRC + DEST */
  121077. static readonly ALPHA_ONEONE: number;
  121078. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  121079. static readonly ALPHA_PREMULTIPLIED: number;
  121080. /**
  121081. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  121082. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  121083. */
  121084. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  121085. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  121086. static readonly ALPHA_INTERPOLATE: number;
  121087. /**
  121088. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  121089. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  121090. */
  121091. static readonly ALPHA_SCREENMODE: number;
  121092. /** Defines that the ressource is not delayed*/
  121093. static readonly DELAYLOADSTATE_NONE: number;
  121094. /** Defines that the ressource was successfully delay loaded */
  121095. static readonly DELAYLOADSTATE_LOADED: number;
  121096. /** Defines that the ressource is currently delay loading */
  121097. static readonly DELAYLOADSTATE_LOADING: number;
  121098. /** Defines that the ressource is delayed and has not started loading */
  121099. static readonly DELAYLOADSTATE_NOTLOADED: number;
  121100. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  121101. static readonly NEVER: number;
  121102. /** 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 */
  121103. static readonly ALWAYS: number;
  121104. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  121105. static readonly LESS: number;
  121106. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  121107. static readonly EQUAL: number;
  121108. /** 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 */
  121109. static readonly LEQUAL: number;
  121110. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  121111. static readonly GREATER: number;
  121112. /** 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 */
  121113. static readonly GEQUAL: number;
  121114. /** 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 */
  121115. static readonly NOTEQUAL: number;
  121116. /** Passed to stencilOperation to specify that stencil value must be kept */
  121117. static readonly KEEP: number;
  121118. /** Passed to stencilOperation to specify that stencil value must be replaced */
  121119. static readonly REPLACE: number;
  121120. /** Passed to stencilOperation to specify that stencil value must be incremented */
  121121. static readonly INCR: number;
  121122. /** Passed to stencilOperation to specify that stencil value must be decremented */
  121123. static readonly DECR: number;
  121124. /** Passed to stencilOperation to specify that stencil value must be inverted */
  121125. static readonly INVERT: number;
  121126. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  121127. static readonly INCR_WRAP: number;
  121128. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  121129. static readonly DECR_WRAP: number;
  121130. /** Texture is not repeating outside of 0..1 UVs */
  121131. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  121132. /** Texture is repeating outside of 0..1 UVs */
  121133. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  121134. /** Texture is repeating and mirrored */
  121135. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  121136. /** ALPHA */
  121137. static readonly TEXTUREFORMAT_ALPHA: number;
  121138. /** LUMINANCE */
  121139. static readonly TEXTUREFORMAT_LUMINANCE: number;
  121140. /** LUMINANCE_ALPHA */
  121141. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  121142. /** RGB */
  121143. static readonly TEXTUREFORMAT_RGB: number;
  121144. /** RGBA */
  121145. static readonly TEXTUREFORMAT_RGBA: number;
  121146. /** RED */
  121147. static readonly TEXTUREFORMAT_RED: number;
  121148. /** RED (2nd reference) */
  121149. static readonly TEXTUREFORMAT_R: number;
  121150. /** RG */
  121151. static readonly TEXTUREFORMAT_RG: number;
  121152. /** RED_INTEGER */
  121153. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121154. /** RED_INTEGER (2nd reference) */
  121155. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121156. /** RG_INTEGER */
  121157. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121158. /** RGB_INTEGER */
  121159. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121160. /** RGBA_INTEGER */
  121161. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121162. /** UNSIGNED_BYTE */
  121163. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121164. /** UNSIGNED_BYTE (2nd reference) */
  121165. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121166. /** FLOAT */
  121167. static readonly TEXTURETYPE_FLOAT: number;
  121168. /** HALF_FLOAT */
  121169. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121170. /** BYTE */
  121171. static readonly TEXTURETYPE_BYTE: number;
  121172. /** SHORT */
  121173. static readonly TEXTURETYPE_SHORT: number;
  121174. /** UNSIGNED_SHORT */
  121175. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121176. /** INT */
  121177. static readonly TEXTURETYPE_INT: number;
  121178. /** UNSIGNED_INT */
  121179. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121180. /** UNSIGNED_SHORT_4_4_4_4 */
  121181. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121182. /** UNSIGNED_SHORT_5_5_5_1 */
  121183. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121184. /** UNSIGNED_SHORT_5_6_5 */
  121185. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121186. /** UNSIGNED_INT_2_10_10_10_REV */
  121187. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121188. /** UNSIGNED_INT_24_8 */
  121189. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121190. /** UNSIGNED_INT_10F_11F_11F_REV */
  121191. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121192. /** UNSIGNED_INT_5_9_9_9_REV */
  121193. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121194. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121195. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121196. /** nearest is mag = nearest and min = nearest and mip = linear */
  121197. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121198. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121199. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121200. /** Trilinear is mag = linear and min = linear and mip = linear */
  121201. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121202. /** nearest is mag = nearest and min = nearest and mip = linear */
  121203. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121204. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121205. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121206. /** Trilinear is mag = linear and min = linear and mip = linear */
  121207. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121208. /** mag = nearest and min = nearest and mip = nearest */
  121209. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121210. /** mag = nearest and min = linear and mip = nearest */
  121211. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121212. /** mag = nearest and min = linear and mip = linear */
  121213. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121214. /** mag = nearest and min = linear and mip = none */
  121215. static readonly TEXTURE_NEAREST_LINEAR: number;
  121216. /** mag = nearest and min = nearest and mip = none */
  121217. static readonly TEXTURE_NEAREST_NEAREST: number;
  121218. /** mag = linear and min = nearest and mip = nearest */
  121219. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121220. /** mag = linear and min = nearest and mip = linear */
  121221. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121222. /** mag = linear and min = linear and mip = none */
  121223. static readonly TEXTURE_LINEAR_LINEAR: number;
  121224. /** mag = linear and min = nearest and mip = none */
  121225. static readonly TEXTURE_LINEAR_NEAREST: number;
  121226. /** Explicit coordinates mode */
  121227. static readonly TEXTURE_EXPLICIT_MODE: number;
  121228. /** Spherical coordinates mode */
  121229. static readonly TEXTURE_SPHERICAL_MODE: number;
  121230. /** Planar coordinates mode */
  121231. static readonly TEXTURE_PLANAR_MODE: number;
  121232. /** Cubic coordinates mode */
  121233. static readonly TEXTURE_CUBIC_MODE: number;
  121234. /** Projection coordinates mode */
  121235. static readonly TEXTURE_PROJECTION_MODE: number;
  121236. /** Skybox coordinates mode */
  121237. static readonly TEXTURE_SKYBOX_MODE: number;
  121238. /** Inverse Cubic coordinates mode */
  121239. static readonly TEXTURE_INVCUBIC_MODE: number;
  121240. /** Equirectangular coordinates mode */
  121241. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121242. /** Equirectangular Fixed coordinates mode */
  121243. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121244. /** Equirectangular Fixed Mirrored coordinates mode */
  121245. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121246. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121247. static readonly SCALEMODE_FLOOR: number;
  121248. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121249. static readonly SCALEMODE_NEAREST: number;
  121250. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121251. static readonly SCALEMODE_CEILING: number;
  121252. /**
  121253. * Returns the current npm package of the sdk
  121254. */
  121255. static get NpmPackage(): string;
  121256. /**
  121257. * Returns the current version of the framework
  121258. */
  121259. static get Version(): string;
  121260. /** Gets the list of created engines */
  121261. static get Instances(): Engine[];
  121262. /**
  121263. * Gets the latest created engine
  121264. */
  121265. static get LastCreatedEngine(): Nullable<Engine>;
  121266. /**
  121267. * Gets the latest created scene
  121268. */
  121269. static get LastCreatedScene(): Nullable<Scene>;
  121270. /**
  121271. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  121272. * @param flag defines which part of the materials must be marked as dirty
  121273. * @param predicate defines a predicate used to filter which materials should be affected
  121274. */
  121275. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121276. /**
  121277. * Method called to create the default loading screen.
  121278. * This can be overriden in your own app.
  121279. * @param canvas The rendering canvas element
  121280. * @returns The loading screen
  121281. */
  121282. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  121283. /**
  121284. * Method called to create the default rescale post process on each engine.
  121285. */
  121286. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  121287. /**
  121288. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  121289. **/
  121290. enableOfflineSupport: boolean;
  121291. /**
  121292. * 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)
  121293. **/
  121294. disableManifestCheck: boolean;
  121295. /**
  121296. * Gets the list of created scenes
  121297. */
  121298. scenes: Scene[];
  121299. /**
  121300. * Event raised when a new scene is created
  121301. */
  121302. onNewSceneAddedObservable: Observable<Scene>;
  121303. /**
  121304. * Gets the list of created postprocesses
  121305. */
  121306. postProcesses: PostProcess[];
  121307. /**
  121308. * Gets a boolean indicating if the pointer is currently locked
  121309. */
  121310. isPointerLock: boolean;
  121311. /**
  121312. * Observable event triggered each time the rendering canvas is resized
  121313. */
  121314. onResizeObservable: Observable<Engine>;
  121315. /**
  121316. * Observable event triggered each time the canvas loses focus
  121317. */
  121318. onCanvasBlurObservable: Observable<Engine>;
  121319. /**
  121320. * Observable event triggered each time the canvas gains focus
  121321. */
  121322. onCanvasFocusObservable: Observable<Engine>;
  121323. /**
  121324. * Observable event triggered each time the canvas receives pointerout event
  121325. */
  121326. onCanvasPointerOutObservable: Observable<PointerEvent>;
  121327. /**
  121328. * Observable raised when the engine begins a new frame
  121329. */
  121330. onBeginFrameObservable: Observable<Engine>;
  121331. /**
  121332. * If set, will be used to request the next animation frame for the render loop
  121333. */
  121334. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  121335. /**
  121336. * Observable raised when the engine ends the current frame
  121337. */
  121338. onEndFrameObservable: Observable<Engine>;
  121339. /**
  121340. * Observable raised when the engine is about to compile a shader
  121341. */
  121342. onBeforeShaderCompilationObservable: Observable<Engine>;
  121343. /**
  121344. * Observable raised when the engine has jsut compiled a shader
  121345. */
  121346. onAfterShaderCompilationObservable: Observable<Engine>;
  121347. /**
  121348. * Gets the audio engine
  121349. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121350. * @ignorenaming
  121351. */
  121352. static audioEngine: IAudioEngine;
  121353. /**
  121354. * Default AudioEngine factory responsible of creating the Audio Engine.
  121355. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  121356. */
  121357. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  121358. /**
  121359. * Default offline support factory responsible of creating a tool used to store data locally.
  121360. * By default, this will create a Database object if the workload has been embedded.
  121361. */
  121362. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  121363. private _loadingScreen;
  121364. private _pointerLockRequested;
  121365. private _rescalePostProcess;
  121366. private _deterministicLockstep;
  121367. private _lockstepMaxSteps;
  121368. private _timeStep;
  121369. protected get _supportsHardwareTextureRescaling(): boolean;
  121370. private _fps;
  121371. private _deltaTime;
  121372. /** @hidden */
  121373. _drawCalls: PerfCounter;
  121374. /** 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 */
  121375. canvasTabIndex: number;
  121376. /**
  121377. * Turn this value on if you want to pause FPS computation when in background
  121378. */
  121379. disablePerformanceMonitorInBackground: boolean;
  121380. private _performanceMonitor;
  121381. /**
  121382. * Gets the performance monitor attached to this engine
  121383. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121384. */
  121385. get performanceMonitor(): PerformanceMonitor;
  121386. private _onFocus;
  121387. private _onBlur;
  121388. private _onCanvasPointerOut;
  121389. private _onCanvasBlur;
  121390. private _onCanvasFocus;
  121391. private _onFullscreenChange;
  121392. private _onPointerLockChange;
  121393. /**
  121394. * Gets the HTML element used to attach event listeners
  121395. * @returns a HTML element
  121396. */
  121397. getInputElement(): Nullable<HTMLElement>;
  121398. /**
  121399. * Creates a new engine
  121400. * @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
  121401. * @param antialias defines enable antialiasing (default: false)
  121402. * @param options defines further options to be sent to the getContext() function
  121403. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  121404. */
  121405. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  121406. /**
  121407. * Gets current aspect ratio
  121408. * @param viewportOwner defines the camera to use to get the aspect ratio
  121409. * @param useScreen defines if screen size must be used (or the current render target if any)
  121410. * @returns a number defining the aspect ratio
  121411. */
  121412. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  121413. /**
  121414. * Gets current screen aspect ratio
  121415. * @returns a number defining the aspect ratio
  121416. */
  121417. getScreenAspectRatio(): number;
  121418. /**
  121419. * Gets the client rect of the HTML canvas attached with the current webGL context
  121420. * @returns a client rectanglee
  121421. */
  121422. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  121423. /**
  121424. * Gets the client rect of the HTML element used for events
  121425. * @returns a client rectanglee
  121426. */
  121427. getInputElementClientRect(): Nullable<ClientRect>;
  121428. /**
  121429. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121430. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121431. * @returns true if engine is in deterministic lock step mode
  121432. */
  121433. isDeterministicLockStep(): boolean;
  121434. /**
  121435. * Gets the max steps when engine is running in deterministic lock step
  121436. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121437. * @returns the max steps
  121438. */
  121439. getLockstepMaxSteps(): number;
  121440. /**
  121441. * Returns the time in ms between steps when using deterministic lock step.
  121442. * @returns time step in (ms)
  121443. */
  121444. getTimeStep(): number;
  121445. /**
  121446. * Force the mipmap generation for the given render target texture
  121447. * @param texture defines the render target texture to use
  121448. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  121449. */
  121450. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  121451. /** States */
  121452. /**
  121453. * Set various states to the webGL context
  121454. * @param culling defines backface culling state
  121455. * @param zOffset defines the value to apply to zOffset (0 by default)
  121456. * @param force defines if states must be applied even if cache is up to date
  121457. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121458. */
  121459. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121460. /**
  121461. * Set the z offset to apply to current rendering
  121462. * @param value defines the offset to apply
  121463. */
  121464. setZOffset(value: number): void;
  121465. /**
  121466. * Gets the current value of the zOffset
  121467. * @returns the current zOffset state
  121468. */
  121469. getZOffset(): number;
  121470. /**
  121471. * Enable or disable depth buffering
  121472. * @param enable defines the state to set
  121473. */
  121474. setDepthBuffer(enable: boolean): void;
  121475. /**
  121476. * Gets a boolean indicating if depth writing is enabled
  121477. * @returns the current depth writing state
  121478. */
  121479. getDepthWrite(): boolean;
  121480. /**
  121481. * Enable or disable depth writing
  121482. * @param enable defines the state to set
  121483. */
  121484. setDepthWrite(enable: boolean): void;
  121485. /**
  121486. * Gets a boolean indicating if stencil buffer is enabled
  121487. * @returns the current stencil buffer state
  121488. */
  121489. getStencilBuffer(): boolean;
  121490. /**
  121491. * Enable or disable the stencil buffer
  121492. * @param enable defines if the stencil buffer must be enabled or disabled
  121493. */
  121494. setStencilBuffer(enable: boolean): void;
  121495. /**
  121496. * Gets the current stencil mask
  121497. * @returns a number defining the new stencil mask to use
  121498. */
  121499. getStencilMask(): number;
  121500. /**
  121501. * Sets the current stencil mask
  121502. * @param mask defines the new stencil mask to use
  121503. */
  121504. setStencilMask(mask: number): void;
  121505. /**
  121506. * Gets the current stencil function
  121507. * @returns a number defining the stencil function to use
  121508. */
  121509. getStencilFunction(): number;
  121510. /**
  121511. * Gets the current stencil reference value
  121512. * @returns a number defining the stencil reference value to use
  121513. */
  121514. getStencilFunctionReference(): number;
  121515. /**
  121516. * Gets the current stencil mask
  121517. * @returns a number defining the stencil mask to use
  121518. */
  121519. getStencilFunctionMask(): number;
  121520. /**
  121521. * Sets the current stencil function
  121522. * @param stencilFunc defines the new stencil function to use
  121523. */
  121524. setStencilFunction(stencilFunc: number): void;
  121525. /**
  121526. * Sets the current stencil reference
  121527. * @param reference defines the new stencil reference to use
  121528. */
  121529. setStencilFunctionReference(reference: number): void;
  121530. /**
  121531. * Sets the current stencil mask
  121532. * @param mask defines the new stencil mask to use
  121533. */
  121534. setStencilFunctionMask(mask: number): void;
  121535. /**
  121536. * Gets the current stencil operation when stencil fails
  121537. * @returns a number defining stencil operation to use when stencil fails
  121538. */
  121539. getStencilOperationFail(): number;
  121540. /**
  121541. * Gets the current stencil operation when depth fails
  121542. * @returns a number defining stencil operation to use when depth fails
  121543. */
  121544. getStencilOperationDepthFail(): number;
  121545. /**
  121546. * Gets the current stencil operation when stencil passes
  121547. * @returns a number defining stencil operation to use when stencil passes
  121548. */
  121549. getStencilOperationPass(): number;
  121550. /**
  121551. * Sets the stencil operation to use when stencil fails
  121552. * @param operation defines the stencil operation to use when stencil fails
  121553. */
  121554. setStencilOperationFail(operation: number): void;
  121555. /**
  121556. * Sets the stencil operation to use when depth fails
  121557. * @param operation defines the stencil operation to use when depth fails
  121558. */
  121559. setStencilOperationDepthFail(operation: number): void;
  121560. /**
  121561. * Sets the stencil operation to use when stencil passes
  121562. * @param operation defines the stencil operation to use when stencil passes
  121563. */
  121564. setStencilOperationPass(operation: number): void;
  121565. /**
  121566. * Sets a boolean indicating if the dithering state is enabled or disabled
  121567. * @param value defines the dithering state
  121568. */
  121569. setDitheringState(value: boolean): void;
  121570. /**
  121571. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  121572. * @param value defines the rasterizer state
  121573. */
  121574. setRasterizerState(value: boolean): void;
  121575. /**
  121576. * Gets the current depth function
  121577. * @returns a number defining the depth function
  121578. */
  121579. getDepthFunction(): Nullable<number>;
  121580. /**
  121581. * Sets the current depth function
  121582. * @param depthFunc defines the function to use
  121583. */
  121584. setDepthFunction(depthFunc: number): void;
  121585. /**
  121586. * Sets the current depth function to GREATER
  121587. */
  121588. setDepthFunctionToGreater(): void;
  121589. /**
  121590. * Sets the current depth function to GEQUAL
  121591. */
  121592. setDepthFunctionToGreaterOrEqual(): void;
  121593. /**
  121594. * Sets the current depth function to LESS
  121595. */
  121596. setDepthFunctionToLess(): void;
  121597. /**
  121598. * Sets the current depth function to LEQUAL
  121599. */
  121600. setDepthFunctionToLessOrEqual(): void;
  121601. private _cachedStencilBuffer;
  121602. private _cachedStencilFunction;
  121603. private _cachedStencilMask;
  121604. private _cachedStencilOperationPass;
  121605. private _cachedStencilOperationFail;
  121606. private _cachedStencilOperationDepthFail;
  121607. private _cachedStencilReference;
  121608. /**
  121609. * Caches the the state of the stencil buffer
  121610. */
  121611. cacheStencilState(): void;
  121612. /**
  121613. * Restores the state of the stencil buffer
  121614. */
  121615. restoreStencilState(): void;
  121616. /**
  121617. * Directly set the WebGL Viewport
  121618. * @param x defines the x coordinate of the viewport (in screen space)
  121619. * @param y defines the y coordinate of the viewport (in screen space)
  121620. * @param width defines the width of the viewport (in screen space)
  121621. * @param height defines the height of the viewport (in screen space)
  121622. * @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
  121623. */
  121624. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  121625. /**
  121626. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  121627. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121628. * @param y defines the y-coordinate of the corner of the clear rectangle
  121629. * @param width defines the width of the clear rectangle
  121630. * @param height defines the height of the clear rectangle
  121631. * @param clearColor defines the clear color
  121632. */
  121633. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  121634. /**
  121635. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  121636. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121637. * @param y defines the y-coordinate of the corner of the clear rectangle
  121638. * @param width defines the width of the clear rectangle
  121639. * @param height defines the height of the clear rectangle
  121640. */
  121641. enableScissor(x: number, y: number, width: number, height: number): void;
  121642. /**
  121643. * Disable previously set scissor test rectangle
  121644. */
  121645. disableScissor(): void;
  121646. protected _reportDrawCall(): void;
  121647. /**
  121648. * Initializes a webVR display and starts listening to display change events
  121649. * The onVRDisplayChangedObservable will be notified upon these changes
  121650. * @returns The onVRDisplayChangedObservable
  121651. */
  121652. initWebVR(): Observable<IDisplayChangedEventArgs>;
  121653. /** @hidden */
  121654. _prepareVRComponent(): void;
  121655. /** @hidden */
  121656. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  121657. /** @hidden */
  121658. _submitVRFrame(): void;
  121659. /**
  121660. * Call this function to leave webVR mode
  121661. * Will do nothing if webVR is not supported or if there is no webVR device
  121662. * @see https://doc.babylonjs.com/how_to/webvr_camera
  121663. */
  121664. disableVR(): void;
  121665. /**
  121666. * Gets a boolean indicating that the system is in VR mode and is presenting
  121667. * @returns true if VR mode is engaged
  121668. */
  121669. isVRPresenting(): boolean;
  121670. /** @hidden */
  121671. _requestVRFrame(): void;
  121672. /** @hidden */
  121673. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121674. /**
  121675. * Gets the source code of the vertex shader associated with a specific webGL program
  121676. * @param program defines the program to use
  121677. * @returns a string containing the source code of the vertex shader associated with the program
  121678. */
  121679. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  121680. /**
  121681. * Gets the source code of the fragment shader associated with a specific webGL program
  121682. * @param program defines the program to use
  121683. * @returns a string containing the source code of the fragment shader associated with the program
  121684. */
  121685. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  121686. /**
  121687. * Sets a depth stencil texture from a render target to the according uniform.
  121688. * @param channel The texture channel
  121689. * @param uniform The uniform to set
  121690. * @param texture The render target texture containing the depth stencil texture to apply
  121691. */
  121692. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  121693. /**
  121694. * Sets a texture to the webGL context from a postprocess
  121695. * @param channel defines the channel to use
  121696. * @param postProcess defines the source postprocess
  121697. */
  121698. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  121699. /**
  121700. * Binds the output of the passed in post process to the texture channel specified
  121701. * @param channel The channel the texture should be bound to
  121702. * @param postProcess The post process which's output should be bound
  121703. */
  121704. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  121705. protected _rebuildBuffers(): void;
  121706. /** @hidden */
  121707. _renderFrame(): void;
  121708. _renderLoop(): void;
  121709. /** @hidden */
  121710. _renderViews(): boolean;
  121711. /**
  121712. * Toggle full screen mode
  121713. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121714. */
  121715. switchFullscreen(requestPointerLock: boolean): void;
  121716. /**
  121717. * Enters full screen mode
  121718. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121719. */
  121720. enterFullscreen(requestPointerLock: boolean): void;
  121721. /**
  121722. * Exits full screen mode
  121723. */
  121724. exitFullscreen(): void;
  121725. /**
  121726. * Enters Pointerlock mode
  121727. */
  121728. enterPointerlock(): void;
  121729. /**
  121730. * Exits Pointerlock mode
  121731. */
  121732. exitPointerlock(): void;
  121733. /**
  121734. * Begin a new frame
  121735. */
  121736. beginFrame(): void;
  121737. /**
  121738. * Enf the current frame
  121739. */
  121740. endFrame(): void;
  121741. resize(): void;
  121742. /**
  121743. * Force a specific size of the canvas
  121744. * @param width defines the new canvas' width
  121745. * @param height defines the new canvas' height
  121746. * @returns true if the size was changed
  121747. */
  121748. setSize(width: number, height: number): boolean;
  121749. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121750. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121751. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121752. _releaseTexture(texture: InternalTexture): void;
  121753. /**
  121754. * @hidden
  121755. * Rescales a texture
  121756. * @param source input texutre
  121757. * @param destination destination texture
  121758. * @param scene scene to use to render the resize
  121759. * @param internalFormat format to use when resizing
  121760. * @param onComplete callback to be called when resize has completed
  121761. */
  121762. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121763. /**
  121764. * Gets the current framerate
  121765. * @returns a number representing the framerate
  121766. */
  121767. getFps(): number;
  121768. /**
  121769. * Gets the time spent between current and previous frame
  121770. * @returns a number representing the delta time in ms
  121771. */
  121772. getDeltaTime(): number;
  121773. private _measureFps;
  121774. /** @hidden */
  121775. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  121776. /**
  121777. * Updates the sample count of a render target texture
  121778. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121779. * @param texture defines the texture to update
  121780. * @param samples defines the sample count to set
  121781. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121782. */
  121783. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  121784. /**
  121785. * Updates a depth texture Comparison Mode and Function.
  121786. * If the comparison Function is equal to 0, the mode will be set to none.
  121787. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  121788. * @param texture The texture to set the comparison function for
  121789. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  121790. */
  121791. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  121792. /**
  121793. * Creates a webGL buffer to use with instanciation
  121794. * @param capacity defines the size of the buffer
  121795. * @returns the webGL buffer
  121796. */
  121797. createInstancesBuffer(capacity: number): DataBuffer;
  121798. /**
  121799. * Delete a webGL buffer used with instanciation
  121800. * @param buffer defines the webGL buffer to delete
  121801. */
  121802. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  121803. private _clientWaitAsync;
  121804. /** @hidden */
  121805. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  121806. dispose(): void;
  121807. private _disableTouchAction;
  121808. /**
  121809. * Display the loading screen
  121810. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121811. */
  121812. displayLoadingUI(): void;
  121813. /**
  121814. * Hide the loading screen
  121815. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121816. */
  121817. hideLoadingUI(): void;
  121818. /**
  121819. * Gets the current loading screen object
  121820. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121821. */
  121822. get loadingScreen(): ILoadingScreen;
  121823. /**
  121824. * Sets the current loading screen object
  121825. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121826. */
  121827. set loadingScreen(loadingScreen: ILoadingScreen);
  121828. /**
  121829. * Sets the current loading screen text
  121830. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121831. */
  121832. set loadingUIText(text: string);
  121833. /**
  121834. * Sets the current loading screen background color
  121835. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121836. */
  121837. set loadingUIBackgroundColor(color: string);
  121838. /** Pointerlock and fullscreen */
  121839. /**
  121840. * Ask the browser to promote the current element to pointerlock mode
  121841. * @param element defines the DOM element to promote
  121842. */
  121843. static _RequestPointerlock(element: HTMLElement): void;
  121844. /**
  121845. * Asks the browser to exit pointerlock mode
  121846. */
  121847. static _ExitPointerlock(): void;
  121848. /**
  121849. * Ask the browser to promote the current element to fullscreen rendering mode
  121850. * @param element defines the DOM element to promote
  121851. */
  121852. static _RequestFullscreen(element: HTMLElement): void;
  121853. /**
  121854. * Asks the browser to exit fullscreen mode
  121855. */
  121856. static _ExitFullscreen(): void;
  121857. }
  121858. }
  121859. declare module BABYLON {
  121860. /**
  121861. * The engine store class is responsible to hold all the instances of Engine and Scene created
  121862. * during the life time of the application.
  121863. */
  121864. export class EngineStore {
  121865. /** Gets the list of created engines */
  121866. static Instances: Engine[];
  121867. /** @hidden */
  121868. static _LastCreatedScene: Nullable<Scene>;
  121869. /**
  121870. * Gets the latest created engine
  121871. */
  121872. static get LastCreatedEngine(): Nullable<Engine>;
  121873. /**
  121874. * Gets the latest created scene
  121875. */
  121876. static get LastCreatedScene(): Nullable<Scene>;
  121877. /**
  121878. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  121879. * @ignorenaming
  121880. */
  121881. static UseFallbackTexture: boolean;
  121882. /**
  121883. * Texture content used if a texture cannot loaded
  121884. * @ignorenaming
  121885. */
  121886. static FallbackTexture: string;
  121887. }
  121888. }
  121889. declare module BABYLON {
  121890. /**
  121891. * Helper class that provides a small promise polyfill
  121892. */
  121893. export class PromisePolyfill {
  121894. /**
  121895. * Static function used to check if the polyfill is required
  121896. * If this is the case then the function will inject the polyfill to window.Promise
  121897. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  121898. */
  121899. static Apply(force?: boolean): void;
  121900. }
  121901. }
  121902. declare module BABYLON {
  121903. /**
  121904. * Interface for screenshot methods with describe argument called `size` as object with options
  121905. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  121906. */
  121907. export interface IScreenshotSize {
  121908. /**
  121909. * number in pixels for canvas height
  121910. */
  121911. height?: number;
  121912. /**
  121913. * multiplier allowing render at a higher or lower resolution
  121914. * If value is defined then height and width will be ignored and taken from camera
  121915. */
  121916. precision?: number;
  121917. /**
  121918. * number in pixels for canvas width
  121919. */
  121920. width?: number;
  121921. }
  121922. }
  121923. declare module BABYLON {
  121924. interface IColor4Like {
  121925. r: float;
  121926. g: float;
  121927. b: float;
  121928. a: float;
  121929. }
  121930. /**
  121931. * Class containing a set of static utilities functions
  121932. */
  121933. export class Tools {
  121934. /**
  121935. * Gets or sets the base URL to use to load assets
  121936. */
  121937. static get BaseUrl(): string;
  121938. static set BaseUrl(value: string);
  121939. /**
  121940. * Enable/Disable Custom HTTP Request Headers globally.
  121941. * default = false
  121942. * @see CustomRequestHeaders
  121943. */
  121944. static UseCustomRequestHeaders: boolean;
  121945. /**
  121946. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  121947. * i.e. when loading files, where the server/service expects an Authorization header
  121948. */
  121949. static CustomRequestHeaders: {
  121950. [key: string]: string;
  121951. };
  121952. /**
  121953. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  121954. */
  121955. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  121956. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  121957. /**
  121958. * Default behaviour for cors in the application.
  121959. * It can be a string if the expected behavior is identical in the entire app.
  121960. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  121961. */
  121962. static get CorsBehavior(): string | ((url: string | string[]) => string);
  121963. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  121964. /**
  121965. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  121966. * @ignorenaming
  121967. */
  121968. static get UseFallbackTexture(): boolean;
  121969. static set UseFallbackTexture(value: boolean);
  121970. /**
  121971. * Use this object to register external classes like custom textures or material
  121972. * to allow the laoders to instantiate them
  121973. */
  121974. static get RegisteredExternalClasses(): {
  121975. [key: string]: Object;
  121976. };
  121977. static set RegisteredExternalClasses(classes: {
  121978. [key: string]: Object;
  121979. });
  121980. /**
  121981. * Texture content used if a texture cannot loaded
  121982. * @ignorenaming
  121983. */
  121984. static get fallbackTexture(): string;
  121985. static set fallbackTexture(value: string);
  121986. /**
  121987. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  121988. * @param u defines the coordinate on X axis
  121989. * @param v defines the coordinate on Y axis
  121990. * @param width defines the width of the source data
  121991. * @param height defines the height of the source data
  121992. * @param pixels defines the source byte array
  121993. * @param color defines the output color
  121994. */
  121995. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  121996. /**
  121997. * Interpolates between a and b via alpha
  121998. * @param a The lower value (returned when alpha = 0)
  121999. * @param b The upper value (returned when alpha = 1)
  122000. * @param alpha The interpolation-factor
  122001. * @return The mixed value
  122002. */
  122003. static Mix(a: number, b: number, alpha: number): number;
  122004. /**
  122005. * Tries to instantiate a new object from a given class name
  122006. * @param className defines the class name to instantiate
  122007. * @returns the new object or null if the system was not able to do the instantiation
  122008. */
  122009. static Instantiate(className: string): any;
  122010. /**
  122011. * Provides a slice function that will work even on IE
  122012. * @param data defines the array to slice
  122013. * @param start defines the start of the data (optional)
  122014. * @param end defines the end of the data (optional)
  122015. * @returns the new sliced array
  122016. */
  122017. static Slice<T>(data: T, start?: number, end?: number): T;
  122018. /**
  122019. * Polyfill for setImmediate
  122020. * @param action defines the action to execute after the current execution block
  122021. */
  122022. static SetImmediate(action: () => void): void;
  122023. /**
  122024. * Function indicating if a number is an exponent of 2
  122025. * @param value defines the value to test
  122026. * @returns true if the value is an exponent of 2
  122027. */
  122028. static IsExponentOfTwo(value: number): boolean;
  122029. private static _tmpFloatArray;
  122030. /**
  122031. * Returns the nearest 32-bit single precision float representation of a Number
  122032. * @param value A Number. If the parameter is of a different type, it will get converted
  122033. * to a number or to NaN if it cannot be converted
  122034. * @returns number
  122035. */
  122036. static FloatRound(value: number): number;
  122037. /**
  122038. * Extracts the filename from a path
  122039. * @param path defines the path to use
  122040. * @returns the filename
  122041. */
  122042. static GetFilename(path: string): string;
  122043. /**
  122044. * Extracts the "folder" part of a path (everything before the filename).
  122045. * @param uri The URI to extract the info from
  122046. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  122047. * @returns The "folder" part of the path
  122048. */
  122049. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  122050. /**
  122051. * Extracts text content from a DOM element hierarchy
  122052. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  122053. */
  122054. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  122055. /**
  122056. * Convert an angle in radians to degrees
  122057. * @param angle defines the angle to convert
  122058. * @returns the angle in degrees
  122059. */
  122060. static ToDegrees(angle: number): number;
  122061. /**
  122062. * Convert an angle in degrees to radians
  122063. * @param angle defines the angle to convert
  122064. * @returns the angle in radians
  122065. */
  122066. static ToRadians(angle: number): number;
  122067. /**
  122068. * Returns an array if obj is not an array
  122069. * @param obj defines the object to evaluate as an array
  122070. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  122071. * @returns either obj directly if obj is an array or a new array containing obj
  122072. */
  122073. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  122074. /**
  122075. * Gets the pointer prefix to use
  122076. * @param engine defines the engine we are finding the prefix for
  122077. * @returns "pointer" if touch is enabled. Else returns "mouse"
  122078. */
  122079. static GetPointerPrefix(engine: Engine): string;
  122080. /**
  122081. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  122082. * @param url define the url we are trying
  122083. * @param element define the dom element where to configure the cors policy
  122084. */
  122085. static SetCorsBehavior(url: string | string[], element: {
  122086. crossOrigin: string | null;
  122087. }): void;
  122088. /**
  122089. * Removes unwanted characters from an url
  122090. * @param url defines the url to clean
  122091. * @returns the cleaned url
  122092. */
  122093. static CleanUrl(url: string): string;
  122094. /**
  122095. * Gets or sets a function used to pre-process url before using them to load assets
  122096. */
  122097. static get PreprocessUrl(): (url: string) => string;
  122098. static set PreprocessUrl(processor: (url: string) => string);
  122099. /**
  122100. * Loads an image as an HTMLImageElement.
  122101. * @param input url string, ArrayBuffer, or Blob to load
  122102. * @param onLoad callback called when the image successfully loads
  122103. * @param onError callback called when the image fails to load
  122104. * @param offlineProvider offline provider for caching
  122105. * @param mimeType optional mime type
  122106. * @returns the HTMLImageElement of the loaded image
  122107. */
  122108. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  122109. /**
  122110. * Loads a file from a url
  122111. * @param url url string, ArrayBuffer, or Blob to load
  122112. * @param onSuccess callback called when the file successfully loads
  122113. * @param onProgress callback called while file is loading (if the server supports this mode)
  122114. * @param offlineProvider defines the offline provider for caching
  122115. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122116. * @param onError callback called when the file fails to load
  122117. * @returns a file request object
  122118. */
  122119. 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;
  122120. /**
  122121. * Loads a file from a url
  122122. * @param url the file url to load
  122123. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122124. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  122125. */
  122126. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  122127. /**
  122128. * Load a script (identified by an url). When the url returns, the
  122129. * content of this file is added into a new script element, attached to the DOM (body element)
  122130. * @param scriptUrl defines the url of the script to laod
  122131. * @param onSuccess defines the callback called when the script is loaded
  122132. * @param onError defines the callback to call if an error occurs
  122133. * @param scriptId defines the id of the script element
  122134. */
  122135. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  122136. /**
  122137. * Load an asynchronous script (identified by an url). When the url returns, the
  122138. * content of this file is added into a new script element, attached to the DOM (body element)
  122139. * @param scriptUrl defines the url of the script to laod
  122140. * @param scriptId defines the id of the script element
  122141. * @returns a promise request object
  122142. */
  122143. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  122144. /**
  122145. * Loads a file from a blob
  122146. * @param fileToLoad defines the blob to use
  122147. * @param callback defines the callback to call when data is loaded
  122148. * @param progressCallback defines the callback to call during loading process
  122149. * @returns a file request object
  122150. */
  122151. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122152. /**
  122153. * Reads a file from a File object
  122154. * @param file defines the file to load
  122155. * @param onSuccess defines the callback to call when data is loaded
  122156. * @param onProgress defines the callback to call during loading process
  122157. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122158. * @param onError defines the callback to call when an error occurs
  122159. * @returns a file request object
  122160. */
  122161. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122162. /**
  122163. * Creates a data url from a given string content
  122164. * @param content defines the content to convert
  122165. * @returns the new data url link
  122166. */
  122167. static FileAsURL(content: string): string;
  122168. /**
  122169. * Format the given number to a specific decimal format
  122170. * @param value defines the number to format
  122171. * @param decimals defines the number of decimals to use
  122172. * @returns the formatted string
  122173. */
  122174. static Format(value: number, decimals?: number): string;
  122175. /**
  122176. * Tries to copy an object by duplicating every property
  122177. * @param source defines the source object
  122178. * @param destination defines the target object
  122179. * @param doNotCopyList defines a list of properties to avoid
  122180. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122181. */
  122182. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122183. /**
  122184. * Gets a boolean indicating if the given object has no own property
  122185. * @param obj defines the object to test
  122186. * @returns true if object has no own property
  122187. */
  122188. static IsEmpty(obj: any): boolean;
  122189. /**
  122190. * Function used to register events at window level
  122191. * @param windowElement defines the Window object to use
  122192. * @param events defines the events to register
  122193. */
  122194. static RegisterTopRootEvents(windowElement: Window, events: {
  122195. name: string;
  122196. handler: Nullable<(e: FocusEvent) => any>;
  122197. }[]): void;
  122198. /**
  122199. * Function used to unregister events from window level
  122200. * @param windowElement defines the Window object to use
  122201. * @param events defines the events to unregister
  122202. */
  122203. static UnregisterTopRootEvents(windowElement: Window, events: {
  122204. name: string;
  122205. handler: Nullable<(e: FocusEvent) => any>;
  122206. }[]): void;
  122207. /**
  122208. * @ignore
  122209. */
  122210. static _ScreenshotCanvas: HTMLCanvasElement;
  122211. /**
  122212. * Dumps the current bound framebuffer
  122213. * @param width defines the rendering width
  122214. * @param height defines the rendering height
  122215. * @param engine defines the hosting engine
  122216. * @param successCallback defines the callback triggered once the data are available
  122217. * @param mimeType defines the mime type of the result
  122218. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122219. */
  122220. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122221. /**
  122222. * Converts the canvas data to blob.
  122223. * This acts as a polyfill for browsers not supporting the to blob function.
  122224. * @param canvas Defines the canvas to extract the data from
  122225. * @param successCallback Defines the callback triggered once the data are available
  122226. * @param mimeType Defines the mime type of the result
  122227. */
  122228. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122229. /**
  122230. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122231. * @param successCallback defines the callback triggered once the data are available
  122232. * @param mimeType defines the mime type of the result
  122233. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122234. */
  122235. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122236. /**
  122237. * Downloads a blob in the browser
  122238. * @param blob defines the blob to download
  122239. * @param fileName defines the name of the downloaded file
  122240. */
  122241. static Download(blob: Blob, fileName: string): void;
  122242. /**
  122243. * Captures a screenshot of the current rendering
  122244. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122245. * @param engine defines the rendering engine
  122246. * @param camera defines the source camera
  122247. * @param size This parameter can be set to a single number or to an object with the
  122248. * following (optional) properties: precision, width, height. If a single number is passed,
  122249. * it will be used for both width and height. If an object is passed, the screenshot size
  122250. * will be derived from the parameters. The precision property is a multiplier allowing
  122251. * rendering at a higher or lower resolution
  122252. * @param successCallback defines the callback receives a single parameter which contains the
  122253. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122254. * src parameter of an <img> to display it
  122255. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122256. * Check your browser for supported MIME types
  122257. */
  122258. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  122259. /**
  122260. * Captures a screenshot of the current rendering
  122261. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122262. * @param engine defines the rendering engine
  122263. * @param camera defines the source camera
  122264. * @param size This parameter can be set to a single number or to an object with the
  122265. * following (optional) properties: precision, width, height. If a single number is passed,
  122266. * it will be used for both width and height. If an object is passed, the screenshot size
  122267. * will be derived from the parameters. The precision property is a multiplier allowing
  122268. * rendering at a higher or lower resolution
  122269. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122270. * Check your browser for supported MIME types
  122271. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122272. * to the src parameter of an <img> to display it
  122273. */
  122274. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  122275. /**
  122276. * Generates an image screenshot from the specified camera.
  122277. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122278. * @param engine The engine to use for rendering
  122279. * @param camera The camera to use for rendering
  122280. * @param size This parameter can be set to a single number or to an object with the
  122281. * following (optional) properties: precision, width, height. If a single number is passed,
  122282. * it will be used for both width and height. If an object is passed, the screenshot size
  122283. * will be derived from the parameters. The precision property is a multiplier allowing
  122284. * rendering at a higher or lower resolution
  122285. * @param successCallback The callback receives a single parameter which contains the
  122286. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122287. * src parameter of an <img> to display it
  122288. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122289. * Check your browser for supported MIME types
  122290. * @param samples Texture samples (default: 1)
  122291. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122292. * @param fileName A name for for the downloaded file.
  122293. */
  122294. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122295. /**
  122296. * Generates an image screenshot from the specified camera.
  122297. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122298. * @param engine The engine to use for rendering
  122299. * @param camera The camera to use for rendering
  122300. * @param size This parameter can be set to a single number or to an object with the
  122301. * following (optional) properties: precision, width, height. If a single number is passed,
  122302. * it will be used for both width and height. If an object is passed, the screenshot size
  122303. * will be derived from the parameters. The precision property is a multiplier allowing
  122304. * rendering at a higher or lower resolution
  122305. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122306. * Check your browser for supported MIME types
  122307. * @param samples Texture samples (default: 1)
  122308. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122309. * @param fileName A name for for the downloaded file.
  122310. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122311. * to the src parameter of an <img> to display it
  122312. */
  122313. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  122314. /**
  122315. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  122316. * Be aware Math.random() could cause collisions, but:
  122317. * "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"
  122318. * @returns a pseudo random id
  122319. */
  122320. static RandomId(): string;
  122321. /**
  122322. * Test if the given uri is a base64 string
  122323. * @param uri The uri to test
  122324. * @return True if the uri is a base64 string or false otherwise
  122325. */
  122326. static IsBase64(uri: string): boolean;
  122327. /**
  122328. * Decode the given base64 uri.
  122329. * @param uri The uri to decode
  122330. * @return The decoded base64 data.
  122331. */
  122332. static DecodeBase64(uri: string): ArrayBuffer;
  122333. /**
  122334. * Gets the absolute url.
  122335. * @param url the input url
  122336. * @return the absolute url
  122337. */
  122338. static GetAbsoluteUrl(url: string): string;
  122339. /**
  122340. * No log
  122341. */
  122342. static readonly NoneLogLevel: number;
  122343. /**
  122344. * Only message logs
  122345. */
  122346. static readonly MessageLogLevel: number;
  122347. /**
  122348. * Only warning logs
  122349. */
  122350. static readonly WarningLogLevel: number;
  122351. /**
  122352. * Only error logs
  122353. */
  122354. static readonly ErrorLogLevel: number;
  122355. /**
  122356. * All logs
  122357. */
  122358. static readonly AllLogLevel: number;
  122359. /**
  122360. * Gets a value indicating the number of loading errors
  122361. * @ignorenaming
  122362. */
  122363. static get errorsCount(): number;
  122364. /**
  122365. * Callback called when a new log is added
  122366. */
  122367. static OnNewCacheEntry: (entry: string) => void;
  122368. /**
  122369. * Log a message to the console
  122370. * @param message defines the message to log
  122371. */
  122372. static Log(message: string): void;
  122373. /**
  122374. * Write a warning message to the console
  122375. * @param message defines the message to log
  122376. */
  122377. static Warn(message: string): void;
  122378. /**
  122379. * Write an error message to the console
  122380. * @param message defines the message to log
  122381. */
  122382. static Error(message: string): void;
  122383. /**
  122384. * Gets current log cache (list of logs)
  122385. */
  122386. static get LogCache(): string;
  122387. /**
  122388. * Clears the log cache
  122389. */
  122390. static ClearLogCache(): void;
  122391. /**
  122392. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  122393. */
  122394. static set LogLevels(level: number);
  122395. /**
  122396. * Checks if the window object exists
  122397. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  122398. */
  122399. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  122400. /**
  122401. * No performance log
  122402. */
  122403. static readonly PerformanceNoneLogLevel: number;
  122404. /**
  122405. * Use user marks to log performance
  122406. */
  122407. static readonly PerformanceUserMarkLogLevel: number;
  122408. /**
  122409. * Log performance to the console
  122410. */
  122411. static readonly PerformanceConsoleLogLevel: number;
  122412. private static _performance;
  122413. /**
  122414. * Sets the current performance log level
  122415. */
  122416. static set PerformanceLogLevel(level: number);
  122417. private static _StartPerformanceCounterDisabled;
  122418. private static _EndPerformanceCounterDisabled;
  122419. private static _StartUserMark;
  122420. private static _EndUserMark;
  122421. private static _StartPerformanceConsole;
  122422. private static _EndPerformanceConsole;
  122423. /**
  122424. * Starts a performance counter
  122425. */
  122426. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122427. /**
  122428. * Ends a specific performance coutner
  122429. */
  122430. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122431. /**
  122432. * Gets either window.performance.now() if supported or Date.now() else
  122433. */
  122434. static get Now(): number;
  122435. /**
  122436. * This method will return the name of the class used to create the instance of the given object.
  122437. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  122438. * @param object the object to get the class name from
  122439. * @param isType defines if the object is actually a type
  122440. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  122441. */
  122442. static GetClassName(object: any, isType?: boolean): string;
  122443. /**
  122444. * Gets the first element of an array satisfying a given predicate
  122445. * @param array defines the array to browse
  122446. * @param predicate defines the predicate to use
  122447. * @returns null if not found or the element
  122448. */
  122449. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  122450. /**
  122451. * This method will return the name of the full name of the class, including its owning module (if any).
  122452. * 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).
  122453. * @param object the object to get the class name from
  122454. * @param isType defines if the object is actually a type
  122455. * @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.
  122456. * @ignorenaming
  122457. */
  122458. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  122459. /**
  122460. * Returns a promise that resolves after the given amount of time.
  122461. * @param delay Number of milliseconds to delay
  122462. * @returns Promise that resolves after the given amount of time
  122463. */
  122464. static DelayAsync(delay: number): Promise<void>;
  122465. /**
  122466. * Utility function to detect if the current user agent is Safari
  122467. * @returns whether or not the current user agent is safari
  122468. */
  122469. static IsSafari(): boolean;
  122470. }
  122471. /**
  122472. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  122473. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  122474. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  122475. * @param name The name of the class, case should be preserved
  122476. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  122477. */
  122478. export function className(name: string, module?: string): (target: Object) => void;
  122479. /**
  122480. * An implementation of a loop for asynchronous functions.
  122481. */
  122482. export class AsyncLoop {
  122483. /**
  122484. * Defines the number of iterations for the loop
  122485. */
  122486. iterations: number;
  122487. /**
  122488. * Defines the current index of the loop.
  122489. */
  122490. index: number;
  122491. private _done;
  122492. private _fn;
  122493. private _successCallback;
  122494. /**
  122495. * Constructor.
  122496. * @param iterations the number of iterations.
  122497. * @param func the function to run each iteration
  122498. * @param successCallback the callback that will be called upon succesful execution
  122499. * @param offset starting offset.
  122500. */
  122501. constructor(
  122502. /**
  122503. * Defines the number of iterations for the loop
  122504. */
  122505. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  122506. /**
  122507. * Execute the next iteration. Must be called after the last iteration was finished.
  122508. */
  122509. executeNext(): void;
  122510. /**
  122511. * Break the loop and run the success callback.
  122512. */
  122513. breakLoop(): void;
  122514. /**
  122515. * Create and run an async loop.
  122516. * @param iterations the number of iterations.
  122517. * @param fn the function to run each iteration
  122518. * @param successCallback the callback that will be called upon succesful execution
  122519. * @param offset starting offset.
  122520. * @returns the created async loop object
  122521. */
  122522. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  122523. /**
  122524. * A for-loop that will run a given number of iterations synchronous and the rest async.
  122525. * @param iterations total number of iterations
  122526. * @param syncedIterations number of synchronous iterations in each async iteration.
  122527. * @param fn the function to call each iteration.
  122528. * @param callback a success call back that will be called when iterating stops.
  122529. * @param breakFunction a break condition (optional)
  122530. * @param timeout timeout settings for the setTimeout function. default - 0.
  122531. * @returns the created async loop object
  122532. */
  122533. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  122534. }
  122535. }
  122536. declare module BABYLON {
  122537. /**
  122538. * This class implement a typical dictionary using a string as key and the generic type T as value.
  122539. * The underlying implementation relies on an associative array to ensure the best performances.
  122540. * The value can be anything including 'null' but except 'undefined'
  122541. */
  122542. export class StringDictionary<T> {
  122543. /**
  122544. * This will clear this dictionary and copy the content from the 'source' one.
  122545. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  122546. * @param source the dictionary to take the content from and copy to this dictionary
  122547. */
  122548. copyFrom(source: StringDictionary<T>): void;
  122549. /**
  122550. * Get a value based from its key
  122551. * @param key the given key to get the matching value from
  122552. * @return the value if found, otherwise undefined is returned
  122553. */
  122554. get(key: string): T | undefined;
  122555. /**
  122556. * Get a value from its key or add it if it doesn't exist.
  122557. * This method will ensure you that a given key/data will be present in the dictionary.
  122558. * @param key the given key to get the matching value from
  122559. * @param factory the factory that will create the value if the key is not present in the dictionary.
  122560. * The factory will only be invoked if there's no data for the given key.
  122561. * @return the value corresponding to the key.
  122562. */
  122563. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  122564. /**
  122565. * Get a value from its key if present in the dictionary otherwise add it
  122566. * @param key the key to get the value from
  122567. * @param val if there's no such key/value pair in the dictionary add it with this value
  122568. * @return the value corresponding to the key
  122569. */
  122570. getOrAdd(key: string, val: T): T;
  122571. /**
  122572. * Check if there's a given key in the dictionary
  122573. * @param key the key to check for
  122574. * @return true if the key is present, false otherwise
  122575. */
  122576. contains(key: string): boolean;
  122577. /**
  122578. * Add a new key and its corresponding value
  122579. * @param key the key to add
  122580. * @param value the value corresponding to the key
  122581. * @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
  122582. */
  122583. add(key: string, value: T): boolean;
  122584. /**
  122585. * Update a specific value associated to a key
  122586. * @param key defines the key to use
  122587. * @param value defines the value to store
  122588. * @returns true if the value was updated (or false if the key was not found)
  122589. */
  122590. set(key: string, value: T): boolean;
  122591. /**
  122592. * Get the element of the given key and remove it from the dictionary
  122593. * @param key defines the key to search
  122594. * @returns the value associated with the key or null if not found
  122595. */
  122596. getAndRemove(key: string): Nullable<T>;
  122597. /**
  122598. * Remove a key/value from the dictionary.
  122599. * @param key the key to remove
  122600. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  122601. */
  122602. remove(key: string): boolean;
  122603. /**
  122604. * Clear the whole content of the dictionary
  122605. */
  122606. clear(): void;
  122607. /**
  122608. * Gets the current count
  122609. */
  122610. get count(): number;
  122611. /**
  122612. * Execute a callback on each key/val of the dictionary.
  122613. * Note that you can remove any element in this dictionary in the callback implementation
  122614. * @param callback the callback to execute on a given key/value pair
  122615. */
  122616. forEach(callback: (key: string, val: T) => void): void;
  122617. /**
  122618. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  122619. * If the callback returns null or undefined the method will iterate to the next key/value pair
  122620. * Note that you can remove any element in this dictionary in the callback implementation
  122621. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  122622. * @returns the first item
  122623. */
  122624. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  122625. private _count;
  122626. private _data;
  122627. }
  122628. }
  122629. declare module BABYLON {
  122630. /** @hidden */
  122631. export interface ICollisionCoordinator {
  122632. createCollider(): Collider;
  122633. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122634. init(scene: Scene): void;
  122635. }
  122636. /** @hidden */
  122637. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  122638. private _scene;
  122639. private _scaledPosition;
  122640. private _scaledVelocity;
  122641. private _finalPosition;
  122642. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122643. createCollider(): Collider;
  122644. init(scene: Scene): void;
  122645. private _collideWithWorld;
  122646. }
  122647. }
  122648. declare module BABYLON {
  122649. /**
  122650. * Class used to manage all inputs for the scene.
  122651. */
  122652. export class InputManager {
  122653. /** The distance in pixel that you have to move to prevent some events */
  122654. static DragMovementThreshold: number;
  122655. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  122656. static LongPressDelay: number;
  122657. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  122658. static DoubleClickDelay: number;
  122659. /** If you need to check double click without raising a single click at first click, enable this flag */
  122660. static ExclusiveDoubleClickMode: boolean;
  122661. /** 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. */
  122662. private _alreadyAttached;
  122663. private _wheelEventName;
  122664. private _onPointerMove;
  122665. private _onPointerDown;
  122666. private _onPointerUp;
  122667. private _initClickEvent;
  122668. private _initActionManager;
  122669. private _delayedSimpleClick;
  122670. private _delayedSimpleClickTimeout;
  122671. private _previousDelayedSimpleClickTimeout;
  122672. private _meshPickProceed;
  122673. private _previousButtonPressed;
  122674. private _currentPickResult;
  122675. private _previousPickResult;
  122676. private _totalPointersPressed;
  122677. private _doubleClickOccured;
  122678. private _pointerOverMesh;
  122679. private _pickedDownMesh;
  122680. private _pickedUpMesh;
  122681. private _pointerX;
  122682. private _pointerY;
  122683. private _unTranslatedPointerX;
  122684. private _unTranslatedPointerY;
  122685. private _startingPointerPosition;
  122686. private _previousStartingPointerPosition;
  122687. private _startingPointerTime;
  122688. private _previousStartingPointerTime;
  122689. private _pointerCaptures;
  122690. private _meshUnderPointerId;
  122691. private _onKeyDown;
  122692. private _onKeyUp;
  122693. private _onCanvasFocusObserver;
  122694. private _onCanvasBlurObserver;
  122695. private _scene;
  122696. /**
  122697. * Creates a new InputManager
  122698. * @param scene defines the hosting scene
  122699. */
  122700. constructor(scene: Scene);
  122701. /**
  122702. * Gets the mesh that is currently under the pointer
  122703. */
  122704. get meshUnderPointer(): Nullable<AbstractMesh>;
  122705. /**
  122706. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  122707. * @param pointerId the pointer id to use
  122708. * @returns The mesh under this pointer id or null if not found
  122709. */
  122710. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  122711. /**
  122712. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  122713. */
  122714. get unTranslatedPointer(): Vector2;
  122715. /**
  122716. * Gets or sets the current on-screen X position of the pointer
  122717. */
  122718. get pointerX(): number;
  122719. set pointerX(value: number);
  122720. /**
  122721. * Gets or sets the current on-screen Y position of the pointer
  122722. */
  122723. get pointerY(): number;
  122724. set pointerY(value: number);
  122725. private _updatePointerPosition;
  122726. private _processPointerMove;
  122727. private _setRayOnPointerInfo;
  122728. private _checkPrePointerObservable;
  122729. /**
  122730. * Use this method to simulate a pointer move on a mesh
  122731. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122732. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122733. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122734. */
  122735. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122736. /**
  122737. * Use this method to simulate a pointer down on a mesh
  122738. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122739. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122740. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122741. */
  122742. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122743. private _processPointerDown;
  122744. /** @hidden */
  122745. _isPointerSwiping(): boolean;
  122746. /**
  122747. * Use this method to simulate a pointer up on a mesh
  122748. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122749. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122750. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122751. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  122752. */
  122753. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  122754. private _processPointerUp;
  122755. /**
  122756. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  122757. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  122758. * @returns true if the pointer was captured
  122759. */
  122760. isPointerCaptured(pointerId?: number): boolean;
  122761. /**
  122762. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  122763. * @param attachUp defines if you want to attach events to pointerup
  122764. * @param attachDown defines if you want to attach events to pointerdown
  122765. * @param attachMove defines if you want to attach events to pointermove
  122766. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  122767. */
  122768. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  122769. /**
  122770. * Detaches all event handlers
  122771. */
  122772. detachControl(): void;
  122773. /**
  122774. * Force the value of meshUnderPointer
  122775. * @param mesh defines the mesh to use
  122776. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  122777. */
  122778. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  122779. /**
  122780. * Gets the mesh under the pointer
  122781. * @returns a Mesh or null if no mesh is under the pointer
  122782. */
  122783. getPointerOverMesh(): Nullable<AbstractMesh>;
  122784. }
  122785. }
  122786. declare module BABYLON {
  122787. /**
  122788. * This class defines the direct association between an animation and a target
  122789. */
  122790. export class TargetedAnimation {
  122791. /**
  122792. * Animation to perform
  122793. */
  122794. animation: Animation;
  122795. /**
  122796. * Target to animate
  122797. */
  122798. target: any;
  122799. /**
  122800. * Returns the string "TargetedAnimation"
  122801. * @returns "TargetedAnimation"
  122802. */
  122803. getClassName(): string;
  122804. /**
  122805. * Serialize the object
  122806. * @returns the JSON object representing the current entity
  122807. */
  122808. serialize(): any;
  122809. }
  122810. /**
  122811. * Use this class to create coordinated animations on multiple targets
  122812. */
  122813. export class AnimationGroup implements IDisposable {
  122814. /** The name of the animation group */
  122815. name: string;
  122816. private _scene;
  122817. private _targetedAnimations;
  122818. private _animatables;
  122819. private _from;
  122820. private _to;
  122821. private _isStarted;
  122822. private _isPaused;
  122823. private _speedRatio;
  122824. private _loopAnimation;
  122825. private _isAdditive;
  122826. /**
  122827. * Gets or sets the unique id of the node
  122828. */
  122829. uniqueId: number;
  122830. /**
  122831. * This observable will notify when one animation have ended
  122832. */
  122833. onAnimationEndObservable: Observable<TargetedAnimation>;
  122834. /**
  122835. * Observer raised when one animation loops
  122836. */
  122837. onAnimationLoopObservable: Observable<TargetedAnimation>;
  122838. /**
  122839. * Observer raised when all animations have looped
  122840. */
  122841. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  122842. /**
  122843. * This observable will notify when all animations have ended.
  122844. */
  122845. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  122846. /**
  122847. * This observable will notify when all animations have paused.
  122848. */
  122849. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  122850. /**
  122851. * This observable will notify when all animations are playing.
  122852. */
  122853. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  122854. /**
  122855. * Gets the first frame
  122856. */
  122857. get from(): number;
  122858. /**
  122859. * Gets the last frame
  122860. */
  122861. get to(): number;
  122862. /**
  122863. * Define if the animations are started
  122864. */
  122865. get isStarted(): boolean;
  122866. /**
  122867. * Gets a value indicating that the current group is playing
  122868. */
  122869. get isPlaying(): boolean;
  122870. /**
  122871. * Gets or sets the speed ratio to use for all animations
  122872. */
  122873. get speedRatio(): number;
  122874. /**
  122875. * Gets or sets the speed ratio to use for all animations
  122876. */
  122877. set speedRatio(value: number);
  122878. /**
  122879. * Gets or sets if all animations should loop or not
  122880. */
  122881. get loopAnimation(): boolean;
  122882. set loopAnimation(value: boolean);
  122883. /**
  122884. * Gets or sets if all animations should be evaluated additively
  122885. */
  122886. get isAdditive(): boolean;
  122887. set isAdditive(value: boolean);
  122888. /**
  122889. * Gets the targeted animations for this animation group
  122890. */
  122891. get targetedAnimations(): Array<TargetedAnimation>;
  122892. /**
  122893. * returning the list of animatables controlled by this animation group.
  122894. */
  122895. get animatables(): Array<Animatable>;
  122896. /**
  122897. * Gets the list of target animations
  122898. */
  122899. get children(): TargetedAnimation[];
  122900. /**
  122901. * Instantiates a new Animation Group.
  122902. * This helps managing several animations at once.
  122903. * @see https://doc.babylonjs.com/how_to/group
  122904. * @param name Defines the name of the group
  122905. * @param scene Defines the scene the group belongs to
  122906. */
  122907. constructor(
  122908. /** The name of the animation group */
  122909. name: string, scene?: Nullable<Scene>);
  122910. /**
  122911. * Add an animation (with its target) in the group
  122912. * @param animation defines the animation we want to add
  122913. * @param target defines the target of the animation
  122914. * @returns the TargetedAnimation object
  122915. */
  122916. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  122917. /**
  122918. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  122919. * It can add constant keys at begin or end
  122920. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  122921. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  122922. * @returns the animation group
  122923. */
  122924. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  122925. private _animationLoopCount;
  122926. private _animationLoopFlags;
  122927. private _processLoop;
  122928. /**
  122929. * Start all animations on given targets
  122930. * @param loop defines if animations must loop
  122931. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  122932. * @param from defines the from key (optional)
  122933. * @param to defines the to key (optional)
  122934. * @param isAdditive defines the additive state for the resulting animatables (optional)
  122935. * @returns the current animation group
  122936. */
  122937. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  122938. /**
  122939. * Pause all animations
  122940. * @returns the animation group
  122941. */
  122942. pause(): AnimationGroup;
  122943. /**
  122944. * Play all animations to initial state
  122945. * This function will start() the animations if they were not started or will restart() them if they were paused
  122946. * @param loop defines if animations must loop
  122947. * @returns the animation group
  122948. */
  122949. play(loop?: boolean): AnimationGroup;
  122950. /**
  122951. * Reset all animations to initial state
  122952. * @returns the animation group
  122953. */
  122954. reset(): AnimationGroup;
  122955. /**
  122956. * Restart animations from key 0
  122957. * @returns the animation group
  122958. */
  122959. restart(): AnimationGroup;
  122960. /**
  122961. * Stop all animations
  122962. * @returns the animation group
  122963. */
  122964. stop(): AnimationGroup;
  122965. /**
  122966. * Set animation weight for all animatables
  122967. * @param weight defines the weight to use
  122968. * @return the animationGroup
  122969. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  122970. */
  122971. setWeightForAllAnimatables(weight: number): AnimationGroup;
  122972. /**
  122973. * Synchronize and normalize all animatables with a source animatable
  122974. * @param root defines the root animatable to synchronize with
  122975. * @return the animationGroup
  122976. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  122977. */
  122978. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  122979. /**
  122980. * Goes to a specific frame in this animation group
  122981. * @param frame the frame number to go to
  122982. * @return the animationGroup
  122983. */
  122984. goToFrame(frame: number): AnimationGroup;
  122985. /**
  122986. * Dispose all associated resources
  122987. */
  122988. dispose(): void;
  122989. private _checkAnimationGroupEnded;
  122990. /**
  122991. * Clone the current animation group and returns a copy
  122992. * @param newName defines the name of the new group
  122993. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  122994. * @returns the new aniamtion group
  122995. */
  122996. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  122997. /**
  122998. * Serializes the animationGroup to an object
  122999. * @returns Serialized object
  123000. */
  123001. serialize(): any;
  123002. /**
  123003. * Returns a new AnimationGroup object parsed from the source provided.
  123004. * @param parsedAnimationGroup defines the source
  123005. * @param scene defines the scene that will receive the animationGroup
  123006. * @returns a new AnimationGroup
  123007. */
  123008. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  123009. /**
  123010. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  123011. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  123012. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  123013. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  123014. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  123015. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  123016. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  123017. */
  123018. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  123019. /**
  123020. * Returns the string "AnimationGroup"
  123021. * @returns "AnimationGroup"
  123022. */
  123023. getClassName(): string;
  123024. /**
  123025. * Creates a detailled string about the object
  123026. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  123027. * @returns a string representing the object
  123028. */
  123029. toString(fullDetails?: boolean): string;
  123030. }
  123031. }
  123032. declare module BABYLON {
  123033. /**
  123034. * Define an interface for all classes that will hold resources
  123035. */
  123036. export interface IDisposable {
  123037. /**
  123038. * Releases all held resources
  123039. */
  123040. dispose(): void;
  123041. }
  123042. /** Interface defining initialization parameters for Scene class */
  123043. export interface SceneOptions {
  123044. /**
  123045. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  123046. * It will improve performance when the number of geometries becomes important.
  123047. */
  123048. useGeometryUniqueIdsMap?: boolean;
  123049. /**
  123050. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  123051. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123052. */
  123053. useMaterialMeshMap?: boolean;
  123054. /**
  123055. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  123056. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123057. */
  123058. useClonedMeshMap?: boolean;
  123059. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  123060. virtual?: boolean;
  123061. }
  123062. /**
  123063. * Represents a scene to be rendered by the engine.
  123064. * @see https://doc.babylonjs.com/features/scene
  123065. */
  123066. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  123067. /** The fog is deactivated */
  123068. static readonly FOGMODE_NONE: number;
  123069. /** The fog density is following an exponential function */
  123070. static readonly FOGMODE_EXP: number;
  123071. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  123072. static readonly FOGMODE_EXP2: number;
  123073. /** The fog density is following a linear function. */
  123074. static readonly FOGMODE_LINEAR: number;
  123075. /**
  123076. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  123077. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123078. */
  123079. static MinDeltaTime: number;
  123080. /**
  123081. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  123082. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123083. */
  123084. static MaxDeltaTime: number;
  123085. /**
  123086. * Factory used to create the default material.
  123087. * @param name The name of the material to create
  123088. * @param scene The scene to create the material for
  123089. * @returns The default material
  123090. */
  123091. static DefaultMaterialFactory(scene: Scene): Material;
  123092. /**
  123093. * Factory used to create the a collision coordinator.
  123094. * @returns The collision coordinator
  123095. */
  123096. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  123097. /** @hidden */
  123098. _inputManager: InputManager;
  123099. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  123100. cameraToUseForPointers: Nullable<Camera>;
  123101. /** @hidden */
  123102. readonly _isScene: boolean;
  123103. /** @hidden */
  123104. _blockEntityCollection: boolean;
  123105. /**
  123106. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  123107. */
  123108. autoClear: boolean;
  123109. /**
  123110. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  123111. */
  123112. autoClearDepthAndStencil: boolean;
  123113. /**
  123114. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  123115. */
  123116. clearColor: Color4;
  123117. /**
  123118. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  123119. */
  123120. ambientColor: Color3;
  123121. /**
  123122. * This is use to store the default BRDF lookup for PBR materials in your scene.
  123123. * It should only be one of the following (if not the default embedded one):
  123124. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  123125. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  123126. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  123127. * The material properties need to be setup according to the type of texture in use.
  123128. */
  123129. environmentBRDFTexture: BaseTexture;
  123130. /**
  123131. * Texture used in all pbr material as the reflection texture.
  123132. * As in the majority of the scene they are the same (exception for multi room and so on),
  123133. * this is easier to reference from here than from all the materials.
  123134. */
  123135. get environmentTexture(): Nullable<BaseTexture>;
  123136. /**
  123137. * Texture used in all pbr material as the reflection texture.
  123138. * As in the majority of the scene they are the same (exception for multi room and so on),
  123139. * this is easier to set here than in all the materials.
  123140. */
  123141. set environmentTexture(value: Nullable<BaseTexture>);
  123142. /** @hidden */
  123143. protected _environmentIntensity: number;
  123144. /**
  123145. * Intensity of the environment in all pbr material.
  123146. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123147. * As in the majority of the scene they are the same (exception for multi room and so on),
  123148. * this is easier to reference from here than from all the materials.
  123149. */
  123150. get environmentIntensity(): number;
  123151. /**
  123152. * Intensity of the environment in all pbr material.
  123153. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123154. * As in the majority of the scene they are the same (exception for multi room and so on),
  123155. * this is easier to set here than in all the materials.
  123156. */
  123157. set environmentIntensity(value: number);
  123158. /** @hidden */
  123159. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123160. /**
  123161. * Default image processing configuration used either in the rendering
  123162. * Forward main pass or through the imageProcessingPostProcess if present.
  123163. * As in the majority of the scene they are the same (exception for multi camera),
  123164. * this is easier to reference from here than from all the materials and post process.
  123165. *
  123166. * No setter as we it is a shared configuration, you can set the values instead.
  123167. */
  123168. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123169. private _forceWireframe;
  123170. /**
  123171. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123172. */
  123173. set forceWireframe(value: boolean);
  123174. get forceWireframe(): boolean;
  123175. private _skipFrustumClipping;
  123176. /**
  123177. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123178. */
  123179. set skipFrustumClipping(value: boolean);
  123180. get skipFrustumClipping(): boolean;
  123181. private _forcePointsCloud;
  123182. /**
  123183. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123184. */
  123185. set forcePointsCloud(value: boolean);
  123186. get forcePointsCloud(): boolean;
  123187. /**
  123188. * Gets or sets the active clipplane 1
  123189. */
  123190. clipPlane: Nullable<Plane>;
  123191. /**
  123192. * Gets or sets the active clipplane 2
  123193. */
  123194. clipPlane2: Nullable<Plane>;
  123195. /**
  123196. * Gets or sets the active clipplane 3
  123197. */
  123198. clipPlane3: Nullable<Plane>;
  123199. /**
  123200. * Gets or sets the active clipplane 4
  123201. */
  123202. clipPlane4: Nullable<Plane>;
  123203. /**
  123204. * Gets or sets the active clipplane 5
  123205. */
  123206. clipPlane5: Nullable<Plane>;
  123207. /**
  123208. * Gets or sets the active clipplane 6
  123209. */
  123210. clipPlane6: Nullable<Plane>;
  123211. /**
  123212. * Gets or sets a boolean indicating if animations are enabled
  123213. */
  123214. animationsEnabled: boolean;
  123215. private _animationPropertiesOverride;
  123216. /**
  123217. * Gets or sets the animation properties override
  123218. */
  123219. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123220. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123221. /**
  123222. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123223. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123224. */
  123225. useConstantAnimationDeltaTime: boolean;
  123226. /**
  123227. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123228. * Please note that it requires to run a ray cast through the scene on every frame
  123229. */
  123230. constantlyUpdateMeshUnderPointer: boolean;
  123231. /**
  123232. * Defines the HTML cursor to use when hovering over interactive elements
  123233. */
  123234. hoverCursor: string;
  123235. /**
  123236. * Defines the HTML default cursor to use (empty by default)
  123237. */
  123238. defaultCursor: string;
  123239. /**
  123240. * Defines whether cursors are handled by the scene.
  123241. */
  123242. doNotHandleCursors: boolean;
  123243. /**
  123244. * This is used to call preventDefault() on pointer down
  123245. * in order to block unwanted artifacts like system double clicks
  123246. */
  123247. preventDefaultOnPointerDown: boolean;
  123248. /**
  123249. * This is used to call preventDefault() on pointer up
  123250. * in order to block unwanted artifacts like system double clicks
  123251. */
  123252. preventDefaultOnPointerUp: boolean;
  123253. /**
  123254. * Gets or sets user defined metadata
  123255. */
  123256. metadata: any;
  123257. /**
  123258. * For internal use only. Please do not use.
  123259. */
  123260. reservedDataStore: any;
  123261. /**
  123262. * Gets the name of the plugin used to load this scene (null by default)
  123263. */
  123264. loadingPluginName: string;
  123265. /**
  123266. * Use this array to add regular expressions used to disable offline support for specific urls
  123267. */
  123268. disableOfflineSupportExceptionRules: RegExp[];
  123269. /**
  123270. * An event triggered when the scene is disposed.
  123271. */
  123272. onDisposeObservable: Observable<Scene>;
  123273. private _onDisposeObserver;
  123274. /** Sets a function to be executed when this scene is disposed. */
  123275. set onDispose(callback: () => void);
  123276. /**
  123277. * An event triggered before rendering the scene (right after animations and physics)
  123278. */
  123279. onBeforeRenderObservable: Observable<Scene>;
  123280. private _onBeforeRenderObserver;
  123281. /** Sets a function to be executed before rendering this scene */
  123282. set beforeRender(callback: Nullable<() => void>);
  123283. /**
  123284. * An event triggered after rendering the scene
  123285. */
  123286. onAfterRenderObservable: Observable<Scene>;
  123287. /**
  123288. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  123289. */
  123290. onAfterRenderCameraObservable: Observable<Camera>;
  123291. private _onAfterRenderObserver;
  123292. /** Sets a function to be executed after rendering this scene */
  123293. set afterRender(callback: Nullable<() => void>);
  123294. /**
  123295. * An event triggered before animating the scene
  123296. */
  123297. onBeforeAnimationsObservable: Observable<Scene>;
  123298. /**
  123299. * An event triggered after animations processing
  123300. */
  123301. onAfterAnimationsObservable: Observable<Scene>;
  123302. /**
  123303. * An event triggered before draw calls are ready to be sent
  123304. */
  123305. onBeforeDrawPhaseObservable: Observable<Scene>;
  123306. /**
  123307. * An event triggered after draw calls have been sent
  123308. */
  123309. onAfterDrawPhaseObservable: Observable<Scene>;
  123310. /**
  123311. * An event triggered when the scene is ready
  123312. */
  123313. onReadyObservable: Observable<Scene>;
  123314. /**
  123315. * An event triggered before rendering a camera
  123316. */
  123317. onBeforeCameraRenderObservable: Observable<Camera>;
  123318. private _onBeforeCameraRenderObserver;
  123319. /** Sets a function to be executed before rendering a camera*/
  123320. set beforeCameraRender(callback: () => void);
  123321. /**
  123322. * An event triggered after rendering a camera
  123323. */
  123324. onAfterCameraRenderObservable: Observable<Camera>;
  123325. private _onAfterCameraRenderObserver;
  123326. /** Sets a function to be executed after rendering a camera*/
  123327. set afterCameraRender(callback: () => void);
  123328. /**
  123329. * An event triggered when active meshes evaluation is about to start
  123330. */
  123331. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  123332. /**
  123333. * An event triggered when active meshes evaluation is done
  123334. */
  123335. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  123336. /**
  123337. * An event triggered when particles rendering is about to start
  123338. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123339. */
  123340. onBeforeParticlesRenderingObservable: Observable<Scene>;
  123341. /**
  123342. * An event triggered when particles rendering is done
  123343. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123344. */
  123345. onAfterParticlesRenderingObservable: Observable<Scene>;
  123346. /**
  123347. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  123348. */
  123349. onDataLoadedObservable: Observable<Scene>;
  123350. /**
  123351. * An event triggered when a camera is created
  123352. */
  123353. onNewCameraAddedObservable: Observable<Camera>;
  123354. /**
  123355. * An event triggered when a camera is removed
  123356. */
  123357. onCameraRemovedObservable: Observable<Camera>;
  123358. /**
  123359. * An event triggered when a light is created
  123360. */
  123361. onNewLightAddedObservable: Observable<Light>;
  123362. /**
  123363. * An event triggered when a light is removed
  123364. */
  123365. onLightRemovedObservable: Observable<Light>;
  123366. /**
  123367. * An event triggered when a geometry is created
  123368. */
  123369. onNewGeometryAddedObservable: Observable<Geometry>;
  123370. /**
  123371. * An event triggered when a geometry is removed
  123372. */
  123373. onGeometryRemovedObservable: Observable<Geometry>;
  123374. /**
  123375. * An event triggered when a transform node is created
  123376. */
  123377. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  123378. /**
  123379. * An event triggered when a transform node is removed
  123380. */
  123381. onTransformNodeRemovedObservable: Observable<TransformNode>;
  123382. /**
  123383. * An event triggered when a mesh is created
  123384. */
  123385. onNewMeshAddedObservable: Observable<AbstractMesh>;
  123386. /**
  123387. * An event triggered when a mesh is removed
  123388. */
  123389. onMeshRemovedObservable: Observable<AbstractMesh>;
  123390. /**
  123391. * An event triggered when a skeleton is created
  123392. */
  123393. onNewSkeletonAddedObservable: Observable<Skeleton>;
  123394. /**
  123395. * An event triggered when a skeleton is removed
  123396. */
  123397. onSkeletonRemovedObservable: Observable<Skeleton>;
  123398. /**
  123399. * An event triggered when a material is created
  123400. */
  123401. onNewMaterialAddedObservable: Observable<Material>;
  123402. /**
  123403. * An event triggered when a material is removed
  123404. */
  123405. onMaterialRemovedObservable: Observable<Material>;
  123406. /**
  123407. * An event triggered when a texture is created
  123408. */
  123409. onNewTextureAddedObservable: Observable<BaseTexture>;
  123410. /**
  123411. * An event triggered when a texture is removed
  123412. */
  123413. onTextureRemovedObservable: Observable<BaseTexture>;
  123414. /**
  123415. * An event triggered when render targets are about to be rendered
  123416. * Can happen multiple times per frame.
  123417. */
  123418. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  123419. /**
  123420. * An event triggered when render targets were rendered.
  123421. * Can happen multiple times per frame.
  123422. */
  123423. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  123424. /**
  123425. * An event triggered before calculating deterministic simulation step
  123426. */
  123427. onBeforeStepObservable: Observable<Scene>;
  123428. /**
  123429. * An event triggered after calculating deterministic simulation step
  123430. */
  123431. onAfterStepObservable: Observable<Scene>;
  123432. /**
  123433. * An event triggered when the activeCamera property is updated
  123434. */
  123435. onActiveCameraChanged: Observable<Scene>;
  123436. /**
  123437. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  123438. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123439. * 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)
  123440. */
  123441. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123442. /**
  123443. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  123444. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123445. * 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)
  123446. */
  123447. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123448. /**
  123449. * This Observable will when a mesh has been imported into the scene.
  123450. */
  123451. onMeshImportedObservable: Observable<AbstractMesh>;
  123452. /**
  123453. * This Observable will when an animation file has been imported into the scene.
  123454. */
  123455. onAnimationFileImportedObservable: Observable<Scene>;
  123456. /**
  123457. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  123458. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  123459. */
  123460. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  123461. /** @hidden */
  123462. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  123463. /**
  123464. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  123465. */
  123466. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  123467. /**
  123468. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  123469. */
  123470. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  123471. /**
  123472. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  123473. */
  123474. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  123475. /** Callback called when a pointer move is detected */
  123476. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123477. /** Callback called when a pointer down is detected */
  123478. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123479. /** Callback called when a pointer up is detected */
  123480. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  123481. /** Callback called when a pointer pick is detected */
  123482. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  123483. /**
  123484. * 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).
  123485. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  123486. */
  123487. onPrePointerObservable: Observable<PointerInfoPre>;
  123488. /**
  123489. * Observable event triggered each time an input event is received from the rendering canvas
  123490. */
  123491. onPointerObservable: Observable<PointerInfo>;
  123492. /**
  123493. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  123494. */
  123495. get unTranslatedPointer(): Vector2;
  123496. /**
  123497. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  123498. */
  123499. static get DragMovementThreshold(): number;
  123500. static set DragMovementThreshold(value: number);
  123501. /**
  123502. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  123503. */
  123504. static get LongPressDelay(): number;
  123505. static set LongPressDelay(value: number);
  123506. /**
  123507. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  123508. */
  123509. static get DoubleClickDelay(): number;
  123510. static set DoubleClickDelay(value: number);
  123511. /** If you need to check double click without raising a single click at first click, enable this flag */
  123512. static get ExclusiveDoubleClickMode(): boolean;
  123513. static set ExclusiveDoubleClickMode(value: boolean);
  123514. /** @hidden */
  123515. _mirroredCameraPosition: Nullable<Vector3>;
  123516. /**
  123517. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  123518. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  123519. */
  123520. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  123521. /**
  123522. * Observable event triggered each time an keyboard event is received from the hosting window
  123523. */
  123524. onKeyboardObservable: Observable<KeyboardInfo>;
  123525. private _useRightHandedSystem;
  123526. /**
  123527. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  123528. */
  123529. set useRightHandedSystem(value: boolean);
  123530. get useRightHandedSystem(): boolean;
  123531. private _timeAccumulator;
  123532. private _currentStepId;
  123533. private _currentInternalStep;
  123534. /**
  123535. * Sets the step Id used by deterministic lock step
  123536. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123537. * @param newStepId defines the step Id
  123538. */
  123539. setStepId(newStepId: number): void;
  123540. /**
  123541. * Gets the step Id used by deterministic lock step
  123542. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123543. * @returns the step Id
  123544. */
  123545. getStepId(): number;
  123546. /**
  123547. * Gets the internal step used by deterministic lock step
  123548. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123549. * @returns the internal step
  123550. */
  123551. getInternalStep(): number;
  123552. private _fogEnabled;
  123553. /**
  123554. * Gets or sets a boolean indicating if fog is enabled on this scene
  123555. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123556. * (Default is true)
  123557. */
  123558. set fogEnabled(value: boolean);
  123559. get fogEnabled(): boolean;
  123560. private _fogMode;
  123561. /**
  123562. * Gets or sets the fog mode to use
  123563. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123564. * | mode | value |
  123565. * | --- | --- |
  123566. * | FOGMODE_NONE | 0 |
  123567. * | FOGMODE_EXP | 1 |
  123568. * | FOGMODE_EXP2 | 2 |
  123569. * | FOGMODE_LINEAR | 3 |
  123570. */
  123571. set fogMode(value: number);
  123572. get fogMode(): number;
  123573. /**
  123574. * Gets or sets the fog color to use
  123575. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123576. * (Default is Color3(0.2, 0.2, 0.3))
  123577. */
  123578. fogColor: Color3;
  123579. /**
  123580. * Gets or sets the fog density to use
  123581. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123582. * (Default is 0.1)
  123583. */
  123584. fogDensity: number;
  123585. /**
  123586. * Gets or sets the fog start distance to use
  123587. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123588. * (Default is 0)
  123589. */
  123590. fogStart: number;
  123591. /**
  123592. * Gets or sets the fog end distance to use
  123593. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123594. * (Default is 1000)
  123595. */
  123596. fogEnd: number;
  123597. /**
  123598. * Flag indicating that the frame buffer binding is handled by another component
  123599. */
  123600. prePass: boolean;
  123601. private _shadowsEnabled;
  123602. /**
  123603. * Gets or sets a boolean indicating if shadows are enabled on this scene
  123604. */
  123605. set shadowsEnabled(value: boolean);
  123606. get shadowsEnabled(): boolean;
  123607. private _lightsEnabled;
  123608. /**
  123609. * Gets or sets a boolean indicating if lights are enabled on this scene
  123610. */
  123611. set lightsEnabled(value: boolean);
  123612. get lightsEnabled(): boolean;
  123613. /** All of the active cameras added to this scene. */
  123614. activeCameras: Camera[];
  123615. /** @hidden */
  123616. _activeCamera: Nullable<Camera>;
  123617. /** Gets or sets the current active camera */
  123618. get activeCamera(): Nullable<Camera>;
  123619. set activeCamera(value: Nullable<Camera>);
  123620. private _defaultMaterial;
  123621. /** The default material used on meshes when no material is affected */
  123622. get defaultMaterial(): Material;
  123623. /** The default material used on meshes when no material is affected */
  123624. set defaultMaterial(value: Material);
  123625. private _texturesEnabled;
  123626. /**
  123627. * Gets or sets a boolean indicating if textures are enabled on this scene
  123628. */
  123629. set texturesEnabled(value: boolean);
  123630. get texturesEnabled(): boolean;
  123631. /**
  123632. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  123633. */
  123634. physicsEnabled: boolean;
  123635. /**
  123636. * Gets or sets a boolean indicating if particles are enabled on this scene
  123637. */
  123638. particlesEnabled: boolean;
  123639. /**
  123640. * Gets or sets a boolean indicating if sprites are enabled on this scene
  123641. */
  123642. spritesEnabled: boolean;
  123643. private _skeletonsEnabled;
  123644. /**
  123645. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  123646. */
  123647. set skeletonsEnabled(value: boolean);
  123648. get skeletonsEnabled(): boolean;
  123649. /**
  123650. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  123651. */
  123652. lensFlaresEnabled: boolean;
  123653. /**
  123654. * Gets or sets a boolean indicating if collisions are enabled on this scene
  123655. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123656. */
  123657. collisionsEnabled: boolean;
  123658. private _collisionCoordinator;
  123659. /** @hidden */
  123660. get collisionCoordinator(): ICollisionCoordinator;
  123661. /**
  123662. * Defines the gravity applied to this scene (used only for collisions)
  123663. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123664. */
  123665. gravity: Vector3;
  123666. /**
  123667. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  123668. */
  123669. postProcessesEnabled: boolean;
  123670. /**
  123671. * Gets the current postprocess manager
  123672. */
  123673. postProcessManager: PostProcessManager;
  123674. /**
  123675. * Gets or sets a boolean indicating if render targets are enabled on this scene
  123676. */
  123677. renderTargetsEnabled: boolean;
  123678. /**
  123679. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  123680. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  123681. */
  123682. dumpNextRenderTargets: boolean;
  123683. /**
  123684. * The list of user defined render targets added to the scene
  123685. */
  123686. customRenderTargets: RenderTargetTexture[];
  123687. /**
  123688. * Defines if texture loading must be delayed
  123689. * If true, textures will only be loaded when they need to be rendered
  123690. */
  123691. useDelayedTextureLoading: boolean;
  123692. /**
  123693. * Gets the list of meshes imported to the scene through SceneLoader
  123694. */
  123695. importedMeshesFiles: String[];
  123696. /**
  123697. * Gets or sets a boolean indicating if probes are enabled on this scene
  123698. */
  123699. probesEnabled: boolean;
  123700. /**
  123701. * Gets or sets the current offline provider to use to store scene data
  123702. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  123703. */
  123704. offlineProvider: IOfflineProvider;
  123705. /**
  123706. * Gets or sets the action manager associated with the scene
  123707. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  123708. */
  123709. actionManager: AbstractActionManager;
  123710. private _meshesForIntersections;
  123711. /**
  123712. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  123713. */
  123714. proceduralTexturesEnabled: boolean;
  123715. private _engine;
  123716. private _totalVertices;
  123717. /** @hidden */
  123718. _activeIndices: PerfCounter;
  123719. /** @hidden */
  123720. _activeParticles: PerfCounter;
  123721. /** @hidden */
  123722. _activeBones: PerfCounter;
  123723. private _animationRatio;
  123724. /** @hidden */
  123725. _animationTimeLast: number;
  123726. /** @hidden */
  123727. _animationTime: number;
  123728. /**
  123729. * Gets or sets a general scale for animation speed
  123730. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  123731. */
  123732. animationTimeScale: number;
  123733. /** @hidden */
  123734. _cachedMaterial: Nullable<Material>;
  123735. /** @hidden */
  123736. _cachedEffect: Nullable<Effect>;
  123737. /** @hidden */
  123738. _cachedVisibility: Nullable<number>;
  123739. private _renderId;
  123740. private _frameId;
  123741. private _executeWhenReadyTimeoutId;
  123742. private _intermediateRendering;
  123743. private _viewUpdateFlag;
  123744. private _projectionUpdateFlag;
  123745. /** @hidden */
  123746. _toBeDisposed: Nullable<IDisposable>[];
  123747. private _activeRequests;
  123748. /** @hidden */
  123749. _pendingData: any[];
  123750. private _isDisposed;
  123751. /**
  123752. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  123753. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  123754. */
  123755. dispatchAllSubMeshesOfActiveMeshes: boolean;
  123756. private _activeMeshes;
  123757. private _processedMaterials;
  123758. private _renderTargets;
  123759. /** @hidden */
  123760. _activeParticleSystems: SmartArray<IParticleSystem>;
  123761. private _activeSkeletons;
  123762. private _softwareSkinnedMeshes;
  123763. private _renderingManager;
  123764. /** @hidden */
  123765. _activeAnimatables: Animatable[];
  123766. private _transformMatrix;
  123767. private _sceneUbo;
  123768. /** @hidden */
  123769. _viewMatrix: Matrix;
  123770. private _projectionMatrix;
  123771. /** @hidden */
  123772. _forcedViewPosition: Nullable<Vector3>;
  123773. /** @hidden */
  123774. _frustumPlanes: Plane[];
  123775. /**
  123776. * Gets the list of frustum planes (built from the active camera)
  123777. */
  123778. get frustumPlanes(): Plane[];
  123779. /**
  123780. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  123781. * This is useful if there are more lights that the maximum simulteanous authorized
  123782. */
  123783. requireLightSorting: boolean;
  123784. /** @hidden */
  123785. readonly useMaterialMeshMap: boolean;
  123786. /** @hidden */
  123787. readonly useClonedMeshMap: boolean;
  123788. private _externalData;
  123789. private _uid;
  123790. /**
  123791. * @hidden
  123792. * Backing store of defined scene components.
  123793. */
  123794. _components: ISceneComponent[];
  123795. /**
  123796. * @hidden
  123797. * Backing store of defined scene components.
  123798. */
  123799. _serializableComponents: ISceneSerializableComponent[];
  123800. /**
  123801. * List of components to register on the next registration step.
  123802. */
  123803. private _transientComponents;
  123804. /**
  123805. * Registers the transient components if needed.
  123806. */
  123807. private _registerTransientComponents;
  123808. /**
  123809. * @hidden
  123810. * Add a component to the scene.
  123811. * Note that the ccomponent could be registered on th next frame if this is called after
  123812. * the register component stage.
  123813. * @param component Defines the component to add to the scene
  123814. */
  123815. _addComponent(component: ISceneComponent): void;
  123816. /**
  123817. * @hidden
  123818. * Gets a component from the scene.
  123819. * @param name defines the name of the component to retrieve
  123820. * @returns the component or null if not present
  123821. */
  123822. _getComponent(name: string): Nullable<ISceneComponent>;
  123823. /**
  123824. * @hidden
  123825. * Defines the actions happening before camera updates.
  123826. */
  123827. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  123828. /**
  123829. * @hidden
  123830. * Defines the actions happening before clear the canvas.
  123831. */
  123832. _beforeClearStage: Stage<SimpleStageAction>;
  123833. /**
  123834. * @hidden
  123835. * Defines the actions when collecting render targets for the frame.
  123836. */
  123837. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123838. /**
  123839. * @hidden
  123840. * Defines the actions happening for one camera in the frame.
  123841. */
  123842. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123843. /**
  123844. * @hidden
  123845. * Defines the actions happening during the per mesh ready checks.
  123846. */
  123847. _isReadyForMeshStage: Stage<MeshStageAction>;
  123848. /**
  123849. * @hidden
  123850. * Defines the actions happening before evaluate active mesh checks.
  123851. */
  123852. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  123853. /**
  123854. * @hidden
  123855. * Defines the actions happening during the evaluate sub mesh checks.
  123856. */
  123857. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  123858. /**
  123859. * @hidden
  123860. * Defines the actions happening during the active mesh stage.
  123861. */
  123862. _activeMeshStage: Stage<ActiveMeshStageAction>;
  123863. /**
  123864. * @hidden
  123865. * Defines the actions happening during the per camera render target step.
  123866. */
  123867. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  123868. /**
  123869. * @hidden
  123870. * Defines the actions happening just before the active camera is drawing.
  123871. */
  123872. _beforeCameraDrawStage: Stage<CameraStageAction>;
  123873. /**
  123874. * @hidden
  123875. * Defines the actions happening just before a render target is drawing.
  123876. */
  123877. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123878. /**
  123879. * @hidden
  123880. * Defines the actions happening just before a rendering group is drawing.
  123881. */
  123882. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123883. /**
  123884. * @hidden
  123885. * Defines the actions happening just before a mesh is drawing.
  123886. */
  123887. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  123888. /**
  123889. * @hidden
  123890. * Defines the actions happening just after a mesh has been drawn.
  123891. */
  123892. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  123893. /**
  123894. * @hidden
  123895. * Defines the actions happening just after a rendering group has been drawn.
  123896. */
  123897. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123898. /**
  123899. * @hidden
  123900. * Defines the actions happening just after the active camera has been drawn.
  123901. */
  123902. _afterCameraDrawStage: Stage<CameraStageAction>;
  123903. /**
  123904. * @hidden
  123905. * Defines the actions happening just after a render target has been drawn.
  123906. */
  123907. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123908. /**
  123909. * @hidden
  123910. * Defines the actions happening just after rendering all cameras and computing intersections.
  123911. */
  123912. _afterRenderStage: Stage<SimpleStageAction>;
  123913. /**
  123914. * @hidden
  123915. * Defines the actions happening when a pointer move event happens.
  123916. */
  123917. _pointerMoveStage: Stage<PointerMoveStageAction>;
  123918. /**
  123919. * @hidden
  123920. * Defines the actions happening when a pointer down event happens.
  123921. */
  123922. _pointerDownStage: Stage<PointerUpDownStageAction>;
  123923. /**
  123924. * @hidden
  123925. * Defines the actions happening when a pointer up event happens.
  123926. */
  123927. _pointerUpStage: Stage<PointerUpDownStageAction>;
  123928. /**
  123929. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  123930. */
  123931. private geometriesByUniqueId;
  123932. /**
  123933. * Creates a new Scene
  123934. * @param engine defines the engine to use to render this scene
  123935. * @param options defines the scene options
  123936. */
  123937. constructor(engine: Engine, options?: SceneOptions);
  123938. /**
  123939. * Gets a string identifying the name of the class
  123940. * @returns "Scene" string
  123941. */
  123942. getClassName(): string;
  123943. private _defaultMeshCandidates;
  123944. /**
  123945. * @hidden
  123946. */
  123947. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  123948. private _defaultSubMeshCandidates;
  123949. /**
  123950. * @hidden
  123951. */
  123952. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  123953. /**
  123954. * Sets the default candidate providers for the scene.
  123955. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  123956. * and getCollidingSubMeshCandidates to their default function
  123957. */
  123958. setDefaultCandidateProviders(): void;
  123959. /**
  123960. * Gets the mesh that is currently under the pointer
  123961. */
  123962. get meshUnderPointer(): Nullable<AbstractMesh>;
  123963. /**
  123964. * Gets or sets the current on-screen X position of the pointer
  123965. */
  123966. get pointerX(): number;
  123967. set pointerX(value: number);
  123968. /**
  123969. * Gets or sets the current on-screen Y position of the pointer
  123970. */
  123971. get pointerY(): number;
  123972. set pointerY(value: number);
  123973. /**
  123974. * Gets the cached material (ie. the latest rendered one)
  123975. * @returns the cached material
  123976. */
  123977. getCachedMaterial(): Nullable<Material>;
  123978. /**
  123979. * Gets the cached effect (ie. the latest rendered one)
  123980. * @returns the cached effect
  123981. */
  123982. getCachedEffect(): Nullable<Effect>;
  123983. /**
  123984. * Gets the cached visibility state (ie. the latest rendered one)
  123985. * @returns the cached visibility state
  123986. */
  123987. getCachedVisibility(): Nullable<number>;
  123988. /**
  123989. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  123990. * @param material defines the current material
  123991. * @param effect defines the current effect
  123992. * @param visibility defines the current visibility state
  123993. * @returns true if one parameter is not cached
  123994. */
  123995. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  123996. /**
  123997. * Gets the engine associated with the scene
  123998. * @returns an Engine
  123999. */
  124000. getEngine(): Engine;
  124001. /**
  124002. * Gets the total number of vertices rendered per frame
  124003. * @returns the total number of vertices rendered per frame
  124004. */
  124005. getTotalVertices(): number;
  124006. /**
  124007. * Gets the performance counter for total vertices
  124008. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124009. */
  124010. get totalVerticesPerfCounter(): PerfCounter;
  124011. /**
  124012. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  124013. * @returns the total number of active indices rendered per frame
  124014. */
  124015. getActiveIndices(): number;
  124016. /**
  124017. * Gets the performance counter for active indices
  124018. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124019. */
  124020. get totalActiveIndicesPerfCounter(): PerfCounter;
  124021. /**
  124022. * Gets the total number of active particles rendered per frame
  124023. * @returns the total number of active particles rendered per frame
  124024. */
  124025. getActiveParticles(): number;
  124026. /**
  124027. * Gets the performance counter for active particles
  124028. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124029. */
  124030. get activeParticlesPerfCounter(): PerfCounter;
  124031. /**
  124032. * Gets the total number of active bones rendered per frame
  124033. * @returns the total number of active bones rendered per frame
  124034. */
  124035. getActiveBones(): number;
  124036. /**
  124037. * Gets the performance counter for active bones
  124038. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124039. */
  124040. get activeBonesPerfCounter(): PerfCounter;
  124041. /**
  124042. * Gets the array of active meshes
  124043. * @returns an array of AbstractMesh
  124044. */
  124045. getActiveMeshes(): SmartArray<AbstractMesh>;
  124046. /**
  124047. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  124048. * @returns a number
  124049. */
  124050. getAnimationRatio(): number;
  124051. /**
  124052. * Gets an unique Id for the current render phase
  124053. * @returns a number
  124054. */
  124055. getRenderId(): number;
  124056. /**
  124057. * Gets an unique Id for the current frame
  124058. * @returns a number
  124059. */
  124060. getFrameId(): number;
  124061. /** Call this function if you want to manually increment the render Id*/
  124062. incrementRenderId(): void;
  124063. private _createUbo;
  124064. /**
  124065. * Use this method to simulate a pointer move on a mesh
  124066. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124067. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124068. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124069. * @returns the current scene
  124070. */
  124071. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124072. /**
  124073. * Use this method to simulate a pointer down on a mesh
  124074. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124075. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124076. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124077. * @returns the current scene
  124078. */
  124079. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124080. /**
  124081. * Use this method to simulate a pointer up on a mesh
  124082. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124083. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124084. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124085. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124086. * @returns the current scene
  124087. */
  124088. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  124089. /**
  124090. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124091. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124092. * @returns true if the pointer was captured
  124093. */
  124094. isPointerCaptured(pointerId?: number): boolean;
  124095. /**
  124096. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124097. * @param attachUp defines if you want to attach events to pointerup
  124098. * @param attachDown defines if you want to attach events to pointerdown
  124099. * @param attachMove defines if you want to attach events to pointermove
  124100. */
  124101. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  124102. /** Detaches all event handlers*/
  124103. detachControl(): void;
  124104. /**
  124105. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  124106. * Delay loaded resources are not taking in account
  124107. * @return true if all required resources are ready
  124108. */
  124109. isReady(): boolean;
  124110. /** Resets all cached information relative to material (including effect and visibility) */
  124111. resetCachedMaterial(): void;
  124112. /**
  124113. * Registers a function to be called before every frame render
  124114. * @param func defines the function to register
  124115. */
  124116. registerBeforeRender(func: () => void): void;
  124117. /**
  124118. * Unregisters a function called before every frame render
  124119. * @param func defines the function to unregister
  124120. */
  124121. unregisterBeforeRender(func: () => void): void;
  124122. /**
  124123. * Registers a function to be called after every frame render
  124124. * @param func defines the function to register
  124125. */
  124126. registerAfterRender(func: () => void): void;
  124127. /**
  124128. * Unregisters a function called after every frame render
  124129. * @param func defines the function to unregister
  124130. */
  124131. unregisterAfterRender(func: () => void): void;
  124132. private _executeOnceBeforeRender;
  124133. /**
  124134. * The provided function will run before render once and will be disposed afterwards.
  124135. * A timeout delay can be provided so that the function will be executed in N ms.
  124136. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  124137. * @param func The function to be executed.
  124138. * @param timeout optional delay in ms
  124139. */
  124140. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  124141. /** @hidden */
  124142. _addPendingData(data: any): void;
  124143. /** @hidden */
  124144. _removePendingData(data: any): void;
  124145. /**
  124146. * Returns the number of items waiting to be loaded
  124147. * @returns the number of items waiting to be loaded
  124148. */
  124149. getWaitingItemsCount(): number;
  124150. /**
  124151. * Returns a boolean indicating if the scene is still loading data
  124152. */
  124153. get isLoading(): boolean;
  124154. /**
  124155. * Registers a function to be executed when the scene is ready
  124156. * @param {Function} func - the function to be executed
  124157. */
  124158. executeWhenReady(func: () => void): void;
  124159. /**
  124160. * Returns a promise that resolves when the scene is ready
  124161. * @returns A promise that resolves when the scene is ready
  124162. */
  124163. whenReadyAsync(): Promise<void>;
  124164. /** @hidden */
  124165. _checkIsReady(): void;
  124166. /**
  124167. * Gets all animatable attached to the scene
  124168. */
  124169. get animatables(): Animatable[];
  124170. /**
  124171. * Resets the last animation time frame.
  124172. * Useful to override when animations start running when loading a scene for the first time.
  124173. */
  124174. resetLastAnimationTimeFrame(): void;
  124175. /**
  124176. * Gets the current view matrix
  124177. * @returns a Matrix
  124178. */
  124179. getViewMatrix(): Matrix;
  124180. /**
  124181. * Gets the current projection matrix
  124182. * @returns a Matrix
  124183. */
  124184. getProjectionMatrix(): Matrix;
  124185. /**
  124186. * Gets the current transform matrix
  124187. * @returns a Matrix made of View * Projection
  124188. */
  124189. getTransformMatrix(): Matrix;
  124190. /**
  124191. * Sets the current transform matrix
  124192. * @param viewL defines the View matrix to use
  124193. * @param projectionL defines the Projection matrix to use
  124194. * @param viewR defines the right View matrix to use (if provided)
  124195. * @param projectionR defines the right Projection matrix to use (if provided)
  124196. */
  124197. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124198. /**
  124199. * Gets the uniform buffer used to store scene data
  124200. * @returns a UniformBuffer
  124201. */
  124202. getSceneUniformBuffer(): UniformBuffer;
  124203. /**
  124204. * Gets an unique (relatively to the current scene) Id
  124205. * @returns an unique number for the scene
  124206. */
  124207. getUniqueId(): number;
  124208. /**
  124209. * Add a mesh to the list of scene's meshes
  124210. * @param newMesh defines the mesh to add
  124211. * @param recursive if all child meshes should also be added to the scene
  124212. */
  124213. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124214. /**
  124215. * Remove a mesh for the list of scene's meshes
  124216. * @param toRemove defines the mesh to remove
  124217. * @param recursive if all child meshes should also be removed from the scene
  124218. * @returns the index where the mesh was in the mesh list
  124219. */
  124220. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124221. /**
  124222. * Add a transform node to the list of scene's transform nodes
  124223. * @param newTransformNode defines the transform node to add
  124224. */
  124225. addTransformNode(newTransformNode: TransformNode): void;
  124226. /**
  124227. * Remove a transform node for the list of scene's transform nodes
  124228. * @param toRemove defines the transform node to remove
  124229. * @returns the index where the transform node was in the transform node list
  124230. */
  124231. removeTransformNode(toRemove: TransformNode): number;
  124232. /**
  124233. * Remove a skeleton for the list of scene's skeletons
  124234. * @param toRemove defines the skeleton to remove
  124235. * @returns the index where the skeleton was in the skeleton list
  124236. */
  124237. removeSkeleton(toRemove: Skeleton): number;
  124238. /**
  124239. * Remove a morph target for the list of scene's morph targets
  124240. * @param toRemove defines the morph target to remove
  124241. * @returns the index where the morph target was in the morph target list
  124242. */
  124243. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  124244. /**
  124245. * Remove a light for the list of scene's lights
  124246. * @param toRemove defines the light to remove
  124247. * @returns the index where the light was in the light list
  124248. */
  124249. removeLight(toRemove: Light): number;
  124250. /**
  124251. * Remove a camera for the list of scene's cameras
  124252. * @param toRemove defines the camera to remove
  124253. * @returns the index where the camera was in the camera list
  124254. */
  124255. removeCamera(toRemove: Camera): number;
  124256. /**
  124257. * Remove a particle system for the list of scene's particle systems
  124258. * @param toRemove defines the particle system to remove
  124259. * @returns the index where the particle system was in the particle system list
  124260. */
  124261. removeParticleSystem(toRemove: IParticleSystem): number;
  124262. /**
  124263. * Remove a animation for the list of scene's animations
  124264. * @param toRemove defines the animation to remove
  124265. * @returns the index where the animation was in the animation list
  124266. */
  124267. removeAnimation(toRemove: Animation): number;
  124268. /**
  124269. * Will stop the animation of the given target
  124270. * @param target - the target
  124271. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  124272. * @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)
  124273. */
  124274. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  124275. /**
  124276. * Removes the given animation group from this scene.
  124277. * @param toRemove The animation group to remove
  124278. * @returns The index of the removed animation group
  124279. */
  124280. removeAnimationGroup(toRemove: AnimationGroup): number;
  124281. /**
  124282. * Removes the given multi-material from this scene.
  124283. * @param toRemove The multi-material to remove
  124284. * @returns The index of the removed multi-material
  124285. */
  124286. removeMultiMaterial(toRemove: MultiMaterial): number;
  124287. /**
  124288. * Removes the given material from this scene.
  124289. * @param toRemove The material to remove
  124290. * @returns The index of the removed material
  124291. */
  124292. removeMaterial(toRemove: Material): number;
  124293. /**
  124294. * Removes the given action manager from this scene.
  124295. * @param toRemove The action manager to remove
  124296. * @returns The index of the removed action manager
  124297. */
  124298. removeActionManager(toRemove: AbstractActionManager): number;
  124299. /**
  124300. * Removes the given texture from this scene.
  124301. * @param toRemove The texture to remove
  124302. * @returns The index of the removed texture
  124303. */
  124304. removeTexture(toRemove: BaseTexture): number;
  124305. /**
  124306. * Adds the given light to this scene
  124307. * @param newLight The light to add
  124308. */
  124309. addLight(newLight: Light): void;
  124310. /**
  124311. * Sorts the list list based on light priorities
  124312. */
  124313. sortLightsByPriority(): void;
  124314. /**
  124315. * Adds the given camera to this scene
  124316. * @param newCamera The camera to add
  124317. */
  124318. addCamera(newCamera: Camera): void;
  124319. /**
  124320. * Adds the given skeleton to this scene
  124321. * @param newSkeleton The skeleton to add
  124322. */
  124323. addSkeleton(newSkeleton: Skeleton): void;
  124324. /**
  124325. * Adds the given particle system to this scene
  124326. * @param newParticleSystem The particle system to add
  124327. */
  124328. addParticleSystem(newParticleSystem: IParticleSystem): void;
  124329. /**
  124330. * Adds the given animation to this scene
  124331. * @param newAnimation The animation to add
  124332. */
  124333. addAnimation(newAnimation: Animation): void;
  124334. /**
  124335. * Adds the given animation group to this scene.
  124336. * @param newAnimationGroup The animation group to add
  124337. */
  124338. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  124339. /**
  124340. * Adds the given multi-material to this scene
  124341. * @param newMultiMaterial The multi-material to add
  124342. */
  124343. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  124344. /**
  124345. * Adds the given material to this scene
  124346. * @param newMaterial The material to add
  124347. */
  124348. addMaterial(newMaterial: Material): void;
  124349. /**
  124350. * Adds the given morph target to this scene
  124351. * @param newMorphTargetManager The morph target to add
  124352. */
  124353. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  124354. /**
  124355. * Adds the given geometry to this scene
  124356. * @param newGeometry The geometry to add
  124357. */
  124358. addGeometry(newGeometry: Geometry): void;
  124359. /**
  124360. * Adds the given action manager to this scene
  124361. * @param newActionManager The action manager to add
  124362. */
  124363. addActionManager(newActionManager: AbstractActionManager): void;
  124364. /**
  124365. * Adds the given texture to this scene.
  124366. * @param newTexture The texture to add
  124367. */
  124368. addTexture(newTexture: BaseTexture): void;
  124369. /**
  124370. * Switch active camera
  124371. * @param newCamera defines the new active camera
  124372. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  124373. */
  124374. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  124375. /**
  124376. * sets the active camera of the scene using its ID
  124377. * @param id defines the camera's ID
  124378. * @return the new active camera or null if none found.
  124379. */
  124380. setActiveCameraByID(id: string): Nullable<Camera>;
  124381. /**
  124382. * sets the active camera of the scene using its name
  124383. * @param name defines the camera's name
  124384. * @returns the new active camera or null if none found.
  124385. */
  124386. setActiveCameraByName(name: string): Nullable<Camera>;
  124387. /**
  124388. * get an animation group using its name
  124389. * @param name defines the material's name
  124390. * @return the animation group or null if none found.
  124391. */
  124392. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  124393. /**
  124394. * Get a material using its unique id
  124395. * @param uniqueId defines the material's unique id
  124396. * @return the material or null if none found.
  124397. */
  124398. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  124399. /**
  124400. * get a material using its id
  124401. * @param id defines the material's ID
  124402. * @return the material or null if none found.
  124403. */
  124404. getMaterialByID(id: string): Nullable<Material>;
  124405. /**
  124406. * Gets a the last added material using a given id
  124407. * @param id defines the material's ID
  124408. * @return the last material with the given id or null if none found.
  124409. */
  124410. getLastMaterialByID(id: string): Nullable<Material>;
  124411. /**
  124412. * Gets a material using its name
  124413. * @param name defines the material's name
  124414. * @return the material or null if none found.
  124415. */
  124416. getMaterialByName(name: string): Nullable<Material>;
  124417. /**
  124418. * Get a texture using its unique id
  124419. * @param uniqueId defines the texture's unique id
  124420. * @return the texture or null if none found.
  124421. */
  124422. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  124423. /**
  124424. * Gets a camera using its id
  124425. * @param id defines the id to look for
  124426. * @returns the camera or null if not found
  124427. */
  124428. getCameraByID(id: string): Nullable<Camera>;
  124429. /**
  124430. * Gets a camera using its unique id
  124431. * @param uniqueId defines the unique id to look for
  124432. * @returns the camera or null if not found
  124433. */
  124434. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  124435. /**
  124436. * Gets a camera using its name
  124437. * @param name defines the camera's name
  124438. * @return the camera or null if none found.
  124439. */
  124440. getCameraByName(name: string): Nullable<Camera>;
  124441. /**
  124442. * Gets a bone using its id
  124443. * @param id defines the bone's id
  124444. * @return the bone or null if not found
  124445. */
  124446. getBoneByID(id: string): Nullable<Bone>;
  124447. /**
  124448. * Gets a bone using its id
  124449. * @param name defines the bone's name
  124450. * @return the bone or null if not found
  124451. */
  124452. getBoneByName(name: string): Nullable<Bone>;
  124453. /**
  124454. * Gets a light node using its name
  124455. * @param name defines the the light's name
  124456. * @return the light or null if none found.
  124457. */
  124458. getLightByName(name: string): Nullable<Light>;
  124459. /**
  124460. * Gets a light node using its id
  124461. * @param id defines the light's id
  124462. * @return the light or null if none found.
  124463. */
  124464. getLightByID(id: string): Nullable<Light>;
  124465. /**
  124466. * Gets a light node using its scene-generated unique ID
  124467. * @param uniqueId defines the light's unique id
  124468. * @return the light or null if none found.
  124469. */
  124470. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  124471. /**
  124472. * Gets a particle system by id
  124473. * @param id defines the particle system id
  124474. * @return the corresponding system or null if none found
  124475. */
  124476. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  124477. /**
  124478. * Gets a geometry using its ID
  124479. * @param id defines the geometry's id
  124480. * @return the geometry or null if none found.
  124481. */
  124482. getGeometryByID(id: string): Nullable<Geometry>;
  124483. private _getGeometryByUniqueID;
  124484. /**
  124485. * Add a new geometry to this scene
  124486. * @param geometry defines the geometry to be added to the scene.
  124487. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  124488. * @return a boolean defining if the geometry was added or not
  124489. */
  124490. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  124491. /**
  124492. * Removes an existing geometry
  124493. * @param geometry defines the geometry to be removed from the scene
  124494. * @return a boolean defining if the geometry was removed or not
  124495. */
  124496. removeGeometry(geometry: Geometry): boolean;
  124497. /**
  124498. * Gets the list of geometries attached to the scene
  124499. * @returns an array of Geometry
  124500. */
  124501. getGeometries(): Geometry[];
  124502. /**
  124503. * Gets the first added mesh found of a given ID
  124504. * @param id defines the id to search for
  124505. * @return the mesh found or null if not found at all
  124506. */
  124507. getMeshByID(id: string): Nullable<AbstractMesh>;
  124508. /**
  124509. * Gets a list of meshes using their id
  124510. * @param id defines the id to search for
  124511. * @returns a list of meshes
  124512. */
  124513. getMeshesByID(id: string): Array<AbstractMesh>;
  124514. /**
  124515. * Gets the first added transform node found of a given ID
  124516. * @param id defines the id to search for
  124517. * @return the found transform node or null if not found at all.
  124518. */
  124519. getTransformNodeByID(id: string): Nullable<TransformNode>;
  124520. /**
  124521. * Gets a transform node with its auto-generated unique id
  124522. * @param uniqueId efines the unique id to search for
  124523. * @return the found transform node or null if not found at all.
  124524. */
  124525. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  124526. /**
  124527. * Gets a list of transform nodes using their id
  124528. * @param id defines the id to search for
  124529. * @returns a list of transform nodes
  124530. */
  124531. getTransformNodesByID(id: string): Array<TransformNode>;
  124532. /**
  124533. * Gets a mesh with its auto-generated unique id
  124534. * @param uniqueId defines the unique id to search for
  124535. * @return the found mesh or null if not found at all.
  124536. */
  124537. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  124538. /**
  124539. * Gets a the last added mesh using a given id
  124540. * @param id defines the id to search for
  124541. * @return the found mesh or null if not found at all.
  124542. */
  124543. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  124544. /**
  124545. * Gets a the last added node (Mesh, Camera, Light) using a given id
  124546. * @param id defines the id to search for
  124547. * @return the found node or null if not found at all
  124548. */
  124549. getLastEntryByID(id: string): Nullable<Node>;
  124550. /**
  124551. * Gets a node (Mesh, Camera, Light) using a given id
  124552. * @param id defines the id to search for
  124553. * @return the found node or null if not found at all
  124554. */
  124555. getNodeByID(id: string): Nullable<Node>;
  124556. /**
  124557. * Gets a node (Mesh, Camera, Light) using a given name
  124558. * @param name defines the name to search for
  124559. * @return the found node or null if not found at all.
  124560. */
  124561. getNodeByName(name: string): Nullable<Node>;
  124562. /**
  124563. * Gets a mesh using a given name
  124564. * @param name defines the name to search for
  124565. * @return the found mesh or null if not found at all.
  124566. */
  124567. getMeshByName(name: string): Nullable<AbstractMesh>;
  124568. /**
  124569. * Gets a transform node using a given name
  124570. * @param name defines the name to search for
  124571. * @return the found transform node or null if not found at all.
  124572. */
  124573. getTransformNodeByName(name: string): Nullable<TransformNode>;
  124574. /**
  124575. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  124576. * @param id defines the id to search for
  124577. * @return the found skeleton or null if not found at all.
  124578. */
  124579. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  124580. /**
  124581. * Gets a skeleton using a given auto generated unique id
  124582. * @param uniqueId defines the unique id to search for
  124583. * @return the found skeleton or null if not found at all.
  124584. */
  124585. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  124586. /**
  124587. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  124588. * @param id defines the id to search for
  124589. * @return the found skeleton or null if not found at all.
  124590. */
  124591. getSkeletonById(id: string): Nullable<Skeleton>;
  124592. /**
  124593. * Gets a skeleton using a given name
  124594. * @param name defines the name to search for
  124595. * @return the found skeleton or null if not found at all.
  124596. */
  124597. getSkeletonByName(name: string): Nullable<Skeleton>;
  124598. /**
  124599. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  124600. * @param id defines the id to search for
  124601. * @return the found morph target manager or null if not found at all.
  124602. */
  124603. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  124604. /**
  124605. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  124606. * @param id defines the id to search for
  124607. * @return the found morph target or null if not found at all.
  124608. */
  124609. getMorphTargetById(id: string): Nullable<MorphTarget>;
  124610. /**
  124611. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  124612. * @param name defines the name to search for
  124613. * @return the found morph target or null if not found at all.
  124614. */
  124615. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  124616. /**
  124617. * Gets a post process using a given name (if many are found, this function will pick the first one)
  124618. * @param name defines the name to search for
  124619. * @return the found post process or null if not found at all.
  124620. */
  124621. getPostProcessByName(name: string): Nullable<PostProcess>;
  124622. /**
  124623. * Gets a boolean indicating if the given mesh is active
  124624. * @param mesh defines the mesh to look for
  124625. * @returns true if the mesh is in the active list
  124626. */
  124627. isActiveMesh(mesh: AbstractMesh): boolean;
  124628. /**
  124629. * Return a unique id as a string which can serve as an identifier for the scene
  124630. */
  124631. get uid(): string;
  124632. /**
  124633. * Add an externaly attached data from its key.
  124634. * This method call will fail and return false, if such key already exists.
  124635. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  124636. * @param key the unique key that identifies the data
  124637. * @param data the data object to associate to the key for this Engine instance
  124638. * @return true if no such key were already present and the data was added successfully, false otherwise
  124639. */
  124640. addExternalData<T>(key: string, data: T): boolean;
  124641. /**
  124642. * Get an externaly attached data from its key
  124643. * @param key the unique key that identifies the data
  124644. * @return the associated data, if present (can be null), or undefined if not present
  124645. */
  124646. getExternalData<T>(key: string): Nullable<T>;
  124647. /**
  124648. * Get an externaly attached data from its key, create it using a factory if it's not already present
  124649. * @param key the unique key that identifies the data
  124650. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  124651. * @return the associated data, can be null if the factory returned null.
  124652. */
  124653. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  124654. /**
  124655. * Remove an externaly attached data from the Engine instance
  124656. * @param key the unique key that identifies the data
  124657. * @return true if the data was successfully removed, false if it doesn't exist
  124658. */
  124659. removeExternalData(key: string): boolean;
  124660. private _evaluateSubMesh;
  124661. /**
  124662. * Clear the processed materials smart array preventing retention point in material dispose.
  124663. */
  124664. freeProcessedMaterials(): void;
  124665. private _preventFreeActiveMeshesAndRenderingGroups;
  124666. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  124667. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  124668. * when disposing several meshes in a row or a hierarchy of meshes.
  124669. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  124670. */
  124671. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  124672. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  124673. /**
  124674. * Clear the active meshes smart array preventing retention point in mesh dispose.
  124675. */
  124676. freeActiveMeshes(): void;
  124677. /**
  124678. * Clear the info related to rendering groups preventing retention points during dispose.
  124679. */
  124680. freeRenderingGroups(): void;
  124681. /** @hidden */
  124682. _isInIntermediateRendering(): boolean;
  124683. /**
  124684. * Lambda returning the list of potentially active meshes.
  124685. */
  124686. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  124687. /**
  124688. * Lambda returning the list of potentially active sub meshes.
  124689. */
  124690. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  124691. /**
  124692. * Lambda returning the list of potentially intersecting sub meshes.
  124693. */
  124694. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  124695. /**
  124696. * Lambda returning the list of potentially colliding sub meshes.
  124697. */
  124698. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  124699. private _activeMeshesFrozen;
  124700. private _skipEvaluateActiveMeshesCompletely;
  124701. /**
  124702. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  124703. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  124704. * @param onSuccess optional success callback
  124705. * @param onError optional error callback
  124706. * @returns the current scene
  124707. */
  124708. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  124709. /**
  124710. * Use this function to restart evaluating active meshes on every frame
  124711. * @returns the current scene
  124712. */
  124713. unfreezeActiveMeshes(): Scene;
  124714. private _evaluateActiveMeshes;
  124715. private _activeMesh;
  124716. /**
  124717. * Update the transform matrix to update from the current active camera
  124718. * @param force defines a boolean used to force the update even if cache is up to date
  124719. */
  124720. updateTransformMatrix(force?: boolean): void;
  124721. private _bindFrameBuffer;
  124722. /** @hidden */
  124723. _allowPostProcessClearColor: boolean;
  124724. /** @hidden */
  124725. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  124726. private _processSubCameras;
  124727. private _checkIntersections;
  124728. /** @hidden */
  124729. _advancePhysicsEngineStep(step: number): void;
  124730. /**
  124731. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  124732. */
  124733. getDeterministicFrameTime: () => number;
  124734. /** @hidden */
  124735. _animate(): void;
  124736. /** Execute all animations (for a frame) */
  124737. animate(): void;
  124738. /**
  124739. * Render the scene
  124740. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  124741. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  124742. */
  124743. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  124744. /**
  124745. * Freeze all materials
  124746. * A frozen material will not be updatable but should be faster to render
  124747. */
  124748. freezeMaterials(): void;
  124749. /**
  124750. * Unfreeze all materials
  124751. * A frozen material will not be updatable but should be faster to render
  124752. */
  124753. unfreezeMaterials(): void;
  124754. /**
  124755. * Releases all held ressources
  124756. */
  124757. dispose(): void;
  124758. /**
  124759. * Gets if the scene is already disposed
  124760. */
  124761. get isDisposed(): boolean;
  124762. /**
  124763. * Call this function to reduce memory footprint of the scene.
  124764. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  124765. */
  124766. clearCachedVertexData(): void;
  124767. /**
  124768. * This function will remove the local cached buffer data from texture.
  124769. * It will save memory but will prevent the texture from being rebuilt
  124770. */
  124771. cleanCachedTextureBuffer(): void;
  124772. /**
  124773. * Get the world extend vectors with an optional filter
  124774. *
  124775. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  124776. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  124777. */
  124778. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  124779. min: Vector3;
  124780. max: Vector3;
  124781. };
  124782. /**
  124783. * Creates a ray that can be used to pick in the scene
  124784. * @param x defines the x coordinate of the origin (on-screen)
  124785. * @param y defines the y coordinate of the origin (on-screen)
  124786. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124787. * @param camera defines the camera to use for the picking
  124788. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124789. * @returns a Ray
  124790. */
  124791. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  124792. /**
  124793. * Creates a ray that can be used to pick in the scene
  124794. * @param x defines the x coordinate of the origin (on-screen)
  124795. * @param y defines the y coordinate of the origin (on-screen)
  124796. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124797. * @param result defines the ray where to store the picking ray
  124798. * @param camera defines the camera to use for the picking
  124799. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124800. * @returns the current scene
  124801. */
  124802. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  124803. /**
  124804. * Creates a ray that can be used to pick in the scene
  124805. * @param x defines the x coordinate of the origin (on-screen)
  124806. * @param y defines the y coordinate of the origin (on-screen)
  124807. * @param camera defines the camera to use for the picking
  124808. * @returns a Ray
  124809. */
  124810. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  124811. /**
  124812. * Creates a ray that can be used to pick in the scene
  124813. * @param x defines the x coordinate of the origin (on-screen)
  124814. * @param y defines the y coordinate of the origin (on-screen)
  124815. * @param result defines the ray where to store the picking ray
  124816. * @param camera defines the camera to use for the picking
  124817. * @returns the current scene
  124818. */
  124819. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  124820. /** Launch a ray to try to pick a mesh in the scene
  124821. * @param x position on screen
  124822. * @param y position on screen
  124823. * @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
  124824. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124825. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124826. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124827. * @returns a PickingInfo
  124828. */
  124829. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124830. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  124831. * @param x position on screen
  124832. * @param y position on screen
  124833. * @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
  124834. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124835. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124836. * @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)
  124837. */
  124838. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  124839. /** Use the given ray to pick a mesh in the scene
  124840. * @param ray The ray to use to pick meshes
  124841. * @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
  124842. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124843. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124844. * @returns a PickingInfo
  124845. */
  124846. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124847. /**
  124848. * Launch a ray to try to pick a mesh in the scene
  124849. * @param x X position on screen
  124850. * @param y Y position on screen
  124851. * @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
  124852. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124854. * @returns an array of PickingInfo
  124855. */
  124856. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124857. /**
  124858. * Launch a ray to try to pick a mesh in the scene
  124859. * @param ray Ray to use
  124860. * @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
  124861. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124862. * @returns an array of PickingInfo
  124863. */
  124864. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124865. /**
  124866. * Force the value of meshUnderPointer
  124867. * @param mesh defines the mesh to use
  124868. * @param pointerId optional pointer id when using more than one pointer
  124869. */
  124870. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  124871. /**
  124872. * Gets the mesh under the pointer
  124873. * @returns a Mesh or null if no mesh is under the pointer
  124874. */
  124875. getPointerOverMesh(): Nullable<AbstractMesh>;
  124876. /** @hidden */
  124877. _rebuildGeometries(): void;
  124878. /** @hidden */
  124879. _rebuildTextures(): void;
  124880. private _getByTags;
  124881. /**
  124882. * Get a list of meshes by tags
  124883. * @param tagsQuery defines the tags query to use
  124884. * @param forEach defines a predicate used to filter results
  124885. * @returns an array of Mesh
  124886. */
  124887. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  124888. /**
  124889. * Get a list of cameras by tags
  124890. * @param tagsQuery defines the tags query to use
  124891. * @param forEach defines a predicate used to filter results
  124892. * @returns an array of Camera
  124893. */
  124894. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  124895. /**
  124896. * Get a list of lights by tags
  124897. * @param tagsQuery defines the tags query to use
  124898. * @param forEach defines a predicate used to filter results
  124899. * @returns an array of Light
  124900. */
  124901. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  124902. /**
  124903. * Get a list of materials by tags
  124904. * @param tagsQuery defines the tags query to use
  124905. * @param forEach defines a predicate used to filter results
  124906. * @returns an array of Material
  124907. */
  124908. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  124909. /**
  124910. * Get a list of transform nodes by tags
  124911. * @param tagsQuery defines the tags query to use
  124912. * @param forEach defines a predicate used to filter results
  124913. * @returns an array of TransformNode
  124914. */
  124915. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  124916. /**
  124917. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  124918. * This allowed control for front to back rendering or reversly depending of the special needs.
  124919. *
  124920. * @param renderingGroupId The rendering group id corresponding to its index
  124921. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  124922. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  124923. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  124924. */
  124925. 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;
  124926. /**
  124927. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  124928. *
  124929. * @param renderingGroupId The rendering group id corresponding to its index
  124930. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124931. * @param depth Automatically clears depth between groups if true and autoClear is true.
  124932. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  124933. */
  124934. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  124935. /**
  124936. * Gets the current auto clear configuration for one rendering group of the rendering
  124937. * manager.
  124938. * @param index the rendering group index to get the information for
  124939. * @returns The auto clear setup for the requested rendering group
  124940. */
  124941. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  124942. private _blockMaterialDirtyMechanism;
  124943. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  124944. get blockMaterialDirtyMechanism(): boolean;
  124945. set blockMaterialDirtyMechanism(value: boolean);
  124946. /**
  124947. * Will flag all materials as dirty to trigger new shader compilation
  124948. * @param flag defines the flag used to specify which material part must be marked as dirty
  124949. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  124950. */
  124951. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  124952. /** @hidden */
  124953. _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;
  124954. /** @hidden */
  124955. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  124956. /** @hidden */
  124957. _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;
  124958. /** @hidden */
  124959. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  124960. /** @hidden */
  124961. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  124962. /** @hidden */
  124963. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  124964. }
  124965. }
  124966. declare module BABYLON {
  124967. /**
  124968. * Set of assets to keep when moving a scene into an asset container.
  124969. */
  124970. export class KeepAssets extends AbstractScene {
  124971. }
  124972. /**
  124973. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  124974. */
  124975. export class InstantiatedEntries {
  124976. /**
  124977. * List of new root nodes (eg. nodes with no parent)
  124978. */
  124979. rootNodes: TransformNode[];
  124980. /**
  124981. * List of new skeletons
  124982. */
  124983. skeletons: Skeleton[];
  124984. /**
  124985. * List of new animation groups
  124986. */
  124987. animationGroups: AnimationGroup[];
  124988. }
  124989. /**
  124990. * Container with a set of assets that can be added or removed from a scene.
  124991. */
  124992. export class AssetContainer extends AbstractScene {
  124993. private _wasAddedToScene;
  124994. /**
  124995. * The scene the AssetContainer belongs to.
  124996. */
  124997. scene: Scene;
  124998. /**
  124999. * Instantiates an AssetContainer.
  125000. * @param scene The scene the AssetContainer belongs to.
  125001. */
  125002. constructor(scene: Scene);
  125003. /**
  125004. * Instantiate or clone all meshes and add the new ones to the scene.
  125005. * Skeletons and animation groups will all be cloned
  125006. * @param nameFunction defines an optional function used to get new names for clones
  125007. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  125008. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  125009. */
  125010. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  125011. /**
  125012. * Adds all the assets from the container to the scene.
  125013. */
  125014. addAllToScene(): void;
  125015. /**
  125016. * Removes all the assets in the container from the scene
  125017. */
  125018. removeAllFromScene(): void;
  125019. /**
  125020. * Disposes all the assets in the container
  125021. */
  125022. dispose(): void;
  125023. private _moveAssets;
  125024. /**
  125025. * Removes all the assets contained in the scene and adds them to the container.
  125026. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125027. */
  125028. moveAllFromScene(keepAssets?: KeepAssets): void;
  125029. /**
  125030. * 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.
  125031. * @returns the root mesh
  125032. */
  125033. createRootMesh(): Mesh;
  125034. /**
  125035. * Merge animations (direct and animation groups) from this asset container into a scene
  125036. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125037. * @param animatables set of animatables to retarget to a node from the scene
  125038. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  125039. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  125040. */
  125041. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  125042. }
  125043. }
  125044. declare module BABYLON {
  125045. /**
  125046. * Defines how the parser contract is defined.
  125047. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  125048. */
  125049. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  125050. /**
  125051. * Defines how the individual parser contract is defined.
  125052. * These parser can parse an individual asset
  125053. */
  125054. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  125055. /**
  125056. * Base class of the scene acting as a container for the different elements composing a scene.
  125057. * This class is dynamically extended by the different components of the scene increasing
  125058. * flexibility and reducing coupling
  125059. */
  125060. export abstract class AbstractScene {
  125061. /**
  125062. * Stores the list of available parsers in the application.
  125063. */
  125064. private static _BabylonFileParsers;
  125065. /**
  125066. * Stores the list of available individual parsers in the application.
  125067. */
  125068. private static _IndividualBabylonFileParsers;
  125069. /**
  125070. * Adds a parser in the list of available ones
  125071. * @param name Defines the name of the parser
  125072. * @param parser Defines the parser to add
  125073. */
  125074. static AddParser(name: string, parser: BabylonFileParser): void;
  125075. /**
  125076. * Gets a general parser from the list of avaialble ones
  125077. * @param name Defines the name of the parser
  125078. * @returns the requested parser or null
  125079. */
  125080. static GetParser(name: string): Nullable<BabylonFileParser>;
  125081. /**
  125082. * Adds n individual parser in the list of available ones
  125083. * @param name Defines the name of the parser
  125084. * @param parser Defines the parser to add
  125085. */
  125086. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  125087. /**
  125088. * Gets an individual parser from the list of avaialble ones
  125089. * @param name Defines the name of the parser
  125090. * @returns the requested parser or null
  125091. */
  125092. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  125093. /**
  125094. * Parser json data and populate both a scene and its associated container object
  125095. * @param jsonData Defines the data to parse
  125096. * @param scene Defines the scene to parse the data for
  125097. * @param container Defines the container attached to the parsing sequence
  125098. * @param rootUrl Defines the root url of the data
  125099. */
  125100. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  125101. /**
  125102. * Gets the list of root nodes (ie. nodes with no parent)
  125103. */
  125104. rootNodes: Node[];
  125105. /** All of the cameras added to this scene
  125106. * @see https://doc.babylonjs.com/babylon101/cameras
  125107. */
  125108. cameras: Camera[];
  125109. /**
  125110. * All of the lights added to this scene
  125111. * @see https://doc.babylonjs.com/babylon101/lights
  125112. */
  125113. lights: Light[];
  125114. /**
  125115. * All of the (abstract) meshes added to this scene
  125116. */
  125117. meshes: AbstractMesh[];
  125118. /**
  125119. * The list of skeletons added to the scene
  125120. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125121. */
  125122. skeletons: Skeleton[];
  125123. /**
  125124. * All of the particle systems added to this scene
  125125. * @see https://doc.babylonjs.com/babylon101/particles
  125126. */
  125127. particleSystems: IParticleSystem[];
  125128. /**
  125129. * Gets a list of Animations associated with the scene
  125130. */
  125131. animations: Animation[];
  125132. /**
  125133. * All of the animation groups added to this scene
  125134. * @see https://doc.babylonjs.com/how_to/group
  125135. */
  125136. animationGroups: AnimationGroup[];
  125137. /**
  125138. * All of the multi-materials added to this scene
  125139. * @see https://doc.babylonjs.com/how_to/multi_materials
  125140. */
  125141. multiMaterials: MultiMaterial[];
  125142. /**
  125143. * All of the materials added to this scene
  125144. * In the context of a Scene, it is not supposed to be modified manually.
  125145. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  125146. * Note also that the order of the Material within the array is not significant and might change.
  125147. * @see https://doc.babylonjs.com/babylon101/materials
  125148. */
  125149. materials: Material[];
  125150. /**
  125151. * The list of morph target managers added to the scene
  125152. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125153. */
  125154. morphTargetManagers: MorphTargetManager[];
  125155. /**
  125156. * The list of geometries used in the scene.
  125157. */
  125158. geometries: Geometry[];
  125159. /**
  125160. * All of the tranform nodes added to this scene
  125161. * In the context of a Scene, it is not supposed to be modified manually.
  125162. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125163. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125164. * @see https://doc.babylonjs.com/how_to/transformnode
  125165. */
  125166. transformNodes: TransformNode[];
  125167. /**
  125168. * ActionManagers available on the scene.
  125169. */
  125170. actionManagers: AbstractActionManager[];
  125171. /**
  125172. * Textures to keep.
  125173. */
  125174. textures: BaseTexture[];
  125175. /** @hidden */
  125176. protected _environmentTexture: Nullable<BaseTexture>;
  125177. /**
  125178. * Texture used in all pbr material as the reflection texture.
  125179. * As in the majority of the scene they are the same (exception for multi room and so on),
  125180. * this is easier to reference from here than from all the materials.
  125181. */
  125182. get environmentTexture(): Nullable<BaseTexture>;
  125183. set environmentTexture(value: Nullable<BaseTexture>);
  125184. /**
  125185. * The list of postprocesses added to the scene
  125186. */
  125187. postProcesses: PostProcess[];
  125188. /**
  125189. * @returns all meshes, lights, cameras, transformNodes and bones
  125190. */
  125191. getNodes(): Array<Node>;
  125192. }
  125193. }
  125194. declare module BABYLON {
  125195. /**
  125196. * Interface used to define options for Sound class
  125197. */
  125198. export interface ISoundOptions {
  125199. /**
  125200. * Does the sound autoplay once loaded.
  125201. */
  125202. autoplay?: boolean;
  125203. /**
  125204. * Does the sound loop after it finishes playing once.
  125205. */
  125206. loop?: boolean;
  125207. /**
  125208. * Sound's volume
  125209. */
  125210. volume?: number;
  125211. /**
  125212. * Is it a spatial sound?
  125213. */
  125214. spatialSound?: boolean;
  125215. /**
  125216. * Maximum distance to hear that sound
  125217. */
  125218. maxDistance?: number;
  125219. /**
  125220. * Uses user defined attenuation function
  125221. */
  125222. useCustomAttenuation?: boolean;
  125223. /**
  125224. * Define the roll off factor of spatial sounds.
  125225. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125226. */
  125227. rolloffFactor?: number;
  125228. /**
  125229. * Define the reference distance the sound should be heard perfectly.
  125230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125231. */
  125232. refDistance?: number;
  125233. /**
  125234. * Define the distance attenuation model the sound will follow.
  125235. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125236. */
  125237. distanceModel?: string;
  125238. /**
  125239. * Defines the playback speed (1 by default)
  125240. */
  125241. playbackRate?: number;
  125242. /**
  125243. * Defines if the sound is from a streaming source
  125244. */
  125245. streaming?: boolean;
  125246. /**
  125247. * Defines an optional length (in seconds) inside the sound file
  125248. */
  125249. length?: number;
  125250. /**
  125251. * Defines an optional offset (in seconds) inside the sound file
  125252. */
  125253. offset?: number;
  125254. /**
  125255. * If true, URLs will not be required to state the audio file codec to use.
  125256. */
  125257. skipCodecCheck?: boolean;
  125258. }
  125259. /**
  125260. * Defines a sound that can be played in the application.
  125261. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  125262. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125263. */
  125264. export class Sound {
  125265. /**
  125266. * The name of the sound in the scene.
  125267. */
  125268. name: string;
  125269. /**
  125270. * Does the sound autoplay once loaded.
  125271. */
  125272. autoplay: boolean;
  125273. /**
  125274. * Does the sound loop after it finishes playing once.
  125275. */
  125276. loop: boolean;
  125277. /**
  125278. * Does the sound use a custom attenuation curve to simulate the falloff
  125279. * happening when the source gets further away from the camera.
  125280. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125281. */
  125282. useCustomAttenuation: boolean;
  125283. /**
  125284. * The sound track id this sound belongs to.
  125285. */
  125286. soundTrackId: number;
  125287. /**
  125288. * Is this sound currently played.
  125289. */
  125290. isPlaying: boolean;
  125291. /**
  125292. * Is this sound currently paused.
  125293. */
  125294. isPaused: boolean;
  125295. /**
  125296. * Does this sound enables spatial sound.
  125297. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125298. */
  125299. spatialSound: boolean;
  125300. /**
  125301. * Define the reference distance the sound should be heard perfectly.
  125302. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125303. */
  125304. refDistance: number;
  125305. /**
  125306. * Define the roll off factor of spatial sounds.
  125307. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125308. */
  125309. rolloffFactor: number;
  125310. /**
  125311. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  125312. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125313. */
  125314. maxDistance: number;
  125315. /**
  125316. * Define the distance attenuation model the sound will follow.
  125317. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125318. */
  125319. distanceModel: string;
  125320. /**
  125321. * @hidden
  125322. * Back Compat
  125323. **/
  125324. onended: () => any;
  125325. /**
  125326. * Gets or sets an object used to store user defined information for the sound.
  125327. */
  125328. metadata: any;
  125329. /**
  125330. * Observable event when the current playing sound finishes.
  125331. */
  125332. onEndedObservable: Observable<Sound>;
  125333. private _panningModel;
  125334. private _playbackRate;
  125335. private _streaming;
  125336. private _startTime;
  125337. private _startOffset;
  125338. private _position;
  125339. /** @hidden */
  125340. _positionInEmitterSpace: boolean;
  125341. private _localDirection;
  125342. private _volume;
  125343. private _isReadyToPlay;
  125344. private _isDirectional;
  125345. private _readyToPlayCallback;
  125346. private _audioBuffer;
  125347. private _soundSource;
  125348. private _streamingSource;
  125349. private _soundPanner;
  125350. private _soundGain;
  125351. private _inputAudioNode;
  125352. private _outputAudioNode;
  125353. private _coneInnerAngle;
  125354. private _coneOuterAngle;
  125355. private _coneOuterGain;
  125356. private _scene;
  125357. private _connectedTransformNode;
  125358. private _customAttenuationFunction;
  125359. private _registerFunc;
  125360. private _isOutputConnected;
  125361. private _htmlAudioElement;
  125362. private _urlType;
  125363. private _length?;
  125364. private _offset?;
  125365. /** @hidden */
  125366. static _SceneComponentInitialization: (scene: Scene) => void;
  125367. /**
  125368. * Create a sound and attach it to a scene
  125369. * @param name Name of your sound
  125370. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  125371. * @param scene defines the scene the sound belongs to
  125372. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  125373. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  125374. */
  125375. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  125376. /**
  125377. * Release the sound and its associated resources
  125378. */
  125379. dispose(): void;
  125380. /**
  125381. * Gets if the sounds is ready to be played or not.
  125382. * @returns true if ready, otherwise false
  125383. */
  125384. isReady(): boolean;
  125385. private _soundLoaded;
  125386. /**
  125387. * Sets the data of the sound from an audiobuffer
  125388. * @param audioBuffer The audioBuffer containing the data
  125389. */
  125390. setAudioBuffer(audioBuffer: AudioBuffer): void;
  125391. /**
  125392. * Updates the current sounds options such as maxdistance, loop...
  125393. * @param options A JSON object containing values named as the object properties
  125394. */
  125395. updateOptions(options: ISoundOptions): void;
  125396. private _createSpatialParameters;
  125397. private _updateSpatialParameters;
  125398. /**
  125399. * Switch the panning model to HRTF:
  125400. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125401. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125402. */
  125403. switchPanningModelToHRTF(): void;
  125404. /**
  125405. * Switch the panning model to Equal Power:
  125406. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125407. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125408. */
  125409. switchPanningModelToEqualPower(): void;
  125410. private _switchPanningModel;
  125411. /**
  125412. * Connect this sound to a sound track audio node like gain...
  125413. * @param soundTrackAudioNode the sound track audio node to connect to
  125414. */
  125415. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  125416. /**
  125417. * Transform this sound into a directional source
  125418. * @param coneInnerAngle Size of the inner cone in degree
  125419. * @param coneOuterAngle Size of the outer cone in degree
  125420. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  125421. */
  125422. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  125423. /**
  125424. * Gets or sets the inner angle for the directional cone.
  125425. */
  125426. get directionalConeInnerAngle(): number;
  125427. /**
  125428. * Gets or sets the inner angle for the directional cone.
  125429. */
  125430. set directionalConeInnerAngle(value: number);
  125431. /**
  125432. * Gets or sets the outer angle for the directional cone.
  125433. */
  125434. get directionalConeOuterAngle(): number;
  125435. /**
  125436. * Gets or sets the outer angle for the directional cone.
  125437. */
  125438. set directionalConeOuterAngle(value: number);
  125439. /**
  125440. * Sets the position of the emitter if spatial sound is enabled
  125441. * @param newPosition Defines the new posisiton
  125442. */
  125443. setPosition(newPosition: Vector3): void;
  125444. /**
  125445. * Sets the local direction of the emitter if spatial sound is enabled
  125446. * @param newLocalDirection Defines the new local direction
  125447. */
  125448. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  125449. private _updateDirection;
  125450. /** @hidden */
  125451. updateDistanceFromListener(): void;
  125452. /**
  125453. * Sets a new custom attenuation function for the sound.
  125454. * @param callback Defines the function used for the attenuation
  125455. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125456. */
  125457. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  125458. /**
  125459. * Play the sound
  125460. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  125461. * @param offset (optional) Start the sound at a specific time in seconds
  125462. * @param length (optional) Sound duration (in seconds)
  125463. */
  125464. play(time?: number, offset?: number, length?: number): void;
  125465. private _onended;
  125466. /**
  125467. * Stop the sound
  125468. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  125469. */
  125470. stop(time?: number): void;
  125471. /**
  125472. * Put the sound in pause
  125473. */
  125474. pause(): void;
  125475. /**
  125476. * Sets a dedicated volume for this sounds
  125477. * @param newVolume Define the new volume of the sound
  125478. * @param time Define time for gradual change to new volume
  125479. */
  125480. setVolume(newVolume: number, time?: number): void;
  125481. /**
  125482. * Set the sound play back rate
  125483. * @param newPlaybackRate Define the playback rate the sound should be played at
  125484. */
  125485. setPlaybackRate(newPlaybackRate: number): void;
  125486. /**
  125487. * Gets the volume of the sound.
  125488. * @returns the volume of the sound
  125489. */
  125490. getVolume(): number;
  125491. /**
  125492. * Attach the sound to a dedicated mesh
  125493. * @param transformNode The transform node to connect the sound with
  125494. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125495. */
  125496. attachToMesh(transformNode: TransformNode): void;
  125497. /**
  125498. * Detach the sound from the previously attached mesh
  125499. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125500. */
  125501. detachFromMesh(): void;
  125502. private _onRegisterAfterWorldMatrixUpdate;
  125503. /**
  125504. * Clone the current sound in the scene.
  125505. * @returns the new sound clone
  125506. */
  125507. clone(): Nullable<Sound>;
  125508. /**
  125509. * Gets the current underlying audio buffer containing the data
  125510. * @returns the audio buffer
  125511. */
  125512. getAudioBuffer(): Nullable<AudioBuffer>;
  125513. /**
  125514. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  125515. * @returns the source node
  125516. */
  125517. getSoundSource(): Nullable<AudioBufferSourceNode>;
  125518. /**
  125519. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  125520. * @returns the gain node
  125521. */
  125522. getSoundGain(): Nullable<GainNode>;
  125523. /**
  125524. * Serializes the Sound in a JSON representation
  125525. * @returns the JSON representation of the sound
  125526. */
  125527. serialize(): any;
  125528. /**
  125529. * Parse a JSON representation of a sound to innstantiate in a given scene
  125530. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  125531. * @param scene Define the scene the new parsed sound should be created in
  125532. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  125533. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  125534. * @returns the newly parsed sound
  125535. */
  125536. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  125537. }
  125538. }
  125539. declare module BABYLON {
  125540. /**
  125541. * This defines an action helpful to play a defined sound on a triggered action.
  125542. */
  125543. export class PlaySoundAction extends Action {
  125544. private _sound;
  125545. /**
  125546. * Instantiate the action
  125547. * @param triggerOptions defines the trigger options
  125548. * @param sound defines the sound to play
  125549. * @param condition defines the trigger related conditions
  125550. */
  125551. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125552. /** @hidden */
  125553. _prepare(): void;
  125554. /**
  125555. * Execute the action and play the sound.
  125556. */
  125557. execute(): void;
  125558. /**
  125559. * Serializes the actions and its related information.
  125560. * @param parent defines the object to serialize in
  125561. * @returns the serialized object
  125562. */
  125563. serialize(parent: any): any;
  125564. }
  125565. /**
  125566. * This defines an action helpful to stop a defined sound on a triggered action.
  125567. */
  125568. export class StopSoundAction extends Action {
  125569. private _sound;
  125570. /**
  125571. * Instantiate the action
  125572. * @param triggerOptions defines the trigger options
  125573. * @param sound defines the sound to stop
  125574. * @param condition defines the trigger related conditions
  125575. */
  125576. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125577. /** @hidden */
  125578. _prepare(): void;
  125579. /**
  125580. * Execute the action and stop the sound.
  125581. */
  125582. execute(): void;
  125583. /**
  125584. * Serializes the actions and its related information.
  125585. * @param parent defines the object to serialize in
  125586. * @returns the serialized object
  125587. */
  125588. serialize(parent: any): any;
  125589. }
  125590. }
  125591. declare module BABYLON {
  125592. /**
  125593. * This defines an action responsible to change the value of a property
  125594. * by interpolating between its current value and the newly set one once triggered.
  125595. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125596. */
  125597. export class InterpolateValueAction extends Action {
  125598. /**
  125599. * Defines the path of the property where the value should be interpolated
  125600. */
  125601. propertyPath: string;
  125602. /**
  125603. * Defines the target value at the end of the interpolation.
  125604. */
  125605. value: any;
  125606. /**
  125607. * Defines the time it will take for the property to interpolate to the value.
  125608. */
  125609. duration: number;
  125610. /**
  125611. * Defines if the other scene animations should be stopped when the action has been triggered
  125612. */
  125613. stopOtherAnimations?: boolean;
  125614. /**
  125615. * Defines a callback raised once the interpolation animation has been done.
  125616. */
  125617. onInterpolationDone?: () => void;
  125618. /**
  125619. * Observable triggered once the interpolation animation has been done.
  125620. */
  125621. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  125622. private _target;
  125623. private _effectiveTarget;
  125624. private _property;
  125625. /**
  125626. * Instantiate the action
  125627. * @param triggerOptions defines the trigger options
  125628. * @param target defines the object containing the value to interpolate
  125629. * @param propertyPath defines the path to the property in the target object
  125630. * @param value defines the target value at the end of the interpolation
  125631. * @param duration deines the time it will take for the property to interpolate to the value.
  125632. * @param condition defines the trigger related conditions
  125633. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  125634. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  125635. */
  125636. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  125637. /** @hidden */
  125638. _prepare(): void;
  125639. /**
  125640. * Execute the action starts the value interpolation.
  125641. */
  125642. execute(): void;
  125643. /**
  125644. * Serializes the actions and its related information.
  125645. * @param parent defines the object to serialize in
  125646. * @returns the serialized object
  125647. */
  125648. serialize(parent: any): any;
  125649. }
  125650. }
  125651. declare module BABYLON {
  125652. /**
  125653. * Options allowed during the creation of a sound track.
  125654. */
  125655. export interface ISoundTrackOptions {
  125656. /**
  125657. * The volume the sound track should take during creation
  125658. */
  125659. volume?: number;
  125660. /**
  125661. * Define if the sound track is the main sound track of the scene
  125662. */
  125663. mainTrack?: boolean;
  125664. }
  125665. /**
  125666. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  125667. * It will be also used in a future release to apply effects on a specific track.
  125668. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125669. */
  125670. export class SoundTrack {
  125671. /**
  125672. * The unique identifier of the sound track in the scene.
  125673. */
  125674. id: number;
  125675. /**
  125676. * The list of sounds included in the sound track.
  125677. */
  125678. soundCollection: Array<Sound>;
  125679. private _outputAudioNode;
  125680. private _scene;
  125681. private _connectedAnalyser;
  125682. private _options;
  125683. private _isInitialized;
  125684. /**
  125685. * Creates a new sound track.
  125686. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125687. * @param scene Define the scene the sound track belongs to
  125688. * @param options
  125689. */
  125690. constructor(scene: Scene, options?: ISoundTrackOptions);
  125691. private _initializeSoundTrackAudioGraph;
  125692. /**
  125693. * Release the sound track and its associated resources
  125694. */
  125695. dispose(): void;
  125696. /**
  125697. * Adds a sound to this sound track
  125698. * @param sound define the cound to add
  125699. * @ignoreNaming
  125700. */
  125701. AddSound(sound: Sound): void;
  125702. /**
  125703. * Removes a sound to this sound track
  125704. * @param sound define the cound to remove
  125705. * @ignoreNaming
  125706. */
  125707. RemoveSound(sound: Sound): void;
  125708. /**
  125709. * Set a global volume for the full sound track.
  125710. * @param newVolume Define the new volume of the sound track
  125711. */
  125712. setVolume(newVolume: number): void;
  125713. /**
  125714. * Switch the panning model to HRTF:
  125715. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125716. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125717. */
  125718. switchPanningModelToHRTF(): void;
  125719. /**
  125720. * Switch the panning model to Equal Power:
  125721. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125722. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125723. */
  125724. switchPanningModelToEqualPower(): void;
  125725. /**
  125726. * Connect the sound track to an audio analyser allowing some amazing
  125727. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  125728. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  125729. * @param analyser The analyser to connect to the engine
  125730. */
  125731. connectToAnalyser(analyser: Analyser): void;
  125732. }
  125733. }
  125734. declare module BABYLON {
  125735. interface AbstractScene {
  125736. /**
  125737. * The list of sounds used in the scene.
  125738. */
  125739. sounds: Nullable<Array<Sound>>;
  125740. }
  125741. interface Scene {
  125742. /**
  125743. * @hidden
  125744. * Backing field
  125745. */
  125746. _mainSoundTrack: SoundTrack;
  125747. /**
  125748. * The main sound track played by the scene.
  125749. * It cotains your primary collection of sounds.
  125750. */
  125751. mainSoundTrack: SoundTrack;
  125752. /**
  125753. * The list of sound tracks added to the scene
  125754. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125755. */
  125756. soundTracks: Nullable<Array<SoundTrack>>;
  125757. /**
  125758. * Gets a sound using a given name
  125759. * @param name defines the name to search for
  125760. * @return the found sound or null if not found at all.
  125761. */
  125762. getSoundByName(name: string): Nullable<Sound>;
  125763. /**
  125764. * Gets or sets if audio support is enabled
  125765. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125766. */
  125767. audioEnabled: boolean;
  125768. /**
  125769. * Gets or sets if audio will be output to headphones
  125770. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125771. */
  125772. headphone: boolean;
  125773. /**
  125774. * Gets or sets custom audio listener position provider
  125775. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125776. */
  125777. audioListenerPositionProvider: Nullable<() => Vector3>;
  125778. /**
  125779. * Gets or sets a refresh rate when using 3D audio positioning
  125780. */
  125781. audioPositioningRefreshRate: number;
  125782. }
  125783. /**
  125784. * Defines the sound scene component responsible to manage any sounds
  125785. * in a given scene.
  125786. */
  125787. export class AudioSceneComponent implements ISceneSerializableComponent {
  125788. private static _CameraDirectionLH;
  125789. private static _CameraDirectionRH;
  125790. /**
  125791. * The component name helpfull to identify the component in the list of scene components.
  125792. */
  125793. readonly name: string;
  125794. /**
  125795. * The scene the component belongs to.
  125796. */
  125797. scene: Scene;
  125798. private _audioEnabled;
  125799. /**
  125800. * Gets whether audio is enabled or not.
  125801. * Please use related enable/disable method to switch state.
  125802. */
  125803. get audioEnabled(): boolean;
  125804. private _headphone;
  125805. /**
  125806. * Gets whether audio is outputing to headphone or not.
  125807. * Please use the according Switch methods to change output.
  125808. */
  125809. get headphone(): boolean;
  125810. /**
  125811. * Gets or sets a refresh rate when using 3D audio positioning
  125812. */
  125813. audioPositioningRefreshRate: number;
  125814. private _audioListenerPositionProvider;
  125815. /**
  125816. * Gets the current audio listener position provider
  125817. */
  125818. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  125819. /**
  125820. * Sets a custom listener position for all sounds in the scene
  125821. * By default, this is the position of the first active camera
  125822. */
  125823. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  125824. /**
  125825. * Creates a new instance of the component for the given scene
  125826. * @param scene Defines the scene to register the component in
  125827. */
  125828. constructor(scene: Scene);
  125829. /**
  125830. * Registers the component in a given scene
  125831. */
  125832. register(): void;
  125833. /**
  125834. * Rebuilds the elements related to this component in case of
  125835. * context lost for instance.
  125836. */
  125837. rebuild(): void;
  125838. /**
  125839. * Serializes the component data to the specified json object
  125840. * @param serializationObject The object to serialize to
  125841. */
  125842. serialize(serializationObject: any): void;
  125843. /**
  125844. * Adds all the elements from the container to the scene
  125845. * @param container the container holding the elements
  125846. */
  125847. addFromContainer(container: AbstractScene): void;
  125848. /**
  125849. * Removes all the elements in the container from the scene
  125850. * @param container contains the elements to remove
  125851. * @param dispose if the removed element should be disposed (default: false)
  125852. */
  125853. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125854. /**
  125855. * Disposes the component and the associated ressources.
  125856. */
  125857. dispose(): void;
  125858. /**
  125859. * Disables audio in the associated scene.
  125860. */
  125861. disableAudio(): void;
  125862. /**
  125863. * Enables audio in the associated scene.
  125864. */
  125865. enableAudio(): void;
  125866. /**
  125867. * Switch audio to headphone output.
  125868. */
  125869. switchAudioModeForHeadphones(): void;
  125870. /**
  125871. * Switch audio to normal speakers.
  125872. */
  125873. switchAudioModeForNormalSpeakers(): void;
  125874. private _cachedCameraDirection;
  125875. private _cachedCameraPosition;
  125876. private _lastCheck;
  125877. private _afterRender;
  125878. }
  125879. }
  125880. declare module BABYLON {
  125881. /**
  125882. * Wraps one or more Sound objects and selects one with random weight for playback.
  125883. */
  125884. export class WeightedSound {
  125885. /** When true a Sound will be selected and played when the current playing Sound completes. */
  125886. loop: boolean;
  125887. private _coneInnerAngle;
  125888. private _coneOuterAngle;
  125889. private _volume;
  125890. /** A Sound is currently playing. */
  125891. isPlaying: boolean;
  125892. /** A Sound is currently paused. */
  125893. isPaused: boolean;
  125894. private _sounds;
  125895. private _weights;
  125896. private _currentIndex?;
  125897. /**
  125898. * Creates a new WeightedSound from the list of sounds given.
  125899. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  125900. * @param sounds Array of Sounds that will be selected from.
  125901. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  125902. */
  125903. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  125904. /**
  125905. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  125906. */
  125907. get directionalConeInnerAngle(): number;
  125908. /**
  125909. * The size of cone in degress for a directional sound in which there will be no attenuation.
  125910. */
  125911. set directionalConeInnerAngle(value: number);
  125912. /**
  125913. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  125914. * Listener angles between innerAngle and outerAngle will falloff linearly.
  125915. */
  125916. get directionalConeOuterAngle(): number;
  125917. /**
  125918. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  125919. * Listener angles between innerAngle and outerAngle will falloff linearly.
  125920. */
  125921. set directionalConeOuterAngle(value: number);
  125922. /**
  125923. * Playback volume.
  125924. */
  125925. get volume(): number;
  125926. /**
  125927. * Playback volume.
  125928. */
  125929. set volume(value: number);
  125930. private _onended;
  125931. /**
  125932. * Suspend playback
  125933. */
  125934. pause(): void;
  125935. /**
  125936. * Stop playback
  125937. */
  125938. stop(): void;
  125939. /**
  125940. * Start playback.
  125941. * @param startOffset Position the clip head at a specific time in seconds.
  125942. */
  125943. play(startOffset?: number): void;
  125944. }
  125945. }
  125946. declare module BABYLON {
  125947. /**
  125948. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  125949. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  125950. */
  125951. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  125952. /**
  125953. * Gets the name of the behavior.
  125954. */
  125955. get name(): string;
  125956. /**
  125957. * The easing function used by animations
  125958. */
  125959. static EasingFunction: BackEase;
  125960. /**
  125961. * The easing mode used by animations
  125962. */
  125963. static EasingMode: number;
  125964. /**
  125965. * The duration of the animation, in milliseconds
  125966. */
  125967. transitionDuration: number;
  125968. /**
  125969. * Length of the distance animated by the transition when lower radius is reached
  125970. */
  125971. lowerRadiusTransitionRange: number;
  125972. /**
  125973. * Length of the distance animated by the transition when upper radius is reached
  125974. */
  125975. upperRadiusTransitionRange: number;
  125976. private _autoTransitionRange;
  125977. /**
  125978. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  125979. */
  125980. get autoTransitionRange(): boolean;
  125981. /**
  125982. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  125983. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  125984. */
  125985. set autoTransitionRange(value: boolean);
  125986. private _attachedCamera;
  125987. private _onAfterCheckInputsObserver;
  125988. private _onMeshTargetChangedObserver;
  125989. /**
  125990. * Initializes the behavior.
  125991. */
  125992. init(): void;
  125993. /**
  125994. * Attaches the behavior to its arc rotate camera.
  125995. * @param camera Defines the camera to attach the behavior to
  125996. */
  125997. attach(camera: ArcRotateCamera): void;
  125998. /**
  125999. * Detaches the behavior from its current arc rotate camera.
  126000. */
  126001. detach(): void;
  126002. private _radiusIsAnimating;
  126003. private _radiusBounceTransition;
  126004. private _animatables;
  126005. private _cachedWheelPrecision;
  126006. /**
  126007. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  126008. * @param radiusLimit The limit to check against.
  126009. * @return Bool to indicate if at limit.
  126010. */
  126011. private _isRadiusAtLimit;
  126012. /**
  126013. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  126014. * @param radiusDelta The delta by which to animate to. Can be negative.
  126015. */
  126016. private _applyBoundRadiusAnimation;
  126017. /**
  126018. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  126019. */
  126020. protected _clearAnimationLocks(): void;
  126021. /**
  126022. * Stops and removes all animations that have been applied to the camera
  126023. */
  126024. stopAllAnimations(): void;
  126025. }
  126026. }
  126027. declare module BABYLON {
  126028. /**
  126029. * 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.
  126030. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126031. */
  126032. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  126033. /**
  126034. * Gets the name of the behavior.
  126035. */
  126036. get name(): string;
  126037. private _mode;
  126038. private _radiusScale;
  126039. private _positionScale;
  126040. private _defaultElevation;
  126041. private _elevationReturnTime;
  126042. private _elevationReturnWaitTime;
  126043. private _zoomStopsAnimation;
  126044. private _framingTime;
  126045. /**
  126046. * The easing function used by animations
  126047. */
  126048. static EasingFunction: ExponentialEase;
  126049. /**
  126050. * The easing mode used by animations
  126051. */
  126052. static EasingMode: number;
  126053. /**
  126054. * Sets the current mode used by the behavior
  126055. */
  126056. set mode(mode: number);
  126057. /**
  126058. * Gets current mode used by the behavior.
  126059. */
  126060. get mode(): number;
  126061. /**
  126062. * Sets the scale applied to the radius (1 by default)
  126063. */
  126064. set radiusScale(radius: number);
  126065. /**
  126066. * Gets the scale applied to the radius
  126067. */
  126068. get radiusScale(): number;
  126069. /**
  126070. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126071. */
  126072. set positionScale(scale: number);
  126073. /**
  126074. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126075. */
  126076. get positionScale(): number;
  126077. /**
  126078. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126079. * behaviour is triggered, in radians.
  126080. */
  126081. set defaultElevation(elevation: number);
  126082. /**
  126083. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126084. * behaviour is triggered, in radians.
  126085. */
  126086. get defaultElevation(): number;
  126087. /**
  126088. * Sets the time (in milliseconds) taken to return to the default beta position.
  126089. * Negative value indicates camera should not return to default.
  126090. */
  126091. set elevationReturnTime(speed: number);
  126092. /**
  126093. * Gets the time (in milliseconds) taken to return to the default beta position.
  126094. * Negative value indicates camera should not return to default.
  126095. */
  126096. get elevationReturnTime(): number;
  126097. /**
  126098. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126099. */
  126100. set elevationReturnWaitTime(time: number);
  126101. /**
  126102. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126103. */
  126104. get elevationReturnWaitTime(): number;
  126105. /**
  126106. * Sets the flag that indicates if user zooming should stop animation.
  126107. */
  126108. set zoomStopsAnimation(flag: boolean);
  126109. /**
  126110. * Gets the flag that indicates if user zooming should stop animation.
  126111. */
  126112. get zoomStopsAnimation(): boolean;
  126113. /**
  126114. * Sets the transition time when framing the mesh, in milliseconds
  126115. */
  126116. set framingTime(time: number);
  126117. /**
  126118. * Gets the transition time when framing the mesh, in milliseconds
  126119. */
  126120. get framingTime(): number;
  126121. /**
  126122. * Define if the behavior should automatically change the configured
  126123. * camera limits and sensibilities.
  126124. */
  126125. autoCorrectCameraLimitsAndSensibility: boolean;
  126126. private _onPrePointerObservableObserver;
  126127. private _onAfterCheckInputsObserver;
  126128. private _onMeshTargetChangedObserver;
  126129. private _attachedCamera;
  126130. private _isPointerDown;
  126131. private _lastInteractionTime;
  126132. /**
  126133. * Initializes the behavior.
  126134. */
  126135. init(): void;
  126136. /**
  126137. * Attaches the behavior to its arc rotate camera.
  126138. * @param camera Defines the camera to attach the behavior to
  126139. */
  126140. attach(camera: ArcRotateCamera): void;
  126141. /**
  126142. * Detaches the behavior from its current arc rotate camera.
  126143. */
  126144. detach(): void;
  126145. private _animatables;
  126146. private _betaIsAnimating;
  126147. private _betaTransition;
  126148. private _radiusTransition;
  126149. private _vectorTransition;
  126150. /**
  126151. * Targets the given mesh and updates zoom level accordingly.
  126152. * @param mesh The mesh to target.
  126153. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126154. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126155. */
  126156. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126157. /**
  126158. * Targets the given mesh with its children and updates zoom level accordingly.
  126159. * @param mesh The mesh to target.
  126160. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126161. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126162. */
  126163. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126164. /**
  126165. * Targets the given meshes with their children and updates zoom level accordingly.
  126166. * @param meshes The mesh to target.
  126167. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126168. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126169. */
  126170. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126171. /**
  126172. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  126173. * @param minimumWorld Determines the smaller position of the bounding box extend
  126174. * @param maximumWorld Determines the bigger position of the bounding box extend
  126175. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126176. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126177. */
  126178. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126179. /**
  126180. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  126181. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  126182. * frustum width.
  126183. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  126184. * to fully enclose the mesh in the viewing frustum.
  126185. */
  126186. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  126187. /**
  126188. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  126189. * is automatically returned to its default position (expected to be above ground plane).
  126190. */
  126191. private _maintainCameraAboveGround;
  126192. /**
  126193. * Returns the frustum slope based on the canvas ratio and camera FOV
  126194. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  126195. */
  126196. private _getFrustumSlope;
  126197. /**
  126198. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  126199. */
  126200. private _clearAnimationLocks;
  126201. /**
  126202. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126203. */
  126204. private _applyUserInteraction;
  126205. /**
  126206. * Stops and removes all animations that have been applied to the camera
  126207. */
  126208. stopAllAnimations(): void;
  126209. /**
  126210. * Gets a value indicating if the user is moving the camera
  126211. */
  126212. get isUserIsMoving(): boolean;
  126213. /**
  126214. * The camera can move all the way towards the mesh.
  126215. */
  126216. static IgnoreBoundsSizeMode: number;
  126217. /**
  126218. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  126219. */
  126220. static FitFrustumSidesMode: number;
  126221. }
  126222. }
  126223. declare module BABYLON {
  126224. /**
  126225. * Base class for Camera Pointer Inputs.
  126226. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  126227. * for example usage.
  126228. */
  126229. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  126230. /**
  126231. * Defines the camera the input is attached to.
  126232. */
  126233. abstract camera: Camera;
  126234. /**
  126235. * Whether keyboard modifier keys are pressed at time of last mouse event.
  126236. */
  126237. protected _altKey: boolean;
  126238. protected _ctrlKey: boolean;
  126239. protected _metaKey: boolean;
  126240. protected _shiftKey: boolean;
  126241. /**
  126242. * Which mouse buttons were pressed at time of last mouse event.
  126243. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  126244. */
  126245. protected _buttonsPressed: number;
  126246. /**
  126247. * Defines the buttons associated with the input to handle camera move.
  126248. */
  126249. buttons: number[];
  126250. /**
  126251. * Attach the input controls to a specific dom element to get the input from.
  126252. * @param element Defines the element the controls should be listened from
  126253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126254. */
  126255. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126256. /**
  126257. * Detach the current controls from the specified dom element.
  126258. * @param element Defines the element to stop listening the inputs from
  126259. */
  126260. detachControl(element: Nullable<HTMLElement>): void;
  126261. /**
  126262. * Gets the class name of the current input.
  126263. * @returns the class name
  126264. */
  126265. getClassName(): string;
  126266. /**
  126267. * Get the friendly name associated with the input class.
  126268. * @returns the input friendly name
  126269. */
  126270. getSimpleName(): string;
  126271. /**
  126272. * Called on pointer POINTERDOUBLETAP event.
  126273. * Override this method to provide functionality on POINTERDOUBLETAP event.
  126274. */
  126275. protected onDoubleTap(type: string): void;
  126276. /**
  126277. * Called on pointer POINTERMOVE event if only a single touch is active.
  126278. * Override this method to provide functionality.
  126279. */
  126280. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126281. /**
  126282. * Called on pointer POINTERMOVE event if multiple touches are active.
  126283. * Override this method to provide functionality.
  126284. */
  126285. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126286. /**
  126287. * Called on JS contextmenu event.
  126288. * Override this method to provide functionality.
  126289. */
  126290. protected onContextMenu(evt: PointerEvent): void;
  126291. /**
  126292. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126293. * press.
  126294. * Override this method to provide functionality.
  126295. */
  126296. protected onButtonDown(evt: PointerEvent): void;
  126297. /**
  126298. * Called each time a new POINTERUP event occurs. Ie, for each button
  126299. * release.
  126300. * Override this method to provide functionality.
  126301. */
  126302. protected onButtonUp(evt: PointerEvent): void;
  126303. /**
  126304. * Called when window becomes inactive.
  126305. * Override this method to provide functionality.
  126306. */
  126307. protected onLostFocus(): void;
  126308. private _pointerInput;
  126309. private _observer;
  126310. private _onLostFocus;
  126311. private pointA;
  126312. private pointB;
  126313. }
  126314. }
  126315. declare module BABYLON {
  126316. /**
  126317. * Manage the pointers inputs to control an arc rotate camera.
  126318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126319. */
  126320. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  126321. /**
  126322. * Defines the camera the input is attached to.
  126323. */
  126324. camera: ArcRotateCamera;
  126325. /**
  126326. * Gets the class name of the current input.
  126327. * @returns the class name
  126328. */
  126329. getClassName(): string;
  126330. /**
  126331. * Defines the buttons associated with the input to handle camera move.
  126332. */
  126333. buttons: number[];
  126334. /**
  126335. * Defines the pointer angular sensibility along the X axis or how fast is
  126336. * the camera rotating.
  126337. */
  126338. angularSensibilityX: number;
  126339. /**
  126340. * Defines the pointer angular sensibility along the Y axis or how fast is
  126341. * the camera rotating.
  126342. */
  126343. angularSensibilityY: number;
  126344. /**
  126345. * Defines the pointer pinch precision or how fast is the camera zooming.
  126346. */
  126347. pinchPrecision: number;
  126348. /**
  126349. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  126350. * from 0.
  126351. * It defines the percentage of current camera.radius to use as delta when
  126352. * pinch zoom is used.
  126353. */
  126354. pinchDeltaPercentage: number;
  126355. /**
  126356. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126357. * that any object in the plane at the camera's target point will scale
  126358. * perfectly with finger motion.
  126359. * Overrides pinchDeltaPercentage and pinchPrecision.
  126360. */
  126361. useNaturalPinchZoom: boolean;
  126362. /**
  126363. * Defines the pointer panning sensibility or how fast is the camera moving.
  126364. */
  126365. panningSensibility: number;
  126366. /**
  126367. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  126368. */
  126369. multiTouchPanning: boolean;
  126370. /**
  126371. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  126372. * zoom (pinch) through multitouch.
  126373. */
  126374. multiTouchPanAndZoom: boolean;
  126375. /**
  126376. * Revers pinch action direction.
  126377. */
  126378. pinchInwards: boolean;
  126379. private _isPanClick;
  126380. private _twoFingerActivityCount;
  126381. private _isPinching;
  126382. /**
  126383. * Called on pointer POINTERMOVE event if only a single touch is active.
  126384. */
  126385. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126386. /**
  126387. * Called on pointer POINTERDOUBLETAP event.
  126388. */
  126389. protected onDoubleTap(type: string): void;
  126390. /**
  126391. * Called on pointer POINTERMOVE event if multiple touches are active.
  126392. */
  126393. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126394. /**
  126395. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126396. * press.
  126397. */
  126398. protected onButtonDown(evt: PointerEvent): void;
  126399. /**
  126400. * Called each time a new POINTERUP event occurs. Ie, for each button
  126401. * release.
  126402. */
  126403. protected onButtonUp(evt: PointerEvent): void;
  126404. /**
  126405. * Called when window becomes inactive.
  126406. */
  126407. protected onLostFocus(): void;
  126408. }
  126409. }
  126410. declare module BABYLON {
  126411. /**
  126412. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  126413. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126414. */
  126415. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  126416. /**
  126417. * Defines the camera the input is attached to.
  126418. */
  126419. camera: ArcRotateCamera;
  126420. /**
  126421. * Defines the list of key codes associated with the up action (increase alpha)
  126422. */
  126423. keysUp: number[];
  126424. /**
  126425. * Defines the list of key codes associated with the down action (decrease alpha)
  126426. */
  126427. keysDown: number[];
  126428. /**
  126429. * Defines the list of key codes associated with the left action (increase beta)
  126430. */
  126431. keysLeft: number[];
  126432. /**
  126433. * Defines the list of key codes associated with the right action (decrease beta)
  126434. */
  126435. keysRight: number[];
  126436. /**
  126437. * Defines the list of key codes associated with the reset action.
  126438. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  126439. */
  126440. keysReset: number[];
  126441. /**
  126442. * Defines the panning sensibility of the inputs.
  126443. * (How fast is the camera panning)
  126444. */
  126445. panningSensibility: number;
  126446. /**
  126447. * Defines the zooming sensibility of the inputs.
  126448. * (How fast is the camera zooming)
  126449. */
  126450. zoomingSensibility: number;
  126451. /**
  126452. * Defines whether maintaining the alt key down switch the movement mode from
  126453. * orientation to zoom.
  126454. */
  126455. useAltToZoom: boolean;
  126456. /**
  126457. * Rotation speed of the camera
  126458. */
  126459. angularSpeed: number;
  126460. private _keys;
  126461. private _ctrlPressed;
  126462. private _altPressed;
  126463. private _onCanvasBlurObserver;
  126464. private _onKeyboardObserver;
  126465. private _engine;
  126466. private _scene;
  126467. /**
  126468. * Attach the input controls to a specific dom element to get the input from.
  126469. * @param element Defines the element the controls should be listened from
  126470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126471. */
  126472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126473. /**
  126474. * Detach the current controls from the specified dom element.
  126475. * @param element Defines the element to stop listening the inputs from
  126476. */
  126477. detachControl(element: Nullable<HTMLElement>): void;
  126478. /**
  126479. * Update the current camera state depending on the inputs that have been used this frame.
  126480. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  126481. */
  126482. checkInputs(): void;
  126483. /**
  126484. * Gets the class name of the current intput.
  126485. * @returns the class name
  126486. */
  126487. getClassName(): string;
  126488. /**
  126489. * Get the friendly name associated with the input class.
  126490. * @returns the input friendly name
  126491. */
  126492. getSimpleName(): string;
  126493. }
  126494. }
  126495. declare module BABYLON {
  126496. /**
  126497. * Manage the mouse wheel inputs to control an arc rotate camera.
  126498. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126499. */
  126500. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  126501. /**
  126502. * Defines the camera the input is attached to.
  126503. */
  126504. camera: ArcRotateCamera;
  126505. /**
  126506. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126507. */
  126508. wheelPrecision: number;
  126509. /**
  126510. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  126511. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  126512. */
  126513. wheelDeltaPercentage: number;
  126514. private _wheel;
  126515. private _observer;
  126516. private computeDeltaFromMouseWheelLegacyEvent;
  126517. /**
  126518. * Attach the input controls to a specific dom element to get the input from.
  126519. * @param element Defines the element the controls should be listened from
  126520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126521. */
  126522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126523. /**
  126524. * Detach the current controls from the specified dom element.
  126525. * @param element Defines the element to stop listening the inputs from
  126526. */
  126527. detachControl(element: Nullable<HTMLElement>): void;
  126528. /**
  126529. * Gets the class name of the current intput.
  126530. * @returns the class name
  126531. */
  126532. getClassName(): string;
  126533. /**
  126534. * Get the friendly name associated with the input class.
  126535. * @returns the input friendly name
  126536. */
  126537. getSimpleName(): string;
  126538. }
  126539. }
  126540. declare module BABYLON {
  126541. /**
  126542. * Default Inputs manager for the ArcRotateCamera.
  126543. * It groups all the default supported inputs for ease of use.
  126544. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126545. */
  126546. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  126547. /**
  126548. * Instantiates a new ArcRotateCameraInputsManager.
  126549. * @param camera Defines the camera the inputs belong to
  126550. */
  126551. constructor(camera: ArcRotateCamera);
  126552. /**
  126553. * Add mouse wheel input support to the input manager.
  126554. * @returns the current input manager
  126555. */
  126556. addMouseWheel(): ArcRotateCameraInputsManager;
  126557. /**
  126558. * Add pointers input support to the input manager.
  126559. * @returns the current input manager
  126560. */
  126561. addPointers(): ArcRotateCameraInputsManager;
  126562. /**
  126563. * Add keyboard input support to the input manager.
  126564. * @returns the current input manager
  126565. */
  126566. addKeyboard(): ArcRotateCameraInputsManager;
  126567. }
  126568. }
  126569. declare module BABYLON {
  126570. /**
  126571. * This represents an orbital type of camera.
  126572. *
  126573. * 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.
  126574. * 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.
  126575. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  126576. */
  126577. export class ArcRotateCamera extends TargetCamera {
  126578. /**
  126579. * Defines the rotation angle of the camera along the longitudinal axis.
  126580. */
  126581. alpha: number;
  126582. /**
  126583. * Defines the rotation angle of the camera along the latitudinal axis.
  126584. */
  126585. beta: number;
  126586. /**
  126587. * Defines the radius of the camera from it s target point.
  126588. */
  126589. radius: number;
  126590. protected _target: Vector3;
  126591. protected _targetHost: Nullable<AbstractMesh>;
  126592. /**
  126593. * Defines the target point of the camera.
  126594. * The camera looks towards it form the radius distance.
  126595. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  126596. */
  126597. get target(): Vector3;
  126598. set target(value: Vector3);
  126599. /**
  126600. * Define the current local position of the camera in the scene
  126601. */
  126602. get position(): Vector3;
  126603. set position(newPosition: Vector3);
  126604. protected _upToYMatrix: Matrix;
  126605. protected _YToUpMatrix: Matrix;
  126606. /**
  126607. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  126608. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  126609. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  126610. */
  126611. set upVector(vec: Vector3);
  126612. get upVector(): Vector3;
  126613. /**
  126614. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  126615. */
  126616. setMatUp(): void;
  126617. /**
  126618. * Current inertia value on the longitudinal axis.
  126619. * The bigger this number the longer it will take for the camera to stop.
  126620. */
  126621. inertialAlphaOffset: number;
  126622. /**
  126623. * Current inertia value on the latitudinal axis.
  126624. * The bigger this number the longer it will take for the camera to stop.
  126625. */
  126626. inertialBetaOffset: number;
  126627. /**
  126628. * Current inertia value on the radius axis.
  126629. * The bigger this number the longer it will take for the camera to stop.
  126630. */
  126631. inertialRadiusOffset: number;
  126632. /**
  126633. * Minimum allowed angle on the longitudinal axis.
  126634. * This can help limiting how the Camera is able to move in the scene.
  126635. */
  126636. lowerAlphaLimit: Nullable<number>;
  126637. /**
  126638. * Maximum allowed angle on the longitudinal axis.
  126639. * This can help limiting how the Camera is able to move in the scene.
  126640. */
  126641. upperAlphaLimit: Nullable<number>;
  126642. /**
  126643. * Minimum allowed angle on the latitudinal axis.
  126644. * This can help limiting how the Camera is able to move in the scene.
  126645. */
  126646. lowerBetaLimit: number;
  126647. /**
  126648. * Maximum allowed angle on the latitudinal axis.
  126649. * This can help limiting how the Camera is able to move in the scene.
  126650. */
  126651. upperBetaLimit: number;
  126652. /**
  126653. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  126654. * This can help limiting how the Camera is able to move in the scene.
  126655. */
  126656. lowerRadiusLimit: Nullable<number>;
  126657. /**
  126658. * Maximum allowed distance of the camera to the target (The camera can not get further).
  126659. * This can help limiting how the Camera is able to move in the scene.
  126660. */
  126661. upperRadiusLimit: Nullable<number>;
  126662. /**
  126663. * Defines the current inertia value used during panning of the camera along the X axis.
  126664. */
  126665. inertialPanningX: number;
  126666. /**
  126667. * Defines the current inertia value used during panning of the camera along the Y axis.
  126668. */
  126669. inertialPanningY: number;
  126670. /**
  126671. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  126672. * Basically if your fingers moves away from more than this distance you will be considered
  126673. * in pinch mode.
  126674. */
  126675. pinchToPanMaxDistance: number;
  126676. /**
  126677. * Defines the maximum distance the camera can pan.
  126678. * This could help keeping the cammera always in your scene.
  126679. */
  126680. panningDistanceLimit: Nullable<number>;
  126681. /**
  126682. * Defines the target of the camera before paning.
  126683. */
  126684. panningOriginTarget: Vector3;
  126685. /**
  126686. * Defines the value of the inertia used during panning.
  126687. * 0 would mean stop inertia and one would mean no decelleration at all.
  126688. */
  126689. panningInertia: number;
  126690. /**
  126691. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  126692. */
  126693. get angularSensibilityX(): number;
  126694. set angularSensibilityX(value: number);
  126695. /**
  126696. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  126697. */
  126698. get angularSensibilityY(): number;
  126699. set angularSensibilityY(value: number);
  126700. /**
  126701. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  126702. */
  126703. get pinchPrecision(): number;
  126704. set pinchPrecision(value: number);
  126705. /**
  126706. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  126707. * It will be used instead of pinchDeltaPrecision if different from 0.
  126708. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126709. */
  126710. get pinchDeltaPercentage(): number;
  126711. set pinchDeltaPercentage(value: number);
  126712. /**
  126713. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  126714. * and pinch delta percentage.
  126715. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126716. * that any object in the plane at the camera's target point will scale
  126717. * perfectly with finger motion.
  126718. */
  126719. get useNaturalPinchZoom(): boolean;
  126720. set useNaturalPinchZoom(value: boolean);
  126721. /**
  126722. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  126723. */
  126724. get panningSensibility(): number;
  126725. set panningSensibility(value: number);
  126726. /**
  126727. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  126728. */
  126729. get keysUp(): number[];
  126730. set keysUp(value: number[]);
  126731. /**
  126732. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  126733. */
  126734. get keysDown(): number[];
  126735. set keysDown(value: number[]);
  126736. /**
  126737. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  126738. */
  126739. get keysLeft(): number[];
  126740. set keysLeft(value: number[]);
  126741. /**
  126742. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  126743. */
  126744. get keysRight(): number[];
  126745. set keysRight(value: number[]);
  126746. /**
  126747. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126748. */
  126749. get wheelPrecision(): number;
  126750. set wheelPrecision(value: number);
  126751. /**
  126752. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  126753. * It will be used instead of pinchDeltaPrecision if different from 0.
  126754. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126755. */
  126756. get wheelDeltaPercentage(): number;
  126757. set wheelDeltaPercentage(value: number);
  126758. /**
  126759. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  126760. */
  126761. zoomOnFactor: number;
  126762. /**
  126763. * Defines a screen offset for the camera position.
  126764. */
  126765. targetScreenOffset: Vector2;
  126766. /**
  126767. * Allows the camera to be completely reversed.
  126768. * If false the camera can not arrive upside down.
  126769. */
  126770. allowUpsideDown: boolean;
  126771. /**
  126772. * Define if double tap/click is used to restore the previously saved state of the camera.
  126773. */
  126774. useInputToRestoreState: boolean;
  126775. /** @hidden */
  126776. _viewMatrix: Matrix;
  126777. /** @hidden */
  126778. _useCtrlForPanning: boolean;
  126779. /** @hidden */
  126780. _panningMouseButton: number;
  126781. /**
  126782. * Defines the input associated to the camera.
  126783. */
  126784. inputs: ArcRotateCameraInputsManager;
  126785. /** @hidden */
  126786. _reset: () => void;
  126787. /**
  126788. * Defines the allowed panning axis.
  126789. */
  126790. panningAxis: Vector3;
  126791. protected _localDirection: Vector3;
  126792. protected _transformedDirection: Vector3;
  126793. private _bouncingBehavior;
  126794. /**
  126795. * Gets the bouncing behavior of the camera if it has been enabled.
  126796. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126797. */
  126798. get bouncingBehavior(): Nullable<BouncingBehavior>;
  126799. /**
  126800. * Defines if the bouncing behavior of the camera is enabled on the camera.
  126801. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126802. */
  126803. get useBouncingBehavior(): boolean;
  126804. set useBouncingBehavior(value: boolean);
  126805. private _framingBehavior;
  126806. /**
  126807. * Gets the framing behavior of the camera if it has been enabled.
  126808. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126809. */
  126810. get framingBehavior(): Nullable<FramingBehavior>;
  126811. /**
  126812. * Defines if the framing behavior of the camera is enabled on the camera.
  126813. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126814. */
  126815. get useFramingBehavior(): boolean;
  126816. set useFramingBehavior(value: boolean);
  126817. private _autoRotationBehavior;
  126818. /**
  126819. * Gets the auto rotation behavior of the camera if it has been enabled.
  126820. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126821. */
  126822. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  126823. /**
  126824. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  126825. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126826. */
  126827. get useAutoRotationBehavior(): boolean;
  126828. set useAutoRotationBehavior(value: boolean);
  126829. /**
  126830. * Observable triggered when the mesh target has been changed on the camera.
  126831. */
  126832. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  126833. /**
  126834. * Event raised when the camera is colliding with a mesh.
  126835. */
  126836. onCollide: (collidedMesh: AbstractMesh) => void;
  126837. /**
  126838. * Defines whether the camera should check collision with the objects oh the scene.
  126839. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  126840. */
  126841. checkCollisions: boolean;
  126842. /**
  126843. * Defines the collision radius of the camera.
  126844. * This simulates a sphere around the camera.
  126845. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  126846. */
  126847. collisionRadius: Vector3;
  126848. protected _collider: Collider;
  126849. protected _previousPosition: Vector3;
  126850. protected _collisionVelocity: Vector3;
  126851. protected _newPosition: Vector3;
  126852. protected _previousAlpha: number;
  126853. protected _previousBeta: number;
  126854. protected _previousRadius: number;
  126855. protected _collisionTriggered: boolean;
  126856. protected _targetBoundingCenter: Nullable<Vector3>;
  126857. private _computationVector;
  126858. /**
  126859. * Instantiates a new ArcRotateCamera in a given scene
  126860. * @param name Defines the name of the camera
  126861. * @param alpha Defines the camera rotation along the logitudinal axis
  126862. * @param beta Defines the camera rotation along the latitudinal axis
  126863. * @param radius Defines the camera distance from its target
  126864. * @param target Defines the camera target
  126865. * @param scene Defines the scene the camera belongs to
  126866. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  126867. */
  126868. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  126869. /** @hidden */
  126870. _initCache(): void;
  126871. /** @hidden */
  126872. _updateCache(ignoreParentClass?: boolean): void;
  126873. protected _getTargetPosition(): Vector3;
  126874. private _storedAlpha;
  126875. private _storedBeta;
  126876. private _storedRadius;
  126877. private _storedTarget;
  126878. private _storedTargetScreenOffset;
  126879. /**
  126880. * Stores the current state of the camera (alpha, beta, radius and target)
  126881. * @returns the camera itself
  126882. */
  126883. storeState(): Camera;
  126884. /**
  126885. * @hidden
  126886. * Restored camera state. You must call storeState() first
  126887. */
  126888. _restoreStateValues(): boolean;
  126889. /** @hidden */
  126890. _isSynchronizedViewMatrix(): boolean;
  126891. /**
  126892. * Attached controls to the current camera.
  126893. * @param element Defines the element the controls should be listened from
  126894. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126895. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  126896. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  126897. */
  126898. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  126899. /**
  126900. * Detach the current controls from the camera.
  126901. * The camera will stop reacting to inputs.
  126902. * @param element Defines the element to stop listening the inputs from
  126903. */
  126904. detachControl(element: HTMLElement): void;
  126905. /** @hidden */
  126906. _checkInputs(): void;
  126907. protected _checkLimits(): void;
  126908. /**
  126909. * Rebuilds angles (alpha, beta) and radius from the give position and target
  126910. */
  126911. rebuildAnglesAndRadius(): void;
  126912. /**
  126913. * Use a position to define the current camera related information like alpha, beta and radius
  126914. * @param position Defines the position to set the camera at
  126915. */
  126916. setPosition(position: Vector3): void;
  126917. /**
  126918. * Defines the target the camera should look at.
  126919. * This will automatically adapt alpha beta and radius to fit within the new target.
  126920. * @param target Defines the new target as a Vector or a mesh
  126921. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  126922. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  126923. */
  126924. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  126925. /** @hidden */
  126926. _getViewMatrix(): Matrix;
  126927. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  126928. /**
  126929. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  126930. * @param meshes Defines the mesh to zoom on
  126931. * @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)
  126932. */
  126933. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  126934. /**
  126935. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  126936. * The target will be changed but the radius
  126937. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  126938. * @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)
  126939. */
  126940. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  126941. min: Vector3;
  126942. max: Vector3;
  126943. distance: number;
  126944. }, doNotUpdateMaxZ?: boolean): void;
  126945. /**
  126946. * @override
  126947. * Override Camera.createRigCamera
  126948. */
  126949. createRigCamera(name: string, cameraIndex: number): Camera;
  126950. /**
  126951. * @hidden
  126952. * @override
  126953. * Override Camera._updateRigCameras
  126954. */
  126955. _updateRigCameras(): void;
  126956. /**
  126957. * Destroy the camera and release the current resources hold by it.
  126958. */
  126959. dispose(): void;
  126960. /**
  126961. * Gets the current object class name.
  126962. * @return the class name
  126963. */
  126964. getClassName(): string;
  126965. }
  126966. }
  126967. declare module BABYLON {
  126968. /**
  126969. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  126970. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126971. */
  126972. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  126973. /**
  126974. * Gets the name of the behavior.
  126975. */
  126976. get name(): string;
  126977. private _zoomStopsAnimation;
  126978. private _idleRotationSpeed;
  126979. private _idleRotationWaitTime;
  126980. private _idleRotationSpinupTime;
  126981. /**
  126982. * Sets the flag that indicates if user zooming should stop animation.
  126983. */
  126984. set zoomStopsAnimation(flag: boolean);
  126985. /**
  126986. * Gets the flag that indicates if user zooming should stop animation.
  126987. */
  126988. get zoomStopsAnimation(): boolean;
  126989. /**
  126990. * Sets the default speed at which the camera rotates around the model.
  126991. */
  126992. set idleRotationSpeed(speed: number);
  126993. /**
  126994. * Gets the default speed at which the camera rotates around the model.
  126995. */
  126996. get idleRotationSpeed(): number;
  126997. /**
  126998. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  126999. */
  127000. set idleRotationWaitTime(time: number);
  127001. /**
  127002. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  127003. */
  127004. get idleRotationWaitTime(): number;
  127005. /**
  127006. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127007. */
  127008. set idleRotationSpinupTime(time: number);
  127009. /**
  127010. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127011. */
  127012. get idleRotationSpinupTime(): number;
  127013. /**
  127014. * Gets a value indicating if the camera is currently rotating because of this behavior
  127015. */
  127016. get rotationInProgress(): boolean;
  127017. private _onPrePointerObservableObserver;
  127018. private _onAfterCheckInputsObserver;
  127019. private _attachedCamera;
  127020. private _isPointerDown;
  127021. private _lastFrameTime;
  127022. private _lastInteractionTime;
  127023. private _cameraRotationSpeed;
  127024. /**
  127025. * Initializes the behavior.
  127026. */
  127027. init(): void;
  127028. /**
  127029. * Attaches the behavior to its arc rotate camera.
  127030. * @param camera Defines the camera to attach the behavior to
  127031. */
  127032. attach(camera: ArcRotateCamera): void;
  127033. /**
  127034. * Detaches the behavior from its current arc rotate camera.
  127035. */
  127036. detach(): void;
  127037. /**
  127038. * Returns true if user is scrolling.
  127039. * @return true if user is scrolling.
  127040. */
  127041. private _userIsZooming;
  127042. private _lastFrameRadius;
  127043. private _shouldAnimationStopForInteraction;
  127044. /**
  127045. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127046. */
  127047. private _applyUserInteraction;
  127048. private _userIsMoving;
  127049. }
  127050. }
  127051. declare module BABYLON {
  127052. /**
  127053. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  127054. */
  127055. export class AttachToBoxBehavior implements Behavior<Mesh> {
  127056. private ui;
  127057. /**
  127058. * The name of the behavior
  127059. */
  127060. name: string;
  127061. /**
  127062. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  127063. */
  127064. distanceAwayFromFace: number;
  127065. /**
  127066. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  127067. */
  127068. distanceAwayFromBottomOfFace: number;
  127069. private _faceVectors;
  127070. private _target;
  127071. private _scene;
  127072. private _onRenderObserver;
  127073. private _tmpMatrix;
  127074. private _tmpVector;
  127075. /**
  127076. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  127077. * @param ui The transform node that should be attched to the mesh
  127078. */
  127079. constructor(ui: TransformNode);
  127080. /**
  127081. * Initializes the behavior
  127082. */
  127083. init(): void;
  127084. private _closestFace;
  127085. private _zeroVector;
  127086. private _lookAtTmpMatrix;
  127087. private _lookAtToRef;
  127088. /**
  127089. * Attaches the AttachToBoxBehavior to the passed in mesh
  127090. * @param target The mesh that the specified node will be attached to
  127091. */
  127092. attach(target: Mesh): void;
  127093. /**
  127094. * Detaches the behavior from the mesh
  127095. */
  127096. detach(): void;
  127097. }
  127098. }
  127099. declare module BABYLON {
  127100. /**
  127101. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  127102. */
  127103. export class FadeInOutBehavior implements Behavior<Mesh> {
  127104. /**
  127105. * Time in milliseconds to delay before fading in (Default: 0)
  127106. */
  127107. delay: number;
  127108. /**
  127109. * Time in milliseconds for the mesh to fade in (Default: 300)
  127110. */
  127111. fadeInTime: number;
  127112. private _millisecondsPerFrame;
  127113. private _hovered;
  127114. private _hoverValue;
  127115. private _ownerNode;
  127116. /**
  127117. * Instatiates the FadeInOutBehavior
  127118. */
  127119. constructor();
  127120. /**
  127121. * The name of the behavior
  127122. */
  127123. get name(): string;
  127124. /**
  127125. * Initializes the behavior
  127126. */
  127127. init(): void;
  127128. /**
  127129. * Attaches the fade behavior on the passed in mesh
  127130. * @param ownerNode The mesh that will be faded in/out once attached
  127131. */
  127132. attach(ownerNode: Mesh): void;
  127133. /**
  127134. * Detaches the behavior from the mesh
  127135. */
  127136. detach(): void;
  127137. /**
  127138. * Triggers the mesh to begin fading in or out
  127139. * @param value if the object should fade in or out (true to fade in)
  127140. */
  127141. fadeIn(value: boolean): void;
  127142. private _update;
  127143. private _setAllVisibility;
  127144. }
  127145. }
  127146. declare module BABYLON {
  127147. /**
  127148. * Class containing a set of static utilities functions for managing Pivots
  127149. * @hidden
  127150. */
  127151. export class PivotTools {
  127152. private static _PivotCached;
  127153. private static _OldPivotPoint;
  127154. private static _PivotTranslation;
  127155. private static _PivotTmpVector;
  127156. private static _PivotPostMultiplyPivotMatrix;
  127157. /** @hidden */
  127158. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  127159. /** @hidden */
  127160. static _RestorePivotPoint(mesh: AbstractMesh): void;
  127161. }
  127162. }
  127163. declare module BABYLON {
  127164. /**
  127165. * Class containing static functions to help procedurally build meshes
  127166. */
  127167. export class PlaneBuilder {
  127168. /**
  127169. * Creates a plane mesh
  127170. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127171. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127172. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127176. * @param name defines the name of the mesh
  127177. * @param options defines the options used to create the mesh
  127178. * @param scene defines the hosting scene
  127179. * @returns the plane mesh
  127180. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127181. */
  127182. static CreatePlane(name: string, options: {
  127183. size?: number;
  127184. width?: number;
  127185. height?: number;
  127186. sideOrientation?: number;
  127187. frontUVs?: Vector4;
  127188. backUVs?: Vector4;
  127189. updatable?: boolean;
  127190. sourcePlane?: Plane;
  127191. }, scene?: Nullable<Scene>): Mesh;
  127192. }
  127193. }
  127194. declare module BABYLON {
  127195. /**
  127196. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  127197. */
  127198. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  127199. private static _AnyMouseID;
  127200. /**
  127201. * Abstract mesh the behavior is set on
  127202. */
  127203. attachedNode: AbstractMesh;
  127204. private _dragPlane;
  127205. private _scene;
  127206. private _pointerObserver;
  127207. private _beforeRenderObserver;
  127208. private static _planeScene;
  127209. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  127210. /**
  127211. * 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)
  127212. */
  127213. maxDragAngle: number;
  127214. /**
  127215. * @hidden
  127216. */
  127217. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  127218. /**
  127219. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127220. */
  127221. currentDraggingPointerID: number;
  127222. /**
  127223. * The last position where the pointer hit the drag plane in world space
  127224. */
  127225. lastDragPosition: Vector3;
  127226. /**
  127227. * If the behavior is currently in a dragging state
  127228. */
  127229. dragging: boolean;
  127230. /**
  127231. * 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)
  127232. */
  127233. dragDeltaRatio: number;
  127234. /**
  127235. * If the drag plane orientation should be updated during the dragging (Default: true)
  127236. */
  127237. updateDragPlane: boolean;
  127238. private _debugMode;
  127239. private _moving;
  127240. /**
  127241. * Fires each time the attached mesh is dragged with the pointer
  127242. * * delta between last drag position and current drag position in world space
  127243. * * dragDistance along the drag axis
  127244. * * dragPlaneNormal normal of the current drag plane used during the drag
  127245. * * dragPlanePoint in world space where the drag intersects the drag plane
  127246. */
  127247. onDragObservable: Observable<{
  127248. delta: Vector3;
  127249. dragPlanePoint: Vector3;
  127250. dragPlaneNormal: Vector3;
  127251. dragDistance: number;
  127252. pointerId: number;
  127253. }>;
  127254. /**
  127255. * Fires each time a drag begins (eg. mouse down on mesh)
  127256. */
  127257. onDragStartObservable: Observable<{
  127258. dragPlanePoint: Vector3;
  127259. pointerId: number;
  127260. }>;
  127261. /**
  127262. * Fires each time a drag ends (eg. mouse release after drag)
  127263. */
  127264. onDragEndObservable: Observable<{
  127265. dragPlanePoint: Vector3;
  127266. pointerId: number;
  127267. }>;
  127268. /**
  127269. * If the attached mesh should be moved when dragged
  127270. */
  127271. moveAttached: boolean;
  127272. /**
  127273. * If the drag behavior will react to drag events (Default: true)
  127274. */
  127275. enabled: boolean;
  127276. /**
  127277. * If pointer events should start and release the drag (Default: true)
  127278. */
  127279. startAndReleaseDragOnPointerEvents: boolean;
  127280. /**
  127281. * If camera controls should be detached during the drag
  127282. */
  127283. detachCameraControls: boolean;
  127284. /**
  127285. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  127286. */
  127287. useObjectOrientationForDragging: boolean;
  127288. private _options;
  127289. /**
  127290. * Gets the options used by the behavior
  127291. */
  127292. get options(): {
  127293. dragAxis?: Vector3;
  127294. dragPlaneNormal?: Vector3;
  127295. };
  127296. /**
  127297. * Sets the options used by the behavior
  127298. */
  127299. set options(options: {
  127300. dragAxis?: Vector3;
  127301. dragPlaneNormal?: Vector3;
  127302. });
  127303. /**
  127304. * Creates a pointer drag behavior that can be attached to a mesh
  127305. * @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)
  127306. */
  127307. constructor(options?: {
  127308. dragAxis?: Vector3;
  127309. dragPlaneNormal?: Vector3;
  127310. });
  127311. /**
  127312. * Predicate to determine if it is valid to move the object to a new position when it is moved
  127313. */
  127314. validateDrag: (targetPosition: Vector3) => boolean;
  127315. /**
  127316. * The name of the behavior
  127317. */
  127318. get name(): string;
  127319. /**
  127320. * Initializes the behavior
  127321. */
  127322. init(): void;
  127323. private _tmpVector;
  127324. private _alternatePickedPoint;
  127325. private _worldDragAxis;
  127326. private _targetPosition;
  127327. private _attachedElement;
  127328. /**
  127329. * Attaches the drag behavior the passed in mesh
  127330. * @param ownerNode The mesh that will be dragged around once attached
  127331. * @param predicate Predicate to use for pick filtering
  127332. */
  127333. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  127334. /**
  127335. * Force relase the drag action by code.
  127336. */
  127337. releaseDrag(): void;
  127338. private _startDragRay;
  127339. private _lastPointerRay;
  127340. /**
  127341. * Simulates the start of a pointer drag event on the behavior
  127342. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  127343. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  127344. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  127345. */
  127346. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127347. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127348. private _dragDelta;
  127349. protected _moveDrag(ray: Ray): void;
  127350. private _pickWithRayOnDragPlane;
  127351. private _pointA;
  127352. private _pointC;
  127353. private _localAxis;
  127354. private _lookAt;
  127355. private _updateDragPlanePosition;
  127356. /**
  127357. * Detaches the behavior from the mesh
  127358. */
  127359. detach(): void;
  127360. }
  127361. }
  127362. declare module BABYLON {
  127363. /**
  127364. * A behavior that when attached to a mesh will allow the mesh to be scaled
  127365. */
  127366. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  127367. private _dragBehaviorA;
  127368. private _dragBehaviorB;
  127369. private _startDistance;
  127370. private _initialScale;
  127371. private _targetScale;
  127372. private _ownerNode;
  127373. private _sceneRenderObserver;
  127374. /**
  127375. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  127376. */
  127377. constructor();
  127378. /**
  127379. * The name of the behavior
  127380. */
  127381. get name(): string;
  127382. /**
  127383. * Initializes the behavior
  127384. */
  127385. init(): void;
  127386. private _getCurrentDistance;
  127387. /**
  127388. * Attaches the scale behavior the passed in mesh
  127389. * @param ownerNode The mesh that will be scaled around once attached
  127390. */
  127391. attach(ownerNode: Mesh): void;
  127392. /**
  127393. * Detaches the behavior from the mesh
  127394. */
  127395. detach(): void;
  127396. }
  127397. }
  127398. declare module BABYLON {
  127399. /**
  127400. * 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
  127401. */
  127402. export class SixDofDragBehavior implements Behavior<Mesh> {
  127403. private static _virtualScene;
  127404. private _ownerNode;
  127405. private _sceneRenderObserver;
  127406. private _scene;
  127407. private _targetPosition;
  127408. private _virtualOriginMesh;
  127409. private _virtualDragMesh;
  127410. private _pointerObserver;
  127411. private _moving;
  127412. private _startingOrientation;
  127413. private _attachedElement;
  127414. /**
  127415. * 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)
  127416. */
  127417. private zDragFactor;
  127418. /**
  127419. * If the object should rotate to face the drag origin
  127420. */
  127421. rotateDraggedObject: boolean;
  127422. /**
  127423. * If the behavior is currently in a dragging state
  127424. */
  127425. dragging: boolean;
  127426. /**
  127427. * 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)
  127428. */
  127429. dragDeltaRatio: number;
  127430. /**
  127431. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127432. */
  127433. currentDraggingPointerID: number;
  127434. /**
  127435. * If camera controls should be detached during the drag
  127436. */
  127437. detachCameraControls: boolean;
  127438. /**
  127439. * Fires each time a drag starts
  127440. */
  127441. onDragStartObservable: Observable<{}>;
  127442. /**
  127443. * Fires each time a drag ends (eg. mouse release after drag)
  127444. */
  127445. onDragEndObservable: Observable<{}>;
  127446. /**
  127447. * 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
  127448. */
  127449. constructor();
  127450. /**
  127451. * The name of the behavior
  127452. */
  127453. get name(): string;
  127454. /**
  127455. * Initializes the behavior
  127456. */
  127457. init(): void;
  127458. /**
  127459. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  127460. */
  127461. private get _pointerCamera();
  127462. /**
  127463. * Attaches the scale behavior the passed in mesh
  127464. * @param ownerNode The mesh that will be scaled around once attached
  127465. */
  127466. attach(ownerNode: Mesh): void;
  127467. /**
  127468. * Detaches the behavior from the mesh
  127469. */
  127470. detach(): void;
  127471. }
  127472. }
  127473. declare module BABYLON {
  127474. /**
  127475. * Class used to apply inverse kinematics to bones
  127476. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  127477. */
  127478. export class BoneIKController {
  127479. private static _tmpVecs;
  127480. private static _tmpQuat;
  127481. private static _tmpMats;
  127482. /**
  127483. * Gets or sets the target mesh
  127484. */
  127485. targetMesh: AbstractMesh;
  127486. /** Gets or sets the mesh used as pole */
  127487. poleTargetMesh: AbstractMesh;
  127488. /**
  127489. * Gets or sets the bone used as pole
  127490. */
  127491. poleTargetBone: Nullable<Bone>;
  127492. /**
  127493. * Gets or sets the target position
  127494. */
  127495. targetPosition: Vector3;
  127496. /**
  127497. * Gets or sets the pole target position
  127498. */
  127499. poleTargetPosition: Vector3;
  127500. /**
  127501. * Gets or sets the pole target local offset
  127502. */
  127503. poleTargetLocalOffset: Vector3;
  127504. /**
  127505. * Gets or sets the pole angle
  127506. */
  127507. poleAngle: number;
  127508. /**
  127509. * Gets or sets the mesh associated with the controller
  127510. */
  127511. mesh: AbstractMesh;
  127512. /**
  127513. * 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)
  127514. */
  127515. slerpAmount: number;
  127516. private _bone1Quat;
  127517. private _bone1Mat;
  127518. private _bone2Ang;
  127519. private _bone1;
  127520. private _bone2;
  127521. private _bone1Length;
  127522. private _bone2Length;
  127523. private _maxAngle;
  127524. private _maxReach;
  127525. private _rightHandedSystem;
  127526. private _bendAxis;
  127527. private _slerping;
  127528. private _adjustRoll;
  127529. /**
  127530. * Gets or sets maximum allowed angle
  127531. */
  127532. get maxAngle(): number;
  127533. set maxAngle(value: number);
  127534. /**
  127535. * Creates a new BoneIKController
  127536. * @param mesh defines the mesh to control
  127537. * @param bone defines the bone to control
  127538. * @param options defines options to set up the controller
  127539. */
  127540. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  127541. targetMesh?: AbstractMesh;
  127542. poleTargetMesh?: AbstractMesh;
  127543. poleTargetBone?: Bone;
  127544. poleTargetLocalOffset?: Vector3;
  127545. poleAngle?: number;
  127546. bendAxis?: Vector3;
  127547. maxAngle?: number;
  127548. slerpAmount?: number;
  127549. });
  127550. private _setMaxAngle;
  127551. /**
  127552. * Force the controller to update the bones
  127553. */
  127554. update(): void;
  127555. }
  127556. }
  127557. declare module BABYLON {
  127558. /**
  127559. * Class used to make a bone look toward a point in space
  127560. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  127561. */
  127562. export class BoneLookController {
  127563. private static _tmpVecs;
  127564. private static _tmpQuat;
  127565. private static _tmpMats;
  127566. /**
  127567. * The target Vector3 that the bone will look at
  127568. */
  127569. target: Vector3;
  127570. /**
  127571. * The mesh that the bone is attached to
  127572. */
  127573. mesh: AbstractMesh;
  127574. /**
  127575. * The bone that will be looking to the target
  127576. */
  127577. bone: Bone;
  127578. /**
  127579. * The up axis of the coordinate system that is used when the bone is rotated
  127580. */
  127581. upAxis: Vector3;
  127582. /**
  127583. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  127584. */
  127585. upAxisSpace: Space;
  127586. /**
  127587. * Used to make an adjustment to the yaw of the bone
  127588. */
  127589. adjustYaw: number;
  127590. /**
  127591. * Used to make an adjustment to the pitch of the bone
  127592. */
  127593. adjustPitch: number;
  127594. /**
  127595. * Used to make an adjustment to the roll of the bone
  127596. */
  127597. adjustRoll: number;
  127598. /**
  127599. * 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)
  127600. */
  127601. slerpAmount: number;
  127602. private _minYaw;
  127603. private _maxYaw;
  127604. private _minPitch;
  127605. private _maxPitch;
  127606. private _minYawSin;
  127607. private _minYawCos;
  127608. private _maxYawSin;
  127609. private _maxYawCos;
  127610. private _midYawConstraint;
  127611. private _minPitchTan;
  127612. private _maxPitchTan;
  127613. private _boneQuat;
  127614. private _slerping;
  127615. private _transformYawPitch;
  127616. private _transformYawPitchInv;
  127617. private _firstFrameSkipped;
  127618. private _yawRange;
  127619. private _fowardAxis;
  127620. /**
  127621. * Gets or sets the minimum yaw angle that the bone can look to
  127622. */
  127623. get minYaw(): number;
  127624. set minYaw(value: number);
  127625. /**
  127626. * Gets or sets the maximum yaw angle that the bone can look to
  127627. */
  127628. get maxYaw(): number;
  127629. set maxYaw(value: number);
  127630. /**
  127631. * Gets or sets the minimum pitch angle that the bone can look to
  127632. */
  127633. get minPitch(): number;
  127634. set minPitch(value: number);
  127635. /**
  127636. * Gets or sets the maximum pitch angle that the bone can look to
  127637. */
  127638. get maxPitch(): number;
  127639. set maxPitch(value: number);
  127640. /**
  127641. * Create a BoneLookController
  127642. * @param mesh the mesh that the bone belongs to
  127643. * @param bone the bone that will be looking to the target
  127644. * @param target the target Vector3 to look at
  127645. * @param options optional settings:
  127646. * * maxYaw: the maximum angle the bone will yaw to
  127647. * * minYaw: the minimum angle the bone will yaw to
  127648. * * maxPitch: the maximum angle the bone will pitch to
  127649. * * minPitch: the minimum angle the bone will yaw to
  127650. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  127651. * * upAxis: the up axis of the coordinate system
  127652. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  127653. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  127654. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  127655. * * adjustYaw: used to make an adjustment to the yaw of the bone
  127656. * * adjustPitch: used to make an adjustment to the pitch of the bone
  127657. * * adjustRoll: used to make an adjustment to the roll of the bone
  127658. **/
  127659. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  127660. maxYaw?: number;
  127661. minYaw?: number;
  127662. maxPitch?: number;
  127663. minPitch?: number;
  127664. slerpAmount?: number;
  127665. upAxis?: Vector3;
  127666. upAxisSpace?: Space;
  127667. yawAxis?: Vector3;
  127668. pitchAxis?: Vector3;
  127669. adjustYaw?: number;
  127670. adjustPitch?: number;
  127671. adjustRoll?: number;
  127672. });
  127673. /**
  127674. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  127675. */
  127676. update(): void;
  127677. private _getAngleDiff;
  127678. private _getAngleBetween;
  127679. private _isAngleBetween;
  127680. }
  127681. }
  127682. declare module BABYLON {
  127683. /**
  127684. * Manage the gamepad inputs to control an arc rotate camera.
  127685. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127686. */
  127687. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  127688. /**
  127689. * Defines the camera the input is attached to.
  127690. */
  127691. camera: ArcRotateCamera;
  127692. /**
  127693. * Defines the gamepad the input is gathering event from.
  127694. */
  127695. gamepad: Nullable<Gamepad>;
  127696. /**
  127697. * Defines the gamepad rotation sensiblity.
  127698. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  127699. */
  127700. gamepadRotationSensibility: number;
  127701. /**
  127702. * Defines the gamepad move sensiblity.
  127703. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  127704. */
  127705. gamepadMoveSensibility: number;
  127706. private _yAxisScale;
  127707. /**
  127708. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  127709. */
  127710. get invertYAxis(): boolean;
  127711. set invertYAxis(value: boolean);
  127712. private _onGamepadConnectedObserver;
  127713. private _onGamepadDisconnectedObserver;
  127714. /**
  127715. * Attach the input controls to a specific dom element to get the input from.
  127716. * @param element Defines the element the controls should be listened from
  127717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127718. */
  127719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127720. /**
  127721. * Detach the current controls from the specified dom element.
  127722. * @param element Defines the element to stop listening the inputs from
  127723. */
  127724. detachControl(element: Nullable<HTMLElement>): void;
  127725. /**
  127726. * Update the current camera state depending on the inputs that have been used this frame.
  127727. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127728. */
  127729. checkInputs(): void;
  127730. /**
  127731. * Gets the class name of the current intput.
  127732. * @returns the class name
  127733. */
  127734. getClassName(): string;
  127735. /**
  127736. * Get the friendly name associated with the input class.
  127737. * @returns the input friendly name
  127738. */
  127739. getSimpleName(): string;
  127740. }
  127741. }
  127742. declare module BABYLON {
  127743. interface ArcRotateCameraInputsManager {
  127744. /**
  127745. * Add orientation input support to the input manager.
  127746. * @returns the current input manager
  127747. */
  127748. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  127749. }
  127750. /**
  127751. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  127752. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127753. */
  127754. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  127755. /**
  127756. * Defines the camera the input is attached to.
  127757. */
  127758. camera: ArcRotateCamera;
  127759. /**
  127760. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  127761. */
  127762. alphaCorrection: number;
  127763. /**
  127764. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  127765. */
  127766. gammaCorrection: number;
  127767. private _alpha;
  127768. private _gamma;
  127769. private _dirty;
  127770. private _deviceOrientationHandler;
  127771. /**
  127772. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  127773. */
  127774. constructor();
  127775. /**
  127776. * Attach the input controls to a specific dom element to get the input from.
  127777. * @param element Defines the element the controls should be listened from
  127778. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127779. */
  127780. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127781. /** @hidden */
  127782. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  127783. /**
  127784. * Update the current camera state depending on the inputs that have been used this frame.
  127785. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127786. */
  127787. checkInputs(): void;
  127788. /**
  127789. * Detach the current controls from the specified dom element.
  127790. * @param element Defines the element to stop listening the inputs from
  127791. */
  127792. detachControl(element: Nullable<HTMLElement>): void;
  127793. /**
  127794. * Gets the class name of the current intput.
  127795. * @returns the class name
  127796. */
  127797. getClassName(): string;
  127798. /**
  127799. * Get the friendly name associated with the input class.
  127800. * @returns the input friendly name
  127801. */
  127802. getSimpleName(): string;
  127803. }
  127804. }
  127805. declare module BABYLON {
  127806. /**
  127807. * Listen to mouse events to control the camera.
  127808. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127809. */
  127810. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  127811. /**
  127812. * Defines the camera the input is attached to.
  127813. */
  127814. camera: FlyCamera;
  127815. /**
  127816. * Defines if touch is enabled. (Default is true.)
  127817. */
  127818. touchEnabled: boolean;
  127819. /**
  127820. * Defines the buttons associated with the input to handle camera rotation.
  127821. */
  127822. buttons: number[];
  127823. /**
  127824. * Assign buttons for Yaw control.
  127825. */
  127826. buttonsYaw: number[];
  127827. /**
  127828. * Assign buttons for Pitch control.
  127829. */
  127830. buttonsPitch: number[];
  127831. /**
  127832. * Assign buttons for Roll control.
  127833. */
  127834. buttonsRoll: number[];
  127835. /**
  127836. * Detect if any button is being pressed while mouse is moved.
  127837. * -1 = Mouse locked.
  127838. * 0 = Left button.
  127839. * 1 = Middle Button.
  127840. * 2 = Right Button.
  127841. */
  127842. activeButton: number;
  127843. /**
  127844. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  127845. * Higher values reduce its sensitivity.
  127846. */
  127847. angularSensibility: number;
  127848. private _observer;
  127849. private _rollObserver;
  127850. private previousPosition;
  127851. private noPreventDefault;
  127852. private element;
  127853. /**
  127854. * Listen to mouse events to control the camera.
  127855. * @param touchEnabled Define if touch is enabled. (Default is true.)
  127856. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127857. */
  127858. constructor(touchEnabled?: boolean);
  127859. /**
  127860. * Attach the mouse control to the HTML DOM element.
  127861. * @param element Defines the element that listens to the input events.
  127862. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  127863. */
  127864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127865. /**
  127866. * Detach the current controls from the specified dom element.
  127867. * @param element Defines the element to stop listening the inputs from
  127868. */
  127869. detachControl(element: Nullable<HTMLElement>): void;
  127870. /**
  127871. * Gets the class name of the current input.
  127872. * @returns the class name.
  127873. */
  127874. getClassName(): string;
  127875. /**
  127876. * Get the friendly name associated with the input class.
  127877. * @returns the input's friendly name.
  127878. */
  127879. getSimpleName(): string;
  127880. private _pointerInput;
  127881. private _onMouseMove;
  127882. /**
  127883. * Rotate camera by mouse offset.
  127884. */
  127885. private rotateCamera;
  127886. }
  127887. }
  127888. declare module BABYLON {
  127889. /**
  127890. * Default Inputs manager for the FlyCamera.
  127891. * It groups all the default supported inputs for ease of use.
  127892. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127893. */
  127894. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  127895. /**
  127896. * Instantiates a new FlyCameraInputsManager.
  127897. * @param camera Defines the camera the inputs belong to.
  127898. */
  127899. constructor(camera: FlyCamera);
  127900. /**
  127901. * Add keyboard input support to the input manager.
  127902. * @returns the new FlyCameraKeyboardMoveInput().
  127903. */
  127904. addKeyboard(): FlyCameraInputsManager;
  127905. /**
  127906. * Add mouse input support to the input manager.
  127907. * @param touchEnabled Enable touch screen support.
  127908. * @returns the new FlyCameraMouseInput().
  127909. */
  127910. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  127911. }
  127912. }
  127913. declare module BABYLON {
  127914. /**
  127915. * This is a flying camera, designed for 3D movement and rotation in all directions,
  127916. * such as in a 3D Space Shooter or a Flight Simulator.
  127917. */
  127918. export class FlyCamera extends TargetCamera {
  127919. /**
  127920. * Define the collision ellipsoid of the camera.
  127921. * This is helpful for simulating a camera body, like a player's body.
  127922. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  127923. */
  127924. ellipsoid: Vector3;
  127925. /**
  127926. * Define an offset for the position of the ellipsoid around the camera.
  127927. * This can be helpful if the camera is attached away from the player's body center,
  127928. * such as at its head.
  127929. */
  127930. ellipsoidOffset: Vector3;
  127931. /**
  127932. * Enable or disable collisions of the camera with the rest of the scene objects.
  127933. */
  127934. checkCollisions: boolean;
  127935. /**
  127936. * Enable or disable gravity on the camera.
  127937. */
  127938. applyGravity: boolean;
  127939. /**
  127940. * Define the current direction the camera is moving to.
  127941. */
  127942. cameraDirection: Vector3;
  127943. /**
  127944. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  127945. * This overrides and empties cameraRotation.
  127946. */
  127947. rotationQuaternion: Quaternion;
  127948. /**
  127949. * Track Roll to maintain the wanted Rolling when looking around.
  127950. */
  127951. _trackRoll: number;
  127952. /**
  127953. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  127954. */
  127955. rollCorrect: number;
  127956. /**
  127957. * Mimic a banked turn, Rolling the camera when Yawing.
  127958. * It's recommended to use rollCorrect = 10 for faster banking correction.
  127959. */
  127960. bankedTurn: boolean;
  127961. /**
  127962. * Limit in radians for how much Roll banking will add. (Default: 90°)
  127963. */
  127964. bankedTurnLimit: number;
  127965. /**
  127966. * Value of 0 disables the banked Roll.
  127967. * Value of 1 is equal to the Yaw angle in radians.
  127968. */
  127969. bankedTurnMultiplier: number;
  127970. /**
  127971. * The inputs manager loads all the input sources, such as keyboard and mouse.
  127972. */
  127973. inputs: FlyCameraInputsManager;
  127974. /**
  127975. * Gets the input sensibility for mouse input.
  127976. * Higher values reduce sensitivity.
  127977. */
  127978. get angularSensibility(): number;
  127979. /**
  127980. * Sets the input sensibility for a mouse input.
  127981. * Higher values reduce sensitivity.
  127982. */
  127983. set angularSensibility(value: number);
  127984. /**
  127985. * Get the keys for camera movement forward.
  127986. */
  127987. get keysForward(): number[];
  127988. /**
  127989. * Set the keys for camera movement forward.
  127990. */
  127991. set keysForward(value: number[]);
  127992. /**
  127993. * Get the keys for camera movement backward.
  127994. */
  127995. get keysBackward(): number[];
  127996. set keysBackward(value: number[]);
  127997. /**
  127998. * Get the keys for camera movement up.
  127999. */
  128000. get keysUp(): number[];
  128001. /**
  128002. * Set the keys for camera movement up.
  128003. */
  128004. set keysUp(value: number[]);
  128005. /**
  128006. * Get the keys for camera movement down.
  128007. */
  128008. get keysDown(): number[];
  128009. /**
  128010. * Set the keys for camera movement down.
  128011. */
  128012. set keysDown(value: number[]);
  128013. /**
  128014. * Get the keys for camera movement left.
  128015. */
  128016. get keysLeft(): number[];
  128017. /**
  128018. * Set the keys for camera movement left.
  128019. */
  128020. set keysLeft(value: number[]);
  128021. /**
  128022. * Set the keys for camera movement right.
  128023. */
  128024. get keysRight(): number[];
  128025. /**
  128026. * Set the keys for camera movement right.
  128027. */
  128028. set keysRight(value: number[]);
  128029. /**
  128030. * Event raised when the camera collides with a mesh in the scene.
  128031. */
  128032. onCollide: (collidedMesh: AbstractMesh) => void;
  128033. private _collider;
  128034. private _needMoveForGravity;
  128035. private _oldPosition;
  128036. private _diffPosition;
  128037. private _newPosition;
  128038. /** @hidden */
  128039. _localDirection: Vector3;
  128040. /** @hidden */
  128041. _transformedDirection: Vector3;
  128042. /**
  128043. * Instantiates a FlyCamera.
  128044. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128045. * such as in a 3D Space Shooter or a Flight Simulator.
  128046. * @param name Define the name of the camera in the scene.
  128047. * @param position Define the starting position of the camera in the scene.
  128048. * @param scene Define the scene the camera belongs to.
  128049. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  128050. */
  128051. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128052. /**
  128053. * Attach a control to the HTML DOM element.
  128054. * @param element Defines the element that listens to the input events.
  128055. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  128056. */
  128057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128058. /**
  128059. * Detach a control from the HTML DOM element.
  128060. * The camera will stop reacting to that input.
  128061. * @param element Defines the element that listens to the input events.
  128062. */
  128063. detachControl(element: HTMLElement): void;
  128064. private _collisionMask;
  128065. /**
  128066. * Get the mask that the camera ignores in collision events.
  128067. */
  128068. get collisionMask(): number;
  128069. /**
  128070. * Set the mask that the camera ignores in collision events.
  128071. */
  128072. set collisionMask(mask: number);
  128073. /** @hidden */
  128074. _collideWithWorld(displacement: Vector3): void;
  128075. /** @hidden */
  128076. private _onCollisionPositionChange;
  128077. /** @hidden */
  128078. _checkInputs(): void;
  128079. /** @hidden */
  128080. _decideIfNeedsToMove(): boolean;
  128081. /** @hidden */
  128082. _updatePosition(): void;
  128083. /**
  128084. * Restore the Roll to its target value at the rate specified.
  128085. * @param rate - Higher means slower restoring.
  128086. * @hidden
  128087. */
  128088. restoreRoll(rate: number): void;
  128089. /**
  128090. * Destroy the camera and release the current resources held by it.
  128091. */
  128092. dispose(): void;
  128093. /**
  128094. * Get the current object class name.
  128095. * @returns the class name.
  128096. */
  128097. getClassName(): string;
  128098. }
  128099. }
  128100. declare module BABYLON {
  128101. /**
  128102. * Listen to keyboard events to control the camera.
  128103. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128104. */
  128105. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  128106. /**
  128107. * Defines the camera the input is attached to.
  128108. */
  128109. camera: FlyCamera;
  128110. /**
  128111. * The list of keyboard keys used to control the forward move of the camera.
  128112. */
  128113. keysForward: number[];
  128114. /**
  128115. * The list of keyboard keys used to control the backward move of the camera.
  128116. */
  128117. keysBackward: number[];
  128118. /**
  128119. * The list of keyboard keys used to control the forward move of the camera.
  128120. */
  128121. keysUp: number[];
  128122. /**
  128123. * The list of keyboard keys used to control the backward move of the camera.
  128124. */
  128125. keysDown: number[];
  128126. /**
  128127. * The list of keyboard keys used to control the right strafe move of the camera.
  128128. */
  128129. keysRight: number[];
  128130. /**
  128131. * The list of keyboard keys used to control the left strafe move of the camera.
  128132. */
  128133. keysLeft: number[];
  128134. private _keys;
  128135. private _onCanvasBlurObserver;
  128136. private _onKeyboardObserver;
  128137. private _engine;
  128138. private _scene;
  128139. /**
  128140. * Attach the input controls to a specific dom element to get the input from.
  128141. * @param element Defines the element the controls should be listened from
  128142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128143. */
  128144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128145. /**
  128146. * Detach the current controls from the specified dom element.
  128147. * @param element Defines the element to stop listening the inputs from
  128148. */
  128149. detachControl(element: Nullable<HTMLElement>): void;
  128150. /**
  128151. * Gets the class name of the current intput.
  128152. * @returns the class name
  128153. */
  128154. getClassName(): string;
  128155. /** @hidden */
  128156. _onLostFocus(e: FocusEvent): void;
  128157. /**
  128158. * Get the friendly name associated with the input class.
  128159. * @returns the input friendly name
  128160. */
  128161. getSimpleName(): string;
  128162. /**
  128163. * Update the current camera state depending on the inputs that have been used this frame.
  128164. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128165. */
  128166. checkInputs(): void;
  128167. }
  128168. }
  128169. declare module BABYLON {
  128170. /**
  128171. * Manage the mouse wheel inputs to control a follow camera.
  128172. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128173. */
  128174. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  128175. /**
  128176. * Defines the camera the input is attached to.
  128177. */
  128178. camera: FollowCamera;
  128179. /**
  128180. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  128181. */
  128182. axisControlRadius: boolean;
  128183. /**
  128184. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  128185. */
  128186. axisControlHeight: boolean;
  128187. /**
  128188. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  128189. */
  128190. axisControlRotation: boolean;
  128191. /**
  128192. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  128193. * relation to mouseWheel events.
  128194. */
  128195. wheelPrecision: number;
  128196. /**
  128197. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128198. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128199. */
  128200. wheelDeltaPercentage: number;
  128201. private _wheel;
  128202. private _observer;
  128203. /**
  128204. * Attach the input controls to a specific dom element to get the input from.
  128205. * @param element Defines the element the controls should be listened from
  128206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128207. */
  128208. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128209. /**
  128210. * Detach the current controls from the specified dom element.
  128211. * @param element Defines the element to stop listening the inputs from
  128212. */
  128213. detachControl(element: Nullable<HTMLElement>): void;
  128214. /**
  128215. * Gets the class name of the current intput.
  128216. * @returns the class name
  128217. */
  128218. getClassName(): string;
  128219. /**
  128220. * Get the friendly name associated with the input class.
  128221. * @returns the input friendly name
  128222. */
  128223. getSimpleName(): string;
  128224. }
  128225. }
  128226. declare module BABYLON {
  128227. /**
  128228. * Manage the pointers inputs to control an follow camera.
  128229. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128230. */
  128231. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  128232. /**
  128233. * Defines the camera the input is attached to.
  128234. */
  128235. camera: FollowCamera;
  128236. /**
  128237. * Gets the class name of the current input.
  128238. * @returns the class name
  128239. */
  128240. getClassName(): string;
  128241. /**
  128242. * Defines the pointer angular sensibility along the X axis or how fast is
  128243. * the camera rotating.
  128244. * A negative number will reverse the axis direction.
  128245. */
  128246. angularSensibilityX: number;
  128247. /**
  128248. * Defines the pointer angular sensibility along the Y axis or how fast is
  128249. * the camera rotating.
  128250. * A negative number will reverse the axis direction.
  128251. */
  128252. angularSensibilityY: number;
  128253. /**
  128254. * Defines the pointer pinch precision or how fast is the camera zooming.
  128255. * A negative number will reverse the axis direction.
  128256. */
  128257. pinchPrecision: number;
  128258. /**
  128259. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  128260. * from 0.
  128261. * It defines the percentage of current camera.radius to use as delta when
  128262. * pinch zoom is used.
  128263. */
  128264. pinchDeltaPercentage: number;
  128265. /**
  128266. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  128267. */
  128268. axisXControlRadius: boolean;
  128269. /**
  128270. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  128271. */
  128272. axisXControlHeight: boolean;
  128273. /**
  128274. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  128275. */
  128276. axisXControlRotation: boolean;
  128277. /**
  128278. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  128279. */
  128280. axisYControlRadius: boolean;
  128281. /**
  128282. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  128283. */
  128284. axisYControlHeight: boolean;
  128285. /**
  128286. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  128287. */
  128288. axisYControlRotation: boolean;
  128289. /**
  128290. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  128291. */
  128292. axisPinchControlRadius: boolean;
  128293. /**
  128294. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  128295. */
  128296. axisPinchControlHeight: boolean;
  128297. /**
  128298. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  128299. */
  128300. axisPinchControlRotation: boolean;
  128301. /**
  128302. * Log error messages if basic misconfiguration has occurred.
  128303. */
  128304. warningEnable: boolean;
  128305. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  128306. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  128307. private _warningCounter;
  128308. private _warning;
  128309. }
  128310. }
  128311. declare module BABYLON {
  128312. /**
  128313. * Default Inputs manager for the FollowCamera.
  128314. * It groups all the default supported inputs for ease of use.
  128315. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128316. */
  128317. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  128318. /**
  128319. * Instantiates a new FollowCameraInputsManager.
  128320. * @param camera Defines the camera the inputs belong to
  128321. */
  128322. constructor(camera: FollowCamera);
  128323. /**
  128324. * Add keyboard input support to the input manager.
  128325. * @returns the current input manager
  128326. */
  128327. addKeyboard(): FollowCameraInputsManager;
  128328. /**
  128329. * Add mouse wheel input support to the input manager.
  128330. * @returns the current input manager
  128331. */
  128332. addMouseWheel(): FollowCameraInputsManager;
  128333. /**
  128334. * Add pointers input support to the input manager.
  128335. * @returns the current input manager
  128336. */
  128337. addPointers(): FollowCameraInputsManager;
  128338. /**
  128339. * Add orientation input support to the input manager.
  128340. * @returns the current input manager
  128341. */
  128342. addVRDeviceOrientation(): FollowCameraInputsManager;
  128343. }
  128344. }
  128345. declare module BABYLON {
  128346. /**
  128347. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  128348. * an arc rotate version arcFollowCamera are available.
  128349. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128350. */
  128351. export class FollowCamera extends TargetCamera {
  128352. /**
  128353. * Distance the follow camera should follow an object at
  128354. */
  128355. radius: number;
  128356. /**
  128357. * Minimum allowed distance of the camera to the axis of rotation
  128358. * (The camera can not get closer).
  128359. * This can help limiting how the Camera is able to move in the scene.
  128360. */
  128361. lowerRadiusLimit: Nullable<number>;
  128362. /**
  128363. * Maximum allowed distance of the camera to the axis of rotation
  128364. * (The camera can not get further).
  128365. * This can help limiting how the Camera is able to move in the scene.
  128366. */
  128367. upperRadiusLimit: Nullable<number>;
  128368. /**
  128369. * Define a rotation offset between the camera and the object it follows
  128370. */
  128371. rotationOffset: number;
  128372. /**
  128373. * Minimum allowed angle to camera position relative to target object.
  128374. * This can help limiting how the Camera is able to move in the scene.
  128375. */
  128376. lowerRotationOffsetLimit: Nullable<number>;
  128377. /**
  128378. * Maximum allowed angle to camera position relative to target object.
  128379. * This can help limiting how the Camera is able to move in the scene.
  128380. */
  128381. upperRotationOffsetLimit: Nullable<number>;
  128382. /**
  128383. * Define a height offset between the camera and the object it follows.
  128384. * It can help following an object from the top (like a car chaing a plane)
  128385. */
  128386. heightOffset: number;
  128387. /**
  128388. * Minimum allowed height of camera position relative to target object.
  128389. * This can help limiting how the Camera is able to move in the scene.
  128390. */
  128391. lowerHeightOffsetLimit: Nullable<number>;
  128392. /**
  128393. * Maximum allowed height of camera position relative to target object.
  128394. * This can help limiting how the Camera is able to move in the scene.
  128395. */
  128396. upperHeightOffsetLimit: Nullable<number>;
  128397. /**
  128398. * Define how fast the camera can accelerate to follow it s target.
  128399. */
  128400. cameraAcceleration: number;
  128401. /**
  128402. * Define the speed limit of the camera following an object.
  128403. */
  128404. maxCameraSpeed: number;
  128405. /**
  128406. * Define the target of the camera.
  128407. */
  128408. lockedTarget: Nullable<AbstractMesh>;
  128409. /**
  128410. * Defines the input associated with the camera.
  128411. */
  128412. inputs: FollowCameraInputsManager;
  128413. /**
  128414. * Instantiates the follow camera.
  128415. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128416. * @param name Define the name of the camera in the scene
  128417. * @param position Define the position of the camera
  128418. * @param scene Define the scene the camera belong to
  128419. * @param lockedTarget Define the target of the camera
  128420. */
  128421. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  128422. private _follow;
  128423. /**
  128424. * Attached controls to the current camera.
  128425. * @param element Defines the element the controls should be listened from
  128426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128427. */
  128428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128429. /**
  128430. * Detach the current controls from the camera.
  128431. * The camera will stop reacting to inputs.
  128432. * @param element Defines the element to stop listening the inputs from
  128433. */
  128434. detachControl(element: HTMLElement): void;
  128435. /** @hidden */
  128436. _checkInputs(): void;
  128437. private _checkLimits;
  128438. /**
  128439. * Gets the camera class name.
  128440. * @returns the class name
  128441. */
  128442. getClassName(): string;
  128443. }
  128444. /**
  128445. * Arc Rotate version of the follow camera.
  128446. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  128447. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128448. */
  128449. export class ArcFollowCamera extends TargetCamera {
  128450. /** The longitudinal angle of the camera */
  128451. alpha: number;
  128452. /** The latitudinal angle of the camera */
  128453. beta: number;
  128454. /** The radius of the camera from its target */
  128455. radius: number;
  128456. private _cartesianCoordinates;
  128457. /** Define the camera target (the mesh it should follow) */
  128458. private _meshTarget;
  128459. /**
  128460. * Instantiates a new ArcFollowCamera
  128461. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128462. * @param name Define the name of the camera
  128463. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  128464. * @param beta Define the rotation angle of the camera around the elevation axis
  128465. * @param radius Define the radius of the camera from its target point
  128466. * @param target Define the target of the camera
  128467. * @param scene Define the scene the camera belongs to
  128468. */
  128469. constructor(name: string,
  128470. /** The longitudinal angle of the camera */
  128471. alpha: number,
  128472. /** The latitudinal angle of the camera */
  128473. beta: number,
  128474. /** The radius of the camera from its target */
  128475. radius: number,
  128476. /** Define the camera target (the mesh it should follow) */
  128477. target: Nullable<AbstractMesh>, scene: Scene);
  128478. private _follow;
  128479. /** @hidden */
  128480. _checkInputs(): void;
  128481. /**
  128482. * Returns the class name of the object.
  128483. * It is mostly used internally for serialization purposes.
  128484. */
  128485. getClassName(): string;
  128486. }
  128487. }
  128488. declare module BABYLON {
  128489. /**
  128490. * Manage the keyboard inputs to control the movement of a follow camera.
  128491. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128492. */
  128493. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  128494. /**
  128495. * Defines the camera the input is attached to.
  128496. */
  128497. camera: FollowCamera;
  128498. /**
  128499. * Defines the list of key codes associated with the up action (increase heightOffset)
  128500. */
  128501. keysHeightOffsetIncr: number[];
  128502. /**
  128503. * Defines the list of key codes associated with the down action (decrease heightOffset)
  128504. */
  128505. keysHeightOffsetDecr: number[];
  128506. /**
  128507. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  128508. */
  128509. keysHeightOffsetModifierAlt: boolean;
  128510. /**
  128511. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  128512. */
  128513. keysHeightOffsetModifierCtrl: boolean;
  128514. /**
  128515. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  128516. */
  128517. keysHeightOffsetModifierShift: boolean;
  128518. /**
  128519. * Defines the list of key codes associated with the left action (increase rotationOffset)
  128520. */
  128521. keysRotationOffsetIncr: number[];
  128522. /**
  128523. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  128524. */
  128525. keysRotationOffsetDecr: number[];
  128526. /**
  128527. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  128528. */
  128529. keysRotationOffsetModifierAlt: boolean;
  128530. /**
  128531. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  128532. */
  128533. keysRotationOffsetModifierCtrl: boolean;
  128534. /**
  128535. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  128536. */
  128537. keysRotationOffsetModifierShift: boolean;
  128538. /**
  128539. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  128540. */
  128541. keysRadiusIncr: number[];
  128542. /**
  128543. * Defines the list of key codes associated with the zoom-out action (increase radius)
  128544. */
  128545. keysRadiusDecr: number[];
  128546. /**
  128547. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  128548. */
  128549. keysRadiusModifierAlt: boolean;
  128550. /**
  128551. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  128552. */
  128553. keysRadiusModifierCtrl: boolean;
  128554. /**
  128555. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  128556. */
  128557. keysRadiusModifierShift: boolean;
  128558. /**
  128559. * Defines the rate of change of heightOffset.
  128560. */
  128561. heightSensibility: number;
  128562. /**
  128563. * Defines the rate of change of rotationOffset.
  128564. */
  128565. rotationSensibility: number;
  128566. /**
  128567. * Defines the rate of change of radius.
  128568. */
  128569. radiusSensibility: number;
  128570. private _keys;
  128571. private _ctrlPressed;
  128572. private _altPressed;
  128573. private _shiftPressed;
  128574. private _onCanvasBlurObserver;
  128575. private _onKeyboardObserver;
  128576. private _engine;
  128577. private _scene;
  128578. /**
  128579. * Attach the input controls to a specific dom element to get the input from.
  128580. * @param element Defines the element the controls should be listened from
  128581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128582. */
  128583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128584. /**
  128585. * Detach the current controls from the specified dom element.
  128586. * @param element Defines the element to stop listening the inputs from
  128587. */
  128588. detachControl(element: Nullable<HTMLElement>): void;
  128589. /**
  128590. * Update the current camera state depending on the inputs that have been used this frame.
  128591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128592. */
  128593. checkInputs(): void;
  128594. /**
  128595. * Gets the class name of the current input.
  128596. * @returns the class name
  128597. */
  128598. getClassName(): string;
  128599. /**
  128600. * Get the friendly name associated with the input class.
  128601. * @returns the input friendly name
  128602. */
  128603. getSimpleName(): string;
  128604. /**
  128605. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128606. * allow modification of the heightOffset value.
  128607. */
  128608. private _modifierHeightOffset;
  128609. /**
  128610. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128611. * allow modification of the rotationOffset value.
  128612. */
  128613. private _modifierRotationOffset;
  128614. /**
  128615. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128616. * allow modification of the radius value.
  128617. */
  128618. private _modifierRadius;
  128619. }
  128620. }
  128621. declare module BABYLON {
  128622. interface FreeCameraInputsManager {
  128623. /**
  128624. * @hidden
  128625. */
  128626. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  128627. /**
  128628. * Add orientation input support to the input manager.
  128629. * @returns the current input manager
  128630. */
  128631. addDeviceOrientation(): FreeCameraInputsManager;
  128632. }
  128633. /**
  128634. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  128635. * Screen rotation is taken into account.
  128636. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128637. */
  128638. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  128639. private _camera;
  128640. private _screenOrientationAngle;
  128641. private _constantTranform;
  128642. private _screenQuaternion;
  128643. private _alpha;
  128644. private _beta;
  128645. private _gamma;
  128646. /**
  128647. * Can be used to detect if a device orientation sensor is available on a device
  128648. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  128649. * @returns a promise that will resolve on orientation change
  128650. */
  128651. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  128652. /**
  128653. * @hidden
  128654. */
  128655. _onDeviceOrientationChangedObservable: Observable<void>;
  128656. /**
  128657. * Instantiates a new input
  128658. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128659. */
  128660. constructor();
  128661. /**
  128662. * Define the camera controlled by the input.
  128663. */
  128664. get camera(): FreeCamera;
  128665. set camera(camera: FreeCamera);
  128666. /**
  128667. * Attach the input controls to a specific dom element to get the input from.
  128668. * @param element Defines the element the controls should be listened from
  128669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128670. */
  128671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128672. private _orientationChanged;
  128673. private _deviceOrientation;
  128674. /**
  128675. * Detach the current controls from the specified dom element.
  128676. * @param element Defines the element to stop listening the inputs from
  128677. */
  128678. detachControl(element: Nullable<HTMLElement>): void;
  128679. /**
  128680. * Update the current camera state depending on the inputs that have been used this frame.
  128681. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128682. */
  128683. checkInputs(): void;
  128684. /**
  128685. * Gets the class name of the current intput.
  128686. * @returns the class name
  128687. */
  128688. getClassName(): string;
  128689. /**
  128690. * Get the friendly name associated with the input class.
  128691. * @returns the input friendly name
  128692. */
  128693. getSimpleName(): string;
  128694. }
  128695. }
  128696. declare module BABYLON {
  128697. /**
  128698. * Manage the gamepad inputs to control a free camera.
  128699. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128700. */
  128701. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  128702. /**
  128703. * Define the camera the input is attached to.
  128704. */
  128705. camera: FreeCamera;
  128706. /**
  128707. * Define the Gamepad controlling the input
  128708. */
  128709. gamepad: Nullable<Gamepad>;
  128710. /**
  128711. * Defines the gamepad rotation sensiblity.
  128712. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128713. */
  128714. gamepadAngularSensibility: number;
  128715. /**
  128716. * Defines the gamepad move sensiblity.
  128717. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128718. */
  128719. gamepadMoveSensibility: number;
  128720. private _yAxisScale;
  128721. /**
  128722. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128723. */
  128724. get invertYAxis(): boolean;
  128725. set invertYAxis(value: boolean);
  128726. private _onGamepadConnectedObserver;
  128727. private _onGamepadDisconnectedObserver;
  128728. private _cameraTransform;
  128729. private _deltaTransform;
  128730. private _vector3;
  128731. private _vector2;
  128732. /**
  128733. * Attach the input controls to a specific dom element to get the input from.
  128734. * @param element Defines the element the controls should be listened from
  128735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128736. */
  128737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128738. /**
  128739. * Detach the current controls from the specified dom element.
  128740. * @param element Defines the element to stop listening the inputs from
  128741. */
  128742. detachControl(element: Nullable<HTMLElement>): void;
  128743. /**
  128744. * Update the current camera state depending on the inputs that have been used this frame.
  128745. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128746. */
  128747. checkInputs(): void;
  128748. /**
  128749. * Gets the class name of the current intput.
  128750. * @returns the class name
  128751. */
  128752. getClassName(): string;
  128753. /**
  128754. * Get the friendly name associated with the input class.
  128755. * @returns the input friendly name
  128756. */
  128757. getSimpleName(): string;
  128758. }
  128759. }
  128760. declare module BABYLON {
  128761. /**
  128762. * Defines the potential axis of a Joystick
  128763. */
  128764. export enum JoystickAxis {
  128765. /** X axis */
  128766. X = 0,
  128767. /** Y axis */
  128768. Y = 1,
  128769. /** Z axis */
  128770. Z = 2
  128771. }
  128772. /**
  128773. * Represents the different customization options available
  128774. * for VirtualJoystick
  128775. */
  128776. interface VirtualJoystickCustomizations {
  128777. /**
  128778. * Size of the joystick's puck
  128779. */
  128780. puckSize: number;
  128781. /**
  128782. * Size of the joystick's container
  128783. */
  128784. containerSize: number;
  128785. /**
  128786. * Color of the joystick && puck
  128787. */
  128788. color: string;
  128789. /**
  128790. * Image URL for the joystick's puck
  128791. */
  128792. puckImage?: string;
  128793. /**
  128794. * Image URL for the joystick's container
  128795. */
  128796. containerImage?: string;
  128797. /**
  128798. * Defines the unmoving position of the joystick container
  128799. */
  128800. position?: {
  128801. x: number;
  128802. y: number;
  128803. };
  128804. /**
  128805. * Defines whether or not the joystick container is always visible
  128806. */
  128807. alwaysVisible: boolean;
  128808. /**
  128809. * Defines whether or not to limit the movement of the puck to the joystick's container
  128810. */
  128811. limitToContainer: boolean;
  128812. }
  128813. /**
  128814. * Class used to define virtual joystick (used in touch mode)
  128815. */
  128816. export class VirtualJoystick {
  128817. /**
  128818. * Gets or sets a boolean indicating that left and right values must be inverted
  128819. */
  128820. reverseLeftRight: boolean;
  128821. /**
  128822. * Gets or sets a boolean indicating that up and down values must be inverted
  128823. */
  128824. reverseUpDown: boolean;
  128825. /**
  128826. * Gets the offset value for the position (ie. the change of the position value)
  128827. */
  128828. deltaPosition: Vector3;
  128829. /**
  128830. * Gets a boolean indicating if the virtual joystick was pressed
  128831. */
  128832. pressed: boolean;
  128833. /**
  128834. * Canvas the virtual joystick will render onto, default z-index of this is 5
  128835. */
  128836. static Canvas: Nullable<HTMLCanvasElement>;
  128837. /**
  128838. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  128839. */
  128840. limitToContainer: boolean;
  128841. private static _globalJoystickIndex;
  128842. private static _alwaysVisibleSticks;
  128843. private static vjCanvasContext;
  128844. private static vjCanvasWidth;
  128845. private static vjCanvasHeight;
  128846. private static halfWidth;
  128847. private static _GetDefaultOptions;
  128848. private _action;
  128849. private _axisTargetedByLeftAndRight;
  128850. private _axisTargetedByUpAndDown;
  128851. private _joystickSensibility;
  128852. private _inversedSensibility;
  128853. private _joystickPointerID;
  128854. private _joystickColor;
  128855. private _joystickPointerPos;
  128856. private _joystickPreviousPointerPos;
  128857. private _joystickPointerStartPos;
  128858. private _deltaJoystickVector;
  128859. private _leftJoystick;
  128860. private _touches;
  128861. private _joystickPosition;
  128862. private _alwaysVisible;
  128863. private _puckImage;
  128864. private _containerImage;
  128865. private _joystickPuckSize;
  128866. private _joystickContainerSize;
  128867. private _clearPuckSize;
  128868. private _clearContainerSize;
  128869. private _clearPuckSizeOffset;
  128870. private _clearContainerSizeOffset;
  128871. private _onPointerDownHandlerRef;
  128872. private _onPointerMoveHandlerRef;
  128873. private _onPointerUpHandlerRef;
  128874. private _onResize;
  128875. /**
  128876. * Creates a new virtual joystick
  128877. * @param leftJoystick defines that the joystick is for left hand (false by default)
  128878. * @param customizations Defines the options we want to customize the VirtualJoystick
  128879. */
  128880. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  128881. /**
  128882. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  128883. * @param newJoystickSensibility defines the new sensibility
  128884. */
  128885. setJoystickSensibility(newJoystickSensibility: number): void;
  128886. private _onPointerDown;
  128887. private _onPointerMove;
  128888. private _onPointerUp;
  128889. /**
  128890. * Change the color of the virtual joystick
  128891. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  128892. */
  128893. setJoystickColor(newColor: string): void;
  128894. /**
  128895. * Size of the joystick's container
  128896. */
  128897. set containerSize(newSize: number);
  128898. get containerSize(): number;
  128899. /**
  128900. * Size of the joystick's puck
  128901. */
  128902. set puckSize(newSize: number);
  128903. get puckSize(): number;
  128904. /**
  128905. * Clears the set position of the joystick
  128906. */
  128907. clearPosition(): void;
  128908. /**
  128909. * Defines whether or not the joystick container is always visible
  128910. */
  128911. set alwaysVisible(value: boolean);
  128912. get alwaysVisible(): boolean;
  128913. /**
  128914. * Sets the constant position of the Joystick container
  128915. * @param x X axis coordinate
  128916. * @param y Y axis coordinate
  128917. */
  128918. setPosition(x: number, y: number): void;
  128919. /**
  128920. * Defines a callback to call when the joystick is touched
  128921. * @param action defines the callback
  128922. */
  128923. setActionOnTouch(action: () => any): void;
  128924. /**
  128925. * Defines which axis you'd like to control for left & right
  128926. * @param axis defines the axis to use
  128927. */
  128928. setAxisForLeftRight(axis: JoystickAxis): void;
  128929. /**
  128930. * Defines which axis you'd like to control for up & down
  128931. * @param axis defines the axis to use
  128932. */
  128933. setAxisForUpDown(axis: JoystickAxis): void;
  128934. /**
  128935. * Clears the canvas from the previous puck / container draw
  128936. */
  128937. private _clearPreviousDraw;
  128938. /**
  128939. * Loads `urlPath` to be used for the container's image
  128940. * @param urlPath defines the urlPath of an image to use
  128941. */
  128942. setContainerImage(urlPath: string): void;
  128943. /**
  128944. * Loads `urlPath` to be used for the puck's image
  128945. * @param urlPath defines the urlPath of an image to use
  128946. */
  128947. setPuckImage(urlPath: string): void;
  128948. /**
  128949. * Draws the Virtual Joystick's container
  128950. */
  128951. private _drawContainer;
  128952. /**
  128953. * Draws the Virtual Joystick's puck
  128954. */
  128955. private _drawPuck;
  128956. private _drawVirtualJoystick;
  128957. /**
  128958. * Release internal HTML canvas
  128959. */
  128960. releaseCanvas(): void;
  128961. }
  128962. }
  128963. declare module BABYLON {
  128964. interface FreeCameraInputsManager {
  128965. /**
  128966. * Add virtual joystick input support to the input manager.
  128967. * @returns the current input manager
  128968. */
  128969. addVirtualJoystick(): FreeCameraInputsManager;
  128970. }
  128971. /**
  128972. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  128973. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128974. */
  128975. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  128976. /**
  128977. * Defines the camera the input is attached to.
  128978. */
  128979. camera: FreeCamera;
  128980. private _leftjoystick;
  128981. private _rightjoystick;
  128982. /**
  128983. * Gets the left stick of the virtual joystick.
  128984. * @returns The virtual Joystick
  128985. */
  128986. getLeftJoystick(): VirtualJoystick;
  128987. /**
  128988. * Gets the right stick of the virtual joystick.
  128989. * @returns The virtual Joystick
  128990. */
  128991. getRightJoystick(): VirtualJoystick;
  128992. /**
  128993. * Update the current camera state depending on the inputs that have been used this frame.
  128994. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128995. */
  128996. checkInputs(): void;
  128997. /**
  128998. * Attach the input controls to a specific dom element to get the input from.
  128999. * @param element Defines the element the controls should be listened from
  129000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129001. */
  129002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  129003. /**
  129004. * Detach the current controls from the specified dom element.
  129005. * @param element Defines the element to stop listening the inputs from
  129006. */
  129007. detachControl(element: Nullable<HTMLElement>): void;
  129008. /**
  129009. * Gets the class name of the current intput.
  129010. * @returns the class name
  129011. */
  129012. getClassName(): string;
  129013. /**
  129014. * Get the friendly name associated with the input class.
  129015. * @returns the input friendly name
  129016. */
  129017. getSimpleName(): string;
  129018. }
  129019. }
  129020. declare module BABYLON {
  129021. /**
  129022. * This represents a FPS type of camera controlled by touch.
  129023. * This is like a universal camera minus the Gamepad controls.
  129024. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129025. */
  129026. export class TouchCamera extends FreeCamera {
  129027. /**
  129028. * Defines the touch sensibility for rotation.
  129029. * The higher the faster.
  129030. */
  129031. get touchAngularSensibility(): number;
  129032. set touchAngularSensibility(value: number);
  129033. /**
  129034. * Defines the touch sensibility for move.
  129035. * The higher the faster.
  129036. */
  129037. get touchMoveSensibility(): number;
  129038. set touchMoveSensibility(value: number);
  129039. /**
  129040. * Instantiates a new touch camera.
  129041. * This represents a FPS type of camera controlled by touch.
  129042. * This is like a universal camera minus the Gamepad controls.
  129043. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129044. * @param name Define the name of the camera in the scene
  129045. * @param position Define the start position of the camera in the scene
  129046. * @param scene Define the scene the camera belongs to
  129047. */
  129048. constructor(name: string, position: Vector3, scene: Scene);
  129049. /**
  129050. * Gets the current object class name.
  129051. * @return the class name
  129052. */
  129053. getClassName(): string;
  129054. /** @hidden */
  129055. _setupInputs(): void;
  129056. }
  129057. }
  129058. declare module BABYLON {
  129059. /**
  129060. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  129061. * being tilted forward or back and left or right.
  129062. */
  129063. export class DeviceOrientationCamera extends FreeCamera {
  129064. private _initialQuaternion;
  129065. private _quaternionCache;
  129066. private _tmpDragQuaternion;
  129067. private _disablePointerInputWhenUsingDeviceOrientation;
  129068. /**
  129069. * Creates a new device orientation camera
  129070. * @param name The name of the camera
  129071. * @param position The start position camera
  129072. * @param scene The scene the camera belongs to
  129073. */
  129074. constructor(name: string, position: Vector3, scene: Scene);
  129075. /**
  129076. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  129077. */
  129078. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  129079. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  129080. private _dragFactor;
  129081. /**
  129082. * Enabled turning on the y axis when the orientation sensor is active
  129083. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  129084. */
  129085. enableHorizontalDragging(dragFactor?: number): void;
  129086. /**
  129087. * Gets the current instance class name ("DeviceOrientationCamera").
  129088. * This helps avoiding instanceof at run time.
  129089. * @returns the class name
  129090. */
  129091. getClassName(): string;
  129092. /**
  129093. * @hidden
  129094. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  129095. */
  129096. _checkInputs(): void;
  129097. /**
  129098. * Reset the camera to its default orientation on the specified axis only.
  129099. * @param axis The axis to reset
  129100. */
  129101. resetToCurrentRotation(axis?: Axis): void;
  129102. }
  129103. }
  129104. declare module BABYLON {
  129105. /**
  129106. * Defines supported buttons for XBox360 compatible gamepads
  129107. */
  129108. export enum Xbox360Button {
  129109. /** A */
  129110. A = 0,
  129111. /** B */
  129112. B = 1,
  129113. /** X */
  129114. X = 2,
  129115. /** Y */
  129116. Y = 3,
  129117. /** Left button */
  129118. LB = 4,
  129119. /** Right button */
  129120. RB = 5,
  129121. /** Back */
  129122. Back = 8,
  129123. /** Start */
  129124. Start = 9,
  129125. /** Left stick */
  129126. LeftStick = 10,
  129127. /** Right stick */
  129128. RightStick = 11
  129129. }
  129130. /** Defines values for XBox360 DPad */
  129131. export enum Xbox360Dpad {
  129132. /** Up */
  129133. Up = 12,
  129134. /** Down */
  129135. Down = 13,
  129136. /** Left */
  129137. Left = 14,
  129138. /** Right */
  129139. Right = 15
  129140. }
  129141. /**
  129142. * Defines a XBox360 gamepad
  129143. */
  129144. export class Xbox360Pad extends Gamepad {
  129145. private _leftTrigger;
  129146. private _rightTrigger;
  129147. private _onlefttriggerchanged;
  129148. private _onrighttriggerchanged;
  129149. private _onbuttondown;
  129150. private _onbuttonup;
  129151. private _ondpaddown;
  129152. private _ondpadup;
  129153. /** Observable raised when a button is pressed */
  129154. onButtonDownObservable: Observable<Xbox360Button>;
  129155. /** Observable raised when a button is released */
  129156. onButtonUpObservable: Observable<Xbox360Button>;
  129157. /** Observable raised when a pad is pressed */
  129158. onPadDownObservable: Observable<Xbox360Dpad>;
  129159. /** Observable raised when a pad is released */
  129160. onPadUpObservable: Observable<Xbox360Dpad>;
  129161. private _buttonA;
  129162. private _buttonB;
  129163. private _buttonX;
  129164. private _buttonY;
  129165. private _buttonBack;
  129166. private _buttonStart;
  129167. private _buttonLB;
  129168. private _buttonRB;
  129169. private _buttonLeftStick;
  129170. private _buttonRightStick;
  129171. private _dPadUp;
  129172. private _dPadDown;
  129173. private _dPadLeft;
  129174. private _dPadRight;
  129175. private _isXboxOnePad;
  129176. /**
  129177. * Creates a new XBox360 gamepad object
  129178. * @param id defines the id of this gamepad
  129179. * @param index defines its index
  129180. * @param gamepad defines the internal HTML gamepad object
  129181. * @param xboxOne defines if it is a XBox One gamepad
  129182. */
  129183. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  129184. /**
  129185. * Defines the callback to call when left trigger is pressed
  129186. * @param callback defines the callback to use
  129187. */
  129188. onlefttriggerchanged(callback: (value: number) => void): void;
  129189. /**
  129190. * Defines the callback to call when right trigger is pressed
  129191. * @param callback defines the callback to use
  129192. */
  129193. onrighttriggerchanged(callback: (value: number) => void): void;
  129194. /**
  129195. * Gets the left trigger value
  129196. */
  129197. get leftTrigger(): number;
  129198. /**
  129199. * Sets the left trigger value
  129200. */
  129201. set leftTrigger(newValue: number);
  129202. /**
  129203. * Gets the right trigger value
  129204. */
  129205. get rightTrigger(): number;
  129206. /**
  129207. * Sets the right trigger value
  129208. */
  129209. set rightTrigger(newValue: number);
  129210. /**
  129211. * Defines the callback to call when a button is pressed
  129212. * @param callback defines the callback to use
  129213. */
  129214. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  129215. /**
  129216. * Defines the callback to call when a button is released
  129217. * @param callback defines the callback to use
  129218. */
  129219. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  129220. /**
  129221. * Defines the callback to call when a pad is pressed
  129222. * @param callback defines the callback to use
  129223. */
  129224. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  129225. /**
  129226. * Defines the callback to call when a pad is released
  129227. * @param callback defines the callback to use
  129228. */
  129229. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  129230. private _setButtonValue;
  129231. private _setDPadValue;
  129232. /**
  129233. * Gets the value of the `A` button
  129234. */
  129235. get buttonA(): number;
  129236. /**
  129237. * Sets the value of the `A` button
  129238. */
  129239. set buttonA(value: number);
  129240. /**
  129241. * Gets the value of the `B` button
  129242. */
  129243. get buttonB(): number;
  129244. /**
  129245. * Sets the value of the `B` button
  129246. */
  129247. set buttonB(value: number);
  129248. /**
  129249. * Gets the value of the `X` button
  129250. */
  129251. get buttonX(): number;
  129252. /**
  129253. * Sets the value of the `X` button
  129254. */
  129255. set buttonX(value: number);
  129256. /**
  129257. * Gets the value of the `Y` button
  129258. */
  129259. get buttonY(): number;
  129260. /**
  129261. * Sets the value of the `Y` button
  129262. */
  129263. set buttonY(value: number);
  129264. /**
  129265. * Gets the value of the `Start` button
  129266. */
  129267. get buttonStart(): number;
  129268. /**
  129269. * Sets the value of the `Start` button
  129270. */
  129271. set buttonStart(value: number);
  129272. /**
  129273. * Gets the value of the `Back` button
  129274. */
  129275. get buttonBack(): number;
  129276. /**
  129277. * Sets the value of the `Back` button
  129278. */
  129279. set buttonBack(value: number);
  129280. /**
  129281. * Gets the value of the `Left` button
  129282. */
  129283. get buttonLB(): number;
  129284. /**
  129285. * Sets the value of the `Left` button
  129286. */
  129287. set buttonLB(value: number);
  129288. /**
  129289. * Gets the value of the `Right` button
  129290. */
  129291. get buttonRB(): number;
  129292. /**
  129293. * Sets the value of the `Right` button
  129294. */
  129295. set buttonRB(value: number);
  129296. /**
  129297. * Gets the value of the Left joystick
  129298. */
  129299. get buttonLeftStick(): number;
  129300. /**
  129301. * Sets the value of the Left joystick
  129302. */
  129303. set buttonLeftStick(value: number);
  129304. /**
  129305. * Gets the value of the Right joystick
  129306. */
  129307. get buttonRightStick(): number;
  129308. /**
  129309. * Sets the value of the Right joystick
  129310. */
  129311. set buttonRightStick(value: number);
  129312. /**
  129313. * Gets the value of D-pad up
  129314. */
  129315. get dPadUp(): number;
  129316. /**
  129317. * Sets the value of D-pad up
  129318. */
  129319. set dPadUp(value: number);
  129320. /**
  129321. * Gets the value of D-pad down
  129322. */
  129323. get dPadDown(): number;
  129324. /**
  129325. * Sets the value of D-pad down
  129326. */
  129327. set dPadDown(value: number);
  129328. /**
  129329. * Gets the value of D-pad left
  129330. */
  129331. get dPadLeft(): number;
  129332. /**
  129333. * Sets the value of D-pad left
  129334. */
  129335. set dPadLeft(value: number);
  129336. /**
  129337. * Gets the value of D-pad right
  129338. */
  129339. get dPadRight(): number;
  129340. /**
  129341. * Sets the value of D-pad right
  129342. */
  129343. set dPadRight(value: number);
  129344. /**
  129345. * Force the gamepad to synchronize with device values
  129346. */
  129347. update(): void;
  129348. /**
  129349. * Disposes the gamepad
  129350. */
  129351. dispose(): void;
  129352. }
  129353. }
  129354. declare module BABYLON {
  129355. /**
  129356. * Defines supported buttons for DualShock compatible gamepads
  129357. */
  129358. export enum DualShockButton {
  129359. /** Cross */
  129360. Cross = 0,
  129361. /** Circle */
  129362. Circle = 1,
  129363. /** Square */
  129364. Square = 2,
  129365. /** Triangle */
  129366. Triangle = 3,
  129367. /** L1 */
  129368. L1 = 4,
  129369. /** R1 */
  129370. R1 = 5,
  129371. /** Share */
  129372. Share = 8,
  129373. /** Options */
  129374. Options = 9,
  129375. /** Left stick */
  129376. LeftStick = 10,
  129377. /** Right stick */
  129378. RightStick = 11
  129379. }
  129380. /** Defines values for DualShock DPad */
  129381. export enum DualShockDpad {
  129382. /** Up */
  129383. Up = 12,
  129384. /** Down */
  129385. Down = 13,
  129386. /** Left */
  129387. Left = 14,
  129388. /** Right */
  129389. Right = 15
  129390. }
  129391. /**
  129392. * Defines a DualShock gamepad
  129393. */
  129394. export class DualShockPad extends Gamepad {
  129395. private _leftTrigger;
  129396. private _rightTrigger;
  129397. private _onlefttriggerchanged;
  129398. private _onrighttriggerchanged;
  129399. private _onbuttondown;
  129400. private _onbuttonup;
  129401. private _ondpaddown;
  129402. private _ondpadup;
  129403. /** Observable raised when a button is pressed */
  129404. onButtonDownObservable: Observable<DualShockButton>;
  129405. /** Observable raised when a button is released */
  129406. onButtonUpObservable: Observable<DualShockButton>;
  129407. /** Observable raised when a pad is pressed */
  129408. onPadDownObservable: Observable<DualShockDpad>;
  129409. /** Observable raised when a pad is released */
  129410. onPadUpObservable: Observable<DualShockDpad>;
  129411. private _buttonCross;
  129412. private _buttonCircle;
  129413. private _buttonSquare;
  129414. private _buttonTriangle;
  129415. private _buttonShare;
  129416. private _buttonOptions;
  129417. private _buttonL1;
  129418. private _buttonR1;
  129419. private _buttonLeftStick;
  129420. private _buttonRightStick;
  129421. private _dPadUp;
  129422. private _dPadDown;
  129423. private _dPadLeft;
  129424. private _dPadRight;
  129425. /**
  129426. * Creates a new DualShock gamepad object
  129427. * @param id defines the id of this gamepad
  129428. * @param index defines its index
  129429. * @param gamepad defines the internal HTML gamepad object
  129430. */
  129431. constructor(id: string, index: number, gamepad: any);
  129432. /**
  129433. * Defines the callback to call when left trigger is pressed
  129434. * @param callback defines the callback to use
  129435. */
  129436. onlefttriggerchanged(callback: (value: number) => void): void;
  129437. /**
  129438. * Defines the callback to call when right trigger is pressed
  129439. * @param callback defines the callback to use
  129440. */
  129441. onrighttriggerchanged(callback: (value: number) => void): void;
  129442. /**
  129443. * Gets the left trigger value
  129444. */
  129445. get leftTrigger(): number;
  129446. /**
  129447. * Sets the left trigger value
  129448. */
  129449. set leftTrigger(newValue: number);
  129450. /**
  129451. * Gets the right trigger value
  129452. */
  129453. get rightTrigger(): number;
  129454. /**
  129455. * Sets the right trigger value
  129456. */
  129457. set rightTrigger(newValue: number);
  129458. /**
  129459. * Defines the callback to call when a button is pressed
  129460. * @param callback defines the callback to use
  129461. */
  129462. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  129463. /**
  129464. * Defines the callback to call when a button is released
  129465. * @param callback defines the callback to use
  129466. */
  129467. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  129468. /**
  129469. * Defines the callback to call when a pad is pressed
  129470. * @param callback defines the callback to use
  129471. */
  129472. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  129473. /**
  129474. * Defines the callback to call when a pad is released
  129475. * @param callback defines the callback to use
  129476. */
  129477. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  129478. private _setButtonValue;
  129479. private _setDPadValue;
  129480. /**
  129481. * Gets the value of the `Cross` button
  129482. */
  129483. get buttonCross(): number;
  129484. /**
  129485. * Sets the value of the `Cross` button
  129486. */
  129487. set buttonCross(value: number);
  129488. /**
  129489. * Gets the value of the `Circle` button
  129490. */
  129491. get buttonCircle(): number;
  129492. /**
  129493. * Sets the value of the `Circle` button
  129494. */
  129495. set buttonCircle(value: number);
  129496. /**
  129497. * Gets the value of the `Square` button
  129498. */
  129499. get buttonSquare(): number;
  129500. /**
  129501. * Sets the value of the `Square` button
  129502. */
  129503. set buttonSquare(value: number);
  129504. /**
  129505. * Gets the value of the `Triangle` button
  129506. */
  129507. get buttonTriangle(): number;
  129508. /**
  129509. * Sets the value of the `Triangle` button
  129510. */
  129511. set buttonTriangle(value: number);
  129512. /**
  129513. * Gets the value of the `Options` button
  129514. */
  129515. get buttonOptions(): number;
  129516. /**
  129517. * Sets the value of the `Options` button
  129518. */
  129519. set buttonOptions(value: number);
  129520. /**
  129521. * Gets the value of the `Share` button
  129522. */
  129523. get buttonShare(): number;
  129524. /**
  129525. * Sets the value of the `Share` button
  129526. */
  129527. set buttonShare(value: number);
  129528. /**
  129529. * Gets the value of the `L1` button
  129530. */
  129531. get buttonL1(): number;
  129532. /**
  129533. * Sets the value of the `L1` button
  129534. */
  129535. set buttonL1(value: number);
  129536. /**
  129537. * Gets the value of the `R1` button
  129538. */
  129539. get buttonR1(): number;
  129540. /**
  129541. * Sets the value of the `R1` button
  129542. */
  129543. set buttonR1(value: number);
  129544. /**
  129545. * Gets the value of the Left joystick
  129546. */
  129547. get buttonLeftStick(): number;
  129548. /**
  129549. * Sets the value of the Left joystick
  129550. */
  129551. set buttonLeftStick(value: number);
  129552. /**
  129553. * Gets the value of the Right joystick
  129554. */
  129555. get buttonRightStick(): number;
  129556. /**
  129557. * Sets the value of the Right joystick
  129558. */
  129559. set buttonRightStick(value: number);
  129560. /**
  129561. * Gets the value of D-pad up
  129562. */
  129563. get dPadUp(): number;
  129564. /**
  129565. * Sets the value of D-pad up
  129566. */
  129567. set dPadUp(value: number);
  129568. /**
  129569. * Gets the value of D-pad down
  129570. */
  129571. get dPadDown(): number;
  129572. /**
  129573. * Sets the value of D-pad down
  129574. */
  129575. set dPadDown(value: number);
  129576. /**
  129577. * Gets the value of D-pad left
  129578. */
  129579. get dPadLeft(): number;
  129580. /**
  129581. * Sets the value of D-pad left
  129582. */
  129583. set dPadLeft(value: number);
  129584. /**
  129585. * Gets the value of D-pad right
  129586. */
  129587. get dPadRight(): number;
  129588. /**
  129589. * Sets the value of D-pad right
  129590. */
  129591. set dPadRight(value: number);
  129592. /**
  129593. * Force the gamepad to synchronize with device values
  129594. */
  129595. update(): void;
  129596. /**
  129597. * Disposes the gamepad
  129598. */
  129599. dispose(): void;
  129600. }
  129601. }
  129602. declare module BABYLON {
  129603. /**
  129604. * Manager for handling gamepads
  129605. */
  129606. export class GamepadManager {
  129607. private _scene?;
  129608. private _babylonGamepads;
  129609. private _oneGamepadConnected;
  129610. /** @hidden */
  129611. _isMonitoring: boolean;
  129612. private _gamepadEventSupported;
  129613. private _gamepadSupport?;
  129614. /**
  129615. * observable to be triggered when the gamepad controller has been connected
  129616. */
  129617. onGamepadConnectedObservable: Observable<Gamepad>;
  129618. /**
  129619. * observable to be triggered when the gamepad controller has been disconnected
  129620. */
  129621. onGamepadDisconnectedObservable: Observable<Gamepad>;
  129622. private _onGamepadConnectedEvent;
  129623. private _onGamepadDisconnectedEvent;
  129624. /**
  129625. * Initializes the gamepad manager
  129626. * @param _scene BabylonJS scene
  129627. */
  129628. constructor(_scene?: Scene | undefined);
  129629. /**
  129630. * The gamepads in the game pad manager
  129631. */
  129632. get gamepads(): Gamepad[];
  129633. /**
  129634. * Get the gamepad controllers based on type
  129635. * @param type The type of gamepad controller
  129636. * @returns Nullable gamepad
  129637. */
  129638. getGamepadByType(type?: number): Nullable<Gamepad>;
  129639. /**
  129640. * Disposes the gamepad manager
  129641. */
  129642. dispose(): void;
  129643. private _addNewGamepad;
  129644. private _startMonitoringGamepads;
  129645. private _stopMonitoringGamepads;
  129646. /** @hidden */
  129647. _checkGamepadsStatus(): void;
  129648. private _updateGamepadObjects;
  129649. }
  129650. }
  129651. declare module BABYLON {
  129652. interface Scene {
  129653. /** @hidden */
  129654. _gamepadManager: Nullable<GamepadManager>;
  129655. /**
  129656. * Gets the gamepad manager associated with the scene
  129657. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  129658. */
  129659. gamepadManager: GamepadManager;
  129660. }
  129661. /**
  129662. * Interface representing a free camera inputs manager
  129663. */
  129664. interface FreeCameraInputsManager {
  129665. /**
  129666. * Adds gamepad input support to the FreeCameraInputsManager.
  129667. * @returns the FreeCameraInputsManager
  129668. */
  129669. addGamepad(): FreeCameraInputsManager;
  129670. }
  129671. /**
  129672. * Interface representing an arc rotate camera inputs manager
  129673. */
  129674. interface ArcRotateCameraInputsManager {
  129675. /**
  129676. * Adds gamepad input support to the ArcRotateCamera InputManager.
  129677. * @returns the camera inputs manager
  129678. */
  129679. addGamepad(): ArcRotateCameraInputsManager;
  129680. }
  129681. /**
  129682. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  129683. */
  129684. export class GamepadSystemSceneComponent implements ISceneComponent {
  129685. /**
  129686. * The component name helpfull to identify the component in the list of scene components.
  129687. */
  129688. readonly name: string;
  129689. /**
  129690. * The scene the component belongs to.
  129691. */
  129692. scene: Scene;
  129693. /**
  129694. * Creates a new instance of the component for the given scene
  129695. * @param scene Defines the scene to register the component in
  129696. */
  129697. constructor(scene: Scene);
  129698. /**
  129699. * Registers the component in a given scene
  129700. */
  129701. register(): void;
  129702. /**
  129703. * Rebuilds the elements related to this component in case of
  129704. * context lost for instance.
  129705. */
  129706. rebuild(): void;
  129707. /**
  129708. * Disposes the component and the associated ressources
  129709. */
  129710. dispose(): void;
  129711. private _beforeCameraUpdate;
  129712. }
  129713. }
  129714. declare module BABYLON {
  129715. /**
  129716. * 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,
  129717. * which still works and will still be found in many Playgrounds.
  129718. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129719. */
  129720. export class UniversalCamera extends TouchCamera {
  129721. /**
  129722. * Defines the gamepad rotation sensiblity.
  129723. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129724. */
  129725. get gamepadAngularSensibility(): number;
  129726. set gamepadAngularSensibility(value: number);
  129727. /**
  129728. * Defines the gamepad move sensiblity.
  129729. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129730. */
  129731. get gamepadMoveSensibility(): number;
  129732. set gamepadMoveSensibility(value: number);
  129733. /**
  129734. * 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,
  129735. * which still works and will still be found in many Playgrounds.
  129736. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129737. * @param name Define the name of the camera in the scene
  129738. * @param position Define the start position of the camera in the scene
  129739. * @param scene Define the scene the camera belongs to
  129740. */
  129741. constructor(name: string, position: Vector3, scene: Scene);
  129742. /**
  129743. * Gets the current object class name.
  129744. * @return the class name
  129745. */
  129746. getClassName(): string;
  129747. }
  129748. }
  129749. declare module BABYLON {
  129750. /**
  129751. * This represents a FPS type of camera. This is only here for back compat purpose.
  129752. * Please use the UniversalCamera instead as both are identical.
  129753. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129754. */
  129755. export class GamepadCamera extends UniversalCamera {
  129756. /**
  129757. * Instantiates a new Gamepad Camera
  129758. * This represents a FPS type of camera. This is only here for back compat purpose.
  129759. * Please use the UniversalCamera instead as both are identical.
  129760. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129761. * @param name Define the name of the camera in the scene
  129762. * @param position Define the start position of the camera in the scene
  129763. * @param scene Define the scene the camera belongs to
  129764. */
  129765. constructor(name: string, position: Vector3, scene: Scene);
  129766. /**
  129767. * Gets the current object class name.
  129768. * @return the class name
  129769. */
  129770. getClassName(): string;
  129771. }
  129772. }
  129773. declare module BABYLON {
  129774. /** @hidden */
  129775. export var passPixelShader: {
  129776. name: string;
  129777. shader: string;
  129778. };
  129779. }
  129780. declare module BABYLON {
  129781. /** @hidden */
  129782. export var passCubePixelShader: {
  129783. name: string;
  129784. shader: string;
  129785. };
  129786. }
  129787. declare module BABYLON {
  129788. /**
  129789. * PassPostProcess which produces an output the same as it's input
  129790. */
  129791. export class PassPostProcess extends PostProcess {
  129792. /**
  129793. * Gets a string identifying the name of the class
  129794. * @returns "PassPostProcess" string
  129795. */
  129796. getClassName(): string;
  129797. /**
  129798. * Creates the PassPostProcess
  129799. * @param name The name of the effect.
  129800. * @param options The required width/height ratio to downsize to before computing the render pass.
  129801. * @param camera The camera to apply the render pass to.
  129802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129803. * @param engine The engine which the post process will be applied. (default: current engine)
  129804. * @param reusable If the post process can be reused on the same frame. (default: false)
  129805. * @param textureType The type of texture to be used when performing the post processing.
  129806. * @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)
  129807. */
  129808. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129809. /** @hidden */
  129810. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  129811. }
  129812. /**
  129813. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  129814. */
  129815. export class PassCubePostProcess extends PostProcess {
  129816. private _face;
  129817. /**
  129818. * Gets or sets the cube face to display.
  129819. * * 0 is +X
  129820. * * 1 is -X
  129821. * * 2 is +Y
  129822. * * 3 is -Y
  129823. * * 4 is +Z
  129824. * * 5 is -Z
  129825. */
  129826. get face(): number;
  129827. set face(value: number);
  129828. /**
  129829. * Gets a string identifying the name of the class
  129830. * @returns "PassCubePostProcess" string
  129831. */
  129832. getClassName(): string;
  129833. /**
  129834. * Creates the PassCubePostProcess
  129835. * @param name The name of the effect.
  129836. * @param options The required width/height ratio to downsize to before computing the render pass.
  129837. * @param camera The camera to apply the render pass to.
  129838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129839. * @param engine The engine which the post process will be applied. (default: current engine)
  129840. * @param reusable If the post process can be reused on the same frame. (default: false)
  129841. * @param textureType The type of texture to be used when performing the post processing.
  129842. * @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)
  129843. */
  129844. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129845. /** @hidden */
  129846. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  129847. }
  129848. }
  129849. declare module BABYLON {
  129850. /** @hidden */
  129851. export var anaglyphPixelShader: {
  129852. name: string;
  129853. shader: string;
  129854. };
  129855. }
  129856. declare module BABYLON {
  129857. /**
  129858. * Postprocess used to generate anaglyphic rendering
  129859. */
  129860. export class AnaglyphPostProcess extends PostProcess {
  129861. private _passedProcess;
  129862. /**
  129863. * Gets a string identifying the name of the class
  129864. * @returns "AnaglyphPostProcess" string
  129865. */
  129866. getClassName(): string;
  129867. /**
  129868. * Creates a new AnaglyphPostProcess
  129869. * @param name defines postprocess name
  129870. * @param options defines creation options or target ratio scale
  129871. * @param rigCameras defines cameras using this postprocess
  129872. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  129873. * @param engine defines hosting engine
  129874. * @param reusable defines if the postprocess will be reused multiple times per frame
  129875. */
  129876. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  129877. }
  129878. }
  129879. declare module BABYLON {
  129880. /**
  129881. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  129882. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129883. */
  129884. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  129885. /**
  129886. * Creates a new AnaglyphArcRotateCamera
  129887. * @param name defines camera name
  129888. * @param alpha defines alpha angle (in radians)
  129889. * @param beta defines beta angle (in radians)
  129890. * @param radius defines radius
  129891. * @param target defines camera target
  129892. * @param interaxialDistance defines distance between each color axis
  129893. * @param scene defines the hosting scene
  129894. */
  129895. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  129896. /**
  129897. * Gets camera class name
  129898. * @returns AnaglyphArcRotateCamera
  129899. */
  129900. getClassName(): string;
  129901. }
  129902. }
  129903. declare module BABYLON {
  129904. /**
  129905. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  129906. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129907. */
  129908. export class AnaglyphFreeCamera extends FreeCamera {
  129909. /**
  129910. * Creates a new AnaglyphFreeCamera
  129911. * @param name defines camera name
  129912. * @param position defines initial position
  129913. * @param interaxialDistance defines distance between each color axis
  129914. * @param scene defines the hosting scene
  129915. */
  129916. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129917. /**
  129918. * Gets camera class name
  129919. * @returns AnaglyphFreeCamera
  129920. */
  129921. getClassName(): string;
  129922. }
  129923. }
  129924. declare module BABYLON {
  129925. /**
  129926. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  129927. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129928. */
  129929. export class AnaglyphGamepadCamera extends GamepadCamera {
  129930. /**
  129931. * Creates a new AnaglyphGamepadCamera
  129932. * @param name defines camera name
  129933. * @param position defines initial position
  129934. * @param interaxialDistance defines distance between each color axis
  129935. * @param scene defines the hosting scene
  129936. */
  129937. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129938. /**
  129939. * Gets camera class name
  129940. * @returns AnaglyphGamepadCamera
  129941. */
  129942. getClassName(): string;
  129943. }
  129944. }
  129945. declare module BABYLON {
  129946. /**
  129947. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  129948. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129949. */
  129950. export class AnaglyphUniversalCamera extends UniversalCamera {
  129951. /**
  129952. * Creates a new AnaglyphUniversalCamera
  129953. * @param name defines camera name
  129954. * @param position defines initial position
  129955. * @param interaxialDistance defines distance between each color axis
  129956. * @param scene defines the hosting scene
  129957. */
  129958. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129959. /**
  129960. * Gets camera class name
  129961. * @returns AnaglyphUniversalCamera
  129962. */
  129963. getClassName(): string;
  129964. }
  129965. }
  129966. declare module BABYLON {
  129967. /**
  129968. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  129969. * @see https://doc.babylonjs.com/features/cameras
  129970. */
  129971. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  129972. /**
  129973. * Creates a new StereoscopicArcRotateCamera
  129974. * @param name defines camera name
  129975. * @param alpha defines alpha angle (in radians)
  129976. * @param beta defines beta angle (in radians)
  129977. * @param radius defines radius
  129978. * @param target defines camera target
  129979. * @param interaxialDistance defines distance between each color axis
  129980. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129981. * @param scene defines the hosting scene
  129982. */
  129983. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129984. /**
  129985. * Gets camera class name
  129986. * @returns StereoscopicArcRotateCamera
  129987. */
  129988. getClassName(): string;
  129989. }
  129990. }
  129991. declare module BABYLON {
  129992. /**
  129993. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  129994. * @see https://doc.babylonjs.com/features/cameras
  129995. */
  129996. export class StereoscopicFreeCamera extends FreeCamera {
  129997. /**
  129998. * Creates a new StereoscopicFreeCamera
  129999. * @param name defines camera name
  130000. * @param position defines initial position
  130001. * @param interaxialDistance defines distance between each color axis
  130002. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130003. * @param scene defines the hosting scene
  130004. */
  130005. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130006. /**
  130007. * Gets camera class name
  130008. * @returns StereoscopicFreeCamera
  130009. */
  130010. getClassName(): string;
  130011. }
  130012. }
  130013. declare module BABYLON {
  130014. /**
  130015. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  130016. * @see https://doc.babylonjs.com/features/cameras
  130017. */
  130018. export class StereoscopicGamepadCamera extends GamepadCamera {
  130019. /**
  130020. * Creates a new StereoscopicGamepadCamera
  130021. * @param name defines camera name
  130022. * @param position defines initial position
  130023. * @param interaxialDistance defines distance between each color axis
  130024. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130025. * @param scene defines the hosting scene
  130026. */
  130027. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130028. /**
  130029. * Gets camera class name
  130030. * @returns StereoscopicGamepadCamera
  130031. */
  130032. getClassName(): string;
  130033. }
  130034. }
  130035. declare module BABYLON {
  130036. /**
  130037. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  130038. * @see https://doc.babylonjs.com/features/cameras
  130039. */
  130040. export class StereoscopicUniversalCamera extends UniversalCamera {
  130041. /**
  130042. * Creates a new StereoscopicUniversalCamera
  130043. * @param name defines camera name
  130044. * @param position defines initial position
  130045. * @param interaxialDistance defines distance between each color axis
  130046. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130047. * @param scene defines the hosting scene
  130048. */
  130049. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130050. /**
  130051. * Gets camera class name
  130052. * @returns StereoscopicUniversalCamera
  130053. */
  130054. getClassName(): string;
  130055. }
  130056. }
  130057. declare module BABYLON {
  130058. /**
  130059. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  130060. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130061. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130062. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130063. */
  130064. export class VirtualJoysticksCamera extends FreeCamera {
  130065. /**
  130066. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  130067. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130068. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130069. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130070. * @param name Define the name of the camera in the scene
  130071. * @param position Define the start position of the camera in the scene
  130072. * @param scene Define the scene the camera belongs to
  130073. */
  130074. constructor(name: string, position: Vector3, scene: Scene);
  130075. /**
  130076. * Gets the current object class name.
  130077. * @return the class name
  130078. */
  130079. getClassName(): string;
  130080. }
  130081. }
  130082. declare module BABYLON {
  130083. /**
  130084. * This represents all the required metrics to create a VR camera.
  130085. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  130086. */
  130087. export class VRCameraMetrics {
  130088. /**
  130089. * Define the horizontal resolution off the screen.
  130090. */
  130091. hResolution: number;
  130092. /**
  130093. * Define the vertical resolution off the screen.
  130094. */
  130095. vResolution: number;
  130096. /**
  130097. * Define the horizontal screen size.
  130098. */
  130099. hScreenSize: number;
  130100. /**
  130101. * Define the vertical screen size.
  130102. */
  130103. vScreenSize: number;
  130104. /**
  130105. * Define the vertical screen center position.
  130106. */
  130107. vScreenCenter: number;
  130108. /**
  130109. * Define the distance of the eyes to the screen.
  130110. */
  130111. eyeToScreenDistance: number;
  130112. /**
  130113. * Define the distance between both lenses
  130114. */
  130115. lensSeparationDistance: number;
  130116. /**
  130117. * Define the distance between both viewer's eyes.
  130118. */
  130119. interpupillaryDistance: number;
  130120. /**
  130121. * Define the distortion factor of the VR postprocess.
  130122. * Please, touch with care.
  130123. */
  130124. distortionK: number[];
  130125. /**
  130126. * Define the chromatic aberration correction factors for the VR post process.
  130127. */
  130128. chromaAbCorrection: number[];
  130129. /**
  130130. * Define the scale factor of the post process.
  130131. * The smaller the better but the slower.
  130132. */
  130133. postProcessScaleFactor: number;
  130134. /**
  130135. * Define an offset for the lens center.
  130136. */
  130137. lensCenterOffset: number;
  130138. /**
  130139. * Define if the current vr camera should compensate the distortion of the lense or not.
  130140. */
  130141. compensateDistortion: boolean;
  130142. /**
  130143. * Defines if multiview should be enabled when rendering (Default: false)
  130144. */
  130145. multiviewEnabled: boolean;
  130146. /**
  130147. * Gets the rendering aspect ratio based on the provided resolutions.
  130148. */
  130149. get aspectRatio(): number;
  130150. /**
  130151. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  130152. */
  130153. get aspectRatioFov(): number;
  130154. /**
  130155. * @hidden
  130156. */
  130157. get leftHMatrix(): Matrix;
  130158. /**
  130159. * @hidden
  130160. */
  130161. get rightHMatrix(): Matrix;
  130162. /**
  130163. * @hidden
  130164. */
  130165. get leftPreViewMatrix(): Matrix;
  130166. /**
  130167. * @hidden
  130168. */
  130169. get rightPreViewMatrix(): Matrix;
  130170. /**
  130171. * Get the default VRMetrics based on the most generic setup.
  130172. * @returns the default vr metrics
  130173. */
  130174. static GetDefault(): VRCameraMetrics;
  130175. }
  130176. }
  130177. declare module BABYLON {
  130178. /** @hidden */
  130179. export var vrDistortionCorrectionPixelShader: {
  130180. name: string;
  130181. shader: string;
  130182. };
  130183. }
  130184. declare module BABYLON {
  130185. /**
  130186. * VRDistortionCorrectionPostProcess used for mobile VR
  130187. */
  130188. export class VRDistortionCorrectionPostProcess extends PostProcess {
  130189. private _isRightEye;
  130190. private _distortionFactors;
  130191. private _postProcessScaleFactor;
  130192. private _lensCenterOffset;
  130193. private _scaleIn;
  130194. private _scaleFactor;
  130195. private _lensCenter;
  130196. /**
  130197. * Gets a string identifying the name of the class
  130198. * @returns "VRDistortionCorrectionPostProcess" string
  130199. */
  130200. getClassName(): string;
  130201. /**
  130202. * Initializes the VRDistortionCorrectionPostProcess
  130203. * @param name The name of the effect.
  130204. * @param camera The camera to apply the render pass to.
  130205. * @param isRightEye If this is for the right eye distortion
  130206. * @param vrMetrics All the required metrics for the VR camera
  130207. */
  130208. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  130209. }
  130210. }
  130211. declare module BABYLON {
  130212. /**
  130213. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  130214. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130215. */
  130216. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  130217. /**
  130218. * Creates a new VRDeviceOrientationArcRotateCamera
  130219. * @param name defines camera name
  130220. * @param alpha defines the camera rotation along the logitudinal axis
  130221. * @param beta defines the camera rotation along the latitudinal axis
  130222. * @param radius defines the camera distance from its target
  130223. * @param target defines the camera target
  130224. * @param scene defines the scene the camera belongs to
  130225. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130226. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130227. */
  130228. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130229. /**
  130230. * Gets camera class name
  130231. * @returns VRDeviceOrientationArcRotateCamera
  130232. */
  130233. getClassName(): string;
  130234. }
  130235. }
  130236. declare module BABYLON {
  130237. /**
  130238. * Camera used to simulate VR rendering (based on FreeCamera)
  130239. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130240. */
  130241. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  130242. /**
  130243. * Creates a new VRDeviceOrientationFreeCamera
  130244. * @param name defines camera name
  130245. * @param position defines the start position of the camera
  130246. * @param scene defines the scene the camera belongs to
  130247. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130248. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130249. */
  130250. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130251. /**
  130252. * Gets camera class name
  130253. * @returns VRDeviceOrientationFreeCamera
  130254. */
  130255. getClassName(): string;
  130256. }
  130257. }
  130258. declare module BABYLON {
  130259. /**
  130260. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  130261. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130262. */
  130263. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  130264. /**
  130265. * Creates a new VRDeviceOrientationGamepadCamera
  130266. * @param name defines camera name
  130267. * @param position defines the start position of the camera
  130268. * @param scene defines the scene the camera belongs to
  130269. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130270. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130271. */
  130272. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130273. /**
  130274. * Gets camera class name
  130275. * @returns VRDeviceOrientationGamepadCamera
  130276. */
  130277. getClassName(): string;
  130278. }
  130279. }
  130280. declare module BABYLON {
  130281. /**
  130282. * A class extending Texture allowing drawing on a texture
  130283. * @see https://doc.babylonjs.com/how_to/dynamictexture
  130284. */
  130285. export class DynamicTexture extends Texture {
  130286. private _generateMipMaps;
  130287. private _canvas;
  130288. private _context;
  130289. /**
  130290. * Creates a DynamicTexture
  130291. * @param name defines the name of the texture
  130292. * @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
  130293. * @param scene defines the scene where you want the texture
  130294. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  130295. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130296. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  130297. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  130298. */
  130299. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  130300. /**
  130301. * Get the current class name of the texture useful for serialization or dynamic coding.
  130302. * @returns "DynamicTexture"
  130303. */
  130304. getClassName(): string;
  130305. /**
  130306. * Gets the current state of canRescale
  130307. */
  130308. get canRescale(): boolean;
  130309. private _recreate;
  130310. /**
  130311. * Scales the texture
  130312. * @param ratio the scale factor to apply to both width and height
  130313. */
  130314. scale(ratio: number): void;
  130315. /**
  130316. * Resizes the texture
  130317. * @param width the new width
  130318. * @param height the new height
  130319. */
  130320. scaleTo(width: number, height: number): void;
  130321. /**
  130322. * Gets the context of the canvas used by the texture
  130323. * @returns the canvas context of the dynamic texture
  130324. */
  130325. getContext(): CanvasRenderingContext2D;
  130326. /**
  130327. * Clears the texture
  130328. */
  130329. clear(): void;
  130330. /**
  130331. * Updates the texture
  130332. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130333. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  130334. */
  130335. update(invertY?: boolean, premulAlpha?: boolean): void;
  130336. /**
  130337. * Draws text onto the texture
  130338. * @param text defines the text to be drawn
  130339. * @param x defines the placement of the text from the left
  130340. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  130341. * @param font defines the font to be used with font-style, font-size, font-name
  130342. * @param color defines the color used for the text
  130343. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  130344. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130345. * @param update defines whether texture is immediately update (default is true)
  130346. */
  130347. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  130348. /**
  130349. * Clones the texture
  130350. * @returns the clone of the texture.
  130351. */
  130352. clone(): DynamicTexture;
  130353. /**
  130354. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  130355. * @returns a serialized dynamic texture object
  130356. */
  130357. serialize(): any;
  130358. private _IsCanvasElement;
  130359. /** @hidden */
  130360. _rebuild(): void;
  130361. }
  130362. }
  130363. declare module BABYLON {
  130364. /**
  130365. * Class containing static functions to help procedurally build meshes
  130366. */
  130367. export class GroundBuilder {
  130368. /**
  130369. * Creates a ground mesh
  130370. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130371. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130373. * @param name defines the name of the mesh
  130374. * @param options defines the options used to create the mesh
  130375. * @param scene defines the hosting scene
  130376. * @returns the ground mesh
  130377. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130378. */
  130379. static CreateGround(name: string, options: {
  130380. width?: number;
  130381. height?: number;
  130382. subdivisions?: number;
  130383. subdivisionsX?: number;
  130384. subdivisionsY?: number;
  130385. updatable?: boolean;
  130386. }, scene: any): Mesh;
  130387. /**
  130388. * Creates a tiled ground mesh
  130389. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130390. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130391. * * 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
  130392. * * 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
  130393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130394. * @param name defines the name of the mesh
  130395. * @param options defines the options used to create the mesh
  130396. * @param scene defines the hosting scene
  130397. * @returns the tiled ground mesh
  130398. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130399. */
  130400. static CreateTiledGround(name: string, options: {
  130401. xmin: number;
  130402. zmin: number;
  130403. xmax: number;
  130404. zmax: number;
  130405. subdivisions?: {
  130406. w: number;
  130407. h: number;
  130408. };
  130409. precision?: {
  130410. w: number;
  130411. h: number;
  130412. };
  130413. updatable?: boolean;
  130414. }, scene?: Nullable<Scene>): Mesh;
  130415. /**
  130416. * Creates a ground mesh from a height map
  130417. * * The parameter `url` sets the URL of the height map image resource.
  130418. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130419. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130420. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130421. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130422. * * 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.
  130423. * * 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).
  130424. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130426. * @param name defines the name of the mesh
  130427. * @param url defines the url to the height map
  130428. * @param options defines the options used to create the mesh
  130429. * @param scene defines the hosting scene
  130430. * @returns the ground mesh
  130431. * @see https://doc.babylonjs.com/babylon101/height_map
  130432. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130433. */
  130434. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130435. width?: number;
  130436. height?: number;
  130437. subdivisions?: number;
  130438. minHeight?: number;
  130439. maxHeight?: number;
  130440. colorFilter?: Color3;
  130441. alphaFilter?: number;
  130442. updatable?: boolean;
  130443. onReady?: (mesh: GroundMesh) => void;
  130444. }, scene?: Nullable<Scene>): GroundMesh;
  130445. }
  130446. }
  130447. declare module BABYLON {
  130448. /**
  130449. * Class containing static functions to help procedurally build meshes
  130450. */
  130451. export class TorusBuilder {
  130452. /**
  130453. * Creates a torus mesh
  130454. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130455. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130456. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130460. * @param name defines the name of the mesh
  130461. * @param options defines the options used to create the mesh
  130462. * @param scene defines the hosting scene
  130463. * @returns the torus mesh
  130464. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130465. */
  130466. static CreateTorus(name: string, options: {
  130467. diameter?: number;
  130468. thickness?: number;
  130469. tessellation?: number;
  130470. updatable?: boolean;
  130471. sideOrientation?: number;
  130472. frontUVs?: Vector4;
  130473. backUVs?: Vector4;
  130474. }, scene: any): Mesh;
  130475. }
  130476. }
  130477. declare module BABYLON {
  130478. /**
  130479. * Class containing static functions to help procedurally build meshes
  130480. */
  130481. export class CylinderBuilder {
  130482. /**
  130483. * Creates a cylinder or a cone mesh
  130484. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130485. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130486. * * 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.
  130487. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130488. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130489. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130490. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130491. * * 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).
  130492. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130493. * * 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).
  130494. * * 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
  130495. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130496. * * 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
  130497. * * 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.
  130498. * * If `enclose` is false, a ring surface is one element.
  130499. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130500. * * 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
  130501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130504. * @param name defines the name of the mesh
  130505. * @param options defines the options used to create the mesh
  130506. * @param scene defines the hosting scene
  130507. * @returns the cylinder mesh
  130508. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130509. */
  130510. static CreateCylinder(name: string, options: {
  130511. height?: number;
  130512. diameterTop?: number;
  130513. diameterBottom?: number;
  130514. diameter?: number;
  130515. tessellation?: number;
  130516. subdivisions?: number;
  130517. arc?: number;
  130518. faceColors?: Color4[];
  130519. faceUV?: Vector4[];
  130520. updatable?: boolean;
  130521. hasRings?: boolean;
  130522. enclose?: boolean;
  130523. cap?: number;
  130524. sideOrientation?: number;
  130525. frontUVs?: Vector4;
  130526. backUVs?: Vector4;
  130527. }, scene: any): Mesh;
  130528. }
  130529. }
  130530. declare module BABYLON {
  130531. /**
  130532. * States of the webXR experience
  130533. */
  130534. export enum WebXRState {
  130535. /**
  130536. * Transitioning to being in XR mode
  130537. */
  130538. ENTERING_XR = 0,
  130539. /**
  130540. * Transitioning to non XR mode
  130541. */
  130542. EXITING_XR = 1,
  130543. /**
  130544. * In XR mode and presenting
  130545. */
  130546. IN_XR = 2,
  130547. /**
  130548. * Not entered XR mode
  130549. */
  130550. NOT_IN_XR = 3
  130551. }
  130552. /**
  130553. * Abstraction of the XR render target
  130554. */
  130555. export interface WebXRRenderTarget extends IDisposable {
  130556. /**
  130557. * xrpresent context of the canvas which can be used to display/mirror xr content
  130558. */
  130559. canvasContext: WebGLRenderingContext;
  130560. /**
  130561. * xr layer for the canvas
  130562. */
  130563. xrLayer: Nullable<XRWebGLLayer>;
  130564. /**
  130565. * Initializes the xr layer for the session
  130566. * @param xrSession xr session
  130567. * @returns a promise that will resolve once the XR Layer has been created
  130568. */
  130569. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130570. }
  130571. }
  130572. declare module BABYLON {
  130573. /**
  130574. * COnfiguration object for WebXR output canvas
  130575. */
  130576. export class WebXRManagedOutputCanvasOptions {
  130577. /**
  130578. * An optional canvas in case you wish to create it yourself and provide it here.
  130579. * If not provided, a new canvas will be created
  130580. */
  130581. canvasElement?: HTMLCanvasElement;
  130582. /**
  130583. * Options for this XR Layer output
  130584. */
  130585. canvasOptions?: XRWebGLLayerOptions;
  130586. /**
  130587. * CSS styling for a newly created canvas (if not provided)
  130588. */
  130589. newCanvasCssStyle?: string;
  130590. /**
  130591. * Get the default values of the configuration object
  130592. * @param engine defines the engine to use (can be null)
  130593. * @returns default values of this configuration object
  130594. */
  130595. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  130596. }
  130597. /**
  130598. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  130599. */
  130600. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  130601. private _options;
  130602. private _canvas;
  130603. private _engine;
  130604. private _originalCanvasSize;
  130605. /**
  130606. * Rendering context of the canvas which can be used to display/mirror xr content
  130607. */
  130608. canvasContext: WebGLRenderingContext;
  130609. /**
  130610. * xr layer for the canvas
  130611. */
  130612. xrLayer: Nullable<XRWebGLLayer>;
  130613. /**
  130614. * Obseervers registered here will be triggered when the xr layer was initialized
  130615. */
  130616. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  130617. /**
  130618. * Initializes the canvas to be added/removed upon entering/exiting xr
  130619. * @param _xrSessionManager The XR Session manager
  130620. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  130621. */
  130622. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  130623. /**
  130624. * Disposes of the object
  130625. */
  130626. dispose(): void;
  130627. /**
  130628. * Initializes the xr layer for the session
  130629. * @param xrSession xr session
  130630. * @returns a promise that will resolve once the XR Layer has been created
  130631. */
  130632. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130633. private _addCanvas;
  130634. private _removeCanvas;
  130635. private _setCanvasSize;
  130636. private _setManagedOutputCanvas;
  130637. }
  130638. }
  130639. declare module BABYLON {
  130640. /**
  130641. * Manages an XRSession to work with Babylon's engine
  130642. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  130643. */
  130644. export class WebXRSessionManager implements IDisposable {
  130645. /** The scene which the session should be created for */
  130646. scene: Scene;
  130647. private _referenceSpace;
  130648. private _rttProvider;
  130649. private _sessionEnded;
  130650. private _xrNavigator;
  130651. private baseLayer;
  130652. /**
  130653. * The base reference space from which the session started. good if you want to reset your
  130654. * reference space
  130655. */
  130656. baseReferenceSpace: XRReferenceSpace;
  130657. /**
  130658. * Current XR frame
  130659. */
  130660. currentFrame: Nullable<XRFrame>;
  130661. /** WebXR timestamp updated every frame */
  130662. currentTimestamp: number;
  130663. /**
  130664. * Used just in case of a failure to initialize an immersive session.
  130665. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  130666. */
  130667. defaultHeightCompensation: number;
  130668. /**
  130669. * Fires every time a new xrFrame arrives which can be used to update the camera
  130670. */
  130671. onXRFrameObservable: Observable<XRFrame>;
  130672. /**
  130673. * Fires when the reference space changed
  130674. */
  130675. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  130676. /**
  130677. * Fires when the xr session is ended either by the device or manually done
  130678. */
  130679. onXRSessionEnded: Observable<any>;
  130680. /**
  130681. * Fires when the xr session is ended either by the device or manually done
  130682. */
  130683. onXRSessionInit: Observable<XRSession>;
  130684. /**
  130685. * Underlying xr session
  130686. */
  130687. session: XRSession;
  130688. /**
  130689. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  130690. * or get the offset the player is currently at.
  130691. */
  130692. viewerReferenceSpace: XRReferenceSpace;
  130693. /**
  130694. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  130695. * @param scene The scene which the session should be created for
  130696. */
  130697. constructor(
  130698. /** The scene which the session should be created for */
  130699. scene: Scene);
  130700. /**
  130701. * The current reference space used in this session. This reference space can constantly change!
  130702. * It is mainly used to offset the camera's position.
  130703. */
  130704. get referenceSpace(): XRReferenceSpace;
  130705. /**
  130706. * Set a new reference space and triggers the observable
  130707. */
  130708. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  130709. /**
  130710. * Disposes of the session manager
  130711. */
  130712. dispose(): void;
  130713. /**
  130714. * Stops the xrSession and restores the render loop
  130715. * @returns Promise which resolves after it exits XR
  130716. */
  130717. exitXRAsync(): Promise<void>;
  130718. /**
  130719. * Gets the correct render target texture to be rendered this frame for this eye
  130720. * @param eye the eye for which to get the render target
  130721. * @returns the render target for the specified eye
  130722. */
  130723. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  130724. /**
  130725. * Creates a WebXRRenderTarget object for the XR session
  130726. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  130727. * @param options optional options to provide when creating a new render target
  130728. * @returns a WebXR render target to which the session can render
  130729. */
  130730. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  130731. /**
  130732. * Initializes the manager
  130733. * After initialization enterXR can be called to start an XR session
  130734. * @returns Promise which resolves after it is initialized
  130735. */
  130736. initializeAsync(): Promise<void>;
  130737. /**
  130738. * Initializes an xr session
  130739. * @param xrSessionMode mode to initialize
  130740. * @param xrSessionInit defines optional and required values to pass to the session builder
  130741. * @returns a promise which will resolve once the session has been initialized
  130742. */
  130743. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  130744. /**
  130745. * Checks if a session would be supported for the creation options specified
  130746. * @param sessionMode session mode to check if supported eg. immersive-vr
  130747. * @returns A Promise that resolves to true if supported and false if not
  130748. */
  130749. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130750. /**
  130751. * Resets the reference space to the one started the session
  130752. */
  130753. resetReferenceSpace(): void;
  130754. /**
  130755. * Starts rendering to the xr layer
  130756. */
  130757. runXRRenderLoop(): void;
  130758. /**
  130759. * Sets the reference space on the xr session
  130760. * @param referenceSpaceType space to set
  130761. * @returns a promise that will resolve once the reference space has been set
  130762. */
  130763. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130764. /**
  130765. * Updates the render state of the session
  130766. * @param state state to set
  130767. * @returns a promise that resolves once the render state has been updated
  130768. */
  130769. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  130770. /**
  130771. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  130772. * @param sessionMode defines the session to test
  130773. * @returns a promise with boolean as final value
  130774. */
  130775. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130776. private _createRenderTargetTexture;
  130777. }
  130778. }
  130779. declare module BABYLON {
  130780. /**
  130781. * WebXR Camera which holds the views for the xrSession
  130782. * @see https://doc.babylonjs.com/how_to/webxr_camera
  130783. */
  130784. export class WebXRCamera extends FreeCamera {
  130785. private _xrSessionManager;
  130786. private _firstFrame;
  130787. private _referenceQuaternion;
  130788. private _referencedPosition;
  130789. private _xrInvPositionCache;
  130790. private _xrInvQuaternionCache;
  130791. /**
  130792. * Observable raised before camera teleportation
  130793. */
  130794. onBeforeCameraTeleport: Observable<Vector3>;
  130795. /**
  130796. * Observable raised after camera teleportation
  130797. */
  130798. onAfterCameraTeleport: Observable<Vector3>;
  130799. /**
  130800. * Should position compensation execute on first frame.
  130801. * This is used when copying the position from a native (non XR) camera
  130802. */
  130803. compensateOnFirstFrame: boolean;
  130804. /**
  130805. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  130806. * @param name the name of the camera
  130807. * @param scene the scene to add the camera to
  130808. * @param _xrSessionManager a constructed xr session manager
  130809. */
  130810. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  130811. /**
  130812. * Return the user's height, unrelated to the current ground.
  130813. * This will be the y position of this camera, when ground level is 0.
  130814. */
  130815. get realWorldHeight(): number;
  130816. /** @hidden */
  130817. _updateForDualEyeDebugging(): void;
  130818. /**
  130819. * Sets this camera's transformation based on a non-vr camera
  130820. * @param otherCamera the non-vr camera to copy the transformation from
  130821. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  130822. */
  130823. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  130824. /**
  130825. * Gets the current instance class name ("WebXRCamera").
  130826. * @returns the class name
  130827. */
  130828. getClassName(): string;
  130829. private _rotate180;
  130830. private _updateFromXRSession;
  130831. private _updateNumberOfRigCameras;
  130832. private _updateReferenceSpace;
  130833. private _updateReferenceSpaceOffset;
  130834. }
  130835. }
  130836. declare module BABYLON {
  130837. /**
  130838. * Defining the interface required for a (webxr) feature
  130839. */
  130840. export interface IWebXRFeature extends IDisposable {
  130841. /**
  130842. * Is this feature attached
  130843. */
  130844. attached: boolean;
  130845. /**
  130846. * Should auto-attach be disabled?
  130847. */
  130848. disableAutoAttach: boolean;
  130849. /**
  130850. * Attach the feature to the session
  130851. * Will usually be called by the features manager
  130852. *
  130853. * @param force should attachment be forced (even when already attached)
  130854. * @returns true if successful.
  130855. */
  130856. attach(force?: boolean): boolean;
  130857. /**
  130858. * Detach the feature from the session
  130859. * Will usually be called by the features manager
  130860. *
  130861. * @returns true if successful.
  130862. */
  130863. detach(): boolean;
  130864. /**
  130865. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  130866. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  130867. *
  130868. * @returns whether or not the feature is compatible in this environment
  130869. */
  130870. isCompatible(): boolean;
  130871. /**
  130872. * Was this feature disposed;
  130873. */
  130874. isDisposed: boolean;
  130875. /**
  130876. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  130877. */
  130878. xrNativeFeatureName?: string;
  130879. /**
  130880. * A list of (Babylon WebXR) features this feature depends on
  130881. */
  130882. dependsOn?: string[];
  130883. }
  130884. /**
  130885. * A list of the currently available features without referencing them
  130886. */
  130887. export class WebXRFeatureName {
  130888. /**
  130889. * The name of the anchor system feature
  130890. */
  130891. static readonly ANCHOR_SYSTEM: string;
  130892. /**
  130893. * The name of the background remover feature
  130894. */
  130895. static readonly BACKGROUND_REMOVER: string;
  130896. /**
  130897. * The name of the hit test feature
  130898. */
  130899. static readonly HIT_TEST: string;
  130900. /**
  130901. * physics impostors for xr controllers feature
  130902. */
  130903. static readonly PHYSICS_CONTROLLERS: string;
  130904. /**
  130905. * The name of the plane detection feature
  130906. */
  130907. static readonly PLANE_DETECTION: string;
  130908. /**
  130909. * The name of the pointer selection feature
  130910. */
  130911. static readonly POINTER_SELECTION: string;
  130912. /**
  130913. * The name of the teleportation feature
  130914. */
  130915. static readonly TELEPORTATION: string;
  130916. /**
  130917. * The name of the feature points feature.
  130918. */
  130919. static readonly FEATURE_POINTS: string;
  130920. /**
  130921. * The name of the hand tracking feature.
  130922. */
  130923. static readonly HAND_TRACKING: string;
  130924. }
  130925. /**
  130926. * Defining the constructor of a feature. Used to register the modules.
  130927. */
  130928. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  130929. /**
  130930. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  130931. * It is mainly used in AR sessions.
  130932. *
  130933. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  130934. */
  130935. export class WebXRFeaturesManager implements IDisposable {
  130936. private _xrSessionManager;
  130937. private static readonly _AvailableFeatures;
  130938. private _features;
  130939. /**
  130940. * constructs a new features manages.
  130941. *
  130942. * @param _xrSessionManager an instance of WebXRSessionManager
  130943. */
  130944. constructor(_xrSessionManager: WebXRSessionManager);
  130945. /**
  130946. * Used to register a module. After calling this function a developer can use this feature in the scene.
  130947. * Mainly used internally.
  130948. *
  130949. * @param featureName the name of the feature to register
  130950. * @param constructorFunction the function used to construct the module
  130951. * @param version the (babylon) version of the module
  130952. * @param stable is that a stable version of this module
  130953. */
  130954. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  130955. /**
  130956. * Returns a constructor of a specific feature.
  130957. *
  130958. * @param featureName the name of the feature to construct
  130959. * @param version the version of the feature to load
  130960. * @param xrSessionManager the xrSessionManager. Used to construct the module
  130961. * @param options optional options provided to the module.
  130962. * @returns a function that, when called, will return a new instance of this feature
  130963. */
  130964. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  130965. /**
  130966. * Can be used to return the list of features currently registered
  130967. *
  130968. * @returns an Array of available features
  130969. */
  130970. static GetAvailableFeatures(): string[];
  130971. /**
  130972. * Gets the versions available for a specific feature
  130973. * @param featureName the name of the feature
  130974. * @returns an array with the available versions
  130975. */
  130976. static GetAvailableVersions(featureName: string): string[];
  130977. /**
  130978. * Return the latest unstable version of this feature
  130979. * @param featureName the name of the feature to search
  130980. * @returns the version number. if not found will return -1
  130981. */
  130982. static GetLatestVersionOfFeature(featureName: string): number;
  130983. /**
  130984. * Return the latest stable version of this feature
  130985. * @param featureName the name of the feature to search
  130986. * @returns the version number. if not found will return -1
  130987. */
  130988. static GetStableVersionOfFeature(featureName: string): number;
  130989. /**
  130990. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  130991. * Can be used during a session to start a feature
  130992. * @param featureName the name of feature to attach
  130993. */
  130994. attachFeature(featureName: string): void;
  130995. /**
  130996. * Can be used inside a session or when the session ends to detach a specific feature
  130997. * @param featureName the name of the feature to detach
  130998. */
  130999. detachFeature(featureName: string): void;
  131000. /**
  131001. * Used to disable an already-enabled feature
  131002. * The feature will be disposed and will be recreated once enabled.
  131003. * @param featureName the feature to disable
  131004. * @returns true if disable was successful
  131005. */
  131006. disableFeature(featureName: string | {
  131007. Name: string;
  131008. }): boolean;
  131009. /**
  131010. * dispose this features manager
  131011. */
  131012. dispose(): void;
  131013. /**
  131014. * 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.
  131015. * 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.
  131016. *
  131017. * @param featureName the name of the feature to load or the class of the feature
  131018. * @param version optional version to load. if not provided the latest version will be enabled
  131019. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  131020. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  131021. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  131022. * @returns a new constructed feature or throws an error if feature not found.
  131023. */
  131024. enableFeature(featureName: string | {
  131025. Name: string;
  131026. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  131027. /**
  131028. * get the implementation of an enabled feature.
  131029. * @param featureName the name of the feature to load
  131030. * @returns the feature class, if found
  131031. */
  131032. getEnabledFeature(featureName: string): IWebXRFeature;
  131033. /**
  131034. * Get the list of enabled features
  131035. * @returns an array of enabled features
  131036. */
  131037. getEnabledFeatures(): string[];
  131038. /**
  131039. * This function will exten the session creation configuration object with enabled features.
  131040. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  131041. * according to the defined "required" variable, provided during enableFeature call
  131042. * @param xrSessionInit the xr Session init object to extend
  131043. *
  131044. * @returns an extended XRSessionInit object
  131045. */
  131046. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  131047. }
  131048. }
  131049. declare module BABYLON {
  131050. /**
  131051. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  131052. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  131053. */
  131054. export class WebXRExperienceHelper implements IDisposable {
  131055. private scene;
  131056. private _nonVRCamera;
  131057. private _originalSceneAutoClear;
  131058. private _supported;
  131059. /**
  131060. * Camera used to render xr content
  131061. */
  131062. camera: WebXRCamera;
  131063. /** A features manager for this xr session */
  131064. featuresManager: WebXRFeaturesManager;
  131065. /**
  131066. * Observers registered here will be triggered after the camera's initial transformation is set
  131067. * This can be used to set a different ground level or an extra rotation.
  131068. *
  131069. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  131070. * to the position set after this observable is done executing.
  131071. */
  131072. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  131073. /**
  131074. * Fires when the state of the experience helper has changed
  131075. */
  131076. onStateChangedObservable: Observable<WebXRState>;
  131077. /** Session manager used to keep track of xr session */
  131078. sessionManager: WebXRSessionManager;
  131079. /**
  131080. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  131081. */
  131082. state: WebXRState;
  131083. /**
  131084. * Creates a WebXRExperienceHelper
  131085. * @param scene The scene the helper should be created in
  131086. */
  131087. private constructor();
  131088. /**
  131089. * Creates the experience helper
  131090. * @param scene the scene to attach the experience helper to
  131091. * @returns a promise for the experience helper
  131092. */
  131093. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  131094. /**
  131095. * Disposes of the experience helper
  131096. */
  131097. dispose(): void;
  131098. /**
  131099. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  131100. * @param sessionMode options for the XR session
  131101. * @param referenceSpaceType frame of reference of the XR session
  131102. * @param renderTarget the output canvas that will be used to enter XR mode
  131103. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  131104. * @returns promise that resolves after xr mode has entered
  131105. */
  131106. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  131107. /**
  131108. * Exits XR mode and returns the scene to its original state
  131109. * @returns promise that resolves after xr mode has exited
  131110. */
  131111. exitXRAsync(): Promise<void>;
  131112. private _nonXRToXRCamera;
  131113. private _setState;
  131114. }
  131115. }
  131116. declare module BABYLON {
  131117. /**
  131118. * X-Y values for axes in WebXR
  131119. */
  131120. export interface IWebXRMotionControllerAxesValue {
  131121. /**
  131122. * The value of the x axis
  131123. */
  131124. x: number;
  131125. /**
  131126. * The value of the y-axis
  131127. */
  131128. y: number;
  131129. }
  131130. /**
  131131. * changed / previous values for the values of this component
  131132. */
  131133. export interface IWebXRMotionControllerComponentChangesValues<T> {
  131134. /**
  131135. * current (this frame) value
  131136. */
  131137. current: T;
  131138. /**
  131139. * previous (last change) value
  131140. */
  131141. previous: T;
  131142. }
  131143. /**
  131144. * Represents changes in the component between current frame and last values recorded
  131145. */
  131146. export interface IWebXRMotionControllerComponentChanges {
  131147. /**
  131148. * will be populated with previous and current values if axes changed
  131149. */
  131150. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  131151. /**
  131152. * will be populated with previous and current values if pressed changed
  131153. */
  131154. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131155. /**
  131156. * will be populated with previous and current values if touched changed
  131157. */
  131158. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131159. /**
  131160. * will be populated with previous and current values if value changed
  131161. */
  131162. value?: IWebXRMotionControllerComponentChangesValues<number>;
  131163. }
  131164. /**
  131165. * This class represents a single component (for example button or thumbstick) of a motion controller
  131166. */
  131167. export class WebXRControllerComponent implements IDisposable {
  131168. /**
  131169. * the id of this component
  131170. */
  131171. id: string;
  131172. /**
  131173. * the type of the component
  131174. */
  131175. type: MotionControllerComponentType;
  131176. private _buttonIndex;
  131177. private _axesIndices;
  131178. private _axes;
  131179. private _changes;
  131180. private _currentValue;
  131181. private _hasChanges;
  131182. private _pressed;
  131183. private _touched;
  131184. /**
  131185. * button component type
  131186. */
  131187. static BUTTON_TYPE: MotionControllerComponentType;
  131188. /**
  131189. * squeeze component type
  131190. */
  131191. static SQUEEZE_TYPE: MotionControllerComponentType;
  131192. /**
  131193. * Thumbstick component type
  131194. */
  131195. static THUMBSTICK_TYPE: MotionControllerComponentType;
  131196. /**
  131197. * Touchpad component type
  131198. */
  131199. static TOUCHPAD_TYPE: MotionControllerComponentType;
  131200. /**
  131201. * trigger component type
  131202. */
  131203. static TRIGGER_TYPE: MotionControllerComponentType;
  131204. /**
  131205. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  131206. * the axes data changes
  131207. */
  131208. onAxisValueChangedObservable: Observable<{
  131209. x: number;
  131210. y: number;
  131211. }>;
  131212. /**
  131213. * Observers registered here will be triggered when the state of a button changes
  131214. * State change is either pressed / touched / value
  131215. */
  131216. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  131217. /**
  131218. * Creates a new component for a motion controller.
  131219. * It is created by the motion controller itself
  131220. *
  131221. * @param id the id of this component
  131222. * @param type the type of the component
  131223. * @param _buttonIndex index in the buttons array of the gamepad
  131224. * @param _axesIndices indices of the values in the axes array of the gamepad
  131225. */
  131226. constructor(
  131227. /**
  131228. * the id of this component
  131229. */
  131230. id: string,
  131231. /**
  131232. * the type of the component
  131233. */
  131234. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  131235. /**
  131236. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  131237. */
  131238. get axes(): IWebXRMotionControllerAxesValue;
  131239. /**
  131240. * Get the changes. Elements will be populated only if they changed with their previous and current value
  131241. */
  131242. get changes(): IWebXRMotionControllerComponentChanges;
  131243. /**
  131244. * Return whether or not the component changed the last frame
  131245. */
  131246. get hasChanges(): boolean;
  131247. /**
  131248. * is the button currently pressed
  131249. */
  131250. get pressed(): boolean;
  131251. /**
  131252. * is the button currently touched
  131253. */
  131254. get touched(): boolean;
  131255. /**
  131256. * Get the current value of this component
  131257. */
  131258. get value(): number;
  131259. /**
  131260. * Dispose this component
  131261. */
  131262. dispose(): void;
  131263. /**
  131264. * Are there axes correlating to this component
  131265. * @return true is axes data is available
  131266. */
  131267. isAxes(): boolean;
  131268. /**
  131269. * Is this component a button (hence - pressable)
  131270. * @returns true if can be pressed
  131271. */
  131272. isButton(): boolean;
  131273. /**
  131274. * update this component using the gamepad object it is in. Called on every frame
  131275. * @param nativeController the native gamepad controller object
  131276. */
  131277. update(nativeController: IMinimalMotionControllerObject): void;
  131278. }
  131279. }
  131280. declare module BABYLON {
  131281. /**
  131282. * Interface used to represent data loading progression
  131283. */
  131284. export interface ISceneLoaderProgressEvent {
  131285. /**
  131286. * Defines if data length to load can be evaluated
  131287. */
  131288. readonly lengthComputable: boolean;
  131289. /**
  131290. * Defines the loaded data length
  131291. */
  131292. readonly loaded: number;
  131293. /**
  131294. * Defines the data length to load
  131295. */
  131296. readonly total: number;
  131297. }
  131298. /**
  131299. * Interface used by SceneLoader plugins to define supported file extensions
  131300. */
  131301. export interface ISceneLoaderPluginExtensions {
  131302. /**
  131303. * Defines the list of supported extensions
  131304. */
  131305. [extension: string]: {
  131306. isBinary: boolean;
  131307. };
  131308. }
  131309. /**
  131310. * Interface used by SceneLoader plugin factory
  131311. */
  131312. export interface ISceneLoaderPluginFactory {
  131313. /**
  131314. * Defines the name of the factory
  131315. */
  131316. name: string;
  131317. /**
  131318. * Function called to create a new plugin
  131319. * @return the new plugin
  131320. */
  131321. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  131322. /**
  131323. * The callback that returns true if the data can be directly loaded.
  131324. * @param data string containing the file data
  131325. * @returns if the data can be loaded directly
  131326. */
  131327. canDirectLoad?(data: string): boolean;
  131328. }
  131329. /**
  131330. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  131331. */
  131332. export interface ISceneLoaderPluginBase {
  131333. /**
  131334. * The friendly name of this plugin.
  131335. */
  131336. name: string;
  131337. /**
  131338. * The file extensions supported by this plugin.
  131339. */
  131340. extensions: string | ISceneLoaderPluginExtensions;
  131341. /**
  131342. * The callback called when loading from a url.
  131343. * @param scene scene loading this url
  131344. * @param url url to load
  131345. * @param onSuccess callback called when the file successfully loads
  131346. * @param onProgress callback called while file is loading (if the server supports this mode)
  131347. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  131348. * @param onError callback called when the file fails to load
  131349. * @returns a file request object
  131350. */
  131351. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131352. /**
  131353. * The callback called when loading from a file object.
  131354. * @param scene scene loading this file
  131355. * @param file defines the file to load
  131356. * @param onSuccess defines the callback to call when data is loaded
  131357. * @param onProgress defines the callback to call during loading process
  131358. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  131359. * @param onError defines the callback to call when an error occurs
  131360. * @returns a file request object
  131361. */
  131362. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131363. /**
  131364. * The callback that returns true if the data can be directly loaded.
  131365. * @param data string containing the file data
  131366. * @returns if the data can be loaded directly
  131367. */
  131368. canDirectLoad?(data: string): boolean;
  131369. /**
  131370. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  131371. * @param scene scene loading this data
  131372. * @param data string containing the data
  131373. * @returns data to pass to the plugin
  131374. */
  131375. directLoad?(scene: Scene, data: string): any;
  131376. /**
  131377. * The callback that allows custom handling of the root url based on the response url.
  131378. * @param rootUrl the original root url
  131379. * @param responseURL the response url if available
  131380. * @returns the new root url
  131381. */
  131382. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  131383. }
  131384. /**
  131385. * Interface used to define a SceneLoader plugin
  131386. */
  131387. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  131388. /**
  131389. * Import meshes into a scene.
  131390. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131391. * @param scene The scene to import into
  131392. * @param data The data to import
  131393. * @param rootUrl The root url for scene and resources
  131394. * @param meshes The meshes array to import into
  131395. * @param particleSystems The particle systems array to import into
  131396. * @param skeletons The skeletons array to import into
  131397. * @param onError The callback when import fails
  131398. * @returns True if successful or false otherwise
  131399. */
  131400. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  131401. /**
  131402. * Load into a scene.
  131403. * @param scene The scene to load into
  131404. * @param data The data to import
  131405. * @param rootUrl The root url for scene and resources
  131406. * @param onError The callback when import fails
  131407. * @returns True if successful or false otherwise
  131408. */
  131409. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  131410. /**
  131411. * Load into an asset container.
  131412. * @param scene The scene to load into
  131413. * @param data The data to import
  131414. * @param rootUrl The root url for scene and resources
  131415. * @param onError The callback when import fails
  131416. * @returns The loaded asset container
  131417. */
  131418. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  131419. }
  131420. /**
  131421. * Interface used to define an async SceneLoader plugin
  131422. */
  131423. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  131424. /**
  131425. * Import meshes into a scene.
  131426. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131427. * @param scene The scene to import into
  131428. * @param data The data to import
  131429. * @param rootUrl The root url for scene and resources
  131430. * @param onProgress The callback when the load progresses
  131431. * @param fileName Defines the name of the file to load
  131432. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  131433. */
  131434. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  131435. meshes: AbstractMesh[];
  131436. particleSystems: IParticleSystem[];
  131437. skeletons: Skeleton[];
  131438. animationGroups: AnimationGroup[];
  131439. }>;
  131440. /**
  131441. * Load into a scene.
  131442. * @param scene The scene to load into
  131443. * @param data The data to import
  131444. * @param rootUrl The root url for scene and resources
  131445. * @param onProgress The callback when the load progresses
  131446. * @param fileName Defines the name of the file to load
  131447. * @returns Nothing
  131448. */
  131449. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  131450. /**
  131451. * Load into an asset container.
  131452. * @param scene The scene to load into
  131453. * @param data The data to import
  131454. * @param rootUrl The root url for scene and resources
  131455. * @param onProgress The callback when the load progresses
  131456. * @param fileName Defines the name of the file to load
  131457. * @returns The loaded asset container
  131458. */
  131459. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  131460. }
  131461. /**
  131462. * Mode that determines how to handle old animation groups before loading new ones.
  131463. */
  131464. export enum SceneLoaderAnimationGroupLoadingMode {
  131465. /**
  131466. * Reset all old animations to initial state then dispose them.
  131467. */
  131468. Clean = 0,
  131469. /**
  131470. * Stop all old animations.
  131471. */
  131472. Stop = 1,
  131473. /**
  131474. * Restart old animations from first frame.
  131475. */
  131476. Sync = 2,
  131477. /**
  131478. * Old animations remains untouched.
  131479. */
  131480. NoSync = 3
  131481. }
  131482. /**
  131483. * Defines a plugin registered by the SceneLoader
  131484. */
  131485. interface IRegisteredPlugin {
  131486. /**
  131487. * Defines the plugin to use
  131488. */
  131489. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131490. /**
  131491. * Defines if the plugin supports binary data
  131492. */
  131493. isBinary: boolean;
  131494. }
  131495. /**
  131496. * Class used to load scene from various file formats using registered plugins
  131497. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  131498. */
  131499. export class SceneLoader {
  131500. /**
  131501. * No logging while loading
  131502. */
  131503. static readonly NO_LOGGING: number;
  131504. /**
  131505. * Minimal logging while loading
  131506. */
  131507. static readonly MINIMAL_LOGGING: number;
  131508. /**
  131509. * Summary logging while loading
  131510. */
  131511. static readonly SUMMARY_LOGGING: number;
  131512. /**
  131513. * Detailled logging while loading
  131514. */
  131515. static readonly DETAILED_LOGGING: number;
  131516. /**
  131517. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  131518. */
  131519. static get ForceFullSceneLoadingForIncremental(): boolean;
  131520. static set ForceFullSceneLoadingForIncremental(value: boolean);
  131521. /**
  131522. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  131523. */
  131524. static get ShowLoadingScreen(): boolean;
  131525. static set ShowLoadingScreen(value: boolean);
  131526. /**
  131527. * Defines the current logging level (while loading the scene)
  131528. * @ignorenaming
  131529. */
  131530. static get loggingLevel(): number;
  131531. static set loggingLevel(value: number);
  131532. /**
  131533. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  131534. */
  131535. static get CleanBoneMatrixWeights(): boolean;
  131536. static set CleanBoneMatrixWeights(value: boolean);
  131537. /**
  131538. * Event raised when a plugin is used to load a scene
  131539. */
  131540. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  131541. private static _registeredPlugins;
  131542. private static _showingLoadingScreen;
  131543. /**
  131544. * Gets the default plugin (used to load Babylon files)
  131545. * @returns the .babylon plugin
  131546. */
  131547. static GetDefaultPlugin(): IRegisteredPlugin;
  131548. private static _GetPluginForExtension;
  131549. private static _GetPluginForDirectLoad;
  131550. private static _GetPluginForFilename;
  131551. private static _GetDirectLoad;
  131552. private static _LoadData;
  131553. private static _GetFileInfo;
  131554. /**
  131555. * Gets a plugin that can load the given extension
  131556. * @param extension defines the extension to load
  131557. * @returns a plugin or null if none works
  131558. */
  131559. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131560. /**
  131561. * Gets a boolean indicating that the given extension can be loaded
  131562. * @param extension defines the extension to load
  131563. * @returns true if the extension is supported
  131564. */
  131565. static IsPluginForExtensionAvailable(extension: string): boolean;
  131566. /**
  131567. * Adds a new plugin to the list of registered plugins
  131568. * @param plugin defines the plugin to add
  131569. */
  131570. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  131571. /**
  131572. * Import meshes into a scene
  131573. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131574. * @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)
  131575. * @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)
  131576. * @param scene the instance of BABYLON.Scene to append to
  131577. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  131578. * @param onProgress a callback with a progress event for each file being loaded
  131579. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131580. * @param pluginExtension the extension used to determine the plugin
  131581. * @returns The loaded plugin
  131582. */
  131583. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  131584. /**
  131585. * Import meshes into a scene
  131586. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131587. * @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)
  131588. * @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)
  131589. * @param scene the instance of BABYLON.Scene to append to
  131590. * @param onProgress a callback with a progress event for each file being loaded
  131591. * @param pluginExtension the extension used to determine the plugin
  131592. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  131593. */
  131594. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  131595. meshes: AbstractMesh[];
  131596. particleSystems: IParticleSystem[];
  131597. skeletons: Skeleton[];
  131598. animationGroups: AnimationGroup[];
  131599. }>;
  131600. /**
  131601. * Load a scene
  131602. * @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)
  131603. * @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)
  131604. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131605. * @param onSuccess a callback with the scene when import succeeds
  131606. * @param onProgress a callback with a progress event for each file being loaded
  131607. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131608. * @param pluginExtension the extension used to determine the plugin
  131609. * @returns The loaded plugin
  131610. */
  131611. 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>;
  131612. /**
  131613. * Load a scene
  131614. * @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)
  131615. * @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)
  131616. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131617. * @param onProgress a callback with a progress event for each file being loaded
  131618. * @param pluginExtension the extension used to determine the plugin
  131619. * @returns The loaded scene
  131620. */
  131621. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131622. /**
  131623. * Append a scene
  131624. * @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)
  131625. * @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)
  131626. * @param scene is the instance of BABYLON.Scene to append to
  131627. * @param onSuccess a callback with the scene when import succeeds
  131628. * @param onProgress a callback with a progress event for each file being loaded
  131629. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131630. * @param pluginExtension the extension used to determine the plugin
  131631. * @returns The loaded plugin
  131632. */
  131633. 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>;
  131634. /**
  131635. * Append a scene
  131636. * @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)
  131637. * @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)
  131638. * @param scene is the instance of BABYLON.Scene to append to
  131639. * @param onProgress a callback with a progress event for each file being loaded
  131640. * @param pluginExtension the extension used to determine the plugin
  131641. * @returns The given scene
  131642. */
  131643. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131644. /**
  131645. * Load a scene into an asset container
  131646. * @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)
  131647. * @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)
  131648. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131649. * @param onSuccess a callback with the scene when import succeeds
  131650. * @param onProgress a callback with a progress event for each file being loaded
  131651. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131652. * @param pluginExtension the extension used to determine the plugin
  131653. * @returns The loaded plugin
  131654. */
  131655. 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>;
  131656. /**
  131657. * Load a scene into an asset container
  131658. * @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)
  131659. * @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)
  131660. * @param scene is the instance of Scene to append to
  131661. * @param onProgress a callback with a progress event for each file being loaded
  131662. * @param pluginExtension the extension used to determine the plugin
  131663. * @returns The loaded asset container
  131664. */
  131665. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  131666. /**
  131667. * Import animations from a file into a scene
  131668. * @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)
  131669. * @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)
  131670. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131671. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131672. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131673. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131674. * @param onSuccess a callback with the scene when import succeeds
  131675. * @param onProgress a callback with a progress event for each file being loaded
  131676. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131677. * @param pluginExtension the extension used to determine the plugin
  131678. */
  131679. 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;
  131680. /**
  131681. * Import animations from a file into a scene
  131682. * @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)
  131683. * @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)
  131684. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131685. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131686. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131687. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131688. * @param onSuccess a callback with the scene when import succeeds
  131689. * @param onProgress a callback with a progress event for each file being loaded
  131690. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131691. * @param pluginExtension the extension used to determine the plugin
  131692. * @returns the updated scene with imported animations
  131693. */
  131694. 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>;
  131695. }
  131696. }
  131697. declare module BABYLON {
  131698. /**
  131699. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  131700. */
  131701. export type MotionControllerHandedness = "none" | "left" | "right";
  131702. /**
  131703. * The type of components available in motion controllers.
  131704. * This is not the name of the component.
  131705. */
  131706. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  131707. /**
  131708. * The state of a controller component
  131709. */
  131710. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  131711. /**
  131712. * The schema of motion controller layout.
  131713. * No object will be initialized using this interface
  131714. * This is used just to define the profile.
  131715. */
  131716. export interface IMotionControllerLayout {
  131717. /**
  131718. * Path to load the assets. Usually relative to the base path
  131719. */
  131720. assetPath: string;
  131721. /**
  131722. * Available components (unsorted)
  131723. */
  131724. components: {
  131725. /**
  131726. * A map of component Ids
  131727. */
  131728. [componentId: string]: {
  131729. /**
  131730. * The type of input the component outputs
  131731. */
  131732. type: MotionControllerComponentType;
  131733. /**
  131734. * The indices of this component in the gamepad object
  131735. */
  131736. gamepadIndices: {
  131737. /**
  131738. * Index of button
  131739. */
  131740. button?: number;
  131741. /**
  131742. * If available, index of x-axis
  131743. */
  131744. xAxis?: number;
  131745. /**
  131746. * If available, index of y-axis
  131747. */
  131748. yAxis?: number;
  131749. };
  131750. /**
  131751. * The mesh's root node name
  131752. */
  131753. rootNodeName: string;
  131754. /**
  131755. * Animation definitions for this model
  131756. */
  131757. visualResponses: {
  131758. [stateKey: string]: {
  131759. /**
  131760. * What property will be animated
  131761. */
  131762. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  131763. /**
  131764. * What states influence this visual response
  131765. */
  131766. states: MotionControllerComponentStateType[];
  131767. /**
  131768. * Type of animation - movement or visibility
  131769. */
  131770. valueNodeProperty: "transform" | "visibility";
  131771. /**
  131772. * Base node name to move. Its position will be calculated according to the min and max nodes
  131773. */
  131774. valueNodeName?: string;
  131775. /**
  131776. * Minimum movement node
  131777. */
  131778. minNodeName?: string;
  131779. /**
  131780. * Max movement node
  131781. */
  131782. maxNodeName?: string;
  131783. };
  131784. };
  131785. /**
  131786. * If touch enabled, what is the name of node to display user feedback
  131787. */
  131788. touchPointNodeName?: string;
  131789. };
  131790. };
  131791. /**
  131792. * Is it xr standard mapping or not
  131793. */
  131794. gamepadMapping: "" | "xr-standard";
  131795. /**
  131796. * Base root node of this entire model
  131797. */
  131798. rootNodeName: string;
  131799. /**
  131800. * Defines the main button component id
  131801. */
  131802. selectComponentId: string;
  131803. }
  131804. /**
  131805. * A definition for the layout map in the input profile
  131806. */
  131807. export interface IMotionControllerLayoutMap {
  131808. /**
  131809. * Layouts with handedness type as a key
  131810. */
  131811. [handedness: string]: IMotionControllerLayout;
  131812. }
  131813. /**
  131814. * The XR Input profile schema
  131815. * Profiles can be found here:
  131816. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  131817. */
  131818. export interface IMotionControllerProfile {
  131819. /**
  131820. * fallback profiles for this profileId
  131821. */
  131822. fallbackProfileIds: string[];
  131823. /**
  131824. * The layout map, with handedness as key
  131825. */
  131826. layouts: IMotionControllerLayoutMap;
  131827. /**
  131828. * The id of this profile
  131829. * correlates to the profile(s) in the xrInput.profiles array
  131830. */
  131831. profileId: string;
  131832. }
  131833. /**
  131834. * A helper-interface for the 3 meshes needed for controller button animation
  131835. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  131836. */
  131837. export interface IMotionControllerButtonMeshMap {
  131838. /**
  131839. * the mesh that defines the pressed value mesh position.
  131840. * This is used to find the max-position of this button
  131841. */
  131842. pressedMesh: AbstractMesh;
  131843. /**
  131844. * the mesh that defines the unpressed value mesh position.
  131845. * This is used to find the min (or initial) position of this button
  131846. */
  131847. unpressedMesh: AbstractMesh;
  131848. /**
  131849. * The mesh that will be changed when value changes
  131850. */
  131851. valueMesh: AbstractMesh;
  131852. }
  131853. /**
  131854. * A helper-interface for the 3 meshes needed for controller axis animation.
  131855. * This will be expanded when touchpad animations are fully supported
  131856. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  131857. */
  131858. export interface IMotionControllerMeshMap {
  131859. /**
  131860. * the mesh that defines the maximum value mesh position.
  131861. */
  131862. maxMesh?: AbstractMesh;
  131863. /**
  131864. * the mesh that defines the minimum value mesh position.
  131865. */
  131866. minMesh?: AbstractMesh;
  131867. /**
  131868. * The mesh that will be changed when axis value changes
  131869. */
  131870. valueMesh?: AbstractMesh;
  131871. }
  131872. /**
  131873. * The elements needed for change-detection of the gamepad objects in motion controllers
  131874. */
  131875. export interface IMinimalMotionControllerObject {
  131876. /**
  131877. * Available axes of this controller
  131878. */
  131879. axes: number[];
  131880. /**
  131881. * An array of available buttons
  131882. */
  131883. buttons: Array<{
  131884. /**
  131885. * Value of the button/trigger
  131886. */
  131887. value: number;
  131888. /**
  131889. * If the button/trigger is currently touched
  131890. */
  131891. touched: boolean;
  131892. /**
  131893. * If the button/trigger is currently pressed
  131894. */
  131895. pressed: boolean;
  131896. }>;
  131897. /**
  131898. * EXPERIMENTAL haptic support.
  131899. */
  131900. hapticActuators?: Array<{
  131901. pulse: (value: number, duration: number) => Promise<boolean>;
  131902. }>;
  131903. }
  131904. /**
  131905. * An Abstract Motion controller
  131906. * This class receives an xrInput and a profile layout and uses those to initialize the components
  131907. * Each component has an observable to check for changes in value and state
  131908. */
  131909. export abstract class WebXRAbstractMotionController implements IDisposable {
  131910. protected scene: Scene;
  131911. protected layout: IMotionControllerLayout;
  131912. /**
  131913. * The gamepad object correlating to this controller
  131914. */
  131915. gamepadObject: IMinimalMotionControllerObject;
  131916. /**
  131917. * handedness (left/right/none) of this controller
  131918. */
  131919. handedness: MotionControllerHandedness;
  131920. private _initComponent;
  131921. private _modelReady;
  131922. /**
  131923. * A map of components (WebXRControllerComponent) in this motion controller
  131924. * Components have a ComponentType and can also have both button and axis definitions
  131925. */
  131926. readonly components: {
  131927. [id: string]: WebXRControllerComponent;
  131928. };
  131929. /**
  131930. * Disable the model's animation. Can be set at any time.
  131931. */
  131932. disableAnimation: boolean;
  131933. /**
  131934. * Observers registered here will be triggered when the model of this controller is done loading
  131935. */
  131936. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  131937. /**
  131938. * The profile id of this motion controller
  131939. */
  131940. abstract profileId: string;
  131941. /**
  131942. * The root mesh of the model. It is null if the model was not yet initialized
  131943. */
  131944. rootMesh: Nullable<AbstractMesh>;
  131945. /**
  131946. * constructs a new abstract motion controller
  131947. * @param scene the scene to which the model of the controller will be added
  131948. * @param layout The profile layout to load
  131949. * @param gamepadObject The gamepad object correlating to this controller
  131950. * @param handedness handedness (left/right/none) of this controller
  131951. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  131952. */
  131953. constructor(scene: Scene, layout: IMotionControllerLayout,
  131954. /**
  131955. * The gamepad object correlating to this controller
  131956. */
  131957. gamepadObject: IMinimalMotionControllerObject,
  131958. /**
  131959. * handedness (left/right/none) of this controller
  131960. */
  131961. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  131962. /**
  131963. * Dispose this controller, the model mesh and all its components
  131964. */
  131965. dispose(): void;
  131966. /**
  131967. * Returns all components of specific type
  131968. * @param type the type to search for
  131969. * @return an array of components with this type
  131970. */
  131971. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  131972. /**
  131973. * get a component based an its component id as defined in layout.components
  131974. * @param id the id of the component
  131975. * @returns the component correlates to the id or undefined if not found
  131976. */
  131977. getComponent(id: string): WebXRControllerComponent;
  131978. /**
  131979. * Get the list of components available in this motion controller
  131980. * @returns an array of strings correlating to available components
  131981. */
  131982. getComponentIds(): string[];
  131983. /**
  131984. * Get the first component of specific type
  131985. * @param type type of component to find
  131986. * @return a controller component or null if not found
  131987. */
  131988. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  131989. /**
  131990. * Get the main (Select) component of this controller as defined in the layout
  131991. * @returns the main component of this controller
  131992. */
  131993. getMainComponent(): WebXRControllerComponent;
  131994. /**
  131995. * Loads the model correlating to this controller
  131996. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  131997. * @returns A promise fulfilled with the result of the model loading
  131998. */
  131999. loadModel(): Promise<boolean>;
  132000. /**
  132001. * Update this model using the current XRFrame
  132002. * @param xrFrame the current xr frame to use and update the model
  132003. */
  132004. updateFromXRFrame(xrFrame: XRFrame): void;
  132005. /**
  132006. * Backwards compatibility due to a deeply-integrated typo
  132007. */
  132008. get handness(): XREye;
  132009. /**
  132010. * Pulse (vibrate) this controller
  132011. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  132012. * Consecutive calls to this function will cancel the last pulse call
  132013. *
  132014. * @param value the strength of the pulse in 0.0...1.0 range
  132015. * @param duration Duration of the pulse in milliseconds
  132016. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  132017. * @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
  132018. */
  132019. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  132020. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132021. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132022. /**
  132023. * Moves the axis on the controller mesh based on its current state
  132024. * @param axis the index of the axis
  132025. * @param axisValue the value of the axis which determines the meshes new position
  132026. * @hidden
  132027. */
  132028. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  132029. /**
  132030. * Update the model itself with the current frame data
  132031. * @param xrFrame the frame to use for updating the model mesh
  132032. */
  132033. protected updateModel(xrFrame: XRFrame): void;
  132034. /**
  132035. * Get the filename and path for this controller's model
  132036. * @returns a map of filename and path
  132037. */
  132038. protected abstract _getFilenameAndPath(): {
  132039. filename: string;
  132040. path: string;
  132041. };
  132042. /**
  132043. * This function is called before the mesh is loaded. It checks for loading constraints.
  132044. * For example, this function can check if the GLB loader is available
  132045. * If this function returns false, the generic controller will be loaded instead
  132046. * @returns Is the client ready to load the mesh
  132047. */
  132048. protected abstract _getModelLoadingConstraints(): boolean;
  132049. /**
  132050. * This function will be called after the model was successfully loaded and can be used
  132051. * for mesh transformations before it is available for the user
  132052. * @param meshes the loaded meshes
  132053. */
  132054. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  132055. /**
  132056. * Set the root mesh for this controller. Important for the WebXR controller class
  132057. * @param meshes the loaded meshes
  132058. */
  132059. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  132060. /**
  132061. * A function executed each frame that updates the mesh (if needed)
  132062. * @param xrFrame the current xrFrame
  132063. */
  132064. protected abstract _updateModel(xrFrame: XRFrame): void;
  132065. private _getGenericFilenameAndPath;
  132066. private _getGenericParentMesh;
  132067. }
  132068. }
  132069. declare module BABYLON {
  132070. /**
  132071. * A generic trigger-only motion controller for WebXR
  132072. */
  132073. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  132074. /**
  132075. * Static version of the profile id of this controller
  132076. */
  132077. static ProfileId: string;
  132078. profileId: string;
  132079. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  132080. protected _getFilenameAndPath(): {
  132081. filename: string;
  132082. path: string;
  132083. };
  132084. protected _getModelLoadingConstraints(): boolean;
  132085. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  132086. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132087. protected _updateModel(): void;
  132088. }
  132089. }
  132090. declare module BABYLON {
  132091. /**
  132092. * Class containing static functions to help procedurally build meshes
  132093. */
  132094. export class SphereBuilder {
  132095. /**
  132096. * Creates a sphere mesh
  132097. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  132098. * * 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`)
  132099. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  132100. * * 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
  132101. * * 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)
  132102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132105. * @param name defines the name of the mesh
  132106. * @param options defines the options used to create the mesh
  132107. * @param scene defines the hosting scene
  132108. * @returns the sphere mesh
  132109. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  132110. */
  132111. static CreateSphere(name: string, options: {
  132112. segments?: number;
  132113. diameter?: number;
  132114. diameterX?: number;
  132115. diameterY?: number;
  132116. diameterZ?: number;
  132117. arc?: number;
  132118. slice?: number;
  132119. sideOrientation?: number;
  132120. frontUVs?: Vector4;
  132121. backUVs?: Vector4;
  132122. updatable?: boolean;
  132123. }, scene?: Nullable<Scene>): Mesh;
  132124. }
  132125. }
  132126. declare module BABYLON {
  132127. /**
  132128. * A profiled motion controller has its profile loaded from an online repository.
  132129. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  132130. */
  132131. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  132132. private _repositoryUrl;
  132133. private _buttonMeshMapping;
  132134. private _touchDots;
  132135. /**
  132136. * The profile ID of this controller. Will be populated when the controller initializes.
  132137. */
  132138. profileId: string;
  132139. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  132140. dispose(): void;
  132141. protected _getFilenameAndPath(): {
  132142. filename: string;
  132143. path: string;
  132144. };
  132145. protected _getModelLoadingConstraints(): boolean;
  132146. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  132147. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132148. protected _updateModel(_xrFrame: XRFrame): void;
  132149. }
  132150. }
  132151. declare module BABYLON {
  132152. /**
  132153. * A construction function type to create a new controller based on an xrInput object
  132154. */
  132155. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  132156. /**
  132157. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  132158. *
  132159. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  132160. * it should be replaced with auto-loaded controllers.
  132161. *
  132162. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  132163. */
  132164. export class WebXRMotionControllerManager {
  132165. private static _AvailableControllers;
  132166. private static _Fallbacks;
  132167. private static _ProfileLoadingPromises;
  132168. private static _ProfilesList;
  132169. /**
  132170. * The base URL of the online controller repository. Can be changed at any time.
  132171. */
  132172. static BaseRepositoryUrl: string;
  132173. /**
  132174. * Which repository gets priority - local or online
  132175. */
  132176. static PrioritizeOnlineRepository: boolean;
  132177. /**
  132178. * Use the online repository, or use only locally-defined controllers
  132179. */
  132180. static UseOnlineRepository: boolean;
  132181. /**
  132182. * Clear the cache used for profile loading and reload when requested again
  132183. */
  132184. static ClearProfilesCache(): void;
  132185. /**
  132186. * Register the default fallbacks.
  132187. * This function is called automatically when this file is imported.
  132188. */
  132189. static DefaultFallbacks(): void;
  132190. /**
  132191. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  132192. * @param profileId the profile to which a fallback needs to be found
  132193. * @return an array with corresponding fallback profiles
  132194. */
  132195. static FindFallbackWithProfileId(profileId: string): string[];
  132196. /**
  132197. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  132198. * The order of search:
  132199. *
  132200. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  132201. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  132202. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  132203. * 4) return the generic trigger controller if none were found
  132204. *
  132205. * @param xrInput the xrInput to which a new controller is initialized
  132206. * @param scene the scene to which the model will be added
  132207. * @param forceProfile force a certain profile for this controller
  132208. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  132209. */
  132210. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  132211. /**
  132212. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  132213. *
  132214. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  132215. *
  132216. * @param type the profile type to register
  132217. * @param constructFunction the function to be called when loading this profile
  132218. */
  132219. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  132220. /**
  132221. * Register a fallback to a specific profile.
  132222. * @param profileId the profileId that will receive the fallbacks
  132223. * @param fallbacks A list of fallback profiles
  132224. */
  132225. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  132226. /**
  132227. * Will update the list of profiles available in the repository
  132228. * @return a promise that resolves to a map of profiles available online
  132229. */
  132230. static UpdateProfilesList(): Promise<{
  132231. [profile: string]: string;
  132232. }>;
  132233. private static _LoadProfileFromRepository;
  132234. private static _LoadProfilesFromAvailableControllers;
  132235. }
  132236. }
  132237. declare module BABYLON {
  132238. /**
  132239. * Configuration options for the WebXR controller creation
  132240. */
  132241. export interface IWebXRControllerOptions {
  132242. /**
  132243. * Should the controller mesh be animated when a user interacts with it
  132244. * The pressed buttons / thumbstick and touchpad animations will be disabled
  132245. */
  132246. disableMotionControllerAnimation?: boolean;
  132247. /**
  132248. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  132249. */
  132250. doNotLoadControllerMesh?: boolean;
  132251. /**
  132252. * Force a specific controller type for this controller.
  132253. * This can be used when creating your own profile or when testing different controllers
  132254. */
  132255. forceControllerProfile?: string;
  132256. /**
  132257. * Defines a rendering group ID for meshes that will be loaded.
  132258. * This is for the default controllers only.
  132259. */
  132260. renderingGroupId?: number;
  132261. }
  132262. /**
  132263. * Represents an XR controller
  132264. */
  132265. export class WebXRInputSource {
  132266. private _scene;
  132267. /** The underlying input source for the controller */
  132268. inputSource: XRInputSource;
  132269. private _options;
  132270. private _tmpVector;
  132271. private _uniqueId;
  132272. private _disposed;
  132273. /**
  132274. * 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
  132275. */
  132276. grip?: AbstractMesh;
  132277. /**
  132278. * If available, this is the gamepad object related to this controller.
  132279. * Using this object it is possible to get click events and trackpad changes of the
  132280. * webxr controller that is currently being used.
  132281. */
  132282. motionController?: WebXRAbstractMotionController;
  132283. /**
  132284. * Event that fires when the controller is removed/disposed.
  132285. * The object provided as event data is this controller, after associated assets were disposed.
  132286. * uniqueId is still available.
  132287. */
  132288. onDisposeObservable: Observable<WebXRInputSource>;
  132289. /**
  132290. * Will be triggered when the mesh associated with the motion controller is done loading.
  132291. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  132292. * A shortened version of controller -> motion controller -> on mesh loaded.
  132293. */
  132294. onMeshLoadedObservable: Observable<AbstractMesh>;
  132295. /**
  132296. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  132297. */
  132298. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  132299. /**
  132300. * Pointer which can be used to select objects or attach a visible laser to
  132301. */
  132302. pointer: AbstractMesh;
  132303. /**
  132304. * Creates the input source object
  132305. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  132306. * @param _scene the scene which the controller should be associated to
  132307. * @param inputSource the underlying input source for the controller
  132308. * @param _options options for this controller creation
  132309. */
  132310. constructor(_scene: Scene,
  132311. /** The underlying input source for the controller */
  132312. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  132313. /**
  132314. * Get this controllers unique id
  132315. */
  132316. get uniqueId(): string;
  132317. /**
  132318. * Disposes of the object
  132319. */
  132320. dispose(): void;
  132321. /**
  132322. * Gets a world space ray coming from the pointer or grip
  132323. * @param result the resulting ray
  132324. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  132325. */
  132326. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  132327. /**
  132328. * Updates the controller pose based on the given XRFrame
  132329. * @param xrFrame xr frame to update the pose with
  132330. * @param referenceSpace reference space to use
  132331. */
  132332. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  132333. }
  132334. }
  132335. declare module BABYLON {
  132336. /**
  132337. * The schema for initialization options of the XR Input class
  132338. */
  132339. export interface IWebXRInputOptions {
  132340. /**
  132341. * If set to true no model will be automatically loaded
  132342. */
  132343. doNotLoadControllerMeshes?: boolean;
  132344. /**
  132345. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  132346. * If not found, the xr input profile data will be used.
  132347. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  132348. */
  132349. forceInputProfile?: string;
  132350. /**
  132351. * Do not send a request to the controller repository to load the profile.
  132352. *
  132353. * Instead, use the controllers available in babylon itself.
  132354. */
  132355. disableOnlineControllerRepository?: boolean;
  132356. /**
  132357. * A custom URL for the controllers repository
  132358. */
  132359. customControllersRepositoryURL?: string;
  132360. /**
  132361. * Should the controller model's components not move according to the user input
  132362. */
  132363. disableControllerAnimation?: boolean;
  132364. /**
  132365. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  132366. */
  132367. controllerOptions?: IWebXRControllerOptions;
  132368. }
  132369. /**
  132370. * XR input used to track XR inputs such as controllers/rays
  132371. */
  132372. export class WebXRInput implements IDisposable {
  132373. /**
  132374. * the xr session manager for this session
  132375. */
  132376. xrSessionManager: WebXRSessionManager;
  132377. /**
  132378. * the WebXR camera for this session. Mainly used for teleportation
  132379. */
  132380. xrCamera: WebXRCamera;
  132381. private readonly options;
  132382. /**
  132383. * XR controllers being tracked
  132384. */
  132385. controllers: Array<WebXRInputSource>;
  132386. private _frameObserver;
  132387. private _sessionEndedObserver;
  132388. private _sessionInitObserver;
  132389. /**
  132390. * Event when a controller has been connected/added
  132391. */
  132392. onControllerAddedObservable: Observable<WebXRInputSource>;
  132393. /**
  132394. * Event when a controller has been removed/disconnected
  132395. */
  132396. onControllerRemovedObservable: Observable<WebXRInputSource>;
  132397. /**
  132398. * Initializes the WebXRInput
  132399. * @param xrSessionManager the xr session manager for this session
  132400. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  132401. * @param options = initialization options for this xr input
  132402. */
  132403. constructor(
  132404. /**
  132405. * the xr session manager for this session
  132406. */
  132407. xrSessionManager: WebXRSessionManager,
  132408. /**
  132409. * the WebXR camera for this session. Mainly used for teleportation
  132410. */
  132411. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  132412. private _onInputSourcesChange;
  132413. private _addAndRemoveControllers;
  132414. /**
  132415. * Disposes of the object
  132416. */
  132417. dispose(): void;
  132418. }
  132419. }
  132420. declare module BABYLON {
  132421. /**
  132422. * This is the base class for all WebXR features.
  132423. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  132424. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  132425. */
  132426. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  132427. protected _xrSessionManager: WebXRSessionManager;
  132428. private _attached;
  132429. private _removeOnDetach;
  132430. /**
  132431. * Is this feature disposed?
  132432. */
  132433. isDisposed: boolean;
  132434. /**
  132435. * Should auto-attach be disabled?
  132436. */
  132437. disableAutoAttach: boolean;
  132438. /**
  132439. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  132440. */
  132441. xrNativeFeatureName: string;
  132442. /**
  132443. * Construct a new (abstract) WebXR feature
  132444. * @param _xrSessionManager the xr session manager for this feature
  132445. */
  132446. constructor(_xrSessionManager: WebXRSessionManager);
  132447. /**
  132448. * Is this feature attached
  132449. */
  132450. get attached(): boolean;
  132451. /**
  132452. * attach this feature
  132453. *
  132454. * @param force should attachment be forced (even when already attached)
  132455. * @returns true if successful, false is failed or already attached
  132456. */
  132457. attach(force?: boolean): boolean;
  132458. /**
  132459. * detach this feature.
  132460. *
  132461. * @returns true if successful, false if failed or already detached
  132462. */
  132463. detach(): boolean;
  132464. /**
  132465. * Dispose this feature and all of the resources attached
  132466. */
  132467. dispose(): void;
  132468. /**
  132469. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132470. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132471. *
  132472. * @returns whether or not the feature is compatible in this environment
  132473. */
  132474. isCompatible(): boolean;
  132475. /**
  132476. * This is used to register callbacks that will automatically be removed when detach is called.
  132477. * @param observable the observable to which the observer will be attached
  132478. * @param callback the callback to register
  132479. */
  132480. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  132481. /**
  132482. * Code in this function will be executed on each xrFrame received from the browser.
  132483. * This function will not execute after the feature is detached.
  132484. * @param _xrFrame the current frame
  132485. */
  132486. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  132487. }
  132488. }
  132489. declare module BABYLON {
  132490. /**
  132491. * Renders a layer on top of an existing scene
  132492. */
  132493. export class UtilityLayerRenderer implements IDisposable {
  132494. /** the original scene that will be rendered on top of */
  132495. originalScene: Scene;
  132496. private _pointerCaptures;
  132497. private _lastPointerEvents;
  132498. private static _DefaultUtilityLayer;
  132499. private static _DefaultKeepDepthUtilityLayer;
  132500. private _sharedGizmoLight;
  132501. private _renderCamera;
  132502. /**
  132503. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  132504. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  132505. * @returns the camera that is used when rendering the utility layer
  132506. */
  132507. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  132508. /**
  132509. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  132510. * @param cam the camera that should be used when rendering the utility layer
  132511. */
  132512. setRenderCamera(cam: Nullable<Camera>): void;
  132513. /**
  132514. * @hidden
  132515. * Light which used by gizmos to get light shading
  132516. */
  132517. _getSharedGizmoLight(): HemisphericLight;
  132518. /**
  132519. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  132520. */
  132521. pickUtilitySceneFirst: boolean;
  132522. /**
  132523. * 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)
  132524. */
  132525. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  132526. /**
  132527. * 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)
  132528. */
  132529. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  132530. /**
  132531. * The scene that is rendered on top of the original scene
  132532. */
  132533. utilityLayerScene: Scene;
  132534. /**
  132535. * If the utility layer should automatically be rendered on top of existing scene
  132536. */
  132537. shouldRender: boolean;
  132538. /**
  132539. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  132540. */
  132541. onlyCheckPointerDownEvents: boolean;
  132542. /**
  132543. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  132544. */
  132545. processAllEvents: boolean;
  132546. /**
  132547. * Observable raised when the pointer move from the utility layer scene to the main scene
  132548. */
  132549. onPointerOutObservable: Observable<number>;
  132550. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  132551. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  132552. private _afterRenderObserver;
  132553. private _sceneDisposeObserver;
  132554. private _originalPointerObserver;
  132555. /**
  132556. * Instantiates a UtilityLayerRenderer
  132557. * @param originalScene the original scene that will be rendered on top of
  132558. * @param handleEvents boolean indicating if the utility layer should handle events
  132559. */
  132560. constructor(
  132561. /** the original scene that will be rendered on top of */
  132562. originalScene: Scene, handleEvents?: boolean);
  132563. private _notifyObservers;
  132564. /**
  132565. * Renders the utility layers scene on top of the original scene
  132566. */
  132567. render(): void;
  132568. /**
  132569. * Disposes of the renderer
  132570. */
  132571. dispose(): void;
  132572. private _updateCamera;
  132573. }
  132574. }
  132575. declare module BABYLON {
  132576. /**
  132577. * Options interface for the pointer selection module
  132578. */
  132579. export interface IWebXRControllerPointerSelectionOptions {
  132580. /**
  132581. * if provided, this scene will be used to render meshes.
  132582. */
  132583. customUtilityLayerScene?: Scene;
  132584. /**
  132585. * 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)
  132586. * If not disabled, the last picked point will be used to execute a pointer up event
  132587. * If disabled, pointer up event will be triggered right after the pointer down event.
  132588. * Used in screen and gaze target ray mode only
  132589. */
  132590. disablePointerUpOnTouchOut: boolean;
  132591. /**
  132592. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  132593. */
  132594. forceGazeMode: boolean;
  132595. /**
  132596. * 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
  132597. * to start a new countdown to the pointer down event.
  132598. * Defaults to 1.
  132599. */
  132600. gazeModePointerMovedFactor?: number;
  132601. /**
  132602. * Different button type to use instead of the main component
  132603. */
  132604. overrideButtonId?: string;
  132605. /**
  132606. * use this rendering group id for the meshes (optional)
  132607. */
  132608. renderingGroupId?: number;
  132609. /**
  132610. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  132611. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  132612. * 3000 means 3 seconds between pointing at something and selecting it
  132613. */
  132614. timeToSelect?: number;
  132615. /**
  132616. * Should meshes created here be added to a utility layer or the main scene
  132617. */
  132618. useUtilityLayer?: boolean;
  132619. /**
  132620. * Optional WebXR camera to be used for gaze selection
  132621. */
  132622. gazeCamera?: WebXRCamera;
  132623. /**
  132624. * the xr input to use with this pointer selection
  132625. */
  132626. xrInput: WebXRInput;
  132627. }
  132628. /**
  132629. * A module that will enable pointer selection for motion controllers of XR Input Sources
  132630. */
  132631. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  132632. private readonly _options;
  132633. private static _idCounter;
  132634. private _attachController;
  132635. private _controllers;
  132636. private _scene;
  132637. private _tmpVectorForPickCompare;
  132638. /**
  132639. * The module's name
  132640. */
  132641. static readonly Name: string;
  132642. /**
  132643. * The (Babylon) version of this module.
  132644. * This is an integer representing the implementation version.
  132645. * This number does not correspond to the WebXR specs version
  132646. */
  132647. static readonly Version: number;
  132648. /**
  132649. * Disable lighting on the laser pointer (so it will always be visible)
  132650. */
  132651. disablePointerLighting: boolean;
  132652. /**
  132653. * Disable lighting on the selection mesh (so it will always be visible)
  132654. */
  132655. disableSelectionMeshLighting: boolean;
  132656. /**
  132657. * Should the laser pointer be displayed
  132658. */
  132659. displayLaserPointer: boolean;
  132660. /**
  132661. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  132662. */
  132663. displaySelectionMesh: boolean;
  132664. /**
  132665. * This color will be set to the laser pointer when selection is triggered
  132666. */
  132667. laserPointerPickedColor: Color3;
  132668. /**
  132669. * Default color of the laser pointer
  132670. */
  132671. laserPointerDefaultColor: Color3;
  132672. /**
  132673. * default color of the selection ring
  132674. */
  132675. selectionMeshDefaultColor: Color3;
  132676. /**
  132677. * This color will be applied to the selection ring when selection is triggered
  132678. */
  132679. selectionMeshPickedColor: Color3;
  132680. /**
  132681. * Optional filter to be used for ray selection. This predicate shares behavior with
  132682. * scene.pointerMovePredicate which takes priority if it is also assigned.
  132683. */
  132684. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  132685. /**
  132686. * constructs a new background remover module
  132687. * @param _xrSessionManager the session manager for this module
  132688. * @param _options read-only options to be used in this module
  132689. */
  132690. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  132691. /**
  132692. * attach this feature
  132693. * Will usually be called by the features manager
  132694. *
  132695. * @returns true if successful.
  132696. */
  132697. attach(): boolean;
  132698. /**
  132699. * detach this feature.
  132700. * Will usually be called by the features manager
  132701. *
  132702. * @returns true if successful.
  132703. */
  132704. detach(): boolean;
  132705. /**
  132706. * Will get the mesh under a specific pointer.
  132707. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  132708. * @param controllerId the controllerId to check
  132709. * @returns The mesh under pointer or null if no mesh is under the pointer
  132710. */
  132711. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  132712. /**
  132713. * Get the xr controller that correlates to the pointer id in the pointer event
  132714. *
  132715. * @param id the pointer id to search for
  132716. * @returns the controller that correlates to this id or null if not found
  132717. */
  132718. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  132719. protected _onXRFrame(_xrFrame: XRFrame): void;
  132720. private _attachGazeMode;
  132721. private _attachScreenRayMode;
  132722. private _attachTrackedPointerRayMode;
  132723. private _convertNormalToDirectionOfRay;
  132724. private _detachController;
  132725. private _generateNewMeshPair;
  132726. private _pickingMoved;
  132727. private _updatePointerDistance;
  132728. /** @hidden */
  132729. get lasterPointerDefaultColor(): Color3;
  132730. }
  132731. }
  132732. declare module BABYLON {
  132733. /**
  132734. * Button which can be used to enter a different mode of XR
  132735. */
  132736. export class WebXREnterExitUIButton {
  132737. /** button element */
  132738. element: HTMLElement;
  132739. /** XR initialization options for the button */
  132740. sessionMode: XRSessionMode;
  132741. /** Reference space type */
  132742. referenceSpaceType: XRReferenceSpaceType;
  132743. /**
  132744. * Creates a WebXREnterExitUIButton
  132745. * @param element button element
  132746. * @param sessionMode XR initialization session mode
  132747. * @param referenceSpaceType the type of reference space to be used
  132748. */
  132749. constructor(
  132750. /** button element */
  132751. element: HTMLElement,
  132752. /** XR initialization options for the button */
  132753. sessionMode: XRSessionMode,
  132754. /** Reference space type */
  132755. referenceSpaceType: XRReferenceSpaceType);
  132756. /**
  132757. * Extendable function which can be used to update the button's visuals when the state changes
  132758. * @param activeButton the current active button in the UI
  132759. */
  132760. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  132761. }
  132762. /**
  132763. * Options to create the webXR UI
  132764. */
  132765. export class WebXREnterExitUIOptions {
  132766. /**
  132767. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  132768. */
  132769. customButtons?: Array<WebXREnterExitUIButton>;
  132770. /**
  132771. * A reference space type to use when creating the default button.
  132772. * Default is local-floor
  132773. */
  132774. referenceSpaceType?: XRReferenceSpaceType;
  132775. /**
  132776. * Context to enter xr with
  132777. */
  132778. renderTarget?: Nullable<WebXRRenderTarget>;
  132779. /**
  132780. * A session mode to use when creating the default button.
  132781. * Default is immersive-vr
  132782. */
  132783. sessionMode?: XRSessionMode;
  132784. /**
  132785. * A list of optional features to init the session with
  132786. */
  132787. optionalFeatures?: string[];
  132788. /**
  132789. * A list of optional features to init the session with
  132790. */
  132791. requiredFeatures?: string[];
  132792. }
  132793. /**
  132794. * UI to allow the user to enter/exit XR mode
  132795. */
  132796. export class WebXREnterExitUI implements IDisposable {
  132797. private scene;
  132798. /** version of the options passed to this UI */
  132799. options: WebXREnterExitUIOptions;
  132800. private _activeButton;
  132801. private _buttons;
  132802. /**
  132803. * The HTML Div Element to which buttons are added.
  132804. */
  132805. readonly overlay: HTMLDivElement;
  132806. /**
  132807. * Fired every time the active button is changed.
  132808. *
  132809. * When xr is entered via a button that launches xr that button will be the callback parameter
  132810. *
  132811. * When exiting xr the callback parameter will be null)
  132812. */
  132813. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  132814. /**
  132815. *
  132816. * @param scene babylon scene object to use
  132817. * @param options (read-only) version of the options passed to this UI
  132818. */
  132819. private constructor();
  132820. /**
  132821. * Creates UI to allow the user to enter/exit XR mode
  132822. * @param scene the scene to add the ui to
  132823. * @param helper the xr experience helper to enter/exit xr with
  132824. * @param options options to configure the UI
  132825. * @returns the created ui
  132826. */
  132827. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  132828. /**
  132829. * Disposes of the XR UI component
  132830. */
  132831. dispose(): void;
  132832. private _updateButtons;
  132833. }
  132834. }
  132835. declare module BABYLON {
  132836. /**
  132837. * Class containing static functions to help procedurally build meshes
  132838. */
  132839. export class LinesBuilder {
  132840. /**
  132841. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  132842. * * 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
  132843. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  132844. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  132845. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  132846. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  132847. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  132848. * * 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
  132849. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  132850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  132852. * @param name defines the name of the new line system
  132853. * @param options defines the options used to create the line system
  132854. * @param scene defines the hosting scene
  132855. * @returns a new line system mesh
  132856. */
  132857. static CreateLineSystem(name: string, options: {
  132858. lines: Vector3[][];
  132859. updatable?: boolean;
  132860. instance?: Nullable<LinesMesh>;
  132861. colors?: Nullable<Color4[][]>;
  132862. useVertexAlpha?: boolean;
  132863. }, scene: Nullable<Scene>): LinesMesh;
  132864. /**
  132865. * Creates a line mesh
  132866. * 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
  132867. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  132868. * * The parameter `points` is an array successive Vector3
  132869. * * 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
  132870. * * The optional parameter `colors` is an array of successive Color4, one per line point
  132871. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  132872. * * When updating an instance, remember that only point positions can change, not the number of points
  132873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132874. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  132875. * @param name defines the name of the new line system
  132876. * @param options defines the options used to create the line system
  132877. * @param scene defines the hosting scene
  132878. * @returns a new line mesh
  132879. */
  132880. static CreateLines(name: string, options: {
  132881. points: Vector3[];
  132882. updatable?: boolean;
  132883. instance?: Nullable<LinesMesh>;
  132884. colors?: Color4[];
  132885. useVertexAlpha?: boolean;
  132886. }, scene?: Nullable<Scene>): LinesMesh;
  132887. /**
  132888. * Creates a dashed line mesh
  132889. * * 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
  132890. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  132891. * * The parameter `points` is an array successive Vector3
  132892. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  132893. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  132894. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  132895. * * 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
  132896. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  132897. * * When updating an instance, remember that only point positions can change, not the number of points
  132898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132899. * @param name defines the name of the mesh
  132900. * @param options defines the options used to create the mesh
  132901. * @param scene defines the hosting scene
  132902. * @returns the dashed line mesh
  132903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  132904. */
  132905. static CreateDashedLines(name: string, options: {
  132906. points: Vector3[];
  132907. dashSize?: number;
  132908. gapSize?: number;
  132909. dashNb?: number;
  132910. updatable?: boolean;
  132911. instance?: LinesMesh;
  132912. useVertexAlpha?: boolean;
  132913. }, scene?: Nullable<Scene>): LinesMesh;
  132914. }
  132915. }
  132916. declare module BABYLON {
  132917. /**
  132918. * Construction options for a timer
  132919. */
  132920. export interface ITimerOptions<T> {
  132921. /**
  132922. * Time-to-end
  132923. */
  132924. timeout: number;
  132925. /**
  132926. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  132927. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  132928. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  132929. */
  132930. contextObservable: Observable<T>;
  132931. /**
  132932. * Optional parameters when adding an observer to the observable
  132933. */
  132934. observableParameters?: {
  132935. mask?: number;
  132936. insertFirst?: boolean;
  132937. scope?: any;
  132938. };
  132939. /**
  132940. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  132941. */
  132942. breakCondition?: (data?: ITimerData<T>) => boolean;
  132943. /**
  132944. * Will be triggered when the time condition has met
  132945. */
  132946. onEnded?: (data: ITimerData<any>) => void;
  132947. /**
  132948. * Will be triggered when the break condition has met (prematurely ended)
  132949. */
  132950. onAborted?: (data: ITimerData<any>) => void;
  132951. /**
  132952. * Optional function to execute on each tick (or count)
  132953. */
  132954. onTick?: (data: ITimerData<any>) => void;
  132955. }
  132956. /**
  132957. * An interface defining the data sent by the timer
  132958. */
  132959. export interface ITimerData<T> {
  132960. /**
  132961. * When did it start
  132962. */
  132963. startTime: number;
  132964. /**
  132965. * Time now
  132966. */
  132967. currentTime: number;
  132968. /**
  132969. * Time passed since started
  132970. */
  132971. deltaTime: number;
  132972. /**
  132973. * How much is completed, in [0.0...1.0].
  132974. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  132975. */
  132976. completeRate: number;
  132977. /**
  132978. * What the registered observable sent in the last count
  132979. */
  132980. payload: T;
  132981. }
  132982. /**
  132983. * The current state of the timer
  132984. */
  132985. export enum TimerState {
  132986. /**
  132987. * Timer initialized, not yet started
  132988. */
  132989. INIT = 0,
  132990. /**
  132991. * Timer started and counting
  132992. */
  132993. STARTED = 1,
  132994. /**
  132995. * Timer ended (whether aborted or time reached)
  132996. */
  132997. ENDED = 2
  132998. }
  132999. /**
  133000. * A simple version of the timer. Will take options and start the timer immediately after calling it
  133001. *
  133002. * @param options options with which to initialize this timer
  133003. */
  133004. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  133005. /**
  133006. * An advanced implementation of a timer class
  133007. */
  133008. export class AdvancedTimer<T = any> implements IDisposable {
  133009. /**
  133010. * Will notify each time the timer calculates the remaining time
  133011. */
  133012. onEachCountObservable: Observable<ITimerData<T>>;
  133013. /**
  133014. * Will trigger when the timer was aborted due to the break condition
  133015. */
  133016. onTimerAbortedObservable: Observable<ITimerData<T>>;
  133017. /**
  133018. * Will trigger when the timer ended successfully
  133019. */
  133020. onTimerEndedObservable: Observable<ITimerData<T>>;
  133021. /**
  133022. * Will trigger when the timer state has changed
  133023. */
  133024. onStateChangedObservable: Observable<TimerState>;
  133025. private _observer;
  133026. private _contextObservable;
  133027. private _observableParameters;
  133028. private _startTime;
  133029. private _timer;
  133030. private _state;
  133031. private _breakCondition;
  133032. private _timeToEnd;
  133033. private _breakOnNextTick;
  133034. /**
  133035. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  133036. * @param options construction options for this advanced timer
  133037. */
  133038. constructor(options: ITimerOptions<T>);
  133039. /**
  133040. * set a breaking condition for this timer. Default is to never break during count
  133041. * @param predicate the new break condition. Returns true to break, false otherwise
  133042. */
  133043. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  133044. /**
  133045. * Reset ALL associated observables in this advanced timer
  133046. */
  133047. clearObservables(): void;
  133048. /**
  133049. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  133050. *
  133051. * @param timeToEnd how much time to measure until timer ended
  133052. */
  133053. start(timeToEnd?: number): void;
  133054. /**
  133055. * Will force a stop on the next tick.
  133056. */
  133057. stop(): void;
  133058. /**
  133059. * Dispose this timer, clearing all resources
  133060. */
  133061. dispose(): void;
  133062. private _setState;
  133063. private _tick;
  133064. private _stop;
  133065. }
  133066. }
  133067. declare module BABYLON {
  133068. /**
  133069. * The options container for the teleportation module
  133070. */
  133071. export interface IWebXRTeleportationOptions {
  133072. /**
  133073. * if provided, this scene will be used to render meshes.
  133074. */
  133075. customUtilityLayerScene?: Scene;
  133076. /**
  133077. * Values to configure the default target mesh
  133078. */
  133079. defaultTargetMeshOptions?: {
  133080. /**
  133081. * Fill color of the teleportation area
  133082. */
  133083. teleportationFillColor?: string;
  133084. /**
  133085. * Border color for the teleportation area
  133086. */
  133087. teleportationBorderColor?: string;
  133088. /**
  133089. * Disable the mesh's animation sequence
  133090. */
  133091. disableAnimation?: boolean;
  133092. /**
  133093. * Disable lighting on the material or the ring and arrow
  133094. */
  133095. disableLighting?: boolean;
  133096. /**
  133097. * Override the default material of the torus and arrow
  133098. */
  133099. torusArrowMaterial?: Material;
  133100. };
  133101. /**
  133102. * A list of meshes to use as floor meshes.
  133103. * Meshes can be added and removed after initializing the feature using the
  133104. * addFloorMesh and removeFloorMesh functions
  133105. * If empty, rotation will still work
  133106. */
  133107. floorMeshes?: AbstractMesh[];
  133108. /**
  133109. * use this rendering group id for the meshes (optional)
  133110. */
  133111. renderingGroupId?: number;
  133112. /**
  133113. * Should teleportation move only to snap points
  133114. */
  133115. snapPointsOnly?: boolean;
  133116. /**
  133117. * An array of points to which the teleportation will snap to.
  133118. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  133119. */
  133120. snapPositions?: Vector3[];
  133121. /**
  133122. * How close should the teleportation ray be in order to snap to position.
  133123. * Default to 0.8 units (meters)
  133124. */
  133125. snapToPositionRadius?: number;
  133126. /**
  133127. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  133128. * If you want to support rotation, make sure your mesh has a direction indicator.
  133129. *
  133130. * When left untouched, the default mesh will be initialized.
  133131. */
  133132. teleportationTargetMesh?: AbstractMesh;
  133133. /**
  133134. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  133135. */
  133136. timeToTeleport?: number;
  133137. /**
  133138. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  133139. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  133140. */
  133141. useMainComponentOnly?: boolean;
  133142. /**
  133143. * Should meshes created here be added to a utility layer or the main scene
  133144. */
  133145. useUtilityLayer?: boolean;
  133146. /**
  133147. * Babylon XR Input class for controller
  133148. */
  133149. xrInput: WebXRInput;
  133150. /**
  133151. * Meshes that the teleportation ray cannot go through
  133152. */
  133153. pickBlockerMeshes?: AbstractMesh[];
  133154. }
  133155. /**
  133156. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  133157. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  133158. * the input of the attached controllers.
  133159. */
  133160. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  133161. private _options;
  133162. private _controllers;
  133163. private _currentTeleportationControllerId;
  133164. private _floorMeshes;
  133165. private _quadraticBezierCurve;
  133166. private _selectionFeature;
  133167. private _snapToPositions;
  133168. private _snappedToPoint;
  133169. private _teleportationRingMaterial?;
  133170. private _tmpRay;
  133171. private _tmpVector;
  133172. private _tmpQuaternion;
  133173. /**
  133174. * The module's name
  133175. */
  133176. static readonly Name: string;
  133177. /**
  133178. * The (Babylon) version of this module.
  133179. * This is an integer representing the implementation version.
  133180. * This number does not correspond to the webxr specs version
  133181. */
  133182. static readonly Version: number;
  133183. /**
  133184. * Is movement backwards enabled
  133185. */
  133186. backwardsMovementEnabled: boolean;
  133187. /**
  133188. * Distance to travel when moving backwards
  133189. */
  133190. backwardsTeleportationDistance: number;
  133191. /**
  133192. * The distance from the user to the inspection point in the direction of the controller
  133193. * A higher number will allow the user to move further
  133194. * defaults to 5 (meters, in xr units)
  133195. */
  133196. parabolicCheckRadius: number;
  133197. /**
  133198. * Should the module support parabolic ray on top of direct ray
  133199. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  133200. * Very helpful when moving between floors / different heights
  133201. */
  133202. parabolicRayEnabled: boolean;
  133203. /**
  133204. * How much rotation should be applied when rotating right and left
  133205. */
  133206. rotationAngle: number;
  133207. /**
  133208. * Is rotation enabled when moving forward?
  133209. * Disabling this feature will prevent the user from deciding the direction when teleporting
  133210. */
  133211. rotationEnabled: boolean;
  133212. /**
  133213. * constructs a new anchor system
  133214. * @param _xrSessionManager an instance of WebXRSessionManager
  133215. * @param _options configuration object for this feature
  133216. */
  133217. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  133218. /**
  133219. * Get the snapPointsOnly flag
  133220. */
  133221. get snapPointsOnly(): boolean;
  133222. /**
  133223. * Sets the snapPointsOnly flag
  133224. * @param snapToPoints should teleportation be exclusively to snap points
  133225. */
  133226. set snapPointsOnly(snapToPoints: boolean);
  133227. /**
  133228. * Add a new mesh to the floor meshes array
  133229. * @param mesh the mesh to use as floor mesh
  133230. */
  133231. addFloorMesh(mesh: AbstractMesh): void;
  133232. /**
  133233. * Add a new snap-to point to fix teleportation to this position
  133234. * @param newSnapPoint The new Snap-To point
  133235. */
  133236. addSnapPoint(newSnapPoint: Vector3): void;
  133237. attach(): boolean;
  133238. detach(): boolean;
  133239. dispose(): void;
  133240. /**
  133241. * Remove a mesh from the floor meshes array
  133242. * @param mesh the mesh to remove
  133243. */
  133244. removeFloorMesh(mesh: AbstractMesh): void;
  133245. /**
  133246. * Remove a mesh from the floor meshes array using its name
  133247. * @param name the mesh name to remove
  133248. */
  133249. removeFloorMeshByName(name: string): void;
  133250. /**
  133251. * 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
  133252. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  133253. * @returns was the point found and removed or not
  133254. */
  133255. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  133256. /**
  133257. * This function sets a selection feature that will be disabled when
  133258. * the forward ray is shown and will be reattached when hidden.
  133259. * This is used to remove the selection rays when moving.
  133260. * @param selectionFeature the feature to disable when forward movement is enabled
  133261. */
  133262. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  133263. protected _onXRFrame(_xrFrame: XRFrame): void;
  133264. private _attachController;
  133265. private _createDefaultTargetMesh;
  133266. private _detachController;
  133267. private _findClosestSnapPointWithRadius;
  133268. private _setTargetMeshPosition;
  133269. private _setTargetMeshVisibility;
  133270. private _showParabolicPath;
  133271. private _teleportForward;
  133272. }
  133273. }
  133274. declare module BABYLON {
  133275. /**
  133276. * Options for the default xr helper
  133277. */
  133278. export class WebXRDefaultExperienceOptions {
  133279. /**
  133280. * Enable or disable default UI to enter XR
  133281. */
  133282. disableDefaultUI?: boolean;
  133283. /**
  133284. * Should teleportation not initialize. defaults to false.
  133285. */
  133286. disableTeleportation?: boolean;
  133287. /**
  133288. * Floor meshes that will be used for teleport
  133289. */
  133290. floorMeshes?: Array<AbstractMesh>;
  133291. /**
  133292. * If set to true, the first frame will not be used to reset position
  133293. * The first frame is mainly used when copying transformation from the old camera
  133294. * Mainly used in AR
  133295. */
  133296. ignoreNativeCameraTransformation?: boolean;
  133297. /**
  133298. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  133299. */
  133300. inputOptions?: IWebXRInputOptions;
  133301. /**
  133302. * optional configuration for the output canvas
  133303. */
  133304. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  133305. /**
  133306. * optional UI options. This can be used among other to change session mode and reference space type
  133307. */
  133308. uiOptions?: WebXREnterExitUIOptions;
  133309. /**
  133310. * When loading teleportation and pointer select, use stable versions instead of latest.
  133311. */
  133312. useStablePlugins?: boolean;
  133313. /**
  133314. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  133315. */
  133316. renderingGroupId?: number;
  133317. /**
  133318. * A list of optional features to init the session with
  133319. * If set to true, all features we support will be added
  133320. */
  133321. optionalFeatures?: boolean | string[];
  133322. }
  133323. /**
  133324. * Default experience which provides a similar setup to the previous webVRExperience
  133325. */
  133326. export class WebXRDefaultExperience {
  133327. /**
  133328. * Base experience
  133329. */
  133330. baseExperience: WebXRExperienceHelper;
  133331. /**
  133332. * Enables ui for entering/exiting xr
  133333. */
  133334. enterExitUI: WebXREnterExitUI;
  133335. /**
  133336. * Input experience extension
  133337. */
  133338. input: WebXRInput;
  133339. /**
  133340. * Enables laser pointer and selection
  133341. */
  133342. pointerSelection: WebXRControllerPointerSelection;
  133343. /**
  133344. * Default target xr should render to
  133345. */
  133346. renderTarget: WebXRRenderTarget;
  133347. /**
  133348. * Enables teleportation
  133349. */
  133350. teleportation: WebXRMotionControllerTeleportation;
  133351. private constructor();
  133352. /**
  133353. * Creates the default xr experience
  133354. * @param scene scene
  133355. * @param options options for basic configuration
  133356. * @returns resulting WebXRDefaultExperience
  133357. */
  133358. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133359. /**
  133360. * DIsposes of the experience helper
  133361. */
  133362. dispose(): void;
  133363. }
  133364. }
  133365. declare module BABYLON {
  133366. /**
  133367. * Options to modify the vr teleportation behavior.
  133368. */
  133369. export interface VRTeleportationOptions {
  133370. /**
  133371. * The name of the mesh which should be used as the teleportation floor. (default: null)
  133372. */
  133373. floorMeshName?: string;
  133374. /**
  133375. * A list of meshes to be used as the teleportation floor. (default: empty)
  133376. */
  133377. floorMeshes?: Mesh[];
  133378. /**
  133379. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  133380. */
  133381. teleportationMode?: number;
  133382. /**
  133383. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  133384. */
  133385. teleportationTime?: number;
  133386. /**
  133387. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  133388. */
  133389. teleportationSpeed?: number;
  133390. /**
  133391. * The easing function used in the animation or null for Linear. (default CircleEase)
  133392. */
  133393. easingFunction?: EasingFunction;
  133394. }
  133395. /**
  133396. * Options to modify the vr experience helper's behavior.
  133397. */
  133398. export interface VRExperienceHelperOptions extends WebVROptions {
  133399. /**
  133400. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  133401. */
  133402. createDeviceOrientationCamera?: boolean;
  133403. /**
  133404. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  133405. */
  133406. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  133407. /**
  133408. * Uses the main button on the controller to toggle the laser casted. (default: true)
  133409. */
  133410. laserToggle?: boolean;
  133411. /**
  133412. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  133413. */
  133414. floorMeshes?: Mesh[];
  133415. /**
  133416. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  133417. */
  133418. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  133419. /**
  133420. * Defines if WebXR should be used instead of WebVR (if available)
  133421. */
  133422. useXR?: boolean;
  133423. }
  133424. /**
  133425. * Event containing information after VR has been entered
  133426. */
  133427. export class OnAfterEnteringVRObservableEvent {
  133428. /**
  133429. * If entering vr was successful
  133430. */
  133431. success: boolean;
  133432. }
  133433. /**
  133434. * Helps to quickly add VR support to an existing scene.
  133435. * See https://doc.babylonjs.com/how_to/webvr_helper
  133436. */
  133437. export class VRExperienceHelper {
  133438. /** Options to modify the vr experience helper's behavior. */
  133439. webVROptions: VRExperienceHelperOptions;
  133440. private _scene;
  133441. private _position;
  133442. private _btnVR;
  133443. private _btnVRDisplayed;
  133444. private _webVRsupported;
  133445. private _webVRready;
  133446. private _webVRrequesting;
  133447. private _webVRpresenting;
  133448. private _hasEnteredVR;
  133449. private _fullscreenVRpresenting;
  133450. private _inputElement;
  133451. private _webVRCamera;
  133452. private _vrDeviceOrientationCamera;
  133453. private _deviceOrientationCamera;
  133454. private _existingCamera;
  133455. private _onKeyDown;
  133456. private _onVrDisplayPresentChange;
  133457. private _onVRDisplayChanged;
  133458. private _onVRRequestPresentStart;
  133459. private _onVRRequestPresentComplete;
  133460. /**
  133461. * 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)
  133462. */
  133463. enableGazeEvenWhenNoPointerLock: boolean;
  133464. /**
  133465. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  133466. */
  133467. exitVROnDoubleTap: boolean;
  133468. /**
  133469. * Observable raised right before entering VR.
  133470. */
  133471. onEnteringVRObservable: Observable<VRExperienceHelper>;
  133472. /**
  133473. * Observable raised when entering VR has completed.
  133474. */
  133475. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  133476. /**
  133477. * Observable raised when exiting VR.
  133478. */
  133479. onExitingVRObservable: Observable<VRExperienceHelper>;
  133480. /**
  133481. * Observable raised when controller mesh is loaded.
  133482. */
  133483. onControllerMeshLoadedObservable: Observable<WebVRController>;
  133484. /** Return this.onEnteringVRObservable
  133485. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  133486. */
  133487. get onEnteringVR(): Observable<VRExperienceHelper>;
  133488. /** Return this.onExitingVRObservable
  133489. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  133490. */
  133491. get onExitingVR(): Observable<VRExperienceHelper>;
  133492. /** Return this.onControllerMeshLoadedObservable
  133493. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  133494. */
  133495. get onControllerMeshLoaded(): Observable<WebVRController>;
  133496. private _rayLength;
  133497. private _useCustomVRButton;
  133498. private _teleportationRequested;
  133499. private _teleportActive;
  133500. private _floorMeshName;
  133501. private _floorMeshesCollection;
  133502. private _teleportationMode;
  133503. private _teleportationTime;
  133504. private _teleportationSpeed;
  133505. private _teleportationEasing;
  133506. private _rotationAllowed;
  133507. private _teleportBackwardsVector;
  133508. private _teleportationTarget;
  133509. private _isDefaultTeleportationTarget;
  133510. private _postProcessMove;
  133511. private _teleportationFillColor;
  133512. private _teleportationBorderColor;
  133513. private _rotationAngle;
  133514. private _haloCenter;
  133515. private _cameraGazer;
  133516. private _padSensibilityUp;
  133517. private _padSensibilityDown;
  133518. private _leftController;
  133519. private _rightController;
  133520. private _gazeColor;
  133521. private _laserColor;
  133522. private _pickedLaserColor;
  133523. private _pickedGazeColor;
  133524. /**
  133525. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  133526. */
  133527. onNewMeshSelected: Observable<AbstractMesh>;
  133528. /**
  133529. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  133530. * This observable will provide the mesh and the controller used to select the mesh
  133531. */
  133532. onMeshSelectedWithController: Observable<{
  133533. mesh: AbstractMesh;
  133534. controller: WebVRController;
  133535. }>;
  133536. /**
  133537. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  133538. */
  133539. onNewMeshPicked: Observable<PickingInfo>;
  133540. private _circleEase;
  133541. /**
  133542. * Observable raised before camera teleportation
  133543. */
  133544. onBeforeCameraTeleport: Observable<Vector3>;
  133545. /**
  133546. * Observable raised after camera teleportation
  133547. */
  133548. onAfterCameraTeleport: Observable<Vector3>;
  133549. /**
  133550. * Observable raised when current selected mesh gets unselected
  133551. */
  133552. onSelectedMeshUnselected: Observable<AbstractMesh>;
  133553. private _raySelectionPredicate;
  133554. /**
  133555. * To be optionaly changed by user to define custom ray selection
  133556. */
  133557. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133558. /**
  133559. * To be optionaly changed by user to define custom selection logic (after ray selection)
  133560. */
  133561. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  133562. /**
  133563. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  133564. */
  133565. teleportationEnabled: boolean;
  133566. private _defaultHeight;
  133567. private _teleportationInitialized;
  133568. private _interactionsEnabled;
  133569. private _interactionsRequested;
  133570. private _displayGaze;
  133571. private _displayLaserPointer;
  133572. /**
  133573. * The mesh used to display where the user is going to teleport.
  133574. */
  133575. get teleportationTarget(): Mesh;
  133576. /**
  133577. * Sets the mesh to be used to display where the user is going to teleport.
  133578. */
  133579. set teleportationTarget(value: Mesh);
  133580. /**
  133581. * 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
  133582. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  133583. * See https://doc.babylonjs.com/resources/baking_transformations
  133584. */
  133585. get gazeTrackerMesh(): Mesh;
  133586. set gazeTrackerMesh(value: Mesh);
  133587. /**
  133588. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  133589. */
  133590. updateGazeTrackerScale: boolean;
  133591. /**
  133592. * If the gaze trackers color should be updated when selecting meshes
  133593. */
  133594. updateGazeTrackerColor: boolean;
  133595. /**
  133596. * If the controller laser color should be updated when selecting meshes
  133597. */
  133598. updateControllerLaserColor: boolean;
  133599. /**
  133600. * The gaze tracking mesh corresponding to the left controller
  133601. */
  133602. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  133603. /**
  133604. * The gaze tracking mesh corresponding to the right controller
  133605. */
  133606. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  133607. /**
  133608. * If the ray of the gaze should be displayed.
  133609. */
  133610. get displayGaze(): boolean;
  133611. /**
  133612. * Sets if the ray of the gaze should be displayed.
  133613. */
  133614. set displayGaze(value: boolean);
  133615. /**
  133616. * If the ray of the LaserPointer should be displayed.
  133617. */
  133618. get displayLaserPointer(): boolean;
  133619. /**
  133620. * Sets if the ray of the LaserPointer should be displayed.
  133621. */
  133622. set displayLaserPointer(value: boolean);
  133623. /**
  133624. * The deviceOrientationCamera used as the camera when not in VR.
  133625. */
  133626. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  133627. /**
  133628. * Based on the current WebVR support, returns the current VR camera used.
  133629. */
  133630. get currentVRCamera(): Nullable<Camera>;
  133631. /**
  133632. * The webVRCamera which is used when in VR.
  133633. */
  133634. get webVRCamera(): WebVRFreeCamera;
  133635. /**
  133636. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  133637. */
  133638. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  133639. /**
  133640. * The html button that is used to trigger entering into VR.
  133641. */
  133642. get vrButton(): Nullable<HTMLButtonElement>;
  133643. private get _teleportationRequestInitiated();
  133644. /**
  133645. * Defines whether or not Pointer lock should be requested when switching to
  133646. * full screen.
  133647. */
  133648. requestPointerLockOnFullScreen: boolean;
  133649. /**
  133650. * If asking to force XR, this will be populated with the default xr experience
  133651. */
  133652. xr: WebXRDefaultExperience;
  133653. /**
  133654. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  133655. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  133656. */
  133657. xrTestDone: boolean;
  133658. /**
  133659. * Instantiates a VRExperienceHelper.
  133660. * Helps to quickly add VR support to an existing scene.
  133661. * @param scene The scene the VRExperienceHelper belongs to.
  133662. * @param webVROptions Options to modify the vr experience helper's behavior.
  133663. */
  133664. constructor(scene: Scene,
  133665. /** Options to modify the vr experience helper's behavior. */
  133666. webVROptions?: VRExperienceHelperOptions);
  133667. private completeVRInit;
  133668. private _onDefaultMeshLoaded;
  133669. private _onResize;
  133670. private _onFullscreenChange;
  133671. /**
  133672. * Gets a value indicating if we are currently in VR mode.
  133673. */
  133674. get isInVRMode(): boolean;
  133675. private onVrDisplayPresentChange;
  133676. private onVRDisplayChanged;
  133677. private moveButtonToBottomRight;
  133678. private displayVRButton;
  133679. private updateButtonVisibility;
  133680. private _cachedAngularSensibility;
  133681. /**
  133682. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  133683. * Otherwise, will use the fullscreen API.
  133684. */
  133685. enterVR(): void;
  133686. /**
  133687. * Attempt to exit VR, or fullscreen.
  133688. */
  133689. exitVR(): void;
  133690. /**
  133691. * The position of the vr experience helper.
  133692. */
  133693. get position(): Vector3;
  133694. /**
  133695. * Sets the position of the vr experience helper.
  133696. */
  133697. set position(value: Vector3);
  133698. /**
  133699. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  133700. */
  133701. enableInteractions(): void;
  133702. private get _noControllerIsActive();
  133703. private beforeRender;
  133704. private _isTeleportationFloor;
  133705. /**
  133706. * Adds a floor mesh to be used for teleportation.
  133707. * @param floorMesh the mesh to be used for teleportation.
  133708. */
  133709. addFloorMesh(floorMesh: Mesh): void;
  133710. /**
  133711. * Removes a floor mesh from being used for teleportation.
  133712. * @param floorMesh the mesh to be removed.
  133713. */
  133714. removeFloorMesh(floorMesh: Mesh): void;
  133715. /**
  133716. * Enables interactions and teleportation using the VR controllers and gaze.
  133717. * @param vrTeleportationOptions options to modify teleportation behavior.
  133718. */
  133719. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  133720. private _onNewGamepadConnected;
  133721. private _tryEnableInteractionOnController;
  133722. private _onNewGamepadDisconnected;
  133723. private _enableInteractionOnController;
  133724. private _checkTeleportWithRay;
  133725. private _checkRotate;
  133726. private _checkTeleportBackwards;
  133727. private _enableTeleportationOnController;
  133728. private _createTeleportationCircles;
  133729. private _displayTeleportationTarget;
  133730. private _hideTeleportationTarget;
  133731. private _rotateCamera;
  133732. private _moveTeleportationSelectorTo;
  133733. private _workingVector;
  133734. private _workingQuaternion;
  133735. private _workingMatrix;
  133736. /**
  133737. * Time Constant Teleportation Mode
  133738. */
  133739. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  133740. /**
  133741. * Speed Constant Teleportation Mode
  133742. */
  133743. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  133744. /**
  133745. * Teleports the users feet to the desired location
  133746. * @param location The location where the user's feet should be placed
  133747. */
  133748. teleportCamera(location: Vector3): void;
  133749. private _convertNormalToDirectionOfRay;
  133750. private _castRayAndSelectObject;
  133751. private _notifySelectedMeshUnselected;
  133752. /**
  133753. * Permanently set new colors for the laser pointer
  133754. * @param color the new laser color
  133755. * @param pickedColor the new laser color when picked mesh detected
  133756. */
  133757. setLaserColor(color: Color3, pickedColor?: Color3): void;
  133758. /**
  133759. * Set lighting enabled / disabled on the laser pointer of both controllers
  133760. * @param enabled should the lighting be enabled on the laser pointer
  133761. */
  133762. setLaserLightingState(enabled?: boolean): void;
  133763. /**
  133764. * Permanently set new colors for the gaze pointer
  133765. * @param color the new gaze color
  133766. * @param pickedColor the new gaze color when picked mesh detected
  133767. */
  133768. setGazeColor(color: Color3, pickedColor?: Color3): void;
  133769. /**
  133770. * Sets the color of the laser ray from the vr controllers.
  133771. * @param color new color for the ray.
  133772. */
  133773. changeLaserColor(color: Color3): void;
  133774. /**
  133775. * Sets the color of the ray from the vr headsets gaze.
  133776. * @param color new color for the ray.
  133777. */
  133778. changeGazeColor(color: Color3): void;
  133779. /**
  133780. * Exits VR and disposes of the vr experience helper
  133781. */
  133782. dispose(): void;
  133783. /**
  133784. * Gets the name of the VRExperienceHelper class
  133785. * @returns "VRExperienceHelper"
  133786. */
  133787. getClassName(): string;
  133788. }
  133789. }
  133790. declare module BABYLON {
  133791. /**
  133792. * Contains an array of blocks representing the octree
  133793. */
  133794. export interface IOctreeContainer<T> {
  133795. /**
  133796. * Blocks within the octree
  133797. */
  133798. blocks: Array<OctreeBlock<T>>;
  133799. }
  133800. /**
  133801. * Class used to store a cell in an octree
  133802. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133803. */
  133804. export class OctreeBlock<T> {
  133805. /**
  133806. * Gets the content of the current block
  133807. */
  133808. entries: T[];
  133809. /**
  133810. * Gets the list of block children
  133811. */
  133812. blocks: Array<OctreeBlock<T>>;
  133813. private _depth;
  133814. private _maxDepth;
  133815. private _capacity;
  133816. private _minPoint;
  133817. private _maxPoint;
  133818. private _boundingVectors;
  133819. private _creationFunc;
  133820. /**
  133821. * Creates a new block
  133822. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  133823. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  133824. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133825. * @param depth defines the current depth of this block in the octree
  133826. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  133827. * @param creationFunc defines a callback to call when an element is added to the block
  133828. */
  133829. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  133830. /**
  133831. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133832. */
  133833. get capacity(): number;
  133834. /**
  133835. * Gets the minimum vector (in world space) of the block's bounding box
  133836. */
  133837. get minPoint(): Vector3;
  133838. /**
  133839. * Gets the maximum vector (in world space) of the block's bounding box
  133840. */
  133841. get maxPoint(): Vector3;
  133842. /**
  133843. * Add a new element to this block
  133844. * @param entry defines the element to add
  133845. */
  133846. addEntry(entry: T): void;
  133847. /**
  133848. * Remove an element from this block
  133849. * @param entry defines the element to remove
  133850. */
  133851. removeEntry(entry: T): void;
  133852. /**
  133853. * Add an array of elements to this block
  133854. * @param entries defines the array of elements to add
  133855. */
  133856. addEntries(entries: T[]): void;
  133857. /**
  133858. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  133859. * @param frustumPlanes defines the frustum planes to test
  133860. * @param selection defines the array to store current content if selection is positive
  133861. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133862. */
  133863. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  133864. /**
  133865. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  133866. * @param sphereCenter defines the bounding sphere center
  133867. * @param sphereRadius defines the bounding sphere radius
  133868. * @param selection defines the array to store current content if selection is positive
  133869. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133870. */
  133871. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  133872. /**
  133873. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  133874. * @param ray defines the ray to test with
  133875. * @param selection defines the array to store current content if selection is positive
  133876. */
  133877. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  133878. /**
  133879. * Subdivide the content into child blocks (this block will then be empty)
  133880. */
  133881. createInnerBlocks(): void;
  133882. /**
  133883. * @hidden
  133884. */
  133885. 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;
  133886. }
  133887. }
  133888. declare module BABYLON {
  133889. /**
  133890. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  133891. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133892. */
  133893. export class Octree<T> {
  133894. /** 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.) */
  133895. maxDepth: number;
  133896. /**
  133897. * Blocks within the octree containing objects
  133898. */
  133899. blocks: Array<OctreeBlock<T>>;
  133900. /**
  133901. * Content stored in the octree
  133902. */
  133903. dynamicContent: T[];
  133904. private _maxBlockCapacity;
  133905. private _selectionContent;
  133906. private _creationFunc;
  133907. /**
  133908. * Creates a octree
  133909. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133910. * @param creationFunc function to be used to instatiate the octree
  133911. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  133912. * @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.)
  133913. */
  133914. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  133915. /** 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.) */
  133916. maxDepth?: number);
  133917. /**
  133918. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  133919. * @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);
  133920. * @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);
  133921. * @param entries meshes to be added to the octree blocks
  133922. */
  133923. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  133924. /**
  133925. * Adds a mesh to the octree
  133926. * @param entry Mesh to add to the octree
  133927. */
  133928. addMesh(entry: T): void;
  133929. /**
  133930. * Remove an element from the octree
  133931. * @param entry defines the element to remove
  133932. */
  133933. removeMesh(entry: T): void;
  133934. /**
  133935. * Selects an array of meshes within the frustum
  133936. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  133937. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  133938. * @returns array of meshes within the frustum
  133939. */
  133940. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  133941. /**
  133942. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  133943. * @param sphereCenter defines the bounding sphere center
  133944. * @param sphereRadius defines the bounding sphere radius
  133945. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133946. * @returns an array of objects that intersect the sphere
  133947. */
  133948. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  133949. /**
  133950. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  133951. * @param ray defines the ray to test with
  133952. * @returns array of intersected objects
  133953. */
  133954. intersectsRay(ray: Ray): SmartArray<T>;
  133955. /**
  133956. * Adds a mesh into the octree block if it intersects the block
  133957. */
  133958. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  133959. /**
  133960. * Adds a submesh into the octree block if it intersects the block
  133961. */
  133962. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  133963. }
  133964. }
  133965. declare module BABYLON {
  133966. interface Scene {
  133967. /**
  133968. * @hidden
  133969. * Backing Filed
  133970. */
  133971. _selectionOctree: Octree<AbstractMesh>;
  133972. /**
  133973. * Gets the octree used to boost mesh selection (picking)
  133974. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133975. */
  133976. selectionOctree: Octree<AbstractMesh>;
  133977. /**
  133978. * Creates or updates the octree used to boost selection (picking)
  133979. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133980. * @param maxCapacity defines the maximum capacity per leaf
  133981. * @param maxDepth defines the maximum depth of the octree
  133982. * @returns an octree of AbstractMesh
  133983. */
  133984. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  133985. }
  133986. interface AbstractMesh {
  133987. /**
  133988. * @hidden
  133989. * Backing Field
  133990. */
  133991. _submeshesOctree: Octree<SubMesh>;
  133992. /**
  133993. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  133994. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  133995. * @param maxCapacity defines the maximum size of each block (64 by default)
  133996. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  133997. * @returns the new octree
  133998. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  133999. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134000. */
  134001. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  134002. }
  134003. /**
  134004. * Defines the octree scene component responsible to manage any octrees
  134005. * in a given scene.
  134006. */
  134007. export class OctreeSceneComponent {
  134008. /**
  134009. * The component name help to identify the component in the list of scene components.
  134010. */
  134011. readonly name: string;
  134012. /**
  134013. * The scene the component belongs to.
  134014. */
  134015. scene: Scene;
  134016. /**
  134017. * Indicates if the meshes have been checked to make sure they are isEnabled()
  134018. */
  134019. readonly checksIsEnabled: boolean;
  134020. /**
  134021. * Creates a new instance of the component for the given scene
  134022. * @param scene Defines the scene to register the component in
  134023. */
  134024. constructor(scene: Scene);
  134025. /**
  134026. * Registers the component in a given scene
  134027. */
  134028. register(): void;
  134029. /**
  134030. * Return the list of active meshes
  134031. * @returns the list of active meshes
  134032. */
  134033. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  134034. /**
  134035. * Return the list of active sub meshes
  134036. * @param mesh The mesh to get the candidates sub meshes from
  134037. * @returns the list of active sub meshes
  134038. */
  134039. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  134040. private _tempRay;
  134041. /**
  134042. * Return the list of sub meshes intersecting with a given local ray
  134043. * @param mesh defines the mesh to find the submesh for
  134044. * @param localRay defines the ray in local space
  134045. * @returns the list of intersecting sub meshes
  134046. */
  134047. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  134048. /**
  134049. * Return the list of sub meshes colliding with a collider
  134050. * @param mesh defines the mesh to find the submesh for
  134051. * @param collider defines the collider to evaluate the collision against
  134052. * @returns the list of colliding sub meshes
  134053. */
  134054. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  134055. /**
  134056. * Rebuilds the elements related to this component in case of
  134057. * context lost for instance.
  134058. */
  134059. rebuild(): void;
  134060. /**
  134061. * Disposes the component and the associated ressources.
  134062. */
  134063. dispose(): void;
  134064. }
  134065. }
  134066. declare module BABYLON {
  134067. /**
  134068. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  134069. */
  134070. export class Gizmo implements IDisposable {
  134071. /** The utility layer the gizmo will be added to */
  134072. gizmoLayer: UtilityLayerRenderer;
  134073. /**
  134074. * The root mesh of the gizmo
  134075. */
  134076. _rootMesh: Mesh;
  134077. private _attachedMesh;
  134078. private _attachedNode;
  134079. /**
  134080. * Ratio for the scale of the gizmo (Default: 1)
  134081. */
  134082. protected _scaleRatio: number;
  134083. /**
  134084. * boolean updated by pointermove when a gizmo mesh is hovered
  134085. */
  134086. protected _isHovered: boolean;
  134087. /**
  134088. * Ratio for the scale of the gizmo (Default: 1)
  134089. */
  134090. set scaleRatio(value: number);
  134091. get scaleRatio(): number;
  134092. /**
  134093. * True when the mouse pointer is hovered a gizmo mesh
  134094. */
  134095. get isHovered(): boolean;
  134096. /**
  134097. * If a custom mesh has been set (Default: false)
  134098. */
  134099. protected _customMeshSet: boolean;
  134100. /**
  134101. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  134102. * * When set, interactions will be enabled
  134103. */
  134104. get attachedMesh(): Nullable<AbstractMesh>;
  134105. set attachedMesh(value: Nullable<AbstractMesh>);
  134106. /**
  134107. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  134108. * * When set, interactions will be enabled
  134109. */
  134110. get attachedNode(): Nullable<Node>;
  134111. set attachedNode(value: Nullable<Node>);
  134112. /**
  134113. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134114. * @param mesh The mesh to replace the default mesh of the gizmo
  134115. */
  134116. setCustomMesh(mesh: Mesh): void;
  134117. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  134118. /**
  134119. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  134120. */
  134121. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134122. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134123. /**
  134124. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  134125. */
  134126. updateGizmoPositionToMatchAttachedMesh: boolean;
  134127. /**
  134128. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  134129. */
  134130. updateScale: boolean;
  134131. protected _interactionsEnabled: boolean;
  134132. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134133. private _beforeRenderObserver;
  134134. private _tempQuaternion;
  134135. private _tempVector;
  134136. private _tempVector2;
  134137. private _tempMatrix1;
  134138. private _tempMatrix2;
  134139. private _rightHandtoLeftHandMatrix;
  134140. /**
  134141. * Creates a gizmo
  134142. * @param gizmoLayer The utility layer the gizmo will be added to
  134143. */
  134144. constructor(
  134145. /** The utility layer the gizmo will be added to */
  134146. gizmoLayer?: UtilityLayerRenderer);
  134147. /**
  134148. * Updates the gizmo to match the attached mesh's position/rotation
  134149. */
  134150. protected _update(): void;
  134151. /**
  134152. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  134153. * @param value Node, TransformNode or mesh
  134154. */
  134155. protected _matrixChanged(): void;
  134156. /**
  134157. * Disposes of the gizmo
  134158. */
  134159. dispose(): void;
  134160. }
  134161. }
  134162. declare module BABYLON {
  134163. /**
  134164. * Single plane drag gizmo
  134165. */
  134166. export class PlaneDragGizmo extends Gizmo {
  134167. /**
  134168. * Drag behavior responsible for the gizmos dragging interactions
  134169. */
  134170. dragBehavior: PointerDragBehavior;
  134171. private _pointerObserver;
  134172. /**
  134173. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134174. */
  134175. snapDistance: number;
  134176. /**
  134177. * Event that fires each time the gizmo snaps to a new location.
  134178. * * snapDistance is the the change in distance
  134179. */
  134180. onSnapObservable: Observable<{
  134181. snapDistance: number;
  134182. }>;
  134183. private _plane;
  134184. private _coloredMaterial;
  134185. private _hoverMaterial;
  134186. private _isEnabled;
  134187. private _parent;
  134188. /** @hidden */
  134189. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  134190. /** @hidden */
  134191. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134192. /**
  134193. * Creates a PlaneDragGizmo
  134194. * @param gizmoLayer The utility layer the gizmo will be added to
  134195. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  134196. * @param color The color of the gizmo
  134197. */
  134198. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  134199. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134200. /**
  134201. * If the gizmo is enabled
  134202. */
  134203. set isEnabled(value: boolean);
  134204. get isEnabled(): boolean;
  134205. /**
  134206. * Disposes of the gizmo
  134207. */
  134208. dispose(): void;
  134209. }
  134210. }
  134211. declare module BABYLON {
  134212. /**
  134213. * Gizmo that enables dragging a mesh along 3 axis
  134214. */
  134215. export class PositionGizmo extends Gizmo {
  134216. /**
  134217. * Internal gizmo used for interactions on the x axis
  134218. */
  134219. xGizmo: AxisDragGizmo;
  134220. /**
  134221. * Internal gizmo used for interactions on the y axis
  134222. */
  134223. yGizmo: AxisDragGizmo;
  134224. /**
  134225. * Internal gizmo used for interactions on the z axis
  134226. */
  134227. zGizmo: AxisDragGizmo;
  134228. /**
  134229. * Internal gizmo used for interactions on the yz plane
  134230. */
  134231. xPlaneGizmo: PlaneDragGizmo;
  134232. /**
  134233. * Internal gizmo used for interactions on the xz plane
  134234. */
  134235. yPlaneGizmo: PlaneDragGizmo;
  134236. /**
  134237. * Internal gizmo used for interactions on the xy plane
  134238. */
  134239. zPlaneGizmo: PlaneDragGizmo;
  134240. /**
  134241. * private variables
  134242. */
  134243. private _meshAttached;
  134244. private _nodeAttached;
  134245. private _snapDistance;
  134246. /** Fires an event when any of it's sub gizmos are dragged */
  134247. onDragStartObservable: Observable<unknown>;
  134248. /** Fires an event when any of it's sub gizmos are released from dragging */
  134249. onDragEndObservable: Observable<unknown>;
  134250. /**
  134251. * If set to true, planar drag is enabled
  134252. */
  134253. private _planarGizmoEnabled;
  134254. get attachedMesh(): Nullable<AbstractMesh>;
  134255. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134256. get attachedNode(): Nullable<Node>;
  134257. set attachedNode(node: Nullable<Node>);
  134258. /**
  134259. * True when the mouse pointer is hovering a gizmo mesh
  134260. */
  134261. get isHovered(): boolean;
  134262. /**
  134263. * Creates a PositionGizmo
  134264. * @param gizmoLayer The utility layer the gizmo will be added to
  134265. @param thickness display gizmo axis thickness
  134266. */
  134267. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134268. /**
  134269. * If the planar drag gizmo is enabled
  134270. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  134271. */
  134272. set planarGizmoEnabled(value: boolean);
  134273. get planarGizmoEnabled(): boolean;
  134274. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134275. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134276. /**
  134277. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134278. */
  134279. set snapDistance(value: number);
  134280. get snapDistance(): number;
  134281. /**
  134282. * Ratio for the scale of the gizmo (Default: 1)
  134283. */
  134284. set scaleRatio(value: number);
  134285. get scaleRatio(): number;
  134286. /**
  134287. * Disposes of the gizmo
  134288. */
  134289. dispose(): void;
  134290. /**
  134291. * CustomMeshes are not supported by this gizmo
  134292. * @param mesh The mesh to replace the default mesh of the gizmo
  134293. */
  134294. setCustomMesh(mesh: Mesh): void;
  134295. }
  134296. }
  134297. declare module BABYLON {
  134298. /**
  134299. * Single axis drag gizmo
  134300. */
  134301. export class AxisDragGizmo extends Gizmo {
  134302. /**
  134303. * Drag behavior responsible for the gizmos dragging interactions
  134304. */
  134305. dragBehavior: PointerDragBehavior;
  134306. private _pointerObserver;
  134307. /**
  134308. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134309. */
  134310. snapDistance: number;
  134311. /**
  134312. * Event that fires each time the gizmo snaps to a new location.
  134313. * * snapDistance is the the change in distance
  134314. */
  134315. onSnapObservable: Observable<{
  134316. snapDistance: number;
  134317. }>;
  134318. private _isEnabled;
  134319. private _parent;
  134320. private _arrow;
  134321. private _coloredMaterial;
  134322. private _hoverMaterial;
  134323. /** @hidden */
  134324. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  134325. /** @hidden */
  134326. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134327. /**
  134328. * Creates an AxisDragGizmo
  134329. * @param gizmoLayer The utility layer the gizmo will be added to
  134330. * @param dragAxis The axis which the gizmo will be able to drag on
  134331. * @param color The color of the gizmo
  134332. * @param thickness display gizmo axis thickness
  134333. */
  134334. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  134335. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134336. /**
  134337. * If the gizmo is enabled
  134338. */
  134339. set isEnabled(value: boolean);
  134340. get isEnabled(): boolean;
  134341. /**
  134342. * Disposes of the gizmo
  134343. */
  134344. dispose(): void;
  134345. }
  134346. }
  134347. declare module BABYLON.Debug {
  134348. /**
  134349. * The Axes viewer will show 3 axes in a specific point in space
  134350. */
  134351. export class AxesViewer {
  134352. private _xAxis;
  134353. private _yAxis;
  134354. private _zAxis;
  134355. private _scaleLinesFactor;
  134356. private _instanced;
  134357. /**
  134358. * Gets the hosting scene
  134359. */
  134360. scene: Nullable<Scene>;
  134361. /**
  134362. * Gets or sets a number used to scale line length
  134363. */
  134364. scaleLines: number;
  134365. /** Gets the node hierarchy used to render x-axis */
  134366. get xAxis(): TransformNode;
  134367. /** Gets the node hierarchy used to render y-axis */
  134368. get yAxis(): TransformNode;
  134369. /** Gets the node hierarchy used to render z-axis */
  134370. get zAxis(): TransformNode;
  134371. /**
  134372. * Creates a new AxesViewer
  134373. * @param scene defines the hosting scene
  134374. * @param scaleLines defines a number used to scale line length (1 by default)
  134375. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  134376. * @param xAxis defines the node hierarchy used to render the x-axis
  134377. * @param yAxis defines the node hierarchy used to render the y-axis
  134378. * @param zAxis defines the node hierarchy used to render the z-axis
  134379. */
  134380. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  134381. /**
  134382. * Force the viewer to update
  134383. * @param position defines the position of the viewer
  134384. * @param xaxis defines the x axis of the viewer
  134385. * @param yaxis defines the y axis of the viewer
  134386. * @param zaxis defines the z axis of the viewer
  134387. */
  134388. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  134389. /**
  134390. * Creates an instance of this axes viewer.
  134391. * @returns a new axes viewer with instanced meshes
  134392. */
  134393. createInstance(): AxesViewer;
  134394. /** Releases resources */
  134395. dispose(): void;
  134396. private static _SetRenderingGroupId;
  134397. }
  134398. }
  134399. declare module BABYLON.Debug {
  134400. /**
  134401. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  134402. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  134403. */
  134404. export class BoneAxesViewer extends AxesViewer {
  134405. /**
  134406. * Gets or sets the target mesh where to display the axes viewer
  134407. */
  134408. mesh: Nullable<Mesh>;
  134409. /**
  134410. * Gets or sets the target bone where to display the axes viewer
  134411. */
  134412. bone: Nullable<Bone>;
  134413. /** Gets current position */
  134414. pos: Vector3;
  134415. /** Gets direction of X axis */
  134416. xaxis: Vector3;
  134417. /** Gets direction of Y axis */
  134418. yaxis: Vector3;
  134419. /** Gets direction of Z axis */
  134420. zaxis: Vector3;
  134421. /**
  134422. * Creates a new BoneAxesViewer
  134423. * @param scene defines the hosting scene
  134424. * @param bone defines the target bone
  134425. * @param mesh defines the target mesh
  134426. * @param scaleLines defines a scaling factor for line length (1 by default)
  134427. */
  134428. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  134429. /**
  134430. * Force the viewer to update
  134431. */
  134432. update(): void;
  134433. /** Releases resources */
  134434. dispose(): void;
  134435. }
  134436. }
  134437. declare module BABYLON {
  134438. /**
  134439. * Interface used to define scene explorer extensibility option
  134440. */
  134441. export interface IExplorerExtensibilityOption {
  134442. /**
  134443. * Define the option label
  134444. */
  134445. label: string;
  134446. /**
  134447. * Defines the action to execute on click
  134448. */
  134449. action: (entity: any) => void;
  134450. }
  134451. /**
  134452. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  134453. */
  134454. export interface IExplorerExtensibilityGroup {
  134455. /**
  134456. * Defines a predicate to test if a given type mut be extended
  134457. */
  134458. predicate: (entity: any) => boolean;
  134459. /**
  134460. * Gets the list of options added to a type
  134461. */
  134462. entries: IExplorerExtensibilityOption[];
  134463. }
  134464. /**
  134465. * Interface used to define the options to use to create the Inspector
  134466. */
  134467. export interface IInspectorOptions {
  134468. /**
  134469. * Display in overlay mode (default: false)
  134470. */
  134471. overlay?: boolean;
  134472. /**
  134473. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  134474. */
  134475. globalRoot?: HTMLElement;
  134476. /**
  134477. * Display the Scene explorer
  134478. */
  134479. showExplorer?: boolean;
  134480. /**
  134481. * Display the property inspector
  134482. */
  134483. showInspector?: boolean;
  134484. /**
  134485. * Display in embed mode (both panes on the right)
  134486. */
  134487. embedMode?: boolean;
  134488. /**
  134489. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  134490. */
  134491. handleResize?: boolean;
  134492. /**
  134493. * Allow the panes to popup (default: true)
  134494. */
  134495. enablePopup?: boolean;
  134496. /**
  134497. * Allow the panes to be closed by users (default: true)
  134498. */
  134499. enableClose?: boolean;
  134500. /**
  134501. * Optional list of extensibility entries
  134502. */
  134503. explorerExtensibility?: IExplorerExtensibilityGroup[];
  134504. /**
  134505. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  134506. */
  134507. inspectorURL?: string;
  134508. /**
  134509. * Optional initial tab (default to DebugLayerTab.Properties)
  134510. */
  134511. initialTab?: DebugLayerTab;
  134512. }
  134513. interface Scene {
  134514. /**
  134515. * @hidden
  134516. * Backing field
  134517. */
  134518. _debugLayer: DebugLayer;
  134519. /**
  134520. * Gets the debug layer (aka Inspector) associated with the scene
  134521. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134522. */
  134523. debugLayer: DebugLayer;
  134524. }
  134525. /**
  134526. * Enum of inspector action tab
  134527. */
  134528. export enum DebugLayerTab {
  134529. /**
  134530. * Properties tag (default)
  134531. */
  134532. Properties = 0,
  134533. /**
  134534. * Debug tab
  134535. */
  134536. Debug = 1,
  134537. /**
  134538. * Statistics tab
  134539. */
  134540. Statistics = 2,
  134541. /**
  134542. * Tools tab
  134543. */
  134544. Tools = 3,
  134545. /**
  134546. * Settings tab
  134547. */
  134548. Settings = 4
  134549. }
  134550. /**
  134551. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134552. * what is happening in your scene
  134553. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134554. */
  134555. export class DebugLayer {
  134556. /**
  134557. * Define the url to get the inspector script from.
  134558. * By default it uses the babylonjs CDN.
  134559. * @ignoreNaming
  134560. */
  134561. static InspectorURL: string;
  134562. private _scene;
  134563. private BJSINSPECTOR;
  134564. private _onPropertyChangedObservable?;
  134565. /**
  134566. * Observable triggered when a property is changed through the inspector.
  134567. */
  134568. get onPropertyChangedObservable(): any;
  134569. /**
  134570. * Instantiates a new debug layer.
  134571. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134572. * what is happening in your scene
  134573. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134574. * @param scene Defines the scene to inspect
  134575. */
  134576. constructor(scene: Scene);
  134577. /** Creates the inspector window. */
  134578. private _createInspector;
  134579. /**
  134580. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  134581. * @param entity defines the entity to select
  134582. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  134583. */
  134584. select(entity: any, lineContainerTitles?: string | string[]): void;
  134585. /** Get the inspector from bundle or global */
  134586. private _getGlobalInspector;
  134587. /**
  134588. * Get if the inspector is visible or not.
  134589. * @returns true if visible otherwise, false
  134590. */
  134591. isVisible(): boolean;
  134592. /**
  134593. * Hide the inspector and close its window.
  134594. */
  134595. hide(): void;
  134596. /**
  134597. * Update the scene in the inspector
  134598. */
  134599. setAsActiveScene(): void;
  134600. /**
  134601. * Launch the debugLayer.
  134602. * @param config Define the configuration of the inspector
  134603. * @return a promise fulfilled when the debug layer is visible
  134604. */
  134605. show(config?: IInspectorOptions): Promise<DebugLayer>;
  134606. }
  134607. }
  134608. declare module BABYLON {
  134609. /**
  134610. * Class containing static functions to help procedurally build meshes
  134611. */
  134612. export class BoxBuilder {
  134613. /**
  134614. * Creates a box mesh
  134615. * * The parameter `size` sets the size (float) of each box side (default 1)
  134616. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134617. * * 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)
  134618. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134622. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134623. * @param name defines the name of the mesh
  134624. * @param options defines the options used to create the mesh
  134625. * @param scene defines the hosting scene
  134626. * @returns the box mesh
  134627. */
  134628. static CreateBox(name: string, options: {
  134629. size?: number;
  134630. width?: number;
  134631. height?: number;
  134632. depth?: number;
  134633. faceUV?: Vector4[];
  134634. faceColors?: Color4[];
  134635. sideOrientation?: number;
  134636. frontUVs?: Vector4;
  134637. backUVs?: Vector4;
  134638. wrap?: boolean;
  134639. topBaseAt?: number;
  134640. bottomBaseAt?: number;
  134641. updatable?: boolean;
  134642. }, scene?: Nullable<Scene>): Mesh;
  134643. }
  134644. }
  134645. declare module BABYLON.Debug {
  134646. /**
  134647. * Used to show the physics impostor around the specific mesh
  134648. */
  134649. export class PhysicsViewer {
  134650. /** @hidden */
  134651. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  134652. /** @hidden */
  134653. protected _meshes: Array<Nullable<AbstractMesh>>;
  134654. /** @hidden */
  134655. protected _scene: Nullable<Scene>;
  134656. /** @hidden */
  134657. protected _numMeshes: number;
  134658. /** @hidden */
  134659. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  134660. private _renderFunction;
  134661. private _utilityLayer;
  134662. private _debugBoxMesh;
  134663. private _debugSphereMesh;
  134664. private _debugCylinderMesh;
  134665. private _debugMaterial;
  134666. private _debugMeshMeshes;
  134667. /**
  134668. * Creates a new PhysicsViewer
  134669. * @param scene defines the hosting scene
  134670. */
  134671. constructor(scene: Scene);
  134672. /** @hidden */
  134673. protected _updateDebugMeshes(): void;
  134674. /**
  134675. * Renders a specified physic impostor
  134676. * @param impostor defines the impostor to render
  134677. * @param targetMesh defines the mesh represented by the impostor
  134678. * @returns the new debug mesh used to render the impostor
  134679. */
  134680. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  134681. /**
  134682. * Hides a specified physic impostor
  134683. * @param impostor defines the impostor to hide
  134684. */
  134685. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  134686. private _getDebugMaterial;
  134687. private _getDebugBoxMesh;
  134688. private _getDebugSphereMesh;
  134689. private _getDebugCylinderMesh;
  134690. private _getDebugMeshMesh;
  134691. private _getDebugMesh;
  134692. /** Releases all resources */
  134693. dispose(): void;
  134694. }
  134695. }
  134696. declare module BABYLON {
  134697. /**
  134698. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134699. * in order to better appreciate the issue one might have.
  134700. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134701. */
  134702. export class RayHelper {
  134703. /**
  134704. * Defines the ray we are currently tryin to visualize.
  134705. */
  134706. ray: Nullable<Ray>;
  134707. private _renderPoints;
  134708. private _renderLine;
  134709. private _renderFunction;
  134710. private _scene;
  134711. private _onAfterRenderObserver;
  134712. private _onAfterStepObserver;
  134713. private _attachedToMesh;
  134714. private _meshSpaceDirection;
  134715. private _meshSpaceOrigin;
  134716. /**
  134717. * Helper function to create a colored helper in a scene in one line.
  134718. * @param ray Defines the ray we are currently tryin to visualize
  134719. * @param scene Defines the scene the ray is used in
  134720. * @param color Defines the color we want to see the ray in
  134721. * @returns The newly created ray helper.
  134722. */
  134723. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  134724. /**
  134725. * Instantiate a new ray helper.
  134726. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134727. * in order to better appreciate the issue one might have.
  134728. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134729. * @param ray Defines the ray we are currently tryin to visualize
  134730. */
  134731. constructor(ray: Ray);
  134732. /**
  134733. * Shows the ray we are willing to debug.
  134734. * @param scene Defines the scene the ray needs to be rendered in
  134735. * @param color Defines the color the ray needs to be rendered in
  134736. */
  134737. show(scene: Scene, color?: Color3): void;
  134738. /**
  134739. * Hides the ray we are debugging.
  134740. */
  134741. hide(): void;
  134742. private _render;
  134743. /**
  134744. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  134745. * @param mesh Defines the mesh we want the helper attached to
  134746. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  134747. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  134748. * @param length Defines the length of the ray
  134749. */
  134750. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  134751. /**
  134752. * Detach the ray helper from the mesh it has previously been attached to.
  134753. */
  134754. detachFromMesh(): void;
  134755. private _updateToMesh;
  134756. /**
  134757. * Dispose the helper and release its associated resources.
  134758. */
  134759. dispose(): void;
  134760. }
  134761. }
  134762. declare module BABYLON {
  134763. /**
  134764. * Defines the options associated with the creation of a SkeletonViewer.
  134765. */
  134766. export interface ISkeletonViewerOptions {
  134767. /** Should the system pause animations before building the Viewer? */
  134768. pauseAnimations: boolean;
  134769. /** Should the system return the skeleton to rest before building? */
  134770. returnToRest: boolean;
  134771. /** public Display Mode of the Viewer */
  134772. displayMode: number;
  134773. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134774. displayOptions: ISkeletonViewerDisplayOptions;
  134775. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134776. computeBonesUsingShaders: boolean;
  134777. /** Flag ignore non weighted bones */
  134778. useAllBones: boolean;
  134779. }
  134780. /**
  134781. * Defines how to display the various bone meshes for the viewer.
  134782. */
  134783. export interface ISkeletonViewerDisplayOptions {
  134784. /** How far down to start tapering the bone spurs */
  134785. midStep?: number;
  134786. /** How big is the midStep? */
  134787. midStepFactor?: number;
  134788. /** Base for the Sphere Size */
  134789. sphereBaseSize?: number;
  134790. /** The ratio of the sphere to the longest bone in units */
  134791. sphereScaleUnit?: number;
  134792. /** Ratio for the Sphere Size */
  134793. sphereFactor?: number;
  134794. /** Whether a spur should attach its far end to the child bone position */
  134795. spurFollowsChild?: boolean;
  134796. /** Whether to show local axes or not */
  134797. showLocalAxes?: boolean;
  134798. /** Length of each local axis */
  134799. localAxesSize?: number;
  134800. }
  134801. /**
  134802. * Defines the constructor options for the BoneWeight Shader.
  134803. */
  134804. export interface IBoneWeightShaderOptions {
  134805. /** Skeleton to Map */
  134806. skeleton: Skeleton;
  134807. /** Colors for Uninfluenced bones */
  134808. colorBase?: Color3;
  134809. /** Colors for 0.0-0.25 Weight bones */
  134810. colorZero?: Color3;
  134811. /** Color for 0.25-0.5 Weight Influence */
  134812. colorQuarter?: Color3;
  134813. /** Color for 0.5-0.75 Weight Influence */
  134814. colorHalf?: Color3;
  134815. /** Color for 0.75-1 Weight Influence */
  134816. colorFull?: Color3;
  134817. /** Color for Zero Weight Influence */
  134818. targetBoneIndex?: number;
  134819. }
  134820. /**
  134821. * Simple structure of the gradient steps for the Color Map.
  134822. */
  134823. export interface ISkeletonMapShaderColorMapKnot {
  134824. /** Color of the Knot */
  134825. color: Color3;
  134826. /** Location of the Knot */
  134827. location: number;
  134828. }
  134829. /**
  134830. * Defines the constructor options for the SkeletonMap Shader.
  134831. */
  134832. export interface ISkeletonMapShaderOptions {
  134833. /** Skeleton to Map */
  134834. skeleton: Skeleton;
  134835. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  134836. colorMap?: ISkeletonMapShaderColorMapKnot[];
  134837. }
  134838. }
  134839. declare module BABYLON {
  134840. /**
  134841. * Class containing static functions to help procedurally build meshes
  134842. */
  134843. export class RibbonBuilder {
  134844. /**
  134845. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134846. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134847. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134848. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134849. * * 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
  134850. * * 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
  134851. * * 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
  134852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134854. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134855. * * 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
  134856. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134857. * * 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
  134858. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134860. * @param name defines the name of the mesh
  134861. * @param options defines the options used to create the mesh
  134862. * @param scene defines the hosting scene
  134863. * @returns the ribbon mesh
  134864. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134865. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134866. */
  134867. static CreateRibbon(name: string, options: {
  134868. pathArray: Vector3[][];
  134869. closeArray?: boolean;
  134870. closePath?: boolean;
  134871. offset?: number;
  134872. updatable?: boolean;
  134873. sideOrientation?: number;
  134874. frontUVs?: Vector4;
  134875. backUVs?: Vector4;
  134876. instance?: Mesh;
  134877. invertUV?: boolean;
  134878. uvs?: Vector2[];
  134879. colors?: Color4[];
  134880. }, scene?: Nullable<Scene>): Mesh;
  134881. }
  134882. }
  134883. declare module BABYLON {
  134884. /**
  134885. * Class containing static functions to help procedurally build meshes
  134886. */
  134887. export class ShapeBuilder {
  134888. /**
  134889. * 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.
  134890. * * 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.
  134891. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134892. * * 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.
  134893. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134894. * * 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
  134895. * * 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
  134896. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134899. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134901. * @param name defines the name of the mesh
  134902. * @param options defines the options used to create the mesh
  134903. * @param scene defines the hosting scene
  134904. * @returns the extruded shape mesh
  134905. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134907. */
  134908. static ExtrudeShape(name: string, options: {
  134909. shape: Vector3[];
  134910. path: Vector3[];
  134911. scale?: number;
  134912. rotation?: number;
  134913. cap?: number;
  134914. updatable?: boolean;
  134915. sideOrientation?: number;
  134916. frontUVs?: Vector4;
  134917. backUVs?: Vector4;
  134918. instance?: Mesh;
  134919. invertUV?: boolean;
  134920. }, scene?: Nullable<Scene>): Mesh;
  134921. /**
  134922. * Creates an custom extruded shape mesh.
  134923. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134924. * * 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.
  134925. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134926. * * 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
  134927. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134928. * * 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
  134929. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134930. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134931. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134932. * * 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
  134933. * * 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
  134934. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134939. * @param name defines the name of the mesh
  134940. * @param options defines the options used to create the mesh
  134941. * @param scene defines the hosting scene
  134942. * @returns the custom extruded shape mesh
  134943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134944. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134946. */
  134947. static ExtrudeShapeCustom(name: string, options: {
  134948. shape: Vector3[];
  134949. path: Vector3[];
  134950. scaleFunction?: any;
  134951. rotationFunction?: any;
  134952. ribbonCloseArray?: boolean;
  134953. ribbonClosePath?: boolean;
  134954. cap?: number;
  134955. updatable?: boolean;
  134956. sideOrientation?: number;
  134957. frontUVs?: Vector4;
  134958. backUVs?: Vector4;
  134959. instance?: Mesh;
  134960. invertUV?: boolean;
  134961. }, scene?: Nullable<Scene>): Mesh;
  134962. private static _ExtrudeShapeGeneric;
  134963. }
  134964. }
  134965. declare module BABYLON.Debug {
  134966. /**
  134967. * Class used to render a debug view of a given skeleton
  134968. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  134969. */
  134970. export class SkeletonViewer {
  134971. /** defines the skeleton to render */
  134972. skeleton: Skeleton;
  134973. /** defines the mesh attached to the skeleton */
  134974. mesh: AbstractMesh;
  134975. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  134976. autoUpdateBonesMatrices: boolean;
  134977. /** defines the rendering group id to use with the viewer */
  134978. renderingGroupId: number;
  134979. /** is the options for the viewer */
  134980. options: Partial<ISkeletonViewerOptions>;
  134981. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  134982. static readonly DISPLAY_LINES: number;
  134983. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  134984. static readonly DISPLAY_SPHERES: number;
  134985. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  134986. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  134987. /** public static method to create a BoneWeight Shader
  134988. * @param options The constructor options
  134989. * @param scene The scene that the shader is scoped to
  134990. * @returns The created ShaderMaterial
  134991. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  134992. */
  134993. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  134994. /** public static method to create a BoneWeight Shader
  134995. * @param options The constructor options
  134996. * @param scene The scene that the shader is scoped to
  134997. * @returns The created ShaderMaterial
  134998. */
  134999. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  135000. /** private static method to create a BoneWeight Shader
  135001. * @param size The size of the buffer to create (usually the bone count)
  135002. * @param colorMap The gradient data to generate
  135003. * @param scene The scene that the shader is scoped to
  135004. * @returns an Array of floats from the color gradient values
  135005. */
  135006. private static _CreateBoneMapColorBuffer;
  135007. /** If SkeletonViewer scene scope. */
  135008. private _scene;
  135009. /** Gets or sets the color used to render the skeleton */
  135010. color: Color3;
  135011. /** Array of the points of the skeleton fo the line view. */
  135012. private _debugLines;
  135013. /** The SkeletonViewers Mesh. */
  135014. private _debugMesh;
  135015. /** The local axes Meshes. */
  135016. private _localAxes;
  135017. /** If SkeletonViewer is enabled. */
  135018. private _isEnabled;
  135019. /** If SkeletonViewer is ready. */
  135020. private _ready;
  135021. /** SkeletonViewer render observable. */
  135022. private _obs;
  135023. /** The Utility Layer to render the gizmos in. */
  135024. private _utilityLayer;
  135025. private _boneIndices;
  135026. /** Gets the Scene. */
  135027. get scene(): Scene;
  135028. /** Gets the utilityLayer. */
  135029. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  135030. /** Checks Ready Status. */
  135031. get isReady(): Boolean;
  135032. /** Sets Ready Status. */
  135033. set ready(value: boolean);
  135034. /** Gets the debugMesh */
  135035. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  135036. /** Sets the debugMesh */
  135037. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  135038. /** Gets the displayMode */
  135039. get displayMode(): number;
  135040. /** Sets the displayMode */
  135041. set displayMode(value: number);
  135042. /**
  135043. * Creates a new SkeletonViewer
  135044. * @param skeleton defines the skeleton to render
  135045. * @param mesh defines the mesh attached to the skeleton
  135046. * @param scene defines the hosting scene
  135047. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  135048. * @param renderingGroupId defines the rendering group id to use with the viewer
  135049. * @param options All of the extra constructor options for the SkeletonViewer
  135050. */
  135051. constructor(
  135052. /** defines the skeleton to render */
  135053. skeleton: Skeleton,
  135054. /** defines the mesh attached to the skeleton */
  135055. mesh: AbstractMesh,
  135056. /** The Scene scope*/
  135057. scene: Scene,
  135058. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135059. autoUpdateBonesMatrices?: boolean,
  135060. /** defines the rendering group id to use with the viewer */
  135061. renderingGroupId?: number,
  135062. /** is the options for the viewer */
  135063. options?: Partial<ISkeletonViewerOptions>);
  135064. /** The Dynamic bindings for the update functions */
  135065. private _bindObs;
  135066. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  135067. update(): void;
  135068. /** Gets or sets a boolean indicating if the viewer is enabled */
  135069. set isEnabled(value: boolean);
  135070. get isEnabled(): boolean;
  135071. private _getBonePosition;
  135072. private _getLinesForBonesWithLength;
  135073. private _getLinesForBonesNoLength;
  135074. /** function to revert the mesh and scene back to the initial state. */
  135075. private _revert;
  135076. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  135077. private _getAbsoluteBindPoseToRef;
  135078. /** function to build and bind sphere joint points and spur bone representations. */
  135079. private _buildSpheresAndSpurs;
  135080. private _buildLocalAxes;
  135081. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  135082. private _displayLinesUpdate;
  135083. /** Changes the displayMode of the skeleton viewer
  135084. * @param mode The displayMode numerical value
  135085. */
  135086. changeDisplayMode(mode: number): void;
  135087. /** Sets a display option of the skeleton viewer
  135088. *
  135089. * | Option | Type | Default | Description |
  135090. * | ---------------- | ------- | ------- | ----------- |
  135091. * | 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`. |
  135092. * | 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`. |
  135093. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135094. * | 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`. |
  135095. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  135096. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  135097. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  135098. *
  135099. * @param option String of the option name
  135100. * @param value The numerical option value
  135101. */
  135102. changeDisplayOptions(option: string, value: number): void;
  135103. /** Release associated resources */
  135104. dispose(): void;
  135105. }
  135106. }
  135107. declare module BABYLON {
  135108. /**
  135109. * Enum for Device Types
  135110. */
  135111. export enum DeviceType {
  135112. /** Generic */
  135113. Generic = 0,
  135114. /** Keyboard */
  135115. Keyboard = 1,
  135116. /** Mouse */
  135117. Mouse = 2,
  135118. /** Touch Pointers */
  135119. Touch = 3,
  135120. /** PS4 Dual Shock */
  135121. DualShock = 4,
  135122. /** Xbox */
  135123. Xbox = 5,
  135124. /** Switch Controller */
  135125. Switch = 6
  135126. }
  135127. /**
  135128. * Enum for All Pointers (Touch/Mouse)
  135129. */
  135130. export enum PointerInput {
  135131. /** Horizontal Axis */
  135132. Horizontal = 0,
  135133. /** Vertical Axis */
  135134. Vertical = 1,
  135135. /** Left Click or Touch */
  135136. LeftClick = 2,
  135137. /** Middle Click */
  135138. MiddleClick = 3,
  135139. /** Right Click */
  135140. RightClick = 4,
  135141. /** Browser Back */
  135142. BrowserBack = 5,
  135143. /** Browser Forward */
  135144. BrowserForward = 6
  135145. }
  135146. /**
  135147. * Enum for Dual Shock Gamepad
  135148. */
  135149. export enum DualShockInput {
  135150. /** Cross */
  135151. Cross = 0,
  135152. /** Circle */
  135153. Circle = 1,
  135154. /** Square */
  135155. Square = 2,
  135156. /** Triangle */
  135157. Triangle = 3,
  135158. /** L1 */
  135159. L1 = 4,
  135160. /** R1 */
  135161. R1 = 5,
  135162. /** L2 */
  135163. L2 = 6,
  135164. /** R2 */
  135165. R2 = 7,
  135166. /** Share */
  135167. Share = 8,
  135168. /** Options */
  135169. Options = 9,
  135170. /** L3 */
  135171. L3 = 10,
  135172. /** R3 */
  135173. R3 = 11,
  135174. /** DPadUp */
  135175. DPadUp = 12,
  135176. /** DPadDown */
  135177. DPadDown = 13,
  135178. /** DPadLeft */
  135179. DPadLeft = 14,
  135180. /** DRight */
  135181. DPadRight = 15,
  135182. /** Home */
  135183. Home = 16,
  135184. /** TouchPad */
  135185. TouchPad = 17,
  135186. /** LStickXAxis */
  135187. LStickXAxis = 18,
  135188. /** LStickYAxis */
  135189. LStickYAxis = 19,
  135190. /** RStickXAxis */
  135191. RStickXAxis = 20,
  135192. /** RStickYAxis */
  135193. RStickYAxis = 21
  135194. }
  135195. /**
  135196. * Enum for Xbox Gamepad
  135197. */
  135198. export enum XboxInput {
  135199. /** A */
  135200. A = 0,
  135201. /** B */
  135202. B = 1,
  135203. /** X */
  135204. X = 2,
  135205. /** Y */
  135206. Y = 3,
  135207. /** LB */
  135208. LB = 4,
  135209. /** RB */
  135210. RB = 5,
  135211. /** LT */
  135212. LT = 6,
  135213. /** RT */
  135214. RT = 7,
  135215. /** Back */
  135216. Back = 8,
  135217. /** Start */
  135218. Start = 9,
  135219. /** LS */
  135220. LS = 10,
  135221. /** RS */
  135222. RS = 11,
  135223. /** DPadUp */
  135224. DPadUp = 12,
  135225. /** DPadDown */
  135226. DPadDown = 13,
  135227. /** DPadLeft */
  135228. DPadLeft = 14,
  135229. /** DRight */
  135230. DPadRight = 15,
  135231. /** Home */
  135232. Home = 16,
  135233. /** LStickXAxis */
  135234. LStickXAxis = 17,
  135235. /** LStickYAxis */
  135236. LStickYAxis = 18,
  135237. /** RStickXAxis */
  135238. RStickXAxis = 19,
  135239. /** RStickYAxis */
  135240. RStickYAxis = 20
  135241. }
  135242. /**
  135243. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  135244. */
  135245. export enum SwitchInput {
  135246. /** B */
  135247. B = 0,
  135248. /** A */
  135249. A = 1,
  135250. /** Y */
  135251. Y = 2,
  135252. /** X */
  135253. X = 3,
  135254. /** L */
  135255. L = 4,
  135256. /** R */
  135257. R = 5,
  135258. /** ZL */
  135259. ZL = 6,
  135260. /** ZR */
  135261. ZR = 7,
  135262. /** Minus */
  135263. Minus = 8,
  135264. /** Plus */
  135265. Plus = 9,
  135266. /** LS */
  135267. LS = 10,
  135268. /** RS */
  135269. RS = 11,
  135270. /** DPadUp */
  135271. DPadUp = 12,
  135272. /** DPadDown */
  135273. DPadDown = 13,
  135274. /** DPadLeft */
  135275. DPadLeft = 14,
  135276. /** DRight */
  135277. DPadRight = 15,
  135278. /** Home */
  135279. Home = 16,
  135280. /** Capture */
  135281. Capture = 17,
  135282. /** LStickXAxis */
  135283. LStickXAxis = 18,
  135284. /** LStickYAxis */
  135285. LStickYAxis = 19,
  135286. /** RStickXAxis */
  135287. RStickXAxis = 20,
  135288. /** RStickYAxis */
  135289. RStickYAxis = 21
  135290. }
  135291. }
  135292. declare module BABYLON {
  135293. /**
  135294. * This class will take all inputs from Keyboard, Pointer, and
  135295. * any Gamepads and provide a polling system that all devices
  135296. * will use. This class assumes that there will only be one
  135297. * pointer device and one keyboard.
  135298. */
  135299. export class DeviceInputSystem implements IDisposable {
  135300. /**
  135301. * Callback to be triggered when a device is connected
  135302. */
  135303. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135304. /**
  135305. * Callback to be triggered when a device is disconnected
  135306. */
  135307. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135308. /**
  135309. * Callback to be triggered when event driven input is updated
  135310. */
  135311. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  135312. private _inputs;
  135313. private _gamepads;
  135314. private _keyboardActive;
  135315. private _pointerActive;
  135316. private _elementToAttachTo;
  135317. private _keyboardDownEvent;
  135318. private _keyboardUpEvent;
  135319. private _pointerMoveEvent;
  135320. private _pointerDownEvent;
  135321. private _pointerUpEvent;
  135322. private _gamepadConnectedEvent;
  135323. private _gamepadDisconnectedEvent;
  135324. private static _MAX_KEYCODES;
  135325. private static _MAX_POINTER_INPUTS;
  135326. private constructor();
  135327. /**
  135328. * Creates a new DeviceInputSystem instance
  135329. * @param engine Engine to pull input element from
  135330. * @returns The new instance
  135331. */
  135332. static Create(engine: Engine): DeviceInputSystem;
  135333. /**
  135334. * Checks for current device input value, given an id and input index
  135335. * @param deviceName Id of connected device
  135336. * @param inputIndex Index of device input
  135337. * @returns Current value of input
  135338. */
  135339. /**
  135340. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  135341. * @param deviceType Enum specifiying device type
  135342. * @param deviceSlot "Slot" or index that device is referenced in
  135343. * @param inputIndex Id of input to be checked
  135344. * @returns Current value of input
  135345. */
  135346. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  135347. /**
  135348. * Dispose of all the eventlisteners
  135349. */
  135350. dispose(): void;
  135351. /**
  135352. * Add device and inputs to device array
  135353. * @param deviceType Enum specifiying device type
  135354. * @param deviceSlot "Slot" or index that device is referenced in
  135355. * @param numberOfInputs Number of input entries to create for given device
  135356. */
  135357. private _registerDevice;
  135358. /**
  135359. * Given a specific device name, remove that device from the device map
  135360. * @param deviceType Enum specifiying device type
  135361. * @param deviceSlot "Slot" or index that device is referenced in
  135362. */
  135363. private _unregisterDevice;
  135364. /**
  135365. * Handle all actions that come from keyboard interaction
  135366. */
  135367. private _handleKeyActions;
  135368. /**
  135369. * Handle all actions that come from pointer interaction
  135370. */
  135371. private _handlePointerActions;
  135372. /**
  135373. * Handle all actions that come from gamepad interaction
  135374. */
  135375. private _handleGamepadActions;
  135376. /**
  135377. * Update all non-event based devices with each frame
  135378. * @param deviceType Enum specifiying device type
  135379. * @param deviceSlot "Slot" or index that device is referenced in
  135380. * @param inputIndex Id of input to be checked
  135381. */
  135382. private _updateDevice;
  135383. /**
  135384. * Gets DeviceType from the device name
  135385. * @param deviceName Name of Device from DeviceInputSystem
  135386. * @returns DeviceType enum value
  135387. */
  135388. private _getGamepadDeviceType;
  135389. }
  135390. }
  135391. declare module BABYLON {
  135392. /**
  135393. * Type to handle enforcement of inputs
  135394. */
  135395. 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;
  135396. }
  135397. declare module BABYLON {
  135398. /**
  135399. * Class that handles all input for a specific device
  135400. */
  135401. export class DeviceSource<T extends DeviceType> {
  135402. /** Type of device */
  135403. readonly deviceType: DeviceType;
  135404. /** "Slot" or index that device is referenced in */
  135405. readonly deviceSlot: number;
  135406. /**
  135407. * Observable to handle device input changes per device
  135408. */
  135409. readonly onInputChangedObservable: Observable<{
  135410. inputIndex: DeviceInput<T>;
  135411. previousState: Nullable<number>;
  135412. currentState: Nullable<number>;
  135413. }>;
  135414. private readonly _deviceInputSystem;
  135415. /**
  135416. * Default Constructor
  135417. * @param deviceInputSystem Reference to DeviceInputSystem
  135418. * @param deviceType Type of device
  135419. * @param deviceSlot "Slot" or index that device is referenced in
  135420. */
  135421. constructor(deviceInputSystem: DeviceInputSystem,
  135422. /** Type of device */
  135423. deviceType: DeviceType,
  135424. /** "Slot" or index that device is referenced in */
  135425. deviceSlot?: number);
  135426. /**
  135427. * Get input for specific input
  135428. * @param inputIndex index of specific input on device
  135429. * @returns Input value from DeviceInputSystem
  135430. */
  135431. getInput(inputIndex: DeviceInput<T>): number;
  135432. }
  135433. /**
  135434. * Class to keep track of devices
  135435. */
  135436. export class DeviceSourceManager implements IDisposable {
  135437. /**
  135438. * Observable to be triggered when before a device is connected
  135439. */
  135440. readonly onBeforeDeviceConnectedObservable: Observable<{
  135441. deviceType: DeviceType;
  135442. deviceSlot: number;
  135443. }>;
  135444. /**
  135445. * Observable to be triggered when before a device is disconnected
  135446. */
  135447. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  135448. deviceType: DeviceType;
  135449. deviceSlot: number;
  135450. }>;
  135451. /**
  135452. * Observable to be triggered when after a device is connected
  135453. */
  135454. readonly onAfterDeviceConnectedObservable: Observable<{
  135455. deviceType: DeviceType;
  135456. deviceSlot: number;
  135457. }>;
  135458. /**
  135459. * Observable to be triggered when after a device is disconnected
  135460. */
  135461. readonly onAfterDeviceDisconnectedObservable: Observable<{
  135462. deviceType: DeviceType;
  135463. deviceSlot: number;
  135464. }>;
  135465. private readonly _devices;
  135466. private readonly _firstDevice;
  135467. private readonly _deviceInputSystem;
  135468. /**
  135469. * Default Constructor
  135470. * @param engine engine to pull input element from
  135471. */
  135472. constructor(engine: Engine);
  135473. /**
  135474. * Gets a DeviceSource, given a type and slot
  135475. * @param deviceType Enum specifying device type
  135476. * @param deviceSlot "Slot" or index that device is referenced in
  135477. * @returns DeviceSource object
  135478. */
  135479. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  135480. /**
  135481. * Gets an array of DeviceSource objects for a given device type
  135482. * @param deviceType Enum specifying device type
  135483. * @returns Array of DeviceSource objects
  135484. */
  135485. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  135486. /**
  135487. * Dispose of DeviceInputSystem and other parts
  135488. */
  135489. dispose(): void;
  135490. /**
  135491. * Function to add device name to device list
  135492. * @param deviceType Enum specifying device type
  135493. * @param deviceSlot "Slot" or index that device is referenced in
  135494. */
  135495. private _addDevice;
  135496. /**
  135497. * Function to remove device name to device list
  135498. * @param deviceType Enum specifying device type
  135499. * @param deviceSlot "Slot" or index that device is referenced in
  135500. */
  135501. private _removeDevice;
  135502. /**
  135503. * Updates array storing first connected device of each type
  135504. * @param type Type of Device
  135505. */
  135506. private _updateFirstDevices;
  135507. }
  135508. }
  135509. declare module BABYLON {
  135510. /**
  135511. * Options to create the null engine
  135512. */
  135513. export class NullEngineOptions {
  135514. /**
  135515. * Render width (Default: 512)
  135516. */
  135517. renderWidth: number;
  135518. /**
  135519. * Render height (Default: 256)
  135520. */
  135521. renderHeight: number;
  135522. /**
  135523. * Texture size (Default: 512)
  135524. */
  135525. textureSize: number;
  135526. /**
  135527. * If delta time between frames should be constant
  135528. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135529. */
  135530. deterministicLockstep: boolean;
  135531. /**
  135532. * Maximum about of steps between frames (Default: 4)
  135533. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135534. */
  135535. lockstepMaxSteps: number;
  135536. /**
  135537. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  135538. */
  135539. useHighPrecisionMatrix?: boolean;
  135540. }
  135541. /**
  135542. * The null engine class provides support for headless version of babylon.js.
  135543. * This can be used in server side scenario or for testing purposes
  135544. */
  135545. export class NullEngine extends Engine {
  135546. private _options;
  135547. /**
  135548. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  135549. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135550. * @returns true if engine is in deterministic lock step mode
  135551. */
  135552. isDeterministicLockStep(): boolean;
  135553. /**
  135554. * Gets the max steps when engine is running in deterministic lock step
  135555. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135556. * @returns the max steps
  135557. */
  135558. getLockstepMaxSteps(): number;
  135559. /**
  135560. * Gets the current hardware scaling level.
  135561. * By default the hardware scaling level is computed from the window device ratio.
  135562. * 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.
  135563. * @returns a number indicating the current hardware scaling level
  135564. */
  135565. getHardwareScalingLevel(): number;
  135566. constructor(options?: NullEngineOptions);
  135567. /**
  135568. * Creates a vertex buffer
  135569. * @param vertices the data for the vertex buffer
  135570. * @returns the new WebGL static buffer
  135571. */
  135572. createVertexBuffer(vertices: FloatArray): DataBuffer;
  135573. /**
  135574. * Creates a new index buffer
  135575. * @param indices defines the content of the index buffer
  135576. * @param updatable defines if the index buffer must be updatable
  135577. * @returns a new webGL buffer
  135578. */
  135579. createIndexBuffer(indices: IndicesArray): DataBuffer;
  135580. /**
  135581. * Clear the current render buffer or the current render target (if any is set up)
  135582. * @param color defines the color to use
  135583. * @param backBuffer defines if the back buffer must be cleared
  135584. * @param depth defines if the depth buffer must be cleared
  135585. * @param stencil defines if the stencil buffer must be cleared
  135586. */
  135587. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  135588. /**
  135589. * Gets the current render width
  135590. * @param useScreen defines if screen size must be used (or the current render target if any)
  135591. * @returns a number defining the current render width
  135592. */
  135593. getRenderWidth(useScreen?: boolean): number;
  135594. /**
  135595. * Gets the current render height
  135596. * @param useScreen defines if screen size must be used (or the current render target if any)
  135597. * @returns a number defining the current render height
  135598. */
  135599. getRenderHeight(useScreen?: boolean): number;
  135600. /**
  135601. * Set the WebGL's viewport
  135602. * @param viewport defines the viewport element to be used
  135603. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  135604. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  135605. */
  135606. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  135607. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  135608. /**
  135609. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  135610. * @param pipelineContext defines the pipeline context to use
  135611. * @param uniformsNames defines the list of uniform names
  135612. * @returns an array of webGL uniform locations
  135613. */
  135614. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  135615. /**
  135616. * Gets the lsit of active attributes for a given webGL program
  135617. * @param pipelineContext defines the pipeline context to use
  135618. * @param attributesNames defines the list of attribute names to get
  135619. * @returns an array of indices indicating the offset of each attribute
  135620. */
  135621. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  135622. /**
  135623. * Binds an effect to the webGL context
  135624. * @param effect defines the effect to bind
  135625. */
  135626. bindSamplers(effect: Effect): void;
  135627. /**
  135628. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  135629. * @param effect defines the effect to activate
  135630. */
  135631. enableEffect(effect: Effect): void;
  135632. /**
  135633. * Set various states to the webGL context
  135634. * @param culling defines backface culling state
  135635. * @param zOffset defines the value to apply to zOffset (0 by default)
  135636. * @param force defines if states must be applied even if cache is up to date
  135637. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  135638. */
  135639. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  135640. /**
  135641. * Set the value of an uniform to an array of int32
  135642. * @param uniform defines the webGL uniform location where to store the value
  135643. * @param array defines the array of int32 to store
  135644. * @returns true if value was set
  135645. */
  135646. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135647. /**
  135648. * Set the value of an uniform to an array of int32 (stored as vec2)
  135649. * @param uniform defines the webGL uniform location where to store the value
  135650. * @param array defines the array of int32 to store
  135651. * @returns true if value was set
  135652. */
  135653. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135654. /**
  135655. * Set the value of an uniform to an array of int32 (stored as vec3)
  135656. * @param uniform defines the webGL uniform location where to store the value
  135657. * @param array defines the array of int32 to store
  135658. * @returns true if value was set
  135659. */
  135660. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135661. /**
  135662. * Set the value of an uniform to an array of int32 (stored as vec4)
  135663. * @param uniform defines the webGL uniform location where to store the value
  135664. * @param array defines the array of int32 to store
  135665. * @returns true if value was set
  135666. */
  135667. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135668. /**
  135669. * Set the value of an uniform to an array of float32
  135670. * @param uniform defines the webGL uniform location where to store the value
  135671. * @param array defines the array of float32 to store
  135672. * @returns true if value was set
  135673. */
  135674. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135675. /**
  135676. * Set the value of an uniform to an array of float32 (stored as vec2)
  135677. * @param uniform defines the webGL uniform location where to store the value
  135678. * @param array defines the array of float32 to store
  135679. * @returns true if value was set
  135680. */
  135681. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135682. /**
  135683. * Set the value of an uniform to an array of float32 (stored as vec3)
  135684. * @param uniform defines the webGL uniform location where to store the value
  135685. * @param array defines the array of float32 to store
  135686. * @returns true if value was set
  135687. */
  135688. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135689. /**
  135690. * Set the value of an uniform to an array of float32 (stored as vec4)
  135691. * @param uniform defines the webGL uniform location where to store the value
  135692. * @param array defines the array of float32 to store
  135693. * @returns true if value was set
  135694. */
  135695. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135696. /**
  135697. * Set the value of an uniform to an array of number
  135698. * @param uniform defines the webGL uniform location where to store the value
  135699. * @param array defines the array of number to store
  135700. * @returns true if value was set
  135701. */
  135702. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  135703. /**
  135704. * Set the value of an uniform to an array of number (stored as vec2)
  135705. * @param uniform defines the webGL uniform location where to store the value
  135706. * @param array defines the array of number to store
  135707. * @returns true if value was set
  135708. */
  135709. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  135710. /**
  135711. * Set the value of an uniform to an array of number (stored as vec3)
  135712. * @param uniform defines the webGL uniform location where to store the value
  135713. * @param array defines the array of number to store
  135714. * @returns true if value was set
  135715. */
  135716. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  135717. /**
  135718. * Set the value of an uniform to an array of number (stored as vec4)
  135719. * @param uniform defines the webGL uniform location where to store the value
  135720. * @param array defines the array of number to store
  135721. * @returns true if value was set
  135722. */
  135723. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  135724. /**
  135725. * Set the value of an uniform to an array of float32 (stored as matrices)
  135726. * @param uniform defines the webGL uniform location where to store the value
  135727. * @param matrices defines the array of float32 to store
  135728. * @returns true if value was set
  135729. */
  135730. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  135731. /**
  135732. * Set the value of an uniform to a matrix (3x3)
  135733. * @param uniform defines the webGL uniform location where to store the value
  135734. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  135735. * @returns true if value was set
  135736. */
  135737. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135738. /**
  135739. * Set the value of an uniform to a matrix (2x2)
  135740. * @param uniform defines the webGL uniform location where to store the value
  135741. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  135742. * @returns true if value was set
  135743. */
  135744. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135745. /**
  135746. * Set the value of an uniform to a number (float)
  135747. * @param uniform defines the webGL uniform location where to store the value
  135748. * @param value defines the float number to store
  135749. * @returns true if value was set
  135750. */
  135751. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  135752. /**
  135753. * Set the value of an uniform to a vec2
  135754. * @param uniform defines the webGL uniform location where to store the value
  135755. * @param x defines the 1st component of the value
  135756. * @param y defines the 2nd component of the value
  135757. * @returns true if value was set
  135758. */
  135759. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  135760. /**
  135761. * Set the value of an uniform to a vec3
  135762. * @param uniform defines the webGL uniform location where to store the value
  135763. * @param x defines the 1st component of the value
  135764. * @param y defines the 2nd component of the value
  135765. * @param z defines the 3rd component of the value
  135766. * @returns true if value was set
  135767. */
  135768. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  135769. /**
  135770. * Set the value of an uniform to a boolean
  135771. * @param uniform defines the webGL uniform location where to store the value
  135772. * @param bool defines the boolean to store
  135773. * @returns true if value was set
  135774. */
  135775. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  135776. /**
  135777. * Set the value of an uniform to a vec4
  135778. * @param uniform defines the webGL uniform location where to store the value
  135779. * @param x defines the 1st component of the value
  135780. * @param y defines the 2nd component of the value
  135781. * @param z defines the 3rd component of the value
  135782. * @param w defines the 4th component of the value
  135783. * @returns true if value was set
  135784. */
  135785. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  135786. /**
  135787. * Sets the current alpha mode
  135788. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  135789. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  135790. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  135791. */
  135792. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  135793. /**
  135794. * Bind webGl buffers directly to the webGL context
  135795. * @param vertexBuffers defines the vertex buffer to bind
  135796. * @param indexBuffer defines the index buffer to bind
  135797. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  135798. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  135799. * @param effect defines the effect associated with the vertex buffer
  135800. */
  135801. bindBuffers(vertexBuffers: {
  135802. [key: string]: VertexBuffer;
  135803. }, indexBuffer: DataBuffer, effect: Effect): void;
  135804. /**
  135805. * Force the entire cache to be cleared
  135806. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  135807. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  135808. */
  135809. wipeCaches(bruteForce?: boolean): void;
  135810. /**
  135811. * Send a draw order
  135812. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  135813. * @param indexStart defines the starting index
  135814. * @param indexCount defines the number of index to draw
  135815. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135816. */
  135817. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  135818. /**
  135819. * Draw a list of indexed primitives
  135820. * @param fillMode defines the primitive to use
  135821. * @param indexStart defines the starting index
  135822. * @param indexCount defines the number of index to draw
  135823. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135824. */
  135825. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  135826. /**
  135827. * Draw a list of unindexed primitives
  135828. * @param fillMode defines the primitive to use
  135829. * @param verticesStart defines the index of first vertex to draw
  135830. * @param verticesCount defines the count of vertices to draw
  135831. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135832. */
  135833. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  135834. /** @hidden */
  135835. _createTexture(): WebGLTexture;
  135836. /** @hidden */
  135837. _releaseTexture(texture: InternalTexture): void;
  135838. /**
  135839. * Usually called from Texture.ts.
  135840. * Passed information to create a WebGLTexture
  135841. * @param urlArg defines a value which contains one of the following:
  135842. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  135843. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  135844. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  135845. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  135846. * @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)
  135847. * @param scene needed for loading to the correct scene
  135848. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  135849. * @param onLoad optional callback to be called upon successful completion
  135850. * @param onError optional callback to be called upon failure
  135851. * @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
  135852. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  135853. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  135854. * @param forcedExtension defines the extension to use to pick the right loader
  135855. * @param mimeType defines an optional mime type
  135856. * @returns a InternalTexture for assignment back into BABYLON.Texture
  135857. */
  135858. 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;
  135859. /**
  135860. * Creates a new render target texture
  135861. * @param size defines the size of the texture
  135862. * @param options defines the options used to create the texture
  135863. * @returns a new render target texture stored in an InternalTexture
  135864. */
  135865. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  135866. /**
  135867. * Update the sampling mode of a given texture
  135868. * @param samplingMode defines the required sampling mode
  135869. * @param texture defines the texture to update
  135870. */
  135871. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  135872. /**
  135873. * Binds the frame buffer to the specified texture.
  135874. * @param texture The texture to render to or null for the default canvas
  135875. * @param faceIndex The face of the texture to render to in case of cube texture
  135876. * @param requiredWidth The width of the target to render to
  135877. * @param requiredHeight The height of the target to render to
  135878. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  135879. * @param lodLevel defines le lod level to bind to the frame buffer
  135880. */
  135881. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  135882. /**
  135883. * Unbind the current render target texture from the webGL context
  135884. * @param texture defines the render target texture to unbind
  135885. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  135886. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  135887. */
  135888. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  135889. /**
  135890. * Creates a dynamic vertex buffer
  135891. * @param vertices the data for the dynamic vertex buffer
  135892. * @returns the new WebGL dynamic buffer
  135893. */
  135894. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  135895. /**
  135896. * Update the content of a dynamic texture
  135897. * @param texture defines the texture to update
  135898. * @param canvas defines the canvas containing the source
  135899. * @param invertY defines if data must be stored with Y axis inverted
  135900. * @param premulAlpha defines if alpha is stored as premultiplied
  135901. * @param format defines the format of the data
  135902. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  135903. */
  135904. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  135905. /**
  135906. * Gets a boolean indicating if all created effects are ready
  135907. * @returns true if all effects are ready
  135908. */
  135909. areAllEffectsReady(): boolean;
  135910. /**
  135911. * @hidden
  135912. * Get the current error code of the webGL context
  135913. * @returns the error code
  135914. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  135915. */
  135916. getError(): number;
  135917. /** @hidden */
  135918. _getUnpackAlignement(): number;
  135919. /** @hidden */
  135920. _unpackFlipY(value: boolean): void;
  135921. /**
  135922. * Update a dynamic index buffer
  135923. * @param indexBuffer defines the target index buffer
  135924. * @param indices defines the data to update
  135925. * @param offset defines the offset in the target index buffer where update should start
  135926. */
  135927. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  135928. /**
  135929. * Updates a dynamic vertex buffer.
  135930. * @param vertexBuffer the vertex buffer to update
  135931. * @param vertices the data used to update the vertex buffer
  135932. * @param byteOffset the byte offset of the data (optional)
  135933. * @param byteLength the byte length of the data (optional)
  135934. */
  135935. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  135936. /** @hidden */
  135937. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  135938. /** @hidden */
  135939. _bindTexture(channel: number, texture: InternalTexture): void;
  135940. protected _deleteBuffer(buffer: WebGLBuffer): void;
  135941. /**
  135942. * 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
  135943. */
  135944. releaseEffects(): void;
  135945. displayLoadingUI(): void;
  135946. hideLoadingUI(): void;
  135947. /** @hidden */
  135948. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135949. /** @hidden */
  135950. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135951. /** @hidden */
  135952. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135953. /** @hidden */
  135954. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  135955. }
  135956. }
  135957. declare module BABYLON {
  135958. /**
  135959. * @hidden
  135960. **/
  135961. export class _TimeToken {
  135962. _startTimeQuery: Nullable<WebGLQuery>;
  135963. _endTimeQuery: Nullable<WebGLQuery>;
  135964. _timeElapsedQuery: Nullable<WebGLQuery>;
  135965. _timeElapsedQueryEnded: boolean;
  135966. }
  135967. }
  135968. declare module BABYLON {
  135969. /** @hidden */
  135970. export class _OcclusionDataStorage {
  135971. /** @hidden */
  135972. occlusionInternalRetryCounter: number;
  135973. /** @hidden */
  135974. isOcclusionQueryInProgress: boolean;
  135975. /** @hidden */
  135976. isOccluded: boolean;
  135977. /** @hidden */
  135978. occlusionRetryCount: number;
  135979. /** @hidden */
  135980. occlusionType: number;
  135981. /** @hidden */
  135982. occlusionQueryAlgorithmType: number;
  135983. }
  135984. interface Engine {
  135985. /**
  135986. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  135987. * @return the new query
  135988. */
  135989. createQuery(): WebGLQuery;
  135990. /**
  135991. * Delete and release a webGL query
  135992. * @param query defines the query to delete
  135993. * @return the current engine
  135994. */
  135995. deleteQuery(query: WebGLQuery): Engine;
  135996. /**
  135997. * Check if a given query has resolved and got its value
  135998. * @param query defines the query to check
  135999. * @returns true if the query got its value
  136000. */
  136001. isQueryResultAvailable(query: WebGLQuery): boolean;
  136002. /**
  136003. * Gets the value of a given query
  136004. * @param query defines the query to check
  136005. * @returns the value of the query
  136006. */
  136007. getQueryResult(query: WebGLQuery): number;
  136008. /**
  136009. * Initiates an occlusion query
  136010. * @param algorithmType defines the algorithm to use
  136011. * @param query defines the query to use
  136012. * @returns the current engine
  136013. * @see https://doc.babylonjs.com/features/occlusionquery
  136014. */
  136015. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  136016. /**
  136017. * Ends an occlusion query
  136018. * @see https://doc.babylonjs.com/features/occlusionquery
  136019. * @param algorithmType defines the algorithm to use
  136020. * @returns the current engine
  136021. */
  136022. endOcclusionQuery(algorithmType: number): Engine;
  136023. /**
  136024. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  136025. * Please note that only one query can be issued at a time
  136026. * @returns a time token used to track the time span
  136027. */
  136028. startTimeQuery(): Nullable<_TimeToken>;
  136029. /**
  136030. * Ends a time query
  136031. * @param token defines the token used to measure the time span
  136032. * @returns the time spent (in ns)
  136033. */
  136034. endTimeQuery(token: _TimeToken): int;
  136035. /** @hidden */
  136036. _currentNonTimestampToken: Nullable<_TimeToken>;
  136037. /** @hidden */
  136038. _createTimeQuery(): WebGLQuery;
  136039. /** @hidden */
  136040. _deleteTimeQuery(query: WebGLQuery): void;
  136041. /** @hidden */
  136042. _getGlAlgorithmType(algorithmType: number): number;
  136043. /** @hidden */
  136044. _getTimeQueryResult(query: WebGLQuery): any;
  136045. /** @hidden */
  136046. _getTimeQueryAvailability(query: WebGLQuery): any;
  136047. }
  136048. interface AbstractMesh {
  136049. /**
  136050. * Backing filed
  136051. * @hidden
  136052. */
  136053. __occlusionDataStorage: _OcclusionDataStorage;
  136054. /**
  136055. * Access property
  136056. * @hidden
  136057. */
  136058. _occlusionDataStorage: _OcclusionDataStorage;
  136059. /**
  136060. * 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.
  136061. * The default value is -1 which means don't break the query and wait till the result
  136062. * @see https://doc.babylonjs.com/features/occlusionquery
  136063. */
  136064. occlusionRetryCount: number;
  136065. /**
  136066. * 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:
  136067. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  136068. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  136069. * * 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.
  136070. * @see https://doc.babylonjs.com/features/occlusionquery
  136071. */
  136072. occlusionType: number;
  136073. /**
  136074. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  136075. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  136076. * * 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.
  136077. * @see https://doc.babylonjs.com/features/occlusionquery
  136078. */
  136079. occlusionQueryAlgorithmType: number;
  136080. /**
  136081. * 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
  136082. * @see https://doc.babylonjs.com/features/occlusionquery
  136083. */
  136084. isOccluded: boolean;
  136085. /**
  136086. * Flag to check the progress status of the query
  136087. * @see https://doc.babylonjs.com/features/occlusionquery
  136088. */
  136089. isOcclusionQueryInProgress: boolean;
  136090. }
  136091. }
  136092. declare module BABYLON {
  136093. /** @hidden */
  136094. export var _forceTransformFeedbackToBundle: boolean;
  136095. interface Engine {
  136096. /**
  136097. * Creates a webGL transform feedback object
  136098. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  136099. * @returns the webGL transform feedback object
  136100. */
  136101. createTransformFeedback(): WebGLTransformFeedback;
  136102. /**
  136103. * Delete a webGL transform feedback object
  136104. * @param value defines the webGL transform feedback object to delete
  136105. */
  136106. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  136107. /**
  136108. * Bind a webGL transform feedback object to the webgl context
  136109. * @param value defines the webGL transform feedback object to bind
  136110. */
  136111. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  136112. /**
  136113. * Begins a transform feedback operation
  136114. * @param usePoints defines if points or triangles must be used
  136115. */
  136116. beginTransformFeedback(usePoints: boolean): void;
  136117. /**
  136118. * Ends a transform feedback operation
  136119. */
  136120. endTransformFeedback(): void;
  136121. /**
  136122. * Specify the varyings to use with transform feedback
  136123. * @param program defines the associated webGL program
  136124. * @param value defines the list of strings representing the varying names
  136125. */
  136126. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  136127. /**
  136128. * Bind a webGL buffer for a transform feedback operation
  136129. * @param value defines the webGL buffer to bind
  136130. */
  136131. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  136132. }
  136133. }
  136134. declare module BABYLON {
  136135. /**
  136136. * Class used to define an additional view for the engine
  136137. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136138. */
  136139. export class EngineView {
  136140. /** Defines the canvas where to render the view */
  136141. target: HTMLCanvasElement;
  136142. /** Defines an optional camera used to render the view (will use active camera else) */
  136143. camera?: Camera;
  136144. }
  136145. interface Engine {
  136146. /**
  136147. * Gets or sets the HTML element to use for attaching events
  136148. */
  136149. inputElement: Nullable<HTMLElement>;
  136150. /**
  136151. * Gets the current engine view
  136152. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136153. */
  136154. activeView: Nullable<EngineView>;
  136155. /** Gets or sets the list of views */
  136156. views: EngineView[];
  136157. /**
  136158. * Register a new child canvas
  136159. * @param canvas defines the canvas to register
  136160. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  136161. * @returns the associated view
  136162. */
  136163. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  136164. /**
  136165. * Remove a registered child canvas
  136166. * @param canvas defines the canvas to remove
  136167. * @returns the current engine
  136168. */
  136169. unRegisterView(canvas: HTMLCanvasElement): Engine;
  136170. }
  136171. }
  136172. declare module BABYLON {
  136173. interface Engine {
  136174. /** @hidden */
  136175. _excludedCompressedTextures: string[];
  136176. /** @hidden */
  136177. _textureFormatInUse: string;
  136178. /**
  136179. * Gets the list of texture formats supported
  136180. */
  136181. readonly texturesSupported: Array<string>;
  136182. /**
  136183. * Gets the texture format in use
  136184. */
  136185. readonly textureFormatInUse: Nullable<string>;
  136186. /**
  136187. * Set the compressed texture extensions or file names to skip.
  136188. *
  136189. * @param skippedFiles defines the list of those texture files you want to skip
  136190. * Example: [".dds", ".env", "myfile.png"]
  136191. */
  136192. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  136193. /**
  136194. * Set the compressed texture format to use, based on the formats you have, and the formats
  136195. * supported by the hardware / browser.
  136196. *
  136197. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  136198. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  136199. * to API arguments needed to compressed textures. This puts the burden on the container
  136200. * generator to house the arcane code for determining these for current & future formats.
  136201. *
  136202. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136203. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136204. *
  136205. * Note: The result of this call is not taken into account when a texture is base64.
  136206. *
  136207. * @param formatsAvailable defines the list of those format families you have created
  136208. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  136209. *
  136210. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  136211. * @returns The extension selected.
  136212. */
  136213. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  136214. }
  136215. }
  136216. declare module BABYLON {
  136217. /** @hidden */
  136218. export var rgbdEncodePixelShader: {
  136219. name: string;
  136220. shader: string;
  136221. };
  136222. }
  136223. declare module BABYLON {
  136224. /**
  136225. * Raw texture data and descriptor sufficient for WebGL texture upload
  136226. */
  136227. export interface EnvironmentTextureInfo {
  136228. /**
  136229. * Version of the environment map
  136230. */
  136231. version: number;
  136232. /**
  136233. * Width of image
  136234. */
  136235. width: number;
  136236. /**
  136237. * Irradiance information stored in the file.
  136238. */
  136239. irradiance: any;
  136240. /**
  136241. * Specular information stored in the file.
  136242. */
  136243. specular: any;
  136244. }
  136245. /**
  136246. * Defines One Image in the file. It requires only the position in the file
  136247. * as well as the length.
  136248. */
  136249. interface BufferImageData {
  136250. /**
  136251. * Length of the image data.
  136252. */
  136253. length: number;
  136254. /**
  136255. * Position of the data from the null terminator delimiting the end of the JSON.
  136256. */
  136257. position: number;
  136258. }
  136259. /**
  136260. * Defines the specular data enclosed in the file.
  136261. * This corresponds to the version 1 of the data.
  136262. */
  136263. export interface EnvironmentTextureSpecularInfoV1 {
  136264. /**
  136265. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  136266. */
  136267. specularDataPosition?: number;
  136268. /**
  136269. * This contains all the images data needed to reconstruct the cubemap.
  136270. */
  136271. mipmaps: Array<BufferImageData>;
  136272. /**
  136273. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  136274. */
  136275. lodGenerationScale: number;
  136276. }
  136277. /**
  136278. * Sets of helpers addressing the serialization and deserialization of environment texture
  136279. * stored in a BabylonJS env file.
  136280. * Those files are usually stored as .env files.
  136281. */
  136282. export class EnvironmentTextureTools {
  136283. /**
  136284. * Magic number identifying the env file.
  136285. */
  136286. private static _MagicBytes;
  136287. /**
  136288. * Gets the environment info from an env file.
  136289. * @param data The array buffer containing the .env bytes.
  136290. * @returns the environment file info (the json header) if successfully parsed.
  136291. */
  136292. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  136293. /**
  136294. * Creates an environment texture from a loaded cube texture.
  136295. * @param texture defines the cube texture to convert in env file
  136296. * @return a promise containing the environment data if succesfull.
  136297. */
  136298. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  136299. /**
  136300. * Creates a JSON representation of the spherical data.
  136301. * @param texture defines the texture containing the polynomials
  136302. * @return the JSON representation of the spherical info
  136303. */
  136304. private static _CreateEnvTextureIrradiance;
  136305. /**
  136306. * Creates the ArrayBufferViews used for initializing environment texture image data.
  136307. * @param data the image data
  136308. * @param info parameters that determine what views will be created for accessing the underlying buffer
  136309. * @return the views described by info providing access to the underlying buffer
  136310. */
  136311. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  136312. /**
  136313. * Uploads the texture info contained in the env file to the GPU.
  136314. * @param texture defines the internal texture to upload to
  136315. * @param data defines the data to load
  136316. * @param info defines the texture info retrieved through the GetEnvInfo method
  136317. * @returns a promise
  136318. */
  136319. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  136320. private static _OnImageReadyAsync;
  136321. /**
  136322. * Uploads the levels of image data to the GPU.
  136323. * @param texture defines the internal texture to upload to
  136324. * @param imageData defines the array buffer views of image data [mipmap][face]
  136325. * @returns a promise
  136326. */
  136327. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  136328. /**
  136329. * Uploads spherical polynomials information to the texture.
  136330. * @param texture defines the texture we are trying to upload the information to
  136331. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  136332. */
  136333. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  136334. /** @hidden */
  136335. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  136336. }
  136337. }
  136338. declare module BABYLON {
  136339. /**
  136340. * Class used to inline functions in shader code
  136341. */
  136342. export class ShaderCodeInliner {
  136343. private static readonly _RegexpFindFunctionNameAndType;
  136344. private _sourceCode;
  136345. private _functionDescr;
  136346. private _numMaxIterations;
  136347. /** Gets or sets the token used to mark the functions to inline */
  136348. inlineToken: string;
  136349. /** Gets or sets the debug mode */
  136350. debug: boolean;
  136351. /** Gets the code after the inlining process */
  136352. get code(): string;
  136353. /**
  136354. * Initializes the inliner
  136355. * @param sourceCode shader code source to inline
  136356. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  136357. */
  136358. constructor(sourceCode: string, numMaxIterations?: number);
  136359. /**
  136360. * Start the processing of the shader code
  136361. */
  136362. processCode(): void;
  136363. private _collectFunctions;
  136364. private _processInlining;
  136365. private _extractBetweenMarkers;
  136366. private _skipWhitespaces;
  136367. private _removeComments;
  136368. private _replaceFunctionCallsByCode;
  136369. private _findBackward;
  136370. private _escapeRegExp;
  136371. private _replaceNames;
  136372. }
  136373. }
  136374. declare module BABYLON {
  136375. /**
  136376. * Container for accessors for natively-stored mesh data buffers.
  136377. */
  136378. class NativeDataBuffer extends DataBuffer {
  136379. /**
  136380. * Accessor value used to identify/retrieve a natively-stored index buffer.
  136381. */
  136382. nativeIndexBuffer?: any;
  136383. /**
  136384. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  136385. */
  136386. nativeVertexBuffer?: any;
  136387. }
  136388. /** @hidden */
  136389. class NativeTexture extends InternalTexture {
  136390. getInternalTexture(): InternalTexture;
  136391. getViewCount(): number;
  136392. }
  136393. /** @hidden */
  136394. export class NativeEngine extends Engine {
  136395. private readonly _native;
  136396. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  136397. private readonly INVALID_HANDLE;
  136398. private _boundBuffersVertexArray;
  136399. private _currentDepthTest;
  136400. getHardwareScalingLevel(): number;
  136401. constructor();
  136402. dispose(): void;
  136403. /**
  136404. * Can be used to override the current requestAnimationFrame requester.
  136405. * @hidden
  136406. */
  136407. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  136408. /**
  136409. * Override default engine behavior.
  136410. * @param color
  136411. * @param backBuffer
  136412. * @param depth
  136413. * @param stencil
  136414. */
  136415. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  136416. /**
  136417. * Gets host document
  136418. * @returns the host document object
  136419. */
  136420. getHostDocument(): Nullable<Document>;
  136421. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136422. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  136423. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  136424. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  136425. [key: string]: VertexBuffer;
  136426. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136427. bindBuffers(vertexBuffers: {
  136428. [key: string]: VertexBuffer;
  136429. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136430. recordVertexArrayObject(vertexBuffers: {
  136431. [key: string]: VertexBuffer;
  136432. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  136433. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136434. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136435. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136436. /**
  136437. * Draw a list of indexed primitives
  136438. * @param fillMode defines the primitive to use
  136439. * @param indexStart defines the starting index
  136440. * @param indexCount defines the number of index to draw
  136441. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136442. */
  136443. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136444. /**
  136445. * Draw a list of unindexed primitives
  136446. * @param fillMode defines the primitive to use
  136447. * @param verticesStart defines the index of first vertex to draw
  136448. * @param verticesCount defines the count of vertices to draw
  136449. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136450. */
  136451. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136452. createPipelineContext(): IPipelineContext;
  136453. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  136454. /** @hidden */
  136455. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  136456. /** @hidden */
  136457. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  136458. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136459. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136460. protected _setProgram(program: WebGLProgram): void;
  136461. _releaseEffect(effect: Effect): void;
  136462. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  136463. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  136464. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  136465. bindSamplers(effect: Effect): void;
  136466. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  136467. getRenderWidth(useScreen?: boolean): number;
  136468. getRenderHeight(useScreen?: boolean): number;
  136469. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  136470. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136471. /**
  136472. * Set the z offset to apply to current rendering
  136473. * @param value defines the offset to apply
  136474. */
  136475. setZOffset(value: number): void;
  136476. /**
  136477. * Gets the current value of the zOffset
  136478. * @returns the current zOffset state
  136479. */
  136480. getZOffset(): number;
  136481. /**
  136482. * Enable or disable depth buffering
  136483. * @param enable defines the state to set
  136484. */
  136485. setDepthBuffer(enable: boolean): void;
  136486. /**
  136487. * Gets a boolean indicating if depth writing is enabled
  136488. * @returns the current depth writing state
  136489. */
  136490. getDepthWrite(): boolean;
  136491. setDepthFunctionToGreater(): void;
  136492. setDepthFunctionToGreaterOrEqual(): void;
  136493. setDepthFunctionToLess(): void;
  136494. setDepthFunctionToLessOrEqual(): void;
  136495. /**
  136496. * Enable or disable depth writing
  136497. * @param enable defines the state to set
  136498. */
  136499. setDepthWrite(enable: boolean): void;
  136500. /**
  136501. * Enable or disable color writing
  136502. * @param enable defines the state to set
  136503. */
  136504. setColorWrite(enable: boolean): void;
  136505. /**
  136506. * Gets a boolean indicating if color writing is enabled
  136507. * @returns the current color writing state
  136508. */
  136509. getColorWrite(): boolean;
  136510. /**
  136511. * Sets alpha constants used by some alpha blending modes
  136512. * @param r defines the red component
  136513. * @param g defines the green component
  136514. * @param b defines the blue component
  136515. * @param a defines the alpha component
  136516. */
  136517. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  136518. /**
  136519. * Sets the current alpha mode
  136520. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  136521. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136522. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136523. */
  136524. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136525. /**
  136526. * Gets the current alpha mode
  136527. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136528. * @returns the current alpha mode
  136529. */
  136530. getAlphaMode(): number;
  136531. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  136532. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136533. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136534. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136535. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136536. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136537. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136538. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136539. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136540. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136541. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136542. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136543. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136544. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136545. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136546. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136547. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136548. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136549. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136550. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136551. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  136552. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  136553. wipeCaches(bruteForce?: boolean): void;
  136554. _createTexture(): WebGLTexture;
  136555. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  136556. /**
  136557. * Update the content of a dynamic texture
  136558. * @param texture defines the texture to update
  136559. * @param canvas defines the canvas containing the source
  136560. * @param invertY defines if data must be stored with Y axis inverted
  136561. * @param premulAlpha defines if alpha is stored as premultiplied
  136562. * @param format defines the format of the data
  136563. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136564. */
  136565. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136566. /**
  136567. * Usually called from Texture.ts.
  136568. * Passed information to create a WebGLTexture
  136569. * @param url defines a value which contains one of the following:
  136570. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136571. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136572. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136573. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136574. * @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)
  136575. * @param scene needed for loading to the correct scene
  136576. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136577. * @param onLoad optional callback to be called upon successful completion
  136578. * @param onError optional callback to be called upon failure
  136579. * @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
  136580. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136581. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136582. * @param forcedExtension defines the extension to use to pick the right loader
  136583. * @param mimeType defines an optional mime type
  136584. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136585. */
  136586. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  136587. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  136588. _releaseFramebufferObjects(texture: InternalTexture): void;
  136589. /**
  136590. * Creates a cube texture
  136591. * @param rootUrl defines the url where the files to load is located
  136592. * @param scene defines the current scene
  136593. * @param files defines the list of files to load (1 per face)
  136594. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  136595. * @param onLoad defines an optional callback raised when the texture is loaded
  136596. * @param onError defines an optional callback raised if there is an issue to load the texture
  136597. * @param format defines the format of the data
  136598. * @param forcedExtension defines the extension to use to pick the right loader
  136599. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  136600. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  136601. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  136602. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  136603. * @returns the cube texture as an InternalTexture
  136604. */
  136605. 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;
  136606. createRenderTargetTexture(size: number | {
  136607. width: number;
  136608. height: number;
  136609. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  136610. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136611. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136612. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136613. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  136614. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  136615. /**
  136616. * Updates a dynamic vertex buffer.
  136617. * @param vertexBuffer the vertex buffer to update
  136618. * @param data the data used to update the vertex buffer
  136619. * @param byteOffset the byte offset of the data (optional)
  136620. * @param byteLength the byte length of the data (optional)
  136621. */
  136622. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  136623. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  136624. private _updateAnisotropicLevel;
  136625. private _getAddressMode;
  136626. /** @hidden */
  136627. _bindTexture(channel: number, texture: InternalTexture): void;
  136628. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  136629. releaseEffects(): void;
  136630. /** @hidden */
  136631. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136632. /** @hidden */
  136633. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136634. /** @hidden */
  136635. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136636. /** @hidden */
  136637. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136638. private _getNativeSamplingMode;
  136639. private _getNativeTextureFormat;
  136640. private _getNativeAlphaMode;
  136641. private _getNativeAttribType;
  136642. }
  136643. }
  136644. declare module BABYLON {
  136645. /**
  136646. * Gather the list of clipboard event types as constants.
  136647. */
  136648. export class ClipboardEventTypes {
  136649. /**
  136650. * The clipboard event is fired when a copy command is active (pressed).
  136651. */
  136652. static readonly COPY: number;
  136653. /**
  136654. * The clipboard event is fired when a cut command is active (pressed).
  136655. */
  136656. static readonly CUT: number;
  136657. /**
  136658. * The clipboard event is fired when a paste command is active (pressed).
  136659. */
  136660. static readonly PASTE: number;
  136661. }
  136662. /**
  136663. * This class is used to store clipboard related info for the onClipboardObservable event.
  136664. */
  136665. export class ClipboardInfo {
  136666. /**
  136667. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136668. */
  136669. type: number;
  136670. /**
  136671. * Defines the related dom event
  136672. */
  136673. event: ClipboardEvent;
  136674. /**
  136675. *Creates an instance of ClipboardInfo.
  136676. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  136677. * @param event Defines the related dom event
  136678. */
  136679. constructor(
  136680. /**
  136681. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136682. */
  136683. type: number,
  136684. /**
  136685. * Defines the related dom event
  136686. */
  136687. event: ClipboardEvent);
  136688. /**
  136689. * Get the clipboard event's type from the keycode.
  136690. * @param keyCode Defines the keyCode for the current keyboard event.
  136691. * @return {number}
  136692. */
  136693. static GetTypeFromCharacter(keyCode: number): number;
  136694. }
  136695. }
  136696. declare module BABYLON {
  136697. /**
  136698. * Google Daydream controller
  136699. */
  136700. export class DaydreamController extends WebVRController {
  136701. /**
  136702. * Base Url for the controller model.
  136703. */
  136704. static MODEL_BASE_URL: string;
  136705. /**
  136706. * File name for the controller model.
  136707. */
  136708. static MODEL_FILENAME: string;
  136709. /**
  136710. * Gamepad Id prefix used to identify Daydream Controller.
  136711. */
  136712. static readonly GAMEPAD_ID_PREFIX: string;
  136713. /**
  136714. * Creates a new DaydreamController from a gamepad
  136715. * @param vrGamepad the gamepad that the controller should be created from
  136716. */
  136717. constructor(vrGamepad: any);
  136718. /**
  136719. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136720. * @param scene scene in which to add meshes
  136721. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136722. */
  136723. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136724. /**
  136725. * Called once for each button that changed state since the last frame
  136726. * @param buttonIdx Which button index changed
  136727. * @param state New state of the button
  136728. * @param changes Which properties on the state changed since last frame
  136729. */
  136730. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136731. }
  136732. }
  136733. declare module BABYLON {
  136734. /**
  136735. * Gear VR Controller
  136736. */
  136737. export class GearVRController extends WebVRController {
  136738. /**
  136739. * Base Url for the controller model.
  136740. */
  136741. static MODEL_BASE_URL: string;
  136742. /**
  136743. * File name for the controller model.
  136744. */
  136745. static MODEL_FILENAME: string;
  136746. /**
  136747. * Gamepad Id prefix used to identify this controller.
  136748. */
  136749. static readonly GAMEPAD_ID_PREFIX: string;
  136750. private readonly _buttonIndexToObservableNameMap;
  136751. /**
  136752. * Creates a new GearVRController from a gamepad
  136753. * @param vrGamepad the gamepad that the controller should be created from
  136754. */
  136755. constructor(vrGamepad: any);
  136756. /**
  136757. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136758. * @param scene scene in which to add meshes
  136759. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136760. */
  136761. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136762. /**
  136763. * Called once for each button that changed state since the last frame
  136764. * @param buttonIdx Which button index changed
  136765. * @param state New state of the button
  136766. * @param changes Which properties on the state changed since last frame
  136767. */
  136768. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136769. }
  136770. }
  136771. declare module BABYLON {
  136772. /**
  136773. * Generic Controller
  136774. */
  136775. export class GenericController extends WebVRController {
  136776. /**
  136777. * Base Url for the controller model.
  136778. */
  136779. static readonly MODEL_BASE_URL: string;
  136780. /**
  136781. * File name for the controller model.
  136782. */
  136783. static readonly MODEL_FILENAME: string;
  136784. /**
  136785. * Creates a new GenericController from a gamepad
  136786. * @param vrGamepad the gamepad that the controller should be created from
  136787. */
  136788. constructor(vrGamepad: any);
  136789. /**
  136790. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136791. * @param scene scene in which to add meshes
  136792. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136793. */
  136794. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136795. /**
  136796. * Called once for each button that changed state since the last frame
  136797. * @param buttonIdx Which button index changed
  136798. * @param state New state of the button
  136799. * @param changes Which properties on the state changed since last frame
  136800. */
  136801. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136802. }
  136803. }
  136804. declare module BABYLON {
  136805. /**
  136806. * Oculus Touch Controller
  136807. */
  136808. export class OculusTouchController extends WebVRController {
  136809. /**
  136810. * Base Url for the controller model.
  136811. */
  136812. static MODEL_BASE_URL: string;
  136813. /**
  136814. * File name for the left controller model.
  136815. */
  136816. static MODEL_LEFT_FILENAME: string;
  136817. /**
  136818. * File name for the right controller model.
  136819. */
  136820. static MODEL_RIGHT_FILENAME: string;
  136821. /**
  136822. * Base Url for the Quest controller model.
  136823. */
  136824. static QUEST_MODEL_BASE_URL: string;
  136825. /**
  136826. * @hidden
  136827. * If the controllers are running on a device that needs the updated Quest controller models
  136828. */
  136829. static _IsQuest: boolean;
  136830. /**
  136831. * Fired when the secondary trigger on this controller is modified
  136832. */
  136833. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  136834. /**
  136835. * Fired when the thumb rest on this controller is modified
  136836. */
  136837. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  136838. /**
  136839. * Creates a new OculusTouchController from a gamepad
  136840. * @param vrGamepad the gamepad that the controller should be created from
  136841. */
  136842. constructor(vrGamepad: any);
  136843. /**
  136844. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136845. * @param scene scene in which to add meshes
  136846. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136847. */
  136848. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136849. /**
  136850. * Fired when the A button on this controller is modified
  136851. */
  136852. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136853. /**
  136854. * Fired when the B button on this controller is modified
  136855. */
  136856. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136857. /**
  136858. * Fired when the X button on this controller is modified
  136859. */
  136860. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136861. /**
  136862. * Fired when the Y button on this controller is modified
  136863. */
  136864. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136865. /**
  136866. * Called once for each button that changed state since the last frame
  136867. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  136868. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  136869. * 2) secondary trigger (same)
  136870. * 3) A (right) X (left), touch, pressed = value
  136871. * 4) B / Y
  136872. * 5) thumb rest
  136873. * @param buttonIdx Which button index changed
  136874. * @param state New state of the button
  136875. * @param changes Which properties on the state changed since last frame
  136876. */
  136877. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136878. }
  136879. }
  136880. declare module BABYLON {
  136881. /**
  136882. * Vive Controller
  136883. */
  136884. export class ViveController extends WebVRController {
  136885. /**
  136886. * Base Url for the controller model.
  136887. */
  136888. static MODEL_BASE_URL: string;
  136889. /**
  136890. * File name for the controller model.
  136891. */
  136892. static MODEL_FILENAME: string;
  136893. /**
  136894. * Creates a new ViveController from a gamepad
  136895. * @param vrGamepad the gamepad that the controller should be created from
  136896. */
  136897. constructor(vrGamepad: any);
  136898. /**
  136899. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136900. * @param scene scene in which to add meshes
  136901. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136902. */
  136903. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136904. /**
  136905. * Fired when the left button on this controller is modified
  136906. */
  136907. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136908. /**
  136909. * Fired when the right button on this controller is modified
  136910. */
  136911. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136912. /**
  136913. * Fired when the menu button on this controller is modified
  136914. */
  136915. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136916. /**
  136917. * Called once for each button that changed state since the last frame
  136918. * Vive mapping:
  136919. * 0: touchpad
  136920. * 1: trigger
  136921. * 2: left AND right buttons
  136922. * 3: menu button
  136923. * @param buttonIdx Which button index changed
  136924. * @param state New state of the button
  136925. * @param changes Which properties on the state changed since last frame
  136926. */
  136927. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136928. }
  136929. }
  136930. declare module BABYLON {
  136931. /**
  136932. * Defines the WindowsMotionController object that the state of the windows motion controller
  136933. */
  136934. export class WindowsMotionController extends WebVRController {
  136935. /**
  136936. * The base url used to load the left and right controller models
  136937. */
  136938. static MODEL_BASE_URL: string;
  136939. /**
  136940. * The name of the left controller model file
  136941. */
  136942. static MODEL_LEFT_FILENAME: string;
  136943. /**
  136944. * The name of the right controller model file
  136945. */
  136946. static MODEL_RIGHT_FILENAME: string;
  136947. /**
  136948. * The controller name prefix for this controller type
  136949. */
  136950. static readonly GAMEPAD_ID_PREFIX: string;
  136951. /**
  136952. * The controller id pattern for this controller type
  136953. */
  136954. private static readonly GAMEPAD_ID_PATTERN;
  136955. private _loadedMeshInfo;
  136956. protected readonly _mapping: {
  136957. buttons: string[];
  136958. buttonMeshNames: {
  136959. trigger: string;
  136960. menu: string;
  136961. grip: string;
  136962. thumbstick: string;
  136963. trackpad: string;
  136964. };
  136965. buttonObservableNames: {
  136966. trigger: string;
  136967. menu: string;
  136968. grip: string;
  136969. thumbstick: string;
  136970. trackpad: string;
  136971. };
  136972. axisMeshNames: string[];
  136973. pointingPoseMeshName: string;
  136974. };
  136975. /**
  136976. * Fired when the trackpad on this controller is clicked
  136977. */
  136978. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  136979. /**
  136980. * Fired when the trackpad on this controller is modified
  136981. */
  136982. onTrackpadValuesChangedObservable: Observable<StickValues>;
  136983. /**
  136984. * The current x and y values of this controller's trackpad
  136985. */
  136986. trackpad: StickValues;
  136987. /**
  136988. * Creates a new WindowsMotionController from a gamepad
  136989. * @param vrGamepad the gamepad that the controller should be created from
  136990. */
  136991. constructor(vrGamepad: any);
  136992. /**
  136993. * Fired when the trigger on this controller is modified
  136994. */
  136995. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136996. /**
  136997. * Fired when the menu button on this controller is modified
  136998. */
  136999. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137000. /**
  137001. * Fired when the grip button on this controller is modified
  137002. */
  137003. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137004. /**
  137005. * Fired when the thumbstick button on this controller is modified
  137006. */
  137007. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137008. /**
  137009. * Fired when the touchpad button on this controller is modified
  137010. */
  137011. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137012. /**
  137013. * Fired when the touchpad values on this controller are modified
  137014. */
  137015. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  137016. protected _updateTrackpad(): void;
  137017. /**
  137018. * Called once per frame by the engine.
  137019. */
  137020. update(): void;
  137021. /**
  137022. * Called once for each button that changed state since the last frame
  137023. * @param buttonIdx Which button index changed
  137024. * @param state New state of the button
  137025. * @param changes Which properties on the state changed since last frame
  137026. */
  137027. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137028. /**
  137029. * Moves the buttons on the controller mesh based on their current state
  137030. * @param buttonName the name of the button to move
  137031. * @param buttonValue the value of the button which determines the buttons new position
  137032. */
  137033. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  137034. /**
  137035. * Moves the axis on the controller mesh based on its current state
  137036. * @param axis the index of the axis
  137037. * @param axisValue the value of the axis which determines the meshes new position
  137038. * @hidden
  137039. */
  137040. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  137041. /**
  137042. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137043. * @param scene scene in which to add meshes
  137044. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137045. */
  137046. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  137047. /**
  137048. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  137049. * can be transformed by button presses and axes values, based on this._mapping.
  137050. *
  137051. * @param scene scene in which the meshes exist
  137052. * @param meshes list of meshes that make up the controller model to process
  137053. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  137054. */
  137055. private processModel;
  137056. private createMeshInfo;
  137057. /**
  137058. * Gets the ray of the controller in the direction the controller is pointing
  137059. * @param length the length the resulting ray should be
  137060. * @returns a ray in the direction the controller is pointing
  137061. */
  137062. getForwardRay(length?: number): Ray;
  137063. /**
  137064. * Disposes of the controller
  137065. */
  137066. dispose(): void;
  137067. }
  137068. /**
  137069. * This class represents a new windows motion controller in XR.
  137070. */
  137071. export class XRWindowsMotionController extends WindowsMotionController {
  137072. /**
  137073. * Changing the original WIndowsMotionController mapping to fir the new mapping
  137074. */
  137075. protected readonly _mapping: {
  137076. buttons: string[];
  137077. buttonMeshNames: {
  137078. trigger: string;
  137079. menu: string;
  137080. grip: string;
  137081. thumbstick: string;
  137082. trackpad: string;
  137083. };
  137084. buttonObservableNames: {
  137085. trigger: string;
  137086. menu: string;
  137087. grip: string;
  137088. thumbstick: string;
  137089. trackpad: string;
  137090. };
  137091. axisMeshNames: string[];
  137092. pointingPoseMeshName: string;
  137093. };
  137094. /**
  137095. * Construct a new XR-Based windows motion controller
  137096. *
  137097. * @param gamepadInfo the gamepad object from the browser
  137098. */
  137099. constructor(gamepadInfo: any);
  137100. /**
  137101. * holds the thumbstick values (X,Y)
  137102. */
  137103. thumbstickValues: StickValues;
  137104. /**
  137105. * Fired when the thumbstick on this controller is clicked
  137106. */
  137107. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  137108. /**
  137109. * Fired when the thumbstick on this controller is modified
  137110. */
  137111. onThumbstickValuesChangedObservable: Observable<StickValues>;
  137112. /**
  137113. * Fired when the touchpad button on this controller is modified
  137114. */
  137115. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137116. /**
  137117. * Fired when the touchpad values on this controller are modified
  137118. */
  137119. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137120. /**
  137121. * Fired when the thumbstick button on this controller is modified
  137122. * here to prevent breaking changes
  137123. */
  137124. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137125. /**
  137126. * updating the thumbstick(!) and not the trackpad.
  137127. * This is named this way due to the difference between WebVR and XR and to avoid
  137128. * changing the parent class.
  137129. */
  137130. protected _updateTrackpad(): void;
  137131. /**
  137132. * Disposes the class with joy
  137133. */
  137134. dispose(): void;
  137135. }
  137136. }
  137137. declare module BABYLON {
  137138. /**
  137139. * Class containing static functions to help procedurally build meshes
  137140. */
  137141. export class PolyhedronBuilder {
  137142. /**
  137143. * Creates a polyhedron mesh
  137144. * * 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
  137145. * * The parameter `size` (positive float, default 1) sets the polygon size
  137146. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  137147. * * 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`
  137148. * * 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
  137149. * * 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)`)
  137150. * * 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
  137151. * * 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
  137152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137155. * @param name defines the name of the mesh
  137156. * @param options defines the options used to create the mesh
  137157. * @param scene defines the hosting scene
  137158. * @returns the polyhedron mesh
  137159. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  137160. */
  137161. static CreatePolyhedron(name: string, options: {
  137162. type?: number;
  137163. size?: number;
  137164. sizeX?: number;
  137165. sizeY?: number;
  137166. sizeZ?: number;
  137167. custom?: any;
  137168. faceUV?: Vector4[];
  137169. faceColors?: Color4[];
  137170. flat?: boolean;
  137171. updatable?: boolean;
  137172. sideOrientation?: number;
  137173. frontUVs?: Vector4;
  137174. backUVs?: Vector4;
  137175. }, scene?: Nullable<Scene>): Mesh;
  137176. }
  137177. }
  137178. declare module BABYLON {
  137179. /**
  137180. * Gizmo that enables scaling a mesh along 3 axis
  137181. */
  137182. export class ScaleGizmo extends Gizmo {
  137183. /**
  137184. * Internal gizmo used for interactions on the x axis
  137185. */
  137186. xGizmo: AxisScaleGizmo;
  137187. /**
  137188. * Internal gizmo used for interactions on the y axis
  137189. */
  137190. yGizmo: AxisScaleGizmo;
  137191. /**
  137192. * Internal gizmo used for interactions on the z axis
  137193. */
  137194. zGizmo: AxisScaleGizmo;
  137195. /**
  137196. * Internal gizmo used to scale all axis equally
  137197. */
  137198. uniformScaleGizmo: AxisScaleGizmo;
  137199. private _meshAttached;
  137200. private _nodeAttached;
  137201. private _snapDistance;
  137202. private _uniformScalingMesh;
  137203. private _octahedron;
  137204. private _sensitivity;
  137205. /** Fires an event when any of it's sub gizmos are dragged */
  137206. onDragStartObservable: Observable<unknown>;
  137207. /** Fires an event when any of it's sub gizmos are released from dragging */
  137208. onDragEndObservable: Observable<unknown>;
  137209. get attachedMesh(): Nullable<AbstractMesh>;
  137210. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137211. get attachedNode(): Nullable<Node>;
  137212. set attachedNode(node: Nullable<Node>);
  137213. /**
  137214. * True when the mouse pointer is hovering a gizmo mesh
  137215. */
  137216. get isHovered(): boolean;
  137217. /**
  137218. * Creates a ScaleGizmo
  137219. * @param gizmoLayer The utility layer the gizmo will be added to
  137220. * @param thickness display gizmo axis thickness
  137221. */
  137222. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  137223. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137224. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137225. /**
  137226. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137227. */
  137228. set snapDistance(value: number);
  137229. get snapDistance(): number;
  137230. /**
  137231. * Ratio for the scale of the gizmo (Default: 1)
  137232. */
  137233. set scaleRatio(value: number);
  137234. get scaleRatio(): number;
  137235. /**
  137236. * Sensitivity factor for dragging (Default: 1)
  137237. */
  137238. set sensitivity(value: number);
  137239. get sensitivity(): number;
  137240. /**
  137241. * Disposes of the gizmo
  137242. */
  137243. dispose(): void;
  137244. }
  137245. }
  137246. declare module BABYLON {
  137247. /**
  137248. * Single axis scale gizmo
  137249. */
  137250. export class AxisScaleGizmo extends Gizmo {
  137251. /**
  137252. * Drag behavior responsible for the gizmos dragging interactions
  137253. */
  137254. dragBehavior: PointerDragBehavior;
  137255. private _pointerObserver;
  137256. /**
  137257. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137258. */
  137259. snapDistance: number;
  137260. /**
  137261. * Event that fires each time the gizmo snaps to a new location.
  137262. * * snapDistance is the the change in distance
  137263. */
  137264. onSnapObservable: Observable<{
  137265. snapDistance: number;
  137266. }>;
  137267. /**
  137268. * If the scaling operation should be done on all axis (default: false)
  137269. */
  137270. uniformScaling: boolean;
  137271. /**
  137272. * Custom sensitivity value for the drag strength
  137273. */
  137274. sensitivity: number;
  137275. private _isEnabled;
  137276. private _parent;
  137277. private _arrow;
  137278. private _coloredMaterial;
  137279. private _hoverMaterial;
  137280. /**
  137281. * Creates an AxisScaleGizmo
  137282. * @param gizmoLayer The utility layer the gizmo will be added to
  137283. * @param dragAxis The axis which the gizmo will be able to scale on
  137284. * @param color The color of the gizmo
  137285. * @param thickness display gizmo axis thickness
  137286. */
  137287. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  137288. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137289. /**
  137290. * If the gizmo is enabled
  137291. */
  137292. set isEnabled(value: boolean);
  137293. get isEnabled(): boolean;
  137294. /**
  137295. * Disposes of the gizmo
  137296. */
  137297. dispose(): void;
  137298. /**
  137299. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  137300. * @param mesh The mesh to replace the default mesh of the gizmo
  137301. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  137302. */
  137303. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  137304. }
  137305. }
  137306. declare module BABYLON {
  137307. /**
  137308. * Bounding box gizmo
  137309. */
  137310. export class BoundingBoxGizmo extends Gizmo {
  137311. private _lineBoundingBox;
  137312. private _rotateSpheresParent;
  137313. private _scaleBoxesParent;
  137314. private _boundingDimensions;
  137315. private _renderObserver;
  137316. private _pointerObserver;
  137317. private _scaleDragSpeed;
  137318. private _tmpQuaternion;
  137319. private _tmpVector;
  137320. private _tmpRotationMatrix;
  137321. /**
  137322. * 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)
  137323. */
  137324. ignoreChildren: boolean;
  137325. /**
  137326. * 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)
  137327. */
  137328. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  137329. /**
  137330. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  137331. */
  137332. rotationSphereSize: number;
  137333. /**
  137334. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  137335. */
  137336. scaleBoxSize: number;
  137337. /**
  137338. * 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)
  137339. */
  137340. fixedDragMeshScreenSize: boolean;
  137341. /**
  137342. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  137343. */
  137344. fixedDragMeshScreenSizeDistanceFactor: number;
  137345. /**
  137346. * Fired when a rotation sphere or scale box is dragged
  137347. */
  137348. onDragStartObservable: Observable<{}>;
  137349. /**
  137350. * Fired when a scale box is dragged
  137351. */
  137352. onScaleBoxDragObservable: Observable<{}>;
  137353. /**
  137354. * Fired when a scale box drag is ended
  137355. */
  137356. onScaleBoxDragEndObservable: Observable<{}>;
  137357. /**
  137358. * Fired when a rotation sphere is dragged
  137359. */
  137360. onRotationSphereDragObservable: Observable<{}>;
  137361. /**
  137362. * Fired when a rotation sphere drag is ended
  137363. */
  137364. onRotationSphereDragEndObservable: Observable<{}>;
  137365. /**
  137366. * 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)
  137367. */
  137368. scalePivot: Nullable<Vector3>;
  137369. /**
  137370. * Mesh used as a pivot to rotate the attached node
  137371. */
  137372. private _anchorMesh;
  137373. private _existingMeshScale;
  137374. private _dragMesh;
  137375. private pointerDragBehavior;
  137376. private coloredMaterial;
  137377. private hoverColoredMaterial;
  137378. /**
  137379. * Sets the color of the bounding box gizmo
  137380. * @param color the color to set
  137381. */
  137382. setColor(color: Color3): void;
  137383. /**
  137384. * Creates an BoundingBoxGizmo
  137385. * @param gizmoLayer The utility layer the gizmo will be added to
  137386. * @param color The color of the gizmo
  137387. */
  137388. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  137389. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  137390. private _selectNode;
  137391. /**
  137392. * Updates the bounding box information for the Gizmo
  137393. */
  137394. updateBoundingBox(): void;
  137395. private _updateRotationSpheres;
  137396. private _updateScaleBoxes;
  137397. /**
  137398. * Enables rotation on the specified axis and disables rotation on the others
  137399. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  137400. */
  137401. setEnabledRotationAxis(axis: string): void;
  137402. /**
  137403. * Enables/disables scaling
  137404. * @param enable if scaling should be enabled
  137405. * @param homogeneousScaling defines if scaling should only be homogeneous
  137406. */
  137407. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  137408. private _updateDummy;
  137409. /**
  137410. * Enables a pointer drag behavior on the bounding box of the gizmo
  137411. */
  137412. enableDragBehavior(): void;
  137413. /**
  137414. * Disposes of the gizmo
  137415. */
  137416. dispose(): void;
  137417. /**
  137418. * 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)
  137419. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  137420. * @returns the bounding box mesh with the passed in mesh as a child
  137421. */
  137422. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  137423. /**
  137424. * CustomMeshes are not supported by this gizmo
  137425. * @param mesh The mesh to replace the default mesh of the gizmo
  137426. */
  137427. setCustomMesh(mesh: Mesh): void;
  137428. }
  137429. }
  137430. declare module BABYLON {
  137431. /**
  137432. * Single plane rotation gizmo
  137433. */
  137434. export class PlaneRotationGizmo extends Gizmo {
  137435. /**
  137436. * Drag behavior responsible for the gizmos dragging interactions
  137437. */
  137438. dragBehavior: PointerDragBehavior;
  137439. private _pointerObserver;
  137440. /**
  137441. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  137442. */
  137443. snapDistance: number;
  137444. /**
  137445. * Event that fires each time the gizmo snaps to a new location.
  137446. * * snapDistance is the the change in distance
  137447. */
  137448. onSnapObservable: Observable<{
  137449. snapDistance: number;
  137450. }>;
  137451. private _isEnabled;
  137452. private _parent;
  137453. /**
  137454. * Creates a PlaneRotationGizmo
  137455. * @param gizmoLayer The utility layer the gizmo will be added to
  137456. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  137457. * @param color The color of the gizmo
  137458. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137459. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137460. * @param thickness display gizmo axis thickness
  137461. */
  137462. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  137463. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137464. /**
  137465. * If the gizmo is enabled
  137466. */
  137467. set isEnabled(value: boolean);
  137468. get isEnabled(): boolean;
  137469. /**
  137470. * Disposes of the gizmo
  137471. */
  137472. dispose(): void;
  137473. }
  137474. }
  137475. declare module BABYLON {
  137476. /**
  137477. * Gizmo that enables rotating a mesh along 3 axis
  137478. */
  137479. export class RotationGizmo extends Gizmo {
  137480. /**
  137481. * Internal gizmo used for interactions on the x axis
  137482. */
  137483. xGizmo: PlaneRotationGizmo;
  137484. /**
  137485. * Internal gizmo used for interactions on the y axis
  137486. */
  137487. yGizmo: PlaneRotationGizmo;
  137488. /**
  137489. * Internal gizmo used for interactions on the z axis
  137490. */
  137491. zGizmo: PlaneRotationGizmo;
  137492. /** Fires an event when any of it's sub gizmos are dragged */
  137493. onDragStartObservable: Observable<unknown>;
  137494. /** Fires an event when any of it's sub gizmos are released from dragging */
  137495. onDragEndObservable: Observable<unknown>;
  137496. private _meshAttached;
  137497. private _nodeAttached;
  137498. get attachedMesh(): Nullable<AbstractMesh>;
  137499. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137500. get attachedNode(): Nullable<Node>;
  137501. set attachedNode(node: Nullable<Node>);
  137502. protected _checkBillboardTransform(): void;
  137503. /**
  137504. * True when the mouse pointer is hovering a gizmo mesh
  137505. */
  137506. get isHovered(): boolean;
  137507. /**
  137508. * Creates a RotationGizmo
  137509. * @param gizmoLayer The utility layer the gizmo will be added to
  137510. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137511. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137512. * @param thickness display gizmo axis thickness
  137513. */
  137514. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  137515. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137516. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137517. /**
  137518. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137519. */
  137520. set snapDistance(value: number);
  137521. get snapDistance(): number;
  137522. /**
  137523. * Ratio for the scale of the gizmo (Default: 1)
  137524. */
  137525. set scaleRatio(value: number);
  137526. get scaleRatio(): number;
  137527. /**
  137528. * Disposes of the gizmo
  137529. */
  137530. dispose(): void;
  137531. /**
  137532. * CustomMeshes are not supported by this gizmo
  137533. * @param mesh The mesh to replace the default mesh of the gizmo
  137534. */
  137535. setCustomMesh(mesh: Mesh): void;
  137536. }
  137537. }
  137538. declare module BABYLON {
  137539. /**
  137540. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  137541. */
  137542. export class GizmoManager implements IDisposable {
  137543. private scene;
  137544. /**
  137545. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  137546. */
  137547. gizmos: {
  137548. positionGizmo: Nullable<PositionGizmo>;
  137549. rotationGizmo: Nullable<RotationGizmo>;
  137550. scaleGizmo: Nullable<ScaleGizmo>;
  137551. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  137552. };
  137553. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  137554. clearGizmoOnEmptyPointerEvent: boolean;
  137555. /** Fires an event when the manager is attached to a mesh */
  137556. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  137557. /** Fires an event when the manager is attached to a node */
  137558. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  137559. private _gizmosEnabled;
  137560. private _pointerObserver;
  137561. private _attachedMesh;
  137562. private _attachedNode;
  137563. private _boundingBoxColor;
  137564. private _defaultUtilityLayer;
  137565. private _defaultKeepDepthUtilityLayer;
  137566. private _thickness;
  137567. /**
  137568. * When bounding box gizmo is enabled, this can be used to track drag/end events
  137569. */
  137570. boundingBoxDragBehavior: SixDofDragBehavior;
  137571. /**
  137572. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  137573. */
  137574. attachableMeshes: Nullable<Array<AbstractMesh>>;
  137575. /**
  137576. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  137577. */
  137578. attachableNodes: Nullable<Array<Node>>;
  137579. /**
  137580. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  137581. */
  137582. usePointerToAttachGizmos: boolean;
  137583. /**
  137584. * Utility layer that the bounding box gizmo belongs to
  137585. */
  137586. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  137587. /**
  137588. * Utility layer that all gizmos besides bounding box belong to
  137589. */
  137590. get utilityLayer(): UtilityLayerRenderer;
  137591. /**
  137592. * True when the mouse pointer is hovering a gizmo mesh
  137593. */
  137594. get isHovered(): boolean;
  137595. /**
  137596. * Instatiates a gizmo manager
  137597. * @param scene the scene to overlay the gizmos on top of
  137598. * @param thickness display gizmo axis thickness
  137599. */
  137600. constructor(scene: Scene, thickness?: number);
  137601. /**
  137602. * Attaches a set of gizmos to the specified mesh
  137603. * @param mesh The mesh the gizmo's should be attached to
  137604. */
  137605. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137606. /**
  137607. * Attaches a set of gizmos to the specified node
  137608. * @param node The node the gizmo's should be attached to
  137609. */
  137610. attachToNode(node: Nullable<Node>): void;
  137611. /**
  137612. * If the position gizmo is enabled
  137613. */
  137614. set positionGizmoEnabled(value: boolean);
  137615. get positionGizmoEnabled(): boolean;
  137616. /**
  137617. * If the rotation gizmo is enabled
  137618. */
  137619. set rotationGizmoEnabled(value: boolean);
  137620. get rotationGizmoEnabled(): boolean;
  137621. /**
  137622. * If the scale gizmo is enabled
  137623. */
  137624. set scaleGizmoEnabled(value: boolean);
  137625. get scaleGizmoEnabled(): boolean;
  137626. /**
  137627. * If the boundingBox gizmo is enabled
  137628. */
  137629. set boundingBoxGizmoEnabled(value: boolean);
  137630. get boundingBoxGizmoEnabled(): boolean;
  137631. /**
  137632. * Disposes of the gizmo manager
  137633. */
  137634. dispose(): void;
  137635. }
  137636. }
  137637. declare module BABYLON {
  137638. /**
  137639. * A directional light is defined by a direction (what a surprise!).
  137640. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  137641. * 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.
  137642. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137643. */
  137644. export class DirectionalLight extends ShadowLight {
  137645. private _shadowFrustumSize;
  137646. /**
  137647. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  137648. */
  137649. get shadowFrustumSize(): number;
  137650. /**
  137651. * Specifies a fix frustum size for the shadow generation.
  137652. */
  137653. set shadowFrustumSize(value: number);
  137654. private _shadowOrthoScale;
  137655. /**
  137656. * Gets the shadow projection scale against the optimal computed one.
  137657. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137658. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137659. */
  137660. get shadowOrthoScale(): number;
  137661. /**
  137662. * Sets the shadow projection scale against the optimal computed one.
  137663. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137664. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137665. */
  137666. set shadowOrthoScale(value: number);
  137667. /**
  137668. * Automatically compute the projection matrix to best fit (including all the casters)
  137669. * on each frame.
  137670. */
  137671. autoUpdateExtends: boolean;
  137672. /**
  137673. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  137674. * on each frame. autoUpdateExtends must be set to true for this to work
  137675. */
  137676. autoCalcShadowZBounds: boolean;
  137677. private _orthoLeft;
  137678. private _orthoRight;
  137679. private _orthoTop;
  137680. private _orthoBottom;
  137681. /**
  137682. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  137683. * The directional light is emitted from everywhere in the given direction.
  137684. * It can cast shadows.
  137685. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137686. * @param name The friendly name of the light
  137687. * @param direction The direction of the light
  137688. * @param scene The scene the light belongs to
  137689. */
  137690. constructor(name: string, direction: Vector3, scene: Scene);
  137691. /**
  137692. * Returns the string "DirectionalLight".
  137693. * @return The class name
  137694. */
  137695. getClassName(): string;
  137696. /**
  137697. * Returns the integer 1.
  137698. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137699. */
  137700. getTypeID(): number;
  137701. /**
  137702. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  137703. * Returns the DirectionalLight Shadow projection matrix.
  137704. */
  137705. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137706. /**
  137707. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  137708. * Returns the DirectionalLight Shadow projection matrix.
  137709. */
  137710. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  137711. /**
  137712. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  137713. * Returns the DirectionalLight Shadow projection matrix.
  137714. */
  137715. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137716. protected _buildUniformLayout(): void;
  137717. /**
  137718. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  137719. * @param effect The effect to update
  137720. * @param lightIndex The index of the light in the effect to update
  137721. * @returns The directional light
  137722. */
  137723. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  137724. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  137725. /**
  137726. * Gets the minZ used for shadow according to both the scene and the light.
  137727. *
  137728. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137729. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137730. * @param activeCamera The camera we are returning the min for
  137731. * @returns the depth min z
  137732. */
  137733. getDepthMinZ(activeCamera: Camera): number;
  137734. /**
  137735. * Gets the maxZ used for shadow according to both the scene and the light.
  137736. *
  137737. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137738. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137739. * @param activeCamera The camera we are returning the max for
  137740. * @returns the depth max z
  137741. */
  137742. getDepthMaxZ(activeCamera: Camera): number;
  137743. /**
  137744. * Prepares the list of defines specific to the light type.
  137745. * @param defines the list of defines
  137746. * @param lightIndex defines the index of the light for the effect
  137747. */
  137748. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137749. }
  137750. }
  137751. declare module BABYLON {
  137752. /**
  137753. * Class containing static functions to help procedurally build meshes
  137754. */
  137755. export class HemisphereBuilder {
  137756. /**
  137757. * Creates a hemisphere mesh
  137758. * @param name defines the name of the mesh
  137759. * @param options defines the options used to create the mesh
  137760. * @param scene defines the hosting scene
  137761. * @returns the hemisphere mesh
  137762. */
  137763. static CreateHemisphere(name: string, options: {
  137764. segments?: number;
  137765. diameter?: number;
  137766. sideOrientation?: number;
  137767. }, scene: any): Mesh;
  137768. }
  137769. }
  137770. declare module BABYLON {
  137771. /**
  137772. * A spot light is defined by a position, a direction, an angle, and an exponent.
  137773. * These values define a cone of light starting from the position, emitting toward the direction.
  137774. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  137775. * and the exponent defines the speed of the decay of the light with distance (reach).
  137776. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137777. */
  137778. export class SpotLight extends ShadowLight {
  137779. private _angle;
  137780. private _innerAngle;
  137781. private _cosHalfAngle;
  137782. private _lightAngleScale;
  137783. private _lightAngleOffset;
  137784. /**
  137785. * Gets the cone angle of the spot light in Radians.
  137786. */
  137787. get angle(): number;
  137788. /**
  137789. * Sets the cone angle of the spot light in Radians.
  137790. */
  137791. set angle(value: number);
  137792. /**
  137793. * Only used in gltf falloff mode, this defines the angle where
  137794. * the directional falloff will start before cutting at angle which could be seen
  137795. * as outer angle.
  137796. */
  137797. get innerAngle(): number;
  137798. /**
  137799. * Only used in gltf falloff mode, this defines the angle where
  137800. * the directional falloff will start before cutting at angle which could be seen
  137801. * as outer angle.
  137802. */
  137803. set innerAngle(value: number);
  137804. private _shadowAngleScale;
  137805. /**
  137806. * Allows scaling the angle of the light for shadow generation only.
  137807. */
  137808. get shadowAngleScale(): number;
  137809. /**
  137810. * Allows scaling the angle of the light for shadow generation only.
  137811. */
  137812. set shadowAngleScale(value: number);
  137813. /**
  137814. * The light decay speed with the distance from the emission spot.
  137815. */
  137816. exponent: number;
  137817. private _projectionTextureMatrix;
  137818. /**
  137819. * Allows reading the projecton texture
  137820. */
  137821. get projectionTextureMatrix(): Matrix;
  137822. protected _projectionTextureLightNear: number;
  137823. /**
  137824. * Gets the near clip of the Spotlight for texture projection.
  137825. */
  137826. get projectionTextureLightNear(): number;
  137827. /**
  137828. * Sets the near clip of the Spotlight for texture projection.
  137829. */
  137830. set projectionTextureLightNear(value: number);
  137831. protected _projectionTextureLightFar: number;
  137832. /**
  137833. * Gets the far clip of the Spotlight for texture projection.
  137834. */
  137835. get projectionTextureLightFar(): number;
  137836. /**
  137837. * Sets the far clip of the Spotlight for texture projection.
  137838. */
  137839. set projectionTextureLightFar(value: number);
  137840. protected _projectionTextureUpDirection: Vector3;
  137841. /**
  137842. * Gets the Up vector of the Spotlight for texture projection.
  137843. */
  137844. get projectionTextureUpDirection(): Vector3;
  137845. /**
  137846. * Sets the Up vector of the Spotlight for texture projection.
  137847. */
  137848. set projectionTextureUpDirection(value: Vector3);
  137849. private _projectionTexture;
  137850. /**
  137851. * Gets the projection texture of the light.
  137852. */
  137853. get projectionTexture(): Nullable<BaseTexture>;
  137854. /**
  137855. * Sets the projection texture of the light.
  137856. */
  137857. set projectionTexture(value: Nullable<BaseTexture>);
  137858. private _projectionTextureViewLightDirty;
  137859. private _projectionTextureProjectionLightDirty;
  137860. private _projectionTextureDirty;
  137861. private _projectionTextureViewTargetVector;
  137862. private _projectionTextureViewLightMatrix;
  137863. private _projectionTextureProjectionLightMatrix;
  137864. private _projectionTextureScalingMatrix;
  137865. /**
  137866. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  137867. * It can cast shadows.
  137868. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137869. * @param name The light friendly name
  137870. * @param position The position of the spot light in the scene
  137871. * @param direction The direction of the light in the scene
  137872. * @param angle The cone angle of the light in Radians
  137873. * @param exponent The light decay speed with the distance from the emission spot
  137874. * @param scene The scene the lights belongs to
  137875. */
  137876. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  137877. /**
  137878. * Returns the string "SpotLight".
  137879. * @returns the class name
  137880. */
  137881. getClassName(): string;
  137882. /**
  137883. * Returns the integer 2.
  137884. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137885. */
  137886. getTypeID(): number;
  137887. /**
  137888. * Overrides the direction setter to recompute the projection texture view light Matrix.
  137889. */
  137890. protected _setDirection(value: Vector3): void;
  137891. /**
  137892. * Overrides the position setter to recompute the projection texture view light Matrix.
  137893. */
  137894. protected _setPosition(value: Vector3): void;
  137895. /**
  137896. * 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.
  137897. * Returns the SpotLight.
  137898. */
  137899. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137900. protected _computeProjectionTextureViewLightMatrix(): void;
  137901. protected _computeProjectionTextureProjectionLightMatrix(): void;
  137902. /**
  137903. * Main function for light texture projection matrix computing.
  137904. */
  137905. protected _computeProjectionTextureMatrix(): void;
  137906. protected _buildUniformLayout(): void;
  137907. private _computeAngleValues;
  137908. /**
  137909. * Sets the passed Effect "effect" with the Light textures.
  137910. * @param effect The effect to update
  137911. * @param lightIndex The index of the light in the effect to update
  137912. * @returns The light
  137913. */
  137914. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  137915. /**
  137916. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  137917. * @param effect The effect to update
  137918. * @param lightIndex The index of the light in the effect to update
  137919. * @returns The spot light
  137920. */
  137921. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  137922. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137923. /**
  137924. * Disposes the light and the associated resources.
  137925. */
  137926. dispose(): void;
  137927. /**
  137928. * Prepares the list of defines specific to the light type.
  137929. * @param defines the list of defines
  137930. * @param lightIndex defines the index of the light for the effect
  137931. */
  137932. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137933. }
  137934. }
  137935. declare module BABYLON {
  137936. /**
  137937. * Gizmo that enables viewing a light
  137938. */
  137939. export class LightGizmo extends Gizmo {
  137940. private _lightMesh;
  137941. private _material;
  137942. private _cachedPosition;
  137943. private _cachedForward;
  137944. private _attachedMeshParent;
  137945. private _pointerObserver;
  137946. /**
  137947. * Event that fires each time the gizmo is clicked
  137948. */
  137949. onClickedObservable: Observable<Light>;
  137950. /**
  137951. * Creates a LightGizmo
  137952. * @param gizmoLayer The utility layer the gizmo will be added to
  137953. */
  137954. constructor(gizmoLayer?: UtilityLayerRenderer);
  137955. private _light;
  137956. /**
  137957. * The light that the gizmo is attached to
  137958. */
  137959. set light(light: Nullable<Light>);
  137960. get light(): Nullable<Light>;
  137961. /**
  137962. * Gets the material used to render the light gizmo
  137963. */
  137964. get material(): StandardMaterial;
  137965. /**
  137966. * @hidden
  137967. * Updates the gizmo to match the attached mesh's position/rotation
  137968. */
  137969. protected _update(): void;
  137970. private static _Scale;
  137971. /**
  137972. * Creates the lines for a light mesh
  137973. */
  137974. private static _CreateLightLines;
  137975. /**
  137976. * Disposes of the light gizmo
  137977. */
  137978. dispose(): void;
  137979. private static _CreateHemisphericLightMesh;
  137980. private static _CreatePointLightMesh;
  137981. private static _CreateSpotLightMesh;
  137982. private static _CreateDirectionalLightMesh;
  137983. }
  137984. }
  137985. declare module BABYLON {
  137986. /**
  137987. * Gizmo that enables viewing a camera
  137988. */
  137989. export class CameraGizmo extends Gizmo {
  137990. private _cameraMesh;
  137991. private _cameraLinesMesh;
  137992. private _material;
  137993. private _pointerObserver;
  137994. /**
  137995. * Event that fires each time the gizmo is clicked
  137996. */
  137997. onClickedObservable: Observable<Camera>;
  137998. /**
  137999. * Creates a CameraGizmo
  138000. * @param gizmoLayer The utility layer the gizmo will be added to
  138001. */
  138002. constructor(gizmoLayer?: UtilityLayerRenderer);
  138003. private _camera;
  138004. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  138005. get displayFrustum(): boolean;
  138006. set displayFrustum(value: boolean);
  138007. /**
  138008. * The camera that the gizmo is attached to
  138009. */
  138010. set camera(camera: Nullable<Camera>);
  138011. get camera(): Nullable<Camera>;
  138012. /**
  138013. * Gets the material used to render the camera gizmo
  138014. */
  138015. get material(): StandardMaterial;
  138016. /**
  138017. * @hidden
  138018. * Updates the gizmo to match the attached mesh's position/rotation
  138019. */
  138020. protected _update(): void;
  138021. private static _Scale;
  138022. private _invProjection;
  138023. /**
  138024. * Disposes of the camera gizmo
  138025. */
  138026. dispose(): void;
  138027. private static _CreateCameraMesh;
  138028. private static _CreateCameraFrustum;
  138029. }
  138030. }
  138031. declare module BABYLON {
  138032. /** @hidden */
  138033. export var backgroundFragmentDeclaration: {
  138034. name: string;
  138035. shader: string;
  138036. };
  138037. }
  138038. declare module BABYLON {
  138039. /** @hidden */
  138040. export var backgroundUboDeclaration: {
  138041. name: string;
  138042. shader: string;
  138043. };
  138044. }
  138045. declare module BABYLON {
  138046. /** @hidden */
  138047. export var backgroundPixelShader: {
  138048. name: string;
  138049. shader: string;
  138050. };
  138051. }
  138052. declare module BABYLON {
  138053. /** @hidden */
  138054. export var backgroundVertexDeclaration: {
  138055. name: string;
  138056. shader: string;
  138057. };
  138058. }
  138059. declare module BABYLON {
  138060. /** @hidden */
  138061. export var backgroundVertexShader: {
  138062. name: string;
  138063. shader: string;
  138064. };
  138065. }
  138066. declare module BABYLON {
  138067. /**
  138068. * Background material used to create an efficient environement around your scene.
  138069. */
  138070. export class BackgroundMaterial extends PushMaterial {
  138071. /**
  138072. * Standard reflectance value at parallel view angle.
  138073. */
  138074. static StandardReflectance0: number;
  138075. /**
  138076. * Standard reflectance value at grazing angle.
  138077. */
  138078. static StandardReflectance90: number;
  138079. protected _primaryColor: Color3;
  138080. /**
  138081. * Key light Color (multiply against the environement texture)
  138082. */
  138083. primaryColor: Color3;
  138084. protected __perceptualColor: Nullable<Color3>;
  138085. /**
  138086. * Experimental Internal Use Only.
  138087. *
  138088. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  138089. * This acts as a helper to set the primary color to a more "human friendly" value.
  138090. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  138091. * output color as close as possible from the chosen value.
  138092. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  138093. * part of lighting setup.)
  138094. */
  138095. get _perceptualColor(): Nullable<Color3>;
  138096. set _perceptualColor(value: Nullable<Color3>);
  138097. protected _primaryColorShadowLevel: float;
  138098. /**
  138099. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  138100. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  138101. */
  138102. get primaryColorShadowLevel(): float;
  138103. set primaryColorShadowLevel(value: float);
  138104. protected _primaryColorHighlightLevel: float;
  138105. /**
  138106. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  138107. * The primary color is used at the level chosen to define what the white area would look.
  138108. */
  138109. get primaryColorHighlightLevel(): float;
  138110. set primaryColorHighlightLevel(value: float);
  138111. protected _reflectionTexture: Nullable<BaseTexture>;
  138112. /**
  138113. * Reflection Texture used in the material.
  138114. * Should be author in a specific way for the best result (refer to the documentation).
  138115. */
  138116. reflectionTexture: Nullable<BaseTexture>;
  138117. protected _reflectionBlur: float;
  138118. /**
  138119. * Reflection Texture level of blur.
  138120. *
  138121. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  138122. * texture twice.
  138123. */
  138124. reflectionBlur: float;
  138125. protected _diffuseTexture: Nullable<BaseTexture>;
  138126. /**
  138127. * Diffuse Texture used in the material.
  138128. * Should be author in a specific way for the best result (refer to the documentation).
  138129. */
  138130. diffuseTexture: Nullable<BaseTexture>;
  138131. protected _shadowLights: Nullable<IShadowLight[]>;
  138132. /**
  138133. * Specify the list of lights casting shadow on the material.
  138134. * All scene shadow lights will be included if null.
  138135. */
  138136. shadowLights: Nullable<IShadowLight[]>;
  138137. protected _shadowLevel: float;
  138138. /**
  138139. * Helps adjusting the shadow to a softer level if required.
  138140. * 0 means black shadows and 1 means no shadows.
  138141. */
  138142. shadowLevel: float;
  138143. protected _sceneCenter: Vector3;
  138144. /**
  138145. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  138146. * It is usually zero but might be interesting to modify according to your setup.
  138147. */
  138148. sceneCenter: Vector3;
  138149. protected _opacityFresnel: boolean;
  138150. /**
  138151. * This helps specifying that the material is falling off to the sky box at grazing angle.
  138152. * This helps ensuring a nice transition when the camera goes under the ground.
  138153. */
  138154. opacityFresnel: boolean;
  138155. protected _reflectionFresnel: boolean;
  138156. /**
  138157. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  138158. * This helps adding a mirror texture on the ground.
  138159. */
  138160. reflectionFresnel: boolean;
  138161. protected _reflectionFalloffDistance: number;
  138162. /**
  138163. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  138164. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  138165. */
  138166. reflectionFalloffDistance: number;
  138167. protected _reflectionAmount: number;
  138168. /**
  138169. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  138170. */
  138171. reflectionAmount: number;
  138172. protected _reflectionReflectance0: number;
  138173. /**
  138174. * This specifies the weight of the reflection at grazing angle.
  138175. */
  138176. reflectionReflectance0: number;
  138177. protected _reflectionReflectance90: number;
  138178. /**
  138179. * This specifies the weight of the reflection at a perpendicular point of view.
  138180. */
  138181. reflectionReflectance90: number;
  138182. /**
  138183. * Sets the reflection reflectance fresnel values according to the default standard
  138184. * empirically know to work well :-)
  138185. */
  138186. set reflectionStandardFresnelWeight(value: number);
  138187. protected _useRGBColor: boolean;
  138188. /**
  138189. * Helps to directly use the maps channels instead of their level.
  138190. */
  138191. useRGBColor: boolean;
  138192. protected _enableNoise: boolean;
  138193. /**
  138194. * This helps reducing the banding effect that could occur on the background.
  138195. */
  138196. enableNoise: boolean;
  138197. /**
  138198. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138199. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  138200. * Recommended to be keep at 1.0 except for special cases.
  138201. */
  138202. get fovMultiplier(): number;
  138203. set fovMultiplier(value: number);
  138204. private _fovMultiplier;
  138205. /**
  138206. * Enable the FOV adjustment feature controlled by fovMultiplier.
  138207. */
  138208. useEquirectangularFOV: boolean;
  138209. private _maxSimultaneousLights;
  138210. /**
  138211. * Number of Simultaneous lights allowed on the material.
  138212. */
  138213. maxSimultaneousLights: int;
  138214. private _shadowOnly;
  138215. /**
  138216. * Make the material only render shadows
  138217. */
  138218. shadowOnly: boolean;
  138219. /**
  138220. * Default configuration related to image processing available in the Background Material.
  138221. */
  138222. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  138223. /**
  138224. * Keep track of the image processing observer to allow dispose and replace.
  138225. */
  138226. private _imageProcessingObserver;
  138227. /**
  138228. * Attaches a new image processing configuration to the PBR Material.
  138229. * @param configuration (if null the scene configuration will be use)
  138230. */
  138231. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  138232. /**
  138233. * Gets the image processing configuration used either in this material.
  138234. */
  138235. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  138236. /**
  138237. * Sets the Default image processing configuration used either in the this material.
  138238. *
  138239. * If sets to null, the scene one is in use.
  138240. */
  138241. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  138242. /**
  138243. * Gets wether the color curves effect is enabled.
  138244. */
  138245. get cameraColorCurvesEnabled(): boolean;
  138246. /**
  138247. * Sets wether the color curves effect is enabled.
  138248. */
  138249. set cameraColorCurvesEnabled(value: boolean);
  138250. /**
  138251. * Gets wether the color grading effect is enabled.
  138252. */
  138253. get cameraColorGradingEnabled(): boolean;
  138254. /**
  138255. * Gets wether the color grading effect is enabled.
  138256. */
  138257. set cameraColorGradingEnabled(value: boolean);
  138258. /**
  138259. * Gets wether tonemapping is enabled or not.
  138260. */
  138261. get cameraToneMappingEnabled(): boolean;
  138262. /**
  138263. * Sets wether tonemapping is enabled or not
  138264. */
  138265. set cameraToneMappingEnabled(value: boolean);
  138266. /**
  138267. * The camera exposure used on this material.
  138268. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138269. * This corresponds to a photographic exposure.
  138270. */
  138271. get cameraExposure(): float;
  138272. /**
  138273. * The camera exposure used on this material.
  138274. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138275. * This corresponds to a photographic exposure.
  138276. */
  138277. set cameraExposure(value: float);
  138278. /**
  138279. * Gets The camera contrast used on this material.
  138280. */
  138281. get cameraContrast(): float;
  138282. /**
  138283. * Sets The camera contrast used on this material.
  138284. */
  138285. set cameraContrast(value: float);
  138286. /**
  138287. * Gets the Color Grading 2D Lookup Texture.
  138288. */
  138289. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  138290. /**
  138291. * Sets the Color Grading 2D Lookup Texture.
  138292. */
  138293. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  138294. /**
  138295. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138296. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138297. * 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;
  138298. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138299. */
  138300. get cameraColorCurves(): Nullable<ColorCurves>;
  138301. /**
  138302. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138303. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138304. * 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;
  138305. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138306. */
  138307. set cameraColorCurves(value: Nullable<ColorCurves>);
  138308. /**
  138309. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  138310. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  138311. */
  138312. switchToBGR: boolean;
  138313. private _renderTargets;
  138314. private _reflectionControls;
  138315. private _white;
  138316. private _primaryShadowColor;
  138317. private _primaryHighlightColor;
  138318. /**
  138319. * Instantiates a Background Material in the given scene
  138320. * @param name The friendly name of the material
  138321. * @param scene The scene to add the material to
  138322. */
  138323. constructor(name: string, scene: Scene);
  138324. /**
  138325. * Gets a boolean indicating that current material needs to register RTT
  138326. */
  138327. get hasRenderTargetTextures(): boolean;
  138328. /**
  138329. * The entire material has been created in order to prevent overdraw.
  138330. * @returns false
  138331. */
  138332. needAlphaTesting(): boolean;
  138333. /**
  138334. * The entire material has been created in order to prevent overdraw.
  138335. * @returns true if blending is enable
  138336. */
  138337. needAlphaBlending(): boolean;
  138338. /**
  138339. * Checks wether the material is ready to be rendered for a given mesh.
  138340. * @param mesh The mesh to render
  138341. * @param subMesh The submesh to check against
  138342. * @param useInstances Specify wether or not the material is used with instances
  138343. * @returns true if all the dependencies are ready (Textures, Effects...)
  138344. */
  138345. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  138346. /**
  138347. * Compute the primary color according to the chosen perceptual color.
  138348. */
  138349. private _computePrimaryColorFromPerceptualColor;
  138350. /**
  138351. * Compute the highlights and shadow colors according to their chosen levels.
  138352. */
  138353. private _computePrimaryColors;
  138354. /**
  138355. * Build the uniform buffer used in the material.
  138356. */
  138357. buildUniformLayout(): void;
  138358. /**
  138359. * Unbind the material.
  138360. */
  138361. unbind(): void;
  138362. /**
  138363. * Bind only the world matrix to the material.
  138364. * @param world The world matrix to bind.
  138365. */
  138366. bindOnlyWorldMatrix(world: Matrix): void;
  138367. /**
  138368. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  138369. * @param world The world matrix to bind.
  138370. * @param subMesh The submesh to bind for.
  138371. */
  138372. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  138373. /**
  138374. * Checks to see if a texture is used in the material.
  138375. * @param texture - Base texture to use.
  138376. * @returns - Boolean specifying if a texture is used in the material.
  138377. */
  138378. hasTexture(texture: BaseTexture): boolean;
  138379. /**
  138380. * Dispose the material.
  138381. * @param forceDisposeEffect Force disposal of the associated effect.
  138382. * @param forceDisposeTextures Force disposal of the associated textures.
  138383. */
  138384. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  138385. /**
  138386. * Clones the material.
  138387. * @param name The cloned name.
  138388. * @returns The cloned material.
  138389. */
  138390. clone(name: string): BackgroundMaterial;
  138391. /**
  138392. * Serializes the current material to its JSON representation.
  138393. * @returns The JSON representation.
  138394. */
  138395. serialize(): any;
  138396. /**
  138397. * Gets the class name of the material
  138398. * @returns "BackgroundMaterial"
  138399. */
  138400. getClassName(): string;
  138401. /**
  138402. * Parse a JSON input to create back a background material.
  138403. * @param source The JSON data to parse
  138404. * @param scene The scene to create the parsed material in
  138405. * @param rootUrl The root url of the assets the material depends upon
  138406. * @returns the instantiated BackgroundMaterial.
  138407. */
  138408. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  138409. }
  138410. }
  138411. declare module BABYLON {
  138412. /**
  138413. * Represents the different options available during the creation of
  138414. * a Environment helper.
  138415. *
  138416. * This can control the default ground, skybox and image processing setup of your scene.
  138417. */
  138418. export interface IEnvironmentHelperOptions {
  138419. /**
  138420. * Specifies whether or not to create a ground.
  138421. * True by default.
  138422. */
  138423. createGround: boolean;
  138424. /**
  138425. * Specifies the ground size.
  138426. * 15 by default.
  138427. */
  138428. groundSize: number;
  138429. /**
  138430. * The texture used on the ground for the main color.
  138431. * Comes from the BabylonJS CDN by default.
  138432. *
  138433. * Remarks: Can be either a texture or a url.
  138434. */
  138435. groundTexture: string | BaseTexture;
  138436. /**
  138437. * The color mixed in the ground texture by default.
  138438. * BabylonJS clearColor by default.
  138439. */
  138440. groundColor: Color3;
  138441. /**
  138442. * Specifies the ground opacity.
  138443. * 1 by default.
  138444. */
  138445. groundOpacity: number;
  138446. /**
  138447. * Enables the ground to receive shadows.
  138448. * True by default.
  138449. */
  138450. enableGroundShadow: boolean;
  138451. /**
  138452. * Helps preventing the shadow to be fully black on the ground.
  138453. * 0.5 by default.
  138454. */
  138455. groundShadowLevel: number;
  138456. /**
  138457. * Creates a mirror texture attach to the ground.
  138458. * false by default.
  138459. */
  138460. enableGroundMirror: boolean;
  138461. /**
  138462. * Specifies the ground mirror size ratio.
  138463. * 0.3 by default as the default kernel is 64.
  138464. */
  138465. groundMirrorSizeRatio: number;
  138466. /**
  138467. * Specifies the ground mirror blur kernel size.
  138468. * 64 by default.
  138469. */
  138470. groundMirrorBlurKernel: number;
  138471. /**
  138472. * Specifies the ground mirror visibility amount.
  138473. * 1 by default
  138474. */
  138475. groundMirrorAmount: number;
  138476. /**
  138477. * Specifies the ground mirror reflectance weight.
  138478. * This uses the standard weight of the background material to setup the fresnel effect
  138479. * of the mirror.
  138480. * 1 by default.
  138481. */
  138482. groundMirrorFresnelWeight: number;
  138483. /**
  138484. * Specifies the ground mirror Falloff distance.
  138485. * This can helps reducing the size of the reflection.
  138486. * 0 by Default.
  138487. */
  138488. groundMirrorFallOffDistance: number;
  138489. /**
  138490. * Specifies the ground mirror texture type.
  138491. * Unsigned Int by Default.
  138492. */
  138493. groundMirrorTextureType: number;
  138494. /**
  138495. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  138496. * the shown objects.
  138497. */
  138498. groundYBias: number;
  138499. /**
  138500. * Specifies whether or not to create a skybox.
  138501. * True by default.
  138502. */
  138503. createSkybox: boolean;
  138504. /**
  138505. * Specifies the skybox size.
  138506. * 20 by default.
  138507. */
  138508. skyboxSize: number;
  138509. /**
  138510. * The texture used on the skybox for the main color.
  138511. * Comes from the BabylonJS CDN by default.
  138512. *
  138513. * Remarks: Can be either a texture or a url.
  138514. */
  138515. skyboxTexture: string | BaseTexture;
  138516. /**
  138517. * The color mixed in the skybox texture by default.
  138518. * BabylonJS clearColor by default.
  138519. */
  138520. skyboxColor: Color3;
  138521. /**
  138522. * The background rotation around the Y axis of the scene.
  138523. * This helps aligning the key lights of your scene with the background.
  138524. * 0 by default.
  138525. */
  138526. backgroundYRotation: number;
  138527. /**
  138528. * Compute automatically the size of the elements to best fit with the scene.
  138529. */
  138530. sizeAuto: boolean;
  138531. /**
  138532. * Default position of the rootMesh if autoSize is not true.
  138533. */
  138534. rootPosition: Vector3;
  138535. /**
  138536. * Sets up the image processing in the scene.
  138537. * true by default.
  138538. */
  138539. setupImageProcessing: boolean;
  138540. /**
  138541. * The texture used as your environment texture in the scene.
  138542. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  138543. *
  138544. * Remarks: Can be either a texture or a url.
  138545. */
  138546. environmentTexture: string | BaseTexture;
  138547. /**
  138548. * The value of the exposure to apply to the scene.
  138549. * 0.6 by default if setupImageProcessing is true.
  138550. */
  138551. cameraExposure: number;
  138552. /**
  138553. * The value of the contrast to apply to the scene.
  138554. * 1.6 by default if setupImageProcessing is true.
  138555. */
  138556. cameraContrast: number;
  138557. /**
  138558. * Specifies whether or not tonemapping should be enabled in the scene.
  138559. * true by default if setupImageProcessing is true.
  138560. */
  138561. toneMappingEnabled: boolean;
  138562. }
  138563. /**
  138564. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  138565. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  138566. * It also helps with the default setup of your imageProcessing configuration.
  138567. */
  138568. export class EnvironmentHelper {
  138569. /**
  138570. * Default ground texture URL.
  138571. */
  138572. private static _groundTextureCDNUrl;
  138573. /**
  138574. * Default skybox texture URL.
  138575. */
  138576. private static _skyboxTextureCDNUrl;
  138577. /**
  138578. * Default environment texture URL.
  138579. */
  138580. private static _environmentTextureCDNUrl;
  138581. /**
  138582. * Creates the default options for the helper.
  138583. */
  138584. private static _getDefaultOptions;
  138585. private _rootMesh;
  138586. /**
  138587. * Gets the root mesh created by the helper.
  138588. */
  138589. get rootMesh(): Mesh;
  138590. private _skybox;
  138591. /**
  138592. * Gets the skybox created by the helper.
  138593. */
  138594. get skybox(): Nullable<Mesh>;
  138595. private _skyboxTexture;
  138596. /**
  138597. * Gets the skybox texture created by the helper.
  138598. */
  138599. get skyboxTexture(): Nullable<BaseTexture>;
  138600. private _skyboxMaterial;
  138601. /**
  138602. * Gets the skybox material created by the helper.
  138603. */
  138604. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  138605. private _ground;
  138606. /**
  138607. * Gets the ground mesh created by the helper.
  138608. */
  138609. get ground(): Nullable<Mesh>;
  138610. private _groundTexture;
  138611. /**
  138612. * Gets the ground texture created by the helper.
  138613. */
  138614. get groundTexture(): Nullable<BaseTexture>;
  138615. private _groundMirror;
  138616. /**
  138617. * Gets the ground mirror created by the helper.
  138618. */
  138619. get groundMirror(): Nullable<MirrorTexture>;
  138620. /**
  138621. * Gets the ground mirror render list to helps pushing the meshes
  138622. * you wish in the ground reflection.
  138623. */
  138624. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  138625. private _groundMaterial;
  138626. /**
  138627. * Gets the ground material created by the helper.
  138628. */
  138629. get groundMaterial(): Nullable<BackgroundMaterial>;
  138630. /**
  138631. * Stores the creation options.
  138632. */
  138633. private readonly _scene;
  138634. private _options;
  138635. /**
  138636. * This observable will be notified with any error during the creation of the environment,
  138637. * mainly texture creation errors.
  138638. */
  138639. onErrorObservable: Observable<{
  138640. message?: string;
  138641. exception?: any;
  138642. }>;
  138643. /**
  138644. * constructor
  138645. * @param options Defines the options we want to customize the helper
  138646. * @param scene The scene to add the material to
  138647. */
  138648. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  138649. /**
  138650. * Updates the background according to the new options
  138651. * @param options
  138652. */
  138653. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  138654. /**
  138655. * Sets the primary color of all the available elements.
  138656. * @param color the main color to affect to the ground and the background
  138657. */
  138658. setMainColor(color: Color3): void;
  138659. /**
  138660. * Setup the image processing according to the specified options.
  138661. */
  138662. private _setupImageProcessing;
  138663. /**
  138664. * Setup the environment texture according to the specified options.
  138665. */
  138666. private _setupEnvironmentTexture;
  138667. /**
  138668. * Setup the background according to the specified options.
  138669. */
  138670. private _setupBackground;
  138671. /**
  138672. * Get the scene sizes according to the setup.
  138673. */
  138674. private _getSceneSize;
  138675. /**
  138676. * Setup the ground according to the specified options.
  138677. */
  138678. private _setupGround;
  138679. /**
  138680. * Setup the ground material according to the specified options.
  138681. */
  138682. private _setupGroundMaterial;
  138683. /**
  138684. * Setup the ground diffuse texture according to the specified options.
  138685. */
  138686. private _setupGroundDiffuseTexture;
  138687. /**
  138688. * Setup the ground mirror texture according to the specified options.
  138689. */
  138690. private _setupGroundMirrorTexture;
  138691. /**
  138692. * Setup the ground to receive the mirror texture.
  138693. */
  138694. private _setupMirrorInGroundMaterial;
  138695. /**
  138696. * Setup the skybox according to the specified options.
  138697. */
  138698. private _setupSkybox;
  138699. /**
  138700. * Setup the skybox material according to the specified options.
  138701. */
  138702. private _setupSkyboxMaterial;
  138703. /**
  138704. * Setup the skybox reflection texture according to the specified options.
  138705. */
  138706. private _setupSkyboxReflectionTexture;
  138707. private _errorHandler;
  138708. /**
  138709. * Dispose all the elements created by the Helper.
  138710. */
  138711. dispose(): void;
  138712. }
  138713. }
  138714. declare module BABYLON {
  138715. /**
  138716. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  138717. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  138718. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138719. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138720. */
  138721. export abstract class TextureDome<T extends Texture> extends TransformNode {
  138722. protected onError: Nullable<(message?: string, exception?: any) => void>;
  138723. /**
  138724. * Define the source as a Monoscopic panoramic 360/180.
  138725. */
  138726. static readonly MODE_MONOSCOPIC: number;
  138727. /**
  138728. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  138729. */
  138730. static readonly MODE_TOPBOTTOM: number;
  138731. /**
  138732. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  138733. */
  138734. static readonly MODE_SIDEBYSIDE: number;
  138735. private _halfDome;
  138736. private _crossEye;
  138737. protected _useDirectMapping: boolean;
  138738. /**
  138739. * The texture being displayed on the sphere
  138740. */
  138741. protected _texture: T;
  138742. /**
  138743. * Gets the texture being displayed on the sphere
  138744. */
  138745. get texture(): T;
  138746. /**
  138747. * Sets the texture being displayed on the sphere
  138748. */
  138749. set texture(newTexture: T);
  138750. /**
  138751. * The skybox material
  138752. */
  138753. protected _material: BackgroundMaterial;
  138754. /**
  138755. * The surface used for the dome
  138756. */
  138757. protected _mesh: Mesh;
  138758. /**
  138759. * Gets the mesh used for the dome.
  138760. */
  138761. get mesh(): Mesh;
  138762. /**
  138763. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  138764. */
  138765. private _halfDomeMask;
  138766. /**
  138767. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138768. * Also see the options.resolution property.
  138769. */
  138770. get fovMultiplier(): number;
  138771. set fovMultiplier(value: number);
  138772. protected _textureMode: number;
  138773. /**
  138774. * Gets or set the current texture mode for the texture. It can be:
  138775. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138776. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138777. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138778. */
  138779. get textureMode(): number;
  138780. /**
  138781. * Sets the current texture mode for the texture. It can be:
  138782. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138783. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138784. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138785. */
  138786. set textureMode(value: number);
  138787. /**
  138788. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  138789. */
  138790. get halfDome(): boolean;
  138791. /**
  138792. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  138793. */
  138794. set halfDome(enabled: boolean);
  138795. /**
  138796. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  138797. */
  138798. set crossEye(enabled: boolean);
  138799. /**
  138800. * Is it a cross-eye texture?
  138801. */
  138802. get crossEye(): boolean;
  138803. /**
  138804. * Oberserver used in Stereoscopic VR Mode.
  138805. */
  138806. private _onBeforeCameraRenderObserver;
  138807. /**
  138808. * Observable raised when an error occured while loading the 360 image
  138809. */
  138810. onLoadErrorObservable: Observable<string>;
  138811. /**
  138812. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  138813. * @param name Element's name, child elements will append suffixes for their own names.
  138814. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  138815. * @param options An object containing optional or exposed sub element properties
  138816. */
  138817. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  138818. resolution?: number;
  138819. clickToPlay?: boolean;
  138820. autoPlay?: boolean;
  138821. loop?: boolean;
  138822. size?: number;
  138823. poster?: string;
  138824. faceForward?: boolean;
  138825. useDirectMapping?: boolean;
  138826. halfDomeMode?: boolean;
  138827. crossEyeMode?: boolean;
  138828. generateMipMaps?: boolean;
  138829. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  138830. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  138831. protected _changeTextureMode(value: number): void;
  138832. /**
  138833. * Releases resources associated with this node.
  138834. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  138835. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  138836. */
  138837. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  138838. }
  138839. }
  138840. declare module BABYLON {
  138841. /**
  138842. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  138843. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  138844. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138845. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138846. */
  138847. export class PhotoDome extends TextureDome<Texture> {
  138848. /**
  138849. * Define the image as a Monoscopic panoramic 360 image.
  138850. */
  138851. static readonly MODE_MONOSCOPIC: number;
  138852. /**
  138853. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  138854. */
  138855. static readonly MODE_TOPBOTTOM: number;
  138856. /**
  138857. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  138858. */
  138859. static readonly MODE_SIDEBYSIDE: number;
  138860. /**
  138861. * Gets or sets the texture being displayed on the sphere
  138862. */
  138863. get photoTexture(): Texture;
  138864. /**
  138865. * sets the texture being displayed on the sphere
  138866. */
  138867. set photoTexture(value: Texture);
  138868. /**
  138869. * Gets the current video mode for the video. It can be:
  138870. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138871. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138872. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138873. */
  138874. get imageMode(): number;
  138875. /**
  138876. * Sets the current video mode for the video. It can be:
  138877. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138878. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138879. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138880. */
  138881. set imageMode(value: number);
  138882. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  138883. }
  138884. }
  138885. declare module BABYLON {
  138886. /**
  138887. * Direct draw surface info
  138888. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  138889. */
  138890. export interface DDSInfo {
  138891. /**
  138892. * Width of the texture
  138893. */
  138894. width: number;
  138895. /**
  138896. * Width of the texture
  138897. */
  138898. height: number;
  138899. /**
  138900. * Number of Mipmaps for the texture
  138901. * @see https://en.wikipedia.org/wiki/Mipmap
  138902. */
  138903. mipmapCount: number;
  138904. /**
  138905. * If the textures format is a known fourCC format
  138906. * @see https://www.fourcc.org/
  138907. */
  138908. isFourCC: boolean;
  138909. /**
  138910. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  138911. */
  138912. isRGB: boolean;
  138913. /**
  138914. * If the texture is a lumincance format
  138915. */
  138916. isLuminance: boolean;
  138917. /**
  138918. * If this is a cube texture
  138919. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  138920. */
  138921. isCube: boolean;
  138922. /**
  138923. * If the texture is a compressed format eg. FOURCC_DXT1
  138924. */
  138925. isCompressed: boolean;
  138926. /**
  138927. * The dxgiFormat of the texture
  138928. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  138929. */
  138930. dxgiFormat: number;
  138931. /**
  138932. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  138933. */
  138934. textureType: number;
  138935. /**
  138936. * Sphericle polynomial created for the dds texture
  138937. */
  138938. sphericalPolynomial?: SphericalPolynomial;
  138939. }
  138940. /**
  138941. * Class used to provide DDS decompression tools
  138942. */
  138943. export class DDSTools {
  138944. /**
  138945. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138946. */
  138947. static StoreLODInAlphaChannel: boolean;
  138948. /**
  138949. * Gets DDS information from an array buffer
  138950. * @param data defines the array buffer view to read data from
  138951. * @returns the DDS information
  138952. */
  138953. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138954. private static _FloatView;
  138955. private static _Int32View;
  138956. private static _ToHalfFloat;
  138957. private static _FromHalfFloat;
  138958. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138959. private static _GetHalfFloatRGBAArrayBuffer;
  138960. private static _GetFloatRGBAArrayBuffer;
  138961. private static _GetFloatAsUIntRGBAArrayBuffer;
  138962. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138963. private static _GetRGBAArrayBuffer;
  138964. private static _ExtractLongWordOrder;
  138965. private static _GetRGBArrayBuffer;
  138966. private static _GetLuminanceArrayBuffer;
  138967. /**
  138968. * Uploads DDS Levels to a Babylon Texture
  138969. * @hidden
  138970. */
  138971. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138972. }
  138973. interface ThinEngine {
  138974. /**
  138975. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138976. * @param rootUrl defines the url where the file to load is located
  138977. * @param scene defines the current scene
  138978. * @param lodScale defines scale to apply to the mip map selection
  138979. * @param lodOffset defines offset to apply to the mip map selection
  138980. * @param onLoad defines an optional callback raised when the texture is loaded
  138981. * @param onError defines an optional callback raised if there is an issue to load the texture
  138982. * @param format defines the format of the data
  138983. * @param forcedExtension defines the extension to use to pick the right loader
  138984. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138985. * @returns the cube texture as an InternalTexture
  138986. */
  138987. 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;
  138988. }
  138989. }
  138990. declare module BABYLON {
  138991. /**
  138992. * Implementation of the DDS Texture Loader.
  138993. * @hidden
  138994. */
  138995. export class _DDSTextureLoader implements IInternalTextureLoader {
  138996. /**
  138997. * Defines wether the loader supports cascade loading the different faces.
  138998. */
  138999. readonly supportCascades: boolean;
  139000. /**
  139001. * This returns if the loader support the current file information.
  139002. * @param extension defines the file extension of the file being loaded
  139003. * @returns true if the loader can load the specified file
  139004. */
  139005. canLoad(extension: string): boolean;
  139006. /**
  139007. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139008. * @param data contains the texture data
  139009. * @param texture defines the BabylonJS internal texture
  139010. * @param createPolynomials will be true if polynomials have been requested
  139011. * @param onLoad defines the callback to trigger once the texture is ready
  139012. * @param onError defines the callback to trigger in case of error
  139013. */
  139014. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139015. /**
  139016. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139017. * @param data contains the texture data
  139018. * @param texture defines the BabylonJS internal texture
  139019. * @param callback defines the method to call once ready to upload
  139020. */
  139021. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139022. }
  139023. }
  139024. declare module BABYLON {
  139025. /**
  139026. * Implementation of the ENV Texture Loader.
  139027. * @hidden
  139028. */
  139029. export class _ENVTextureLoader implements IInternalTextureLoader {
  139030. /**
  139031. * Defines wether the loader supports cascade loading the different faces.
  139032. */
  139033. readonly supportCascades: boolean;
  139034. /**
  139035. * This returns if the loader support the current file information.
  139036. * @param extension defines the file extension of the file being loaded
  139037. * @returns true if the loader can load the specified file
  139038. */
  139039. canLoad(extension: string): boolean;
  139040. /**
  139041. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139042. * @param data contains the texture data
  139043. * @param texture defines the BabylonJS internal texture
  139044. * @param createPolynomials will be true if polynomials have been requested
  139045. * @param onLoad defines the callback to trigger once the texture is ready
  139046. * @param onError defines the callback to trigger in case of error
  139047. */
  139048. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139049. /**
  139050. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139051. * @param data contains the texture data
  139052. * @param texture defines the BabylonJS internal texture
  139053. * @param callback defines the method to call once ready to upload
  139054. */
  139055. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139056. }
  139057. }
  139058. declare module BABYLON {
  139059. /**
  139060. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  139061. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  139062. */
  139063. export class KhronosTextureContainer {
  139064. /** contents of the KTX container file */
  139065. data: ArrayBufferView;
  139066. private static HEADER_LEN;
  139067. private static COMPRESSED_2D;
  139068. private static COMPRESSED_3D;
  139069. private static TEX_2D;
  139070. private static TEX_3D;
  139071. /**
  139072. * Gets the openGL type
  139073. */
  139074. glType: number;
  139075. /**
  139076. * Gets the openGL type size
  139077. */
  139078. glTypeSize: number;
  139079. /**
  139080. * Gets the openGL format
  139081. */
  139082. glFormat: number;
  139083. /**
  139084. * Gets the openGL internal format
  139085. */
  139086. glInternalFormat: number;
  139087. /**
  139088. * Gets the base internal format
  139089. */
  139090. glBaseInternalFormat: number;
  139091. /**
  139092. * Gets image width in pixel
  139093. */
  139094. pixelWidth: number;
  139095. /**
  139096. * Gets image height in pixel
  139097. */
  139098. pixelHeight: number;
  139099. /**
  139100. * Gets image depth in pixels
  139101. */
  139102. pixelDepth: number;
  139103. /**
  139104. * Gets the number of array elements
  139105. */
  139106. numberOfArrayElements: number;
  139107. /**
  139108. * Gets the number of faces
  139109. */
  139110. numberOfFaces: number;
  139111. /**
  139112. * Gets the number of mipmap levels
  139113. */
  139114. numberOfMipmapLevels: number;
  139115. /**
  139116. * Gets the bytes of key value data
  139117. */
  139118. bytesOfKeyValueData: number;
  139119. /**
  139120. * Gets the load type
  139121. */
  139122. loadType: number;
  139123. /**
  139124. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  139125. */
  139126. isInvalid: boolean;
  139127. /**
  139128. * Creates a new KhronosTextureContainer
  139129. * @param data contents of the KTX container file
  139130. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  139131. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  139132. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  139133. */
  139134. constructor(
  139135. /** contents of the KTX container file */
  139136. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  139137. /**
  139138. * Uploads KTX content to a Babylon Texture.
  139139. * It is assumed that the texture has already been created & is currently bound
  139140. * @hidden
  139141. */
  139142. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  139143. private _upload2DCompressedLevels;
  139144. /**
  139145. * Checks if the given data starts with a KTX file identifier.
  139146. * @param data the data to check
  139147. * @returns true if the data is a KTX file or false otherwise
  139148. */
  139149. static IsValid(data: ArrayBufferView): boolean;
  139150. }
  139151. }
  139152. declare module BABYLON {
  139153. /**
  139154. * Helper class to push actions to a pool of workers.
  139155. */
  139156. export class WorkerPool implements IDisposable {
  139157. private _workerInfos;
  139158. private _pendingActions;
  139159. /**
  139160. * Constructor
  139161. * @param workers Array of workers to use for actions
  139162. */
  139163. constructor(workers: Array<Worker>);
  139164. /**
  139165. * Terminates all workers and clears any pending actions.
  139166. */
  139167. dispose(): void;
  139168. /**
  139169. * Pushes an action to the worker pool. If all the workers are active, the action will be
  139170. * pended until a worker has completed its action.
  139171. * @param action The action to perform. Call onComplete when the action is complete.
  139172. */
  139173. push(action: (worker: Worker, onComplete: () => void) => void): void;
  139174. private _execute;
  139175. }
  139176. }
  139177. declare module BABYLON {
  139178. /**
  139179. * Class for loading KTX2 files
  139180. */
  139181. export class KhronosTextureContainer2 {
  139182. private static _WorkerPoolPromise?;
  139183. private static _Initialized;
  139184. private static _Ktx2Decoder;
  139185. /**
  139186. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  139187. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  139188. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  139189. * Urls you can change:
  139190. * URLConfig.jsDecoderModule
  139191. * URLConfig.wasmUASTCToASTC
  139192. * URLConfig.wasmUASTCToBC7
  139193. * URLConfig.jsMSCTranscoder
  139194. * URLConfig.wasmMSCTranscoder
  139195. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  139196. */
  139197. static URLConfig: {
  139198. jsDecoderModule: string;
  139199. wasmUASTCToASTC: null;
  139200. wasmUASTCToBC7: null;
  139201. jsMSCTranscoder: null;
  139202. wasmMSCTranscoder: null;
  139203. };
  139204. /**
  139205. * Default number of workers used to handle data decoding
  139206. */
  139207. static DefaultNumWorkers: number;
  139208. private static GetDefaultNumWorkers;
  139209. private _engine;
  139210. private static _CreateWorkerPool;
  139211. /**
  139212. * Constructor
  139213. * @param engine The engine to use
  139214. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  139215. */
  139216. constructor(engine: ThinEngine, numWorkers?: number);
  139217. /** @hidden */
  139218. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  139219. /**
  139220. * Stop all async operations and release resources.
  139221. */
  139222. dispose(): void;
  139223. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  139224. /**
  139225. * Checks if the given data starts with a KTX2 file identifier.
  139226. * @param data the data to check
  139227. * @returns true if the data is a KTX2 file or false otherwise
  139228. */
  139229. static IsValid(data: ArrayBufferView): boolean;
  139230. }
  139231. }
  139232. declare module BABYLON {
  139233. /**
  139234. * Implementation of the KTX Texture Loader.
  139235. * @hidden
  139236. */
  139237. export class _KTXTextureLoader implements IInternalTextureLoader {
  139238. /**
  139239. * Defines wether the loader supports cascade loading the different faces.
  139240. */
  139241. readonly supportCascades: boolean;
  139242. /**
  139243. * This returns if the loader support the current file information.
  139244. * @param extension defines the file extension of the file being loaded
  139245. * @param mimeType defines the optional mime type of the file being loaded
  139246. * @returns true if the loader can load the specified file
  139247. */
  139248. canLoad(extension: string, mimeType?: string): boolean;
  139249. /**
  139250. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139251. * @param data contains the texture data
  139252. * @param texture defines the BabylonJS internal texture
  139253. * @param createPolynomials will be true if polynomials have been requested
  139254. * @param onLoad defines the callback to trigger once the texture is ready
  139255. * @param onError defines the callback to trigger in case of error
  139256. */
  139257. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139258. /**
  139259. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139260. * @param data contains the texture data
  139261. * @param texture defines the BabylonJS internal texture
  139262. * @param callback defines the method to call once ready to upload
  139263. */
  139264. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  139265. }
  139266. }
  139267. declare module BABYLON {
  139268. /** @hidden */
  139269. export var _forceSceneHelpersToBundle: boolean;
  139270. interface Scene {
  139271. /**
  139272. * Creates a default light for the scene.
  139273. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  139274. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  139275. */
  139276. createDefaultLight(replace?: boolean): void;
  139277. /**
  139278. * Creates a default camera for the scene.
  139279. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  139280. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139281. * @param replace has default false, when true replaces the active camera in the scene
  139282. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  139283. */
  139284. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139285. /**
  139286. * Creates a default camera and a default light.
  139287. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  139288. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139289. * @param replace has the default false, when true replaces the active camera/light in the scene
  139290. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  139291. */
  139292. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139293. /**
  139294. * Creates a new sky box
  139295. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  139296. * @param environmentTexture defines the texture to use as environment texture
  139297. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  139298. * @param scale defines the overall scale of the skybox
  139299. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  139300. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  139301. * @returns a new mesh holding the sky box
  139302. */
  139303. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  139304. /**
  139305. * Creates a new environment
  139306. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  139307. * @param options defines the options you can use to configure the environment
  139308. * @returns the new EnvironmentHelper
  139309. */
  139310. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  139311. /**
  139312. * Creates a new VREXperienceHelper
  139313. * @see https://doc.babylonjs.com/how_to/webvr_helper
  139314. * @param webVROptions defines the options used to create the new VREXperienceHelper
  139315. * @returns a new VREXperienceHelper
  139316. */
  139317. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  139318. /**
  139319. * Creates a new WebXRDefaultExperience
  139320. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  139321. * @param options experience options
  139322. * @returns a promise for a new WebXRDefaultExperience
  139323. */
  139324. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  139325. }
  139326. }
  139327. declare module BABYLON {
  139328. /**
  139329. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  139330. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  139331. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  139332. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139333. */
  139334. export class VideoDome extends TextureDome<VideoTexture> {
  139335. /**
  139336. * Define the video source as a Monoscopic panoramic 360 video.
  139337. */
  139338. static readonly MODE_MONOSCOPIC: number;
  139339. /**
  139340. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  139341. */
  139342. static readonly MODE_TOPBOTTOM: number;
  139343. /**
  139344. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  139345. */
  139346. static readonly MODE_SIDEBYSIDE: number;
  139347. /**
  139348. * Get the video texture associated with this video dome
  139349. */
  139350. get videoTexture(): VideoTexture;
  139351. /**
  139352. * Get the video mode of this dome
  139353. */
  139354. get videoMode(): number;
  139355. /**
  139356. * Set the video mode of this dome.
  139357. * @see textureMode
  139358. */
  139359. set videoMode(value: number);
  139360. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  139361. }
  139362. }
  139363. declare module BABYLON {
  139364. /**
  139365. * This class can be used to get instrumentation data from a Babylon engine
  139366. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139367. */
  139368. export class EngineInstrumentation implements IDisposable {
  139369. /**
  139370. * Define the instrumented engine.
  139371. */
  139372. engine: Engine;
  139373. private _captureGPUFrameTime;
  139374. private _gpuFrameTimeToken;
  139375. private _gpuFrameTime;
  139376. private _captureShaderCompilationTime;
  139377. private _shaderCompilationTime;
  139378. private _onBeginFrameObserver;
  139379. private _onEndFrameObserver;
  139380. private _onBeforeShaderCompilationObserver;
  139381. private _onAfterShaderCompilationObserver;
  139382. /**
  139383. * Gets the perf counter used for GPU frame time
  139384. */
  139385. get gpuFrameTimeCounter(): PerfCounter;
  139386. /**
  139387. * Gets the GPU frame time capture status
  139388. */
  139389. get captureGPUFrameTime(): boolean;
  139390. /**
  139391. * Enable or disable the GPU frame time capture
  139392. */
  139393. set captureGPUFrameTime(value: boolean);
  139394. /**
  139395. * Gets the perf counter used for shader compilation time
  139396. */
  139397. get shaderCompilationTimeCounter(): PerfCounter;
  139398. /**
  139399. * Gets the shader compilation time capture status
  139400. */
  139401. get captureShaderCompilationTime(): boolean;
  139402. /**
  139403. * Enable or disable the shader compilation time capture
  139404. */
  139405. set captureShaderCompilationTime(value: boolean);
  139406. /**
  139407. * Instantiates a new engine instrumentation.
  139408. * This class can be used to get instrumentation data from a Babylon engine
  139409. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139410. * @param engine Defines the engine to instrument
  139411. */
  139412. constructor(
  139413. /**
  139414. * Define the instrumented engine.
  139415. */
  139416. engine: Engine);
  139417. /**
  139418. * Dispose and release associated resources.
  139419. */
  139420. dispose(): void;
  139421. }
  139422. }
  139423. declare module BABYLON {
  139424. /**
  139425. * This class can be used to get instrumentation data from a Babylon engine
  139426. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139427. */
  139428. export class SceneInstrumentation implements IDisposable {
  139429. /**
  139430. * Defines the scene to instrument
  139431. */
  139432. scene: Scene;
  139433. private _captureActiveMeshesEvaluationTime;
  139434. private _activeMeshesEvaluationTime;
  139435. private _captureRenderTargetsRenderTime;
  139436. private _renderTargetsRenderTime;
  139437. private _captureFrameTime;
  139438. private _frameTime;
  139439. private _captureRenderTime;
  139440. private _renderTime;
  139441. private _captureInterFrameTime;
  139442. private _interFrameTime;
  139443. private _captureParticlesRenderTime;
  139444. private _particlesRenderTime;
  139445. private _captureSpritesRenderTime;
  139446. private _spritesRenderTime;
  139447. private _capturePhysicsTime;
  139448. private _physicsTime;
  139449. private _captureAnimationsTime;
  139450. private _animationsTime;
  139451. private _captureCameraRenderTime;
  139452. private _cameraRenderTime;
  139453. private _onBeforeActiveMeshesEvaluationObserver;
  139454. private _onAfterActiveMeshesEvaluationObserver;
  139455. private _onBeforeRenderTargetsRenderObserver;
  139456. private _onAfterRenderTargetsRenderObserver;
  139457. private _onAfterRenderObserver;
  139458. private _onBeforeDrawPhaseObserver;
  139459. private _onAfterDrawPhaseObserver;
  139460. private _onBeforeAnimationsObserver;
  139461. private _onBeforeParticlesRenderingObserver;
  139462. private _onAfterParticlesRenderingObserver;
  139463. private _onBeforeSpritesRenderingObserver;
  139464. private _onAfterSpritesRenderingObserver;
  139465. private _onBeforePhysicsObserver;
  139466. private _onAfterPhysicsObserver;
  139467. private _onAfterAnimationsObserver;
  139468. private _onBeforeCameraRenderObserver;
  139469. private _onAfterCameraRenderObserver;
  139470. /**
  139471. * Gets the perf counter used for active meshes evaluation time
  139472. */
  139473. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  139474. /**
  139475. * Gets the active meshes evaluation time capture status
  139476. */
  139477. get captureActiveMeshesEvaluationTime(): boolean;
  139478. /**
  139479. * Enable or disable the active meshes evaluation time capture
  139480. */
  139481. set captureActiveMeshesEvaluationTime(value: boolean);
  139482. /**
  139483. * Gets the perf counter used for render targets render time
  139484. */
  139485. get renderTargetsRenderTimeCounter(): PerfCounter;
  139486. /**
  139487. * Gets the render targets render time capture status
  139488. */
  139489. get captureRenderTargetsRenderTime(): boolean;
  139490. /**
  139491. * Enable or disable the render targets render time capture
  139492. */
  139493. set captureRenderTargetsRenderTime(value: boolean);
  139494. /**
  139495. * Gets the perf counter used for particles render time
  139496. */
  139497. get particlesRenderTimeCounter(): PerfCounter;
  139498. /**
  139499. * Gets the particles render time capture status
  139500. */
  139501. get captureParticlesRenderTime(): boolean;
  139502. /**
  139503. * Enable or disable the particles render time capture
  139504. */
  139505. set captureParticlesRenderTime(value: boolean);
  139506. /**
  139507. * Gets the perf counter used for sprites render time
  139508. */
  139509. get spritesRenderTimeCounter(): PerfCounter;
  139510. /**
  139511. * Gets the sprites render time capture status
  139512. */
  139513. get captureSpritesRenderTime(): boolean;
  139514. /**
  139515. * Enable or disable the sprites render time capture
  139516. */
  139517. set captureSpritesRenderTime(value: boolean);
  139518. /**
  139519. * Gets the perf counter used for physics time
  139520. */
  139521. get physicsTimeCounter(): PerfCounter;
  139522. /**
  139523. * Gets the physics time capture status
  139524. */
  139525. get capturePhysicsTime(): boolean;
  139526. /**
  139527. * Enable or disable the physics time capture
  139528. */
  139529. set capturePhysicsTime(value: boolean);
  139530. /**
  139531. * Gets the perf counter used for animations time
  139532. */
  139533. get animationsTimeCounter(): PerfCounter;
  139534. /**
  139535. * Gets the animations time capture status
  139536. */
  139537. get captureAnimationsTime(): boolean;
  139538. /**
  139539. * Enable or disable the animations time capture
  139540. */
  139541. set captureAnimationsTime(value: boolean);
  139542. /**
  139543. * Gets the perf counter used for frame time capture
  139544. */
  139545. get frameTimeCounter(): PerfCounter;
  139546. /**
  139547. * Gets the frame time capture status
  139548. */
  139549. get captureFrameTime(): boolean;
  139550. /**
  139551. * Enable or disable the frame time capture
  139552. */
  139553. set captureFrameTime(value: boolean);
  139554. /**
  139555. * Gets the perf counter used for inter-frames time capture
  139556. */
  139557. get interFrameTimeCounter(): PerfCounter;
  139558. /**
  139559. * Gets the inter-frames time capture status
  139560. */
  139561. get captureInterFrameTime(): boolean;
  139562. /**
  139563. * Enable or disable the inter-frames time capture
  139564. */
  139565. set captureInterFrameTime(value: boolean);
  139566. /**
  139567. * Gets the perf counter used for render time capture
  139568. */
  139569. get renderTimeCounter(): PerfCounter;
  139570. /**
  139571. * Gets the render time capture status
  139572. */
  139573. get captureRenderTime(): boolean;
  139574. /**
  139575. * Enable or disable the render time capture
  139576. */
  139577. set captureRenderTime(value: boolean);
  139578. /**
  139579. * Gets the perf counter used for camera render time capture
  139580. */
  139581. get cameraRenderTimeCounter(): PerfCounter;
  139582. /**
  139583. * Gets the camera render time capture status
  139584. */
  139585. get captureCameraRenderTime(): boolean;
  139586. /**
  139587. * Enable or disable the camera render time capture
  139588. */
  139589. set captureCameraRenderTime(value: boolean);
  139590. /**
  139591. * Gets the perf counter used for draw calls
  139592. */
  139593. get drawCallsCounter(): PerfCounter;
  139594. /**
  139595. * Instantiates a new scene instrumentation.
  139596. * This class can be used to get instrumentation data from a Babylon engine
  139597. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139598. * @param scene Defines the scene to instrument
  139599. */
  139600. constructor(
  139601. /**
  139602. * Defines the scene to instrument
  139603. */
  139604. scene: Scene);
  139605. /**
  139606. * Dispose and release associated resources.
  139607. */
  139608. dispose(): void;
  139609. }
  139610. }
  139611. declare module BABYLON {
  139612. /** @hidden */
  139613. export var glowMapGenerationPixelShader: {
  139614. name: string;
  139615. shader: string;
  139616. };
  139617. }
  139618. declare module BABYLON {
  139619. /** @hidden */
  139620. export var glowMapGenerationVertexShader: {
  139621. name: string;
  139622. shader: string;
  139623. };
  139624. }
  139625. declare module BABYLON {
  139626. /**
  139627. * Effect layer options. This helps customizing the behaviour
  139628. * of the effect layer.
  139629. */
  139630. export interface IEffectLayerOptions {
  139631. /**
  139632. * Multiplication factor apply to the canvas size to compute the render target size
  139633. * used to generated the objects (the smaller the faster).
  139634. */
  139635. mainTextureRatio: number;
  139636. /**
  139637. * Enforces a fixed size texture to ensure effect stability across devices.
  139638. */
  139639. mainTextureFixedSize?: number;
  139640. /**
  139641. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  139642. */
  139643. alphaBlendingMode: number;
  139644. /**
  139645. * The camera attached to the layer.
  139646. */
  139647. camera: Nullable<Camera>;
  139648. /**
  139649. * The rendering group to draw the layer in.
  139650. */
  139651. renderingGroupId: number;
  139652. }
  139653. /**
  139654. * The effect layer Helps adding post process effect blended with the main pass.
  139655. *
  139656. * This can be for instance use to generate glow or higlight effects on the scene.
  139657. *
  139658. * The effect layer class can not be used directly and is intented to inherited from to be
  139659. * customized per effects.
  139660. */
  139661. export abstract class EffectLayer {
  139662. private _vertexBuffers;
  139663. private _indexBuffer;
  139664. private _cachedDefines;
  139665. private _effectLayerMapGenerationEffect;
  139666. private _effectLayerOptions;
  139667. private _mergeEffect;
  139668. protected _scene: Scene;
  139669. protected _engine: Engine;
  139670. protected _maxSize: number;
  139671. protected _mainTextureDesiredSize: ISize;
  139672. protected _mainTexture: RenderTargetTexture;
  139673. protected _shouldRender: boolean;
  139674. protected _postProcesses: PostProcess[];
  139675. protected _textures: BaseTexture[];
  139676. protected _emissiveTextureAndColor: {
  139677. texture: Nullable<BaseTexture>;
  139678. color: Color4;
  139679. };
  139680. /**
  139681. * The name of the layer
  139682. */
  139683. name: string;
  139684. /**
  139685. * The clear color of the texture used to generate the glow map.
  139686. */
  139687. neutralColor: Color4;
  139688. /**
  139689. * Specifies whether the highlight layer is enabled or not.
  139690. */
  139691. isEnabled: boolean;
  139692. /**
  139693. * Gets the camera attached to the layer.
  139694. */
  139695. get camera(): Nullable<Camera>;
  139696. /**
  139697. * Gets the rendering group id the layer should render in.
  139698. */
  139699. get renderingGroupId(): number;
  139700. set renderingGroupId(renderingGroupId: number);
  139701. /**
  139702. * An event triggered when the effect layer has been disposed.
  139703. */
  139704. onDisposeObservable: Observable<EffectLayer>;
  139705. /**
  139706. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  139707. */
  139708. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  139709. /**
  139710. * An event triggered when the generated texture is being merged in the scene.
  139711. */
  139712. onBeforeComposeObservable: Observable<EffectLayer>;
  139713. /**
  139714. * An event triggered when the mesh is rendered into the effect render target.
  139715. */
  139716. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  139717. /**
  139718. * An event triggered after the mesh has been rendered into the effect render target.
  139719. */
  139720. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  139721. /**
  139722. * An event triggered when the generated texture has been merged in the scene.
  139723. */
  139724. onAfterComposeObservable: Observable<EffectLayer>;
  139725. /**
  139726. * An event triggered when the efffect layer changes its size.
  139727. */
  139728. onSizeChangedObservable: Observable<EffectLayer>;
  139729. /** @hidden */
  139730. static _SceneComponentInitialization: (scene: Scene) => void;
  139731. /**
  139732. * Instantiates a new effect Layer and references it in the scene.
  139733. * @param name The name of the layer
  139734. * @param scene The scene to use the layer in
  139735. */
  139736. constructor(
  139737. /** The Friendly of the effect in the scene */
  139738. name: string, scene: Scene);
  139739. /**
  139740. * Get the effect name of the layer.
  139741. * @return The effect name
  139742. */
  139743. abstract getEffectName(): string;
  139744. /**
  139745. * Checks for the readiness of the element composing the layer.
  139746. * @param subMesh the mesh to check for
  139747. * @param useInstances specify whether or not to use instances to render the mesh
  139748. * @return true if ready otherwise, false
  139749. */
  139750. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139751. /**
  139752. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139753. * @returns true if the effect requires stencil during the main canvas render pass.
  139754. */
  139755. abstract needStencil(): boolean;
  139756. /**
  139757. * Create the merge effect. This is the shader use to blit the information back
  139758. * to the main canvas at the end of the scene rendering.
  139759. * @returns The effect containing the shader used to merge the effect on the main canvas
  139760. */
  139761. protected abstract _createMergeEffect(): Effect;
  139762. /**
  139763. * Creates the render target textures and post processes used in the effect layer.
  139764. */
  139765. protected abstract _createTextureAndPostProcesses(): void;
  139766. /**
  139767. * Implementation specific of rendering the generating effect on the main canvas.
  139768. * @param effect The effect used to render through
  139769. */
  139770. protected abstract _internalRender(effect: Effect): void;
  139771. /**
  139772. * Sets the required values for both the emissive texture and and the main color.
  139773. */
  139774. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139775. /**
  139776. * Free any resources and references associated to a mesh.
  139777. * Internal use
  139778. * @param mesh The mesh to free.
  139779. */
  139780. abstract _disposeMesh(mesh: Mesh): void;
  139781. /**
  139782. * Serializes this layer (Glow or Highlight for example)
  139783. * @returns a serialized layer object
  139784. */
  139785. abstract serialize?(): any;
  139786. /**
  139787. * Initializes the effect layer with the required options.
  139788. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  139789. */
  139790. protected _init(options: Partial<IEffectLayerOptions>): void;
  139791. /**
  139792. * Generates the index buffer of the full screen quad blending to the main canvas.
  139793. */
  139794. private _generateIndexBuffer;
  139795. /**
  139796. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  139797. */
  139798. private _generateVertexBuffer;
  139799. /**
  139800. * Sets the main texture desired size which is the closest power of two
  139801. * of the engine canvas size.
  139802. */
  139803. private _setMainTextureSize;
  139804. /**
  139805. * Creates the main texture for the effect layer.
  139806. */
  139807. protected _createMainTexture(): void;
  139808. /**
  139809. * Adds specific effects defines.
  139810. * @param defines The defines to add specifics to.
  139811. */
  139812. protected _addCustomEffectDefines(defines: string[]): void;
  139813. /**
  139814. * Checks for the readiness of the element composing the layer.
  139815. * @param subMesh the mesh to check for
  139816. * @param useInstances specify whether or not to use instances to render the mesh
  139817. * @param emissiveTexture the associated emissive texture used to generate the glow
  139818. * @return true if ready otherwise, false
  139819. */
  139820. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  139821. /**
  139822. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  139823. */
  139824. render(): void;
  139825. /**
  139826. * Determine if a given mesh will be used in the current effect.
  139827. * @param mesh mesh to test
  139828. * @returns true if the mesh will be used
  139829. */
  139830. hasMesh(mesh: AbstractMesh): boolean;
  139831. /**
  139832. * Returns true if the layer contains information to display, otherwise false.
  139833. * @returns true if the glow layer should be rendered
  139834. */
  139835. shouldRender(): boolean;
  139836. /**
  139837. * Returns true if the mesh should render, otherwise false.
  139838. * @param mesh The mesh to render
  139839. * @returns true if it should render otherwise false
  139840. */
  139841. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  139842. /**
  139843. * Returns true if the mesh can be rendered, otherwise false.
  139844. * @param mesh The mesh to render
  139845. * @param material The material used on the mesh
  139846. * @returns true if it can be rendered otherwise false
  139847. */
  139848. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139849. /**
  139850. * Returns true if the mesh should render, otherwise false.
  139851. * @param mesh The mesh to render
  139852. * @returns true if it should render otherwise false
  139853. */
  139854. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  139855. /**
  139856. * Renders the submesh passed in parameter to the generation map.
  139857. */
  139858. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  139859. /**
  139860. * Defines whether the current material of the mesh should be use to render the effect.
  139861. * @param mesh defines the current mesh to render
  139862. */
  139863. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139864. /**
  139865. * Rebuild the required buffers.
  139866. * @hidden Internal use only.
  139867. */
  139868. _rebuild(): void;
  139869. /**
  139870. * Dispose only the render target textures and post process.
  139871. */
  139872. private _disposeTextureAndPostProcesses;
  139873. /**
  139874. * Dispose the highlight layer and free resources.
  139875. */
  139876. dispose(): void;
  139877. /**
  139878. * Gets the class name of the effect layer
  139879. * @returns the string with the class name of the effect layer
  139880. */
  139881. getClassName(): string;
  139882. /**
  139883. * Creates an effect layer from parsed effect layer data
  139884. * @param parsedEffectLayer defines effect layer data
  139885. * @param scene defines the current scene
  139886. * @param rootUrl defines the root URL containing the effect layer information
  139887. * @returns a parsed effect Layer
  139888. */
  139889. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  139890. }
  139891. }
  139892. declare module BABYLON {
  139893. interface AbstractScene {
  139894. /**
  139895. * The list of effect layers (highlights/glow) added to the scene
  139896. * @see https://doc.babylonjs.com/how_to/highlight_layer
  139897. * @see https://doc.babylonjs.com/how_to/glow_layer
  139898. */
  139899. effectLayers: Array<EffectLayer>;
  139900. /**
  139901. * Removes the given effect layer from this scene.
  139902. * @param toRemove defines the effect layer to remove
  139903. * @returns the index of the removed effect layer
  139904. */
  139905. removeEffectLayer(toRemove: EffectLayer): number;
  139906. /**
  139907. * Adds the given effect layer to this scene
  139908. * @param newEffectLayer defines the effect layer to add
  139909. */
  139910. addEffectLayer(newEffectLayer: EffectLayer): void;
  139911. }
  139912. /**
  139913. * Defines the layer scene component responsible to manage any effect layers
  139914. * in a given scene.
  139915. */
  139916. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  139917. /**
  139918. * The component name helpfull to identify the component in the list of scene components.
  139919. */
  139920. readonly name: string;
  139921. /**
  139922. * The scene the component belongs to.
  139923. */
  139924. scene: Scene;
  139925. private _engine;
  139926. private _renderEffects;
  139927. private _needStencil;
  139928. private _previousStencilState;
  139929. /**
  139930. * Creates a new instance of the component for the given scene
  139931. * @param scene Defines the scene to register the component in
  139932. */
  139933. constructor(scene: Scene);
  139934. /**
  139935. * Registers the component in a given scene
  139936. */
  139937. register(): void;
  139938. /**
  139939. * Rebuilds the elements related to this component in case of
  139940. * context lost for instance.
  139941. */
  139942. rebuild(): void;
  139943. /**
  139944. * Serializes the component data to the specified json object
  139945. * @param serializationObject The object to serialize to
  139946. */
  139947. serialize(serializationObject: any): void;
  139948. /**
  139949. * Adds all the elements from the container to the scene
  139950. * @param container the container holding the elements
  139951. */
  139952. addFromContainer(container: AbstractScene): void;
  139953. /**
  139954. * Removes all the elements in the container from the scene
  139955. * @param container contains the elements to remove
  139956. * @param dispose if the removed element should be disposed (default: false)
  139957. */
  139958. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139959. /**
  139960. * Disposes the component and the associated ressources.
  139961. */
  139962. dispose(): void;
  139963. private _isReadyForMesh;
  139964. private _renderMainTexture;
  139965. private _setStencil;
  139966. private _setStencilBack;
  139967. private _draw;
  139968. private _drawCamera;
  139969. private _drawRenderingGroup;
  139970. }
  139971. }
  139972. declare module BABYLON {
  139973. /** @hidden */
  139974. export var glowMapMergePixelShader: {
  139975. name: string;
  139976. shader: string;
  139977. };
  139978. }
  139979. declare module BABYLON {
  139980. /** @hidden */
  139981. export var glowMapMergeVertexShader: {
  139982. name: string;
  139983. shader: string;
  139984. };
  139985. }
  139986. declare module BABYLON {
  139987. interface AbstractScene {
  139988. /**
  139989. * Return a the first highlight layer of the scene with a given name.
  139990. * @param name The name of the highlight layer to look for.
  139991. * @return The highlight layer if found otherwise null.
  139992. */
  139993. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139994. }
  139995. /**
  139996. * Glow layer options. This helps customizing the behaviour
  139997. * of the glow layer.
  139998. */
  139999. export interface IGlowLayerOptions {
  140000. /**
  140001. * Multiplication factor apply to the canvas size to compute the render target size
  140002. * used to generated the glowing objects (the smaller the faster).
  140003. */
  140004. mainTextureRatio: number;
  140005. /**
  140006. * Enforces a fixed size texture to ensure resize independant blur.
  140007. */
  140008. mainTextureFixedSize?: number;
  140009. /**
  140010. * How big is the kernel of the blur texture.
  140011. */
  140012. blurKernelSize: number;
  140013. /**
  140014. * The camera attached to the layer.
  140015. */
  140016. camera: Nullable<Camera>;
  140017. /**
  140018. * Enable MSAA by chosing the number of samples.
  140019. */
  140020. mainTextureSamples?: number;
  140021. /**
  140022. * The rendering group to draw the layer in.
  140023. */
  140024. renderingGroupId: number;
  140025. }
  140026. /**
  140027. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  140028. *
  140029. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  140030. *
  140031. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  140032. */
  140033. export class GlowLayer extends EffectLayer {
  140034. /**
  140035. * Effect Name of the layer.
  140036. */
  140037. static readonly EffectName: string;
  140038. /**
  140039. * The default blur kernel size used for the glow.
  140040. */
  140041. static DefaultBlurKernelSize: number;
  140042. /**
  140043. * The default texture size ratio used for the glow.
  140044. */
  140045. static DefaultTextureRatio: number;
  140046. /**
  140047. * Sets the kernel size of the blur.
  140048. */
  140049. set blurKernelSize(value: number);
  140050. /**
  140051. * Gets the kernel size of the blur.
  140052. */
  140053. get blurKernelSize(): number;
  140054. /**
  140055. * Sets the glow intensity.
  140056. */
  140057. set intensity(value: number);
  140058. /**
  140059. * Gets the glow intensity.
  140060. */
  140061. get intensity(): number;
  140062. private _options;
  140063. private _intensity;
  140064. private _horizontalBlurPostprocess1;
  140065. private _verticalBlurPostprocess1;
  140066. private _horizontalBlurPostprocess2;
  140067. private _verticalBlurPostprocess2;
  140068. private _blurTexture1;
  140069. private _blurTexture2;
  140070. private _postProcesses1;
  140071. private _postProcesses2;
  140072. private _includedOnlyMeshes;
  140073. private _excludedMeshes;
  140074. private _meshesUsingTheirOwnMaterials;
  140075. /**
  140076. * Callback used to let the user override the color selection on a per mesh basis
  140077. */
  140078. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  140079. /**
  140080. * Callback used to let the user override the texture selection on a per mesh basis
  140081. */
  140082. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  140083. /**
  140084. * Instantiates a new glow Layer and references it to the scene.
  140085. * @param name The name of the layer
  140086. * @param scene The scene to use the layer in
  140087. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  140088. */
  140089. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  140090. /**
  140091. * Get the effect name of the layer.
  140092. * @return The effect name
  140093. */
  140094. getEffectName(): string;
  140095. /**
  140096. * Create the merge effect. This is the shader use to blit the information back
  140097. * to the main canvas at the end of the scene rendering.
  140098. */
  140099. protected _createMergeEffect(): Effect;
  140100. /**
  140101. * Creates the render target textures and post processes used in the glow layer.
  140102. */
  140103. protected _createTextureAndPostProcesses(): void;
  140104. /**
  140105. * Checks for the readiness of the element composing the layer.
  140106. * @param subMesh the mesh to check for
  140107. * @param useInstances specify wether or not to use instances to render the mesh
  140108. * @param emissiveTexture the associated emissive texture used to generate the glow
  140109. * @return true if ready otherwise, false
  140110. */
  140111. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140112. /**
  140113. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140114. */
  140115. needStencil(): boolean;
  140116. /**
  140117. * Returns true if the mesh can be rendered, otherwise false.
  140118. * @param mesh The mesh to render
  140119. * @param material The material used on the mesh
  140120. * @returns true if it can be rendered otherwise false
  140121. */
  140122. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140123. /**
  140124. * Implementation specific of rendering the generating effect on the main canvas.
  140125. * @param effect The effect used to render through
  140126. */
  140127. protected _internalRender(effect: Effect): void;
  140128. /**
  140129. * Sets the required values for both the emissive texture and and the main color.
  140130. */
  140131. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140132. /**
  140133. * Returns true if the mesh should render, otherwise false.
  140134. * @param mesh The mesh to render
  140135. * @returns true if it should render otherwise false
  140136. */
  140137. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140138. /**
  140139. * Adds specific effects defines.
  140140. * @param defines The defines to add specifics to.
  140141. */
  140142. protected _addCustomEffectDefines(defines: string[]): void;
  140143. /**
  140144. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  140145. * @param mesh The mesh to exclude from the glow layer
  140146. */
  140147. addExcludedMesh(mesh: Mesh): void;
  140148. /**
  140149. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  140150. * @param mesh The mesh to remove
  140151. */
  140152. removeExcludedMesh(mesh: Mesh): void;
  140153. /**
  140154. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  140155. * @param mesh The mesh to include in the glow layer
  140156. */
  140157. addIncludedOnlyMesh(mesh: Mesh): void;
  140158. /**
  140159. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  140160. * @param mesh The mesh to remove
  140161. */
  140162. removeIncludedOnlyMesh(mesh: Mesh): void;
  140163. /**
  140164. * Determine if a given mesh will be used in the glow layer
  140165. * @param mesh The mesh to test
  140166. * @returns true if the mesh will be highlighted by the current glow layer
  140167. */
  140168. hasMesh(mesh: AbstractMesh): boolean;
  140169. /**
  140170. * Defines whether the current material of the mesh should be use to render the effect.
  140171. * @param mesh defines the current mesh to render
  140172. */
  140173. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140174. /**
  140175. * Add a mesh to be rendered through its own material and not with emissive only.
  140176. * @param mesh The mesh for which we need to use its material
  140177. */
  140178. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  140179. /**
  140180. * Remove a mesh from being rendered through its own material and not with emissive only.
  140181. * @param mesh The mesh for which we need to not use its material
  140182. */
  140183. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  140184. /**
  140185. * Free any resources and references associated to a mesh.
  140186. * Internal use
  140187. * @param mesh The mesh to free.
  140188. * @hidden
  140189. */
  140190. _disposeMesh(mesh: Mesh): void;
  140191. /**
  140192. * Gets the class name of the effect layer
  140193. * @returns the string with the class name of the effect layer
  140194. */
  140195. getClassName(): string;
  140196. /**
  140197. * Serializes this glow layer
  140198. * @returns a serialized glow layer object
  140199. */
  140200. serialize(): any;
  140201. /**
  140202. * Creates a Glow Layer from parsed glow layer data
  140203. * @param parsedGlowLayer defines glow layer data
  140204. * @param scene defines the current scene
  140205. * @param rootUrl defines the root URL containing the glow layer information
  140206. * @returns a parsed Glow Layer
  140207. */
  140208. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  140209. }
  140210. }
  140211. declare module BABYLON {
  140212. /** @hidden */
  140213. export var glowBlurPostProcessPixelShader: {
  140214. name: string;
  140215. shader: string;
  140216. };
  140217. }
  140218. declare module BABYLON {
  140219. interface AbstractScene {
  140220. /**
  140221. * Return a the first highlight layer of the scene with a given name.
  140222. * @param name The name of the highlight layer to look for.
  140223. * @return The highlight layer if found otherwise null.
  140224. */
  140225. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  140226. }
  140227. /**
  140228. * Highlight layer options. This helps customizing the behaviour
  140229. * of the highlight layer.
  140230. */
  140231. export interface IHighlightLayerOptions {
  140232. /**
  140233. * Multiplication factor apply to the canvas size to compute the render target size
  140234. * used to generated the glowing objects (the smaller the faster).
  140235. */
  140236. mainTextureRatio: number;
  140237. /**
  140238. * Enforces a fixed size texture to ensure resize independant blur.
  140239. */
  140240. mainTextureFixedSize?: number;
  140241. /**
  140242. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  140243. * of the picture to blur (the smaller the faster).
  140244. */
  140245. blurTextureSizeRatio: number;
  140246. /**
  140247. * How big in texel of the blur texture is the vertical blur.
  140248. */
  140249. blurVerticalSize: number;
  140250. /**
  140251. * How big in texel of the blur texture is the horizontal blur.
  140252. */
  140253. blurHorizontalSize: number;
  140254. /**
  140255. * Alpha blending mode used to apply the blur. Default is combine.
  140256. */
  140257. alphaBlendingMode: number;
  140258. /**
  140259. * The camera attached to the layer.
  140260. */
  140261. camera: Nullable<Camera>;
  140262. /**
  140263. * Should we display highlight as a solid stroke?
  140264. */
  140265. isStroke?: boolean;
  140266. /**
  140267. * The rendering group to draw the layer in.
  140268. */
  140269. renderingGroupId: number;
  140270. }
  140271. /**
  140272. * The highlight layer Helps adding a glow effect around a mesh.
  140273. *
  140274. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  140275. * glowy meshes to your scene.
  140276. *
  140277. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  140278. */
  140279. export class HighlightLayer extends EffectLayer {
  140280. name: string;
  140281. /**
  140282. * Effect Name of the highlight layer.
  140283. */
  140284. static readonly EffectName: string;
  140285. /**
  140286. * The neutral color used during the preparation of the glow effect.
  140287. * This is black by default as the blend operation is a blend operation.
  140288. */
  140289. static NeutralColor: Color4;
  140290. /**
  140291. * Stencil value used for glowing meshes.
  140292. */
  140293. static GlowingMeshStencilReference: number;
  140294. /**
  140295. * Stencil value used for the other meshes in the scene.
  140296. */
  140297. static NormalMeshStencilReference: number;
  140298. /**
  140299. * Specifies whether or not the inner glow is ACTIVE in the layer.
  140300. */
  140301. innerGlow: boolean;
  140302. /**
  140303. * Specifies whether or not the outer glow is ACTIVE in the layer.
  140304. */
  140305. outerGlow: boolean;
  140306. /**
  140307. * Specifies the horizontal size of the blur.
  140308. */
  140309. set blurHorizontalSize(value: number);
  140310. /**
  140311. * Specifies the vertical size of the blur.
  140312. */
  140313. set blurVerticalSize(value: number);
  140314. /**
  140315. * Gets the horizontal size of the blur.
  140316. */
  140317. get blurHorizontalSize(): number;
  140318. /**
  140319. * Gets the vertical size of the blur.
  140320. */
  140321. get blurVerticalSize(): number;
  140322. /**
  140323. * An event triggered when the highlight layer is being blurred.
  140324. */
  140325. onBeforeBlurObservable: Observable<HighlightLayer>;
  140326. /**
  140327. * An event triggered when the highlight layer has been blurred.
  140328. */
  140329. onAfterBlurObservable: Observable<HighlightLayer>;
  140330. private _instanceGlowingMeshStencilReference;
  140331. private _options;
  140332. private _downSamplePostprocess;
  140333. private _horizontalBlurPostprocess;
  140334. private _verticalBlurPostprocess;
  140335. private _blurTexture;
  140336. private _meshes;
  140337. private _excludedMeshes;
  140338. /**
  140339. * Instantiates a new highlight Layer and references it to the scene..
  140340. * @param name The name of the layer
  140341. * @param scene The scene to use the layer in
  140342. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  140343. */
  140344. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  140345. /**
  140346. * Get the effect name of the layer.
  140347. * @return The effect name
  140348. */
  140349. getEffectName(): string;
  140350. /**
  140351. * Create the merge effect. This is the shader use to blit the information back
  140352. * to the main canvas at the end of the scene rendering.
  140353. */
  140354. protected _createMergeEffect(): Effect;
  140355. /**
  140356. * Creates the render target textures and post processes used in the highlight layer.
  140357. */
  140358. protected _createTextureAndPostProcesses(): void;
  140359. /**
  140360. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  140361. */
  140362. needStencil(): boolean;
  140363. /**
  140364. * Checks for the readiness of the element composing the layer.
  140365. * @param subMesh the mesh to check for
  140366. * @param useInstances specify wether or not to use instances to render the mesh
  140367. * @param emissiveTexture the associated emissive texture used to generate the glow
  140368. * @return true if ready otherwise, false
  140369. */
  140370. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140371. /**
  140372. * Implementation specific of rendering the generating effect on the main canvas.
  140373. * @param effect The effect used to render through
  140374. */
  140375. protected _internalRender(effect: Effect): void;
  140376. /**
  140377. * Returns true if the layer contains information to display, otherwise false.
  140378. */
  140379. shouldRender(): boolean;
  140380. /**
  140381. * Returns true if the mesh should render, otherwise false.
  140382. * @param mesh The mesh to render
  140383. * @returns true if it should render otherwise false
  140384. */
  140385. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140386. /**
  140387. * Returns true if the mesh can be rendered, otherwise false.
  140388. * @param mesh The mesh to render
  140389. * @param material The material used on the mesh
  140390. * @returns true if it can be rendered otherwise false
  140391. */
  140392. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140393. /**
  140394. * Adds specific effects defines.
  140395. * @param defines The defines to add specifics to.
  140396. */
  140397. protected _addCustomEffectDefines(defines: string[]): void;
  140398. /**
  140399. * Sets the required values for both the emissive texture and and the main color.
  140400. */
  140401. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140402. /**
  140403. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  140404. * @param mesh The mesh to exclude from the highlight layer
  140405. */
  140406. addExcludedMesh(mesh: Mesh): void;
  140407. /**
  140408. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  140409. * @param mesh The mesh to highlight
  140410. */
  140411. removeExcludedMesh(mesh: Mesh): void;
  140412. /**
  140413. * Determine if a given mesh will be highlighted by the current HighlightLayer
  140414. * @param mesh mesh to test
  140415. * @returns true if the mesh will be highlighted by the current HighlightLayer
  140416. */
  140417. hasMesh(mesh: AbstractMesh): boolean;
  140418. /**
  140419. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  140420. * @param mesh The mesh to highlight
  140421. * @param color The color of the highlight
  140422. * @param glowEmissiveOnly Extract the glow from the emissive texture
  140423. */
  140424. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  140425. /**
  140426. * Remove a mesh from the highlight layer in order to make it stop glowing.
  140427. * @param mesh The mesh to highlight
  140428. */
  140429. removeMesh(mesh: Mesh): void;
  140430. /**
  140431. * Remove all the meshes currently referenced in the highlight layer
  140432. */
  140433. removeAllMeshes(): void;
  140434. /**
  140435. * Force the stencil to the normal expected value for none glowing parts
  140436. */
  140437. private _defaultStencilReference;
  140438. /**
  140439. * Free any resources and references associated to a mesh.
  140440. * Internal use
  140441. * @param mesh The mesh to free.
  140442. * @hidden
  140443. */
  140444. _disposeMesh(mesh: Mesh): void;
  140445. /**
  140446. * Dispose the highlight layer and free resources.
  140447. */
  140448. dispose(): void;
  140449. /**
  140450. * Gets the class name of the effect layer
  140451. * @returns the string with the class name of the effect layer
  140452. */
  140453. getClassName(): string;
  140454. /**
  140455. * Serializes this Highlight layer
  140456. * @returns a serialized Highlight layer object
  140457. */
  140458. serialize(): any;
  140459. /**
  140460. * Creates a Highlight layer from parsed Highlight layer data
  140461. * @param parsedHightlightLayer defines the Highlight layer data
  140462. * @param scene defines the current scene
  140463. * @param rootUrl defines the root URL containing the Highlight layer information
  140464. * @returns a parsed Highlight layer
  140465. */
  140466. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  140467. }
  140468. }
  140469. declare module BABYLON {
  140470. interface AbstractScene {
  140471. /**
  140472. * The list of layers (background and foreground) of the scene
  140473. */
  140474. layers: Array<Layer>;
  140475. }
  140476. /**
  140477. * Defines the layer scene component responsible to manage any layers
  140478. * in a given scene.
  140479. */
  140480. export class LayerSceneComponent implements ISceneComponent {
  140481. /**
  140482. * The component name helpfull to identify the component in the list of scene components.
  140483. */
  140484. readonly name: string;
  140485. /**
  140486. * The scene the component belongs to.
  140487. */
  140488. scene: Scene;
  140489. private _engine;
  140490. /**
  140491. * Creates a new instance of the component for the given scene
  140492. * @param scene Defines the scene to register the component in
  140493. */
  140494. constructor(scene: Scene);
  140495. /**
  140496. * Registers the component in a given scene
  140497. */
  140498. register(): void;
  140499. /**
  140500. * Rebuilds the elements related to this component in case of
  140501. * context lost for instance.
  140502. */
  140503. rebuild(): void;
  140504. /**
  140505. * Disposes the component and the associated ressources.
  140506. */
  140507. dispose(): void;
  140508. private _draw;
  140509. private _drawCameraPredicate;
  140510. private _drawCameraBackground;
  140511. private _drawCameraForeground;
  140512. private _drawRenderTargetPredicate;
  140513. private _drawRenderTargetBackground;
  140514. private _drawRenderTargetForeground;
  140515. /**
  140516. * Adds all the elements from the container to the scene
  140517. * @param container the container holding the elements
  140518. */
  140519. addFromContainer(container: AbstractScene): void;
  140520. /**
  140521. * Removes all the elements in the container from the scene
  140522. * @param container contains the elements to remove
  140523. * @param dispose if the removed element should be disposed (default: false)
  140524. */
  140525. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140526. }
  140527. }
  140528. declare module BABYLON {
  140529. /** @hidden */
  140530. export var layerPixelShader: {
  140531. name: string;
  140532. shader: string;
  140533. };
  140534. }
  140535. declare module BABYLON {
  140536. /** @hidden */
  140537. export var layerVertexShader: {
  140538. name: string;
  140539. shader: string;
  140540. };
  140541. }
  140542. declare module BABYLON {
  140543. /**
  140544. * This represents a full screen 2d layer.
  140545. * This can be useful to display a picture in the background of your scene for instance.
  140546. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140547. */
  140548. export class Layer {
  140549. /**
  140550. * Define the name of the layer.
  140551. */
  140552. name: string;
  140553. /**
  140554. * Define the texture the layer should display.
  140555. */
  140556. texture: Nullable<Texture>;
  140557. /**
  140558. * Is the layer in background or foreground.
  140559. */
  140560. isBackground: boolean;
  140561. /**
  140562. * Define the color of the layer (instead of texture).
  140563. */
  140564. color: Color4;
  140565. /**
  140566. * Define the scale of the layer in order to zoom in out of the texture.
  140567. */
  140568. scale: Vector2;
  140569. /**
  140570. * Define an offset for the layer in order to shift the texture.
  140571. */
  140572. offset: Vector2;
  140573. /**
  140574. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  140575. */
  140576. alphaBlendingMode: number;
  140577. /**
  140578. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  140579. * Alpha test will not mix with the background color in case of transparency.
  140580. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  140581. */
  140582. alphaTest: boolean;
  140583. /**
  140584. * Define a mask to restrict the layer to only some of the scene cameras.
  140585. */
  140586. layerMask: number;
  140587. /**
  140588. * Define the list of render target the layer is visible into.
  140589. */
  140590. renderTargetTextures: RenderTargetTexture[];
  140591. /**
  140592. * Define if the layer is only used in renderTarget or if it also
  140593. * renders in the main frame buffer of the canvas.
  140594. */
  140595. renderOnlyInRenderTargetTextures: boolean;
  140596. private _scene;
  140597. private _vertexBuffers;
  140598. private _indexBuffer;
  140599. private _effect;
  140600. private _previousDefines;
  140601. /**
  140602. * An event triggered when the layer is disposed.
  140603. */
  140604. onDisposeObservable: Observable<Layer>;
  140605. private _onDisposeObserver;
  140606. /**
  140607. * Back compatibility with callback before the onDisposeObservable existed.
  140608. * The set callback will be triggered when the layer has been disposed.
  140609. */
  140610. set onDispose(callback: () => void);
  140611. /**
  140612. * An event triggered before rendering the scene
  140613. */
  140614. onBeforeRenderObservable: Observable<Layer>;
  140615. private _onBeforeRenderObserver;
  140616. /**
  140617. * Back compatibility with callback before the onBeforeRenderObservable existed.
  140618. * The set callback will be triggered just before rendering the layer.
  140619. */
  140620. set onBeforeRender(callback: () => void);
  140621. /**
  140622. * An event triggered after rendering the scene
  140623. */
  140624. onAfterRenderObservable: Observable<Layer>;
  140625. private _onAfterRenderObserver;
  140626. /**
  140627. * Back compatibility with callback before the onAfterRenderObservable existed.
  140628. * The set callback will be triggered just after rendering the layer.
  140629. */
  140630. set onAfterRender(callback: () => void);
  140631. /**
  140632. * Instantiates a new layer.
  140633. * This represents a full screen 2d layer.
  140634. * This can be useful to display a picture in the background of your scene for instance.
  140635. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140636. * @param name Define the name of the layer in the scene
  140637. * @param imgUrl Define the url of the texture to display in the layer
  140638. * @param scene Define the scene the layer belongs to
  140639. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  140640. * @param color Defines a color for the layer
  140641. */
  140642. constructor(
  140643. /**
  140644. * Define the name of the layer.
  140645. */
  140646. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  140647. private _createIndexBuffer;
  140648. /** @hidden */
  140649. _rebuild(): void;
  140650. /**
  140651. * Renders the layer in the scene.
  140652. */
  140653. render(): void;
  140654. /**
  140655. * Disposes and releases the associated ressources.
  140656. */
  140657. dispose(): void;
  140658. }
  140659. }
  140660. declare module BABYLON {
  140661. /** @hidden */
  140662. export var lensFlarePixelShader: {
  140663. name: string;
  140664. shader: string;
  140665. };
  140666. }
  140667. declare module BABYLON {
  140668. /** @hidden */
  140669. export var lensFlareVertexShader: {
  140670. name: string;
  140671. shader: string;
  140672. };
  140673. }
  140674. declare module BABYLON {
  140675. /**
  140676. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140677. * It is usually composed of several `lensFlare`.
  140678. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140679. */
  140680. export class LensFlareSystem {
  140681. /**
  140682. * Define the name of the lens flare system
  140683. */
  140684. name: string;
  140685. /**
  140686. * List of lens flares used in this system.
  140687. */
  140688. lensFlares: LensFlare[];
  140689. /**
  140690. * Define a limit from the border the lens flare can be visible.
  140691. */
  140692. borderLimit: number;
  140693. /**
  140694. * Define a viewport border we do not want to see the lens flare in.
  140695. */
  140696. viewportBorder: number;
  140697. /**
  140698. * Define a predicate which could limit the list of meshes able to occlude the effect.
  140699. */
  140700. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140701. /**
  140702. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  140703. */
  140704. layerMask: number;
  140705. /**
  140706. * Define the id of the lens flare system in the scene.
  140707. * (equal to name by default)
  140708. */
  140709. id: string;
  140710. private _scene;
  140711. private _emitter;
  140712. private _vertexBuffers;
  140713. private _indexBuffer;
  140714. private _effect;
  140715. private _positionX;
  140716. private _positionY;
  140717. private _isEnabled;
  140718. /** @hidden */
  140719. static _SceneComponentInitialization: (scene: Scene) => void;
  140720. /**
  140721. * Instantiates a lens flare system.
  140722. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140723. * It is usually composed of several `lensFlare`.
  140724. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140725. * @param name Define the name of the lens flare system in the scene
  140726. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  140727. * @param scene Define the scene the lens flare system belongs to
  140728. */
  140729. constructor(
  140730. /**
  140731. * Define the name of the lens flare system
  140732. */
  140733. name: string, emitter: any, scene: Scene);
  140734. /**
  140735. * Define if the lens flare system is enabled.
  140736. */
  140737. get isEnabled(): boolean;
  140738. set isEnabled(value: boolean);
  140739. /**
  140740. * Get the scene the effects belongs to.
  140741. * @returns the scene holding the lens flare system
  140742. */
  140743. getScene(): Scene;
  140744. /**
  140745. * Get the emitter of the lens flare system.
  140746. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140747. * @returns the emitter of the lens flare system
  140748. */
  140749. getEmitter(): any;
  140750. /**
  140751. * Set the emitter of the lens flare system.
  140752. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140753. * @param newEmitter Define the new emitter of the system
  140754. */
  140755. setEmitter(newEmitter: any): void;
  140756. /**
  140757. * Get the lens flare system emitter position.
  140758. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  140759. * @returns the position
  140760. */
  140761. getEmitterPosition(): Vector3;
  140762. /**
  140763. * @hidden
  140764. */
  140765. computeEffectivePosition(globalViewport: Viewport): boolean;
  140766. /** @hidden */
  140767. _isVisible(): boolean;
  140768. /**
  140769. * @hidden
  140770. */
  140771. render(): boolean;
  140772. /**
  140773. * Dispose and release the lens flare with its associated resources.
  140774. */
  140775. dispose(): void;
  140776. /**
  140777. * Parse a lens flare system from a JSON repressentation
  140778. * @param parsedLensFlareSystem Define the JSON to parse
  140779. * @param scene Define the scene the parsed system should be instantiated in
  140780. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  140781. * @returns the parsed system
  140782. */
  140783. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  140784. /**
  140785. * Serialize the current Lens Flare System into a JSON representation.
  140786. * @returns the serialized JSON
  140787. */
  140788. serialize(): any;
  140789. }
  140790. }
  140791. declare module BABYLON {
  140792. /**
  140793. * This represents one of the lens effect in a `lensFlareSystem`.
  140794. * It controls one of the indiviual texture used in the effect.
  140795. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140796. */
  140797. export class LensFlare {
  140798. /**
  140799. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140800. */
  140801. size: number;
  140802. /**
  140803. * 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.
  140804. */
  140805. position: number;
  140806. /**
  140807. * Define the lens color.
  140808. */
  140809. color: Color3;
  140810. /**
  140811. * Define the lens texture.
  140812. */
  140813. texture: Nullable<Texture>;
  140814. /**
  140815. * Define the alpha mode to render this particular lens.
  140816. */
  140817. alphaMode: number;
  140818. private _system;
  140819. /**
  140820. * Creates a new Lens Flare.
  140821. * This represents one of the lens effect in a `lensFlareSystem`.
  140822. * It controls one of the indiviual texture used in the effect.
  140823. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140824. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  140825. * @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.
  140826. * @param color Define the lens color
  140827. * @param imgUrl Define the lens texture url
  140828. * @param system Define the `lensFlareSystem` this flare is part of
  140829. * @returns The newly created Lens Flare
  140830. */
  140831. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  140832. /**
  140833. * Instantiates a new Lens Flare.
  140834. * This represents one of the lens effect in a `lensFlareSystem`.
  140835. * It controls one of the indiviual texture used in the effect.
  140836. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140837. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  140838. * @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.
  140839. * @param color Define the lens color
  140840. * @param imgUrl Define the lens texture url
  140841. * @param system Define the `lensFlareSystem` this flare is part of
  140842. */
  140843. constructor(
  140844. /**
  140845. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140846. */
  140847. size: number,
  140848. /**
  140849. * 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.
  140850. */
  140851. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  140852. /**
  140853. * Dispose and release the lens flare with its associated resources.
  140854. */
  140855. dispose(): void;
  140856. }
  140857. }
  140858. declare module BABYLON {
  140859. interface AbstractScene {
  140860. /**
  140861. * The list of lens flare system added to the scene
  140862. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140863. */
  140864. lensFlareSystems: Array<LensFlareSystem>;
  140865. /**
  140866. * Removes the given lens flare system from this scene.
  140867. * @param toRemove The lens flare system to remove
  140868. * @returns The index of the removed lens flare system
  140869. */
  140870. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  140871. /**
  140872. * Adds the given lens flare system to this scene
  140873. * @param newLensFlareSystem The lens flare system to add
  140874. */
  140875. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  140876. /**
  140877. * Gets a lens flare system using its name
  140878. * @param name defines the name to look for
  140879. * @returns the lens flare system or null if not found
  140880. */
  140881. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  140882. /**
  140883. * Gets a lens flare system using its id
  140884. * @param id defines the id to look for
  140885. * @returns the lens flare system or null if not found
  140886. */
  140887. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  140888. }
  140889. /**
  140890. * Defines the lens flare scene component responsible to manage any lens flares
  140891. * in a given scene.
  140892. */
  140893. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  140894. /**
  140895. * The component name helpfull to identify the component in the list of scene components.
  140896. */
  140897. readonly name: string;
  140898. /**
  140899. * The scene the component belongs to.
  140900. */
  140901. scene: Scene;
  140902. /**
  140903. * Creates a new instance of the component for the given scene
  140904. * @param scene Defines the scene to register the component in
  140905. */
  140906. constructor(scene: Scene);
  140907. /**
  140908. * Registers the component in a given scene
  140909. */
  140910. register(): void;
  140911. /**
  140912. * Rebuilds the elements related to this component in case of
  140913. * context lost for instance.
  140914. */
  140915. rebuild(): void;
  140916. /**
  140917. * Adds all the elements from the container to the scene
  140918. * @param container the container holding the elements
  140919. */
  140920. addFromContainer(container: AbstractScene): void;
  140921. /**
  140922. * Removes all the elements in the container from the scene
  140923. * @param container contains the elements to remove
  140924. * @param dispose if the removed element should be disposed (default: false)
  140925. */
  140926. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140927. /**
  140928. * Serializes the component data to the specified json object
  140929. * @param serializationObject The object to serialize to
  140930. */
  140931. serialize(serializationObject: any): void;
  140932. /**
  140933. * Disposes the component and the associated ressources.
  140934. */
  140935. dispose(): void;
  140936. private _draw;
  140937. }
  140938. }
  140939. declare module BABYLON {
  140940. /** @hidden */
  140941. export var depthPixelShader: {
  140942. name: string;
  140943. shader: string;
  140944. };
  140945. }
  140946. declare module BABYLON {
  140947. /** @hidden */
  140948. export var depthVertexShader: {
  140949. name: string;
  140950. shader: string;
  140951. };
  140952. }
  140953. declare module BABYLON {
  140954. /**
  140955. * This represents a depth renderer in Babylon.
  140956. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140957. */
  140958. export class DepthRenderer {
  140959. private _scene;
  140960. private _depthMap;
  140961. private _effect;
  140962. private readonly _storeNonLinearDepth;
  140963. private readonly _clearColor;
  140964. /** Get if the depth renderer is using packed depth or not */
  140965. readonly isPacked: boolean;
  140966. private _cachedDefines;
  140967. private _camera;
  140968. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140969. enabled: boolean;
  140970. /**
  140971. * Specifiess that the depth renderer will only be used within
  140972. * the camera it is created for.
  140973. * This can help forcing its rendering during the camera processing.
  140974. */
  140975. useOnlyInActiveCamera: boolean;
  140976. /** @hidden */
  140977. static _SceneComponentInitialization: (scene: Scene) => void;
  140978. /**
  140979. * Instantiates a depth renderer
  140980. * @param scene The scene the renderer belongs to
  140981. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140982. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140983. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140984. */
  140985. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140986. /**
  140987. * Creates the depth rendering effect and checks if the effect is ready.
  140988. * @param subMesh The submesh to be used to render the depth map of
  140989. * @param useInstances If multiple world instances should be used
  140990. * @returns if the depth renderer is ready to render the depth map
  140991. */
  140992. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140993. /**
  140994. * Gets the texture which the depth map will be written to.
  140995. * @returns The depth map texture
  140996. */
  140997. getDepthMap(): RenderTargetTexture;
  140998. /**
  140999. * Disposes of the depth renderer.
  141000. */
  141001. dispose(): void;
  141002. }
  141003. }
  141004. declare module BABYLON {
  141005. /** @hidden */
  141006. export var minmaxReduxPixelShader: {
  141007. name: string;
  141008. shader: string;
  141009. };
  141010. }
  141011. declare module BABYLON {
  141012. /**
  141013. * This class computes a min/max reduction from a texture: it means it computes the minimum
  141014. * and maximum values from all values of the texture.
  141015. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  141016. * The source values are read from the red channel of the texture.
  141017. */
  141018. export class MinMaxReducer {
  141019. /**
  141020. * Observable triggered when the computation has been performed
  141021. */
  141022. onAfterReductionPerformed: Observable<{
  141023. min: number;
  141024. max: number;
  141025. }>;
  141026. protected _camera: Camera;
  141027. protected _sourceTexture: Nullable<RenderTargetTexture>;
  141028. protected _reductionSteps: Nullable<Array<PostProcess>>;
  141029. protected _postProcessManager: PostProcessManager;
  141030. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  141031. protected _forceFullscreenViewport: boolean;
  141032. /**
  141033. * Creates a min/max reducer
  141034. * @param camera The camera to use for the post processes
  141035. */
  141036. constructor(camera: Camera);
  141037. /**
  141038. * Gets the texture used to read the values from.
  141039. */
  141040. get sourceTexture(): Nullable<RenderTargetTexture>;
  141041. /**
  141042. * Sets the source texture to read the values from.
  141043. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  141044. * because in such textures '1' value must not be taken into account to compute the maximum
  141045. * as this value is used to clear the texture.
  141046. * Note that the computation is not activated by calling this function, you must call activate() for that!
  141047. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  141048. * @param depthRedux Indicates if the texture is a depth texture or not
  141049. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  141050. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141051. */
  141052. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141053. /**
  141054. * Defines the refresh rate of the computation.
  141055. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141056. */
  141057. get refreshRate(): number;
  141058. set refreshRate(value: number);
  141059. protected _activated: boolean;
  141060. /**
  141061. * Gets the activation status of the reducer
  141062. */
  141063. get activated(): boolean;
  141064. /**
  141065. * Activates the reduction computation.
  141066. * When activated, the observers registered in onAfterReductionPerformed are
  141067. * called after the compuation is performed
  141068. */
  141069. activate(): void;
  141070. /**
  141071. * Deactivates the reduction computation.
  141072. */
  141073. deactivate(): void;
  141074. /**
  141075. * Disposes the min/max reducer
  141076. * @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.
  141077. */
  141078. dispose(disposeAll?: boolean): void;
  141079. }
  141080. }
  141081. declare module BABYLON {
  141082. /**
  141083. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  141084. */
  141085. export class DepthReducer extends MinMaxReducer {
  141086. private _depthRenderer;
  141087. private _depthRendererId;
  141088. /**
  141089. * Gets the depth renderer used for the computation.
  141090. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  141091. */
  141092. get depthRenderer(): Nullable<DepthRenderer>;
  141093. /**
  141094. * Creates a depth reducer
  141095. * @param camera The camera used to render the depth texture
  141096. */
  141097. constructor(camera: Camera);
  141098. /**
  141099. * Sets the depth renderer to use to generate the depth map
  141100. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  141101. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  141102. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141103. */
  141104. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  141105. /** @hidden */
  141106. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141107. /**
  141108. * Activates the reduction computation.
  141109. * When activated, the observers registered in onAfterReductionPerformed are
  141110. * called after the compuation is performed
  141111. */
  141112. activate(): void;
  141113. /**
  141114. * Deactivates the reduction computation.
  141115. */
  141116. deactivate(): void;
  141117. /**
  141118. * Disposes the depth reducer
  141119. * @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.
  141120. */
  141121. dispose(disposeAll?: boolean): void;
  141122. }
  141123. }
  141124. declare module BABYLON {
  141125. /**
  141126. * A CSM implementation allowing casting shadows on large scenes.
  141127. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141128. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  141129. */
  141130. export class CascadedShadowGenerator extends ShadowGenerator {
  141131. private static readonly frustumCornersNDCSpace;
  141132. /**
  141133. * Name of the CSM class
  141134. */
  141135. static CLASSNAME: string;
  141136. /**
  141137. * Defines the default number of cascades used by the CSM.
  141138. */
  141139. static readonly DEFAULT_CASCADES_COUNT: number;
  141140. /**
  141141. * Defines the minimum number of cascades used by the CSM.
  141142. */
  141143. static readonly MIN_CASCADES_COUNT: number;
  141144. /**
  141145. * Defines the maximum number of cascades used by the CSM.
  141146. */
  141147. static readonly MAX_CASCADES_COUNT: number;
  141148. protected _validateFilter(filter: number): number;
  141149. /**
  141150. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  141151. */
  141152. penumbraDarkness: number;
  141153. private _numCascades;
  141154. /**
  141155. * Gets or set the number of cascades used by the CSM.
  141156. */
  141157. get numCascades(): number;
  141158. set numCascades(value: number);
  141159. /**
  141160. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  141161. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  141162. */
  141163. stabilizeCascades: boolean;
  141164. private _freezeShadowCastersBoundingInfo;
  141165. private _freezeShadowCastersBoundingInfoObservable;
  141166. /**
  141167. * Enables or disables the shadow casters bounding info computation.
  141168. * If your shadow casters don't move, you can disable this feature.
  141169. * If it is enabled, the bounding box computation is done every frame.
  141170. */
  141171. get freezeShadowCastersBoundingInfo(): boolean;
  141172. set freezeShadowCastersBoundingInfo(freeze: boolean);
  141173. private _scbiMin;
  141174. private _scbiMax;
  141175. protected _computeShadowCastersBoundingInfo(): void;
  141176. protected _shadowCastersBoundingInfo: BoundingInfo;
  141177. /**
  141178. * Gets or sets the shadow casters bounding info.
  141179. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  141180. * so that the system won't overwrite the bounds you provide
  141181. */
  141182. get shadowCastersBoundingInfo(): BoundingInfo;
  141183. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  141184. protected _breaksAreDirty: boolean;
  141185. protected _minDistance: number;
  141186. protected _maxDistance: number;
  141187. /**
  141188. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  141189. *
  141190. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  141191. * If you don't know these values, simply leave them to their defaults and don't call this function.
  141192. * @param min minimal distance for the breaks (default to 0.)
  141193. * @param max maximal distance for the breaks (default to 1.)
  141194. */
  141195. setMinMaxDistance(min: number, max: number): void;
  141196. /** Gets the minimal distance used in the cascade break computation */
  141197. get minDistance(): number;
  141198. /** Gets the maximal distance used in the cascade break computation */
  141199. get maxDistance(): number;
  141200. /**
  141201. * Gets the class name of that object
  141202. * @returns "CascadedShadowGenerator"
  141203. */
  141204. getClassName(): string;
  141205. private _cascadeMinExtents;
  141206. private _cascadeMaxExtents;
  141207. /**
  141208. * Gets a cascade minimum extents
  141209. * @param cascadeIndex index of the cascade
  141210. * @returns the minimum cascade extents
  141211. */
  141212. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  141213. /**
  141214. * Gets a cascade maximum extents
  141215. * @param cascadeIndex index of the cascade
  141216. * @returns the maximum cascade extents
  141217. */
  141218. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  141219. private _cascades;
  141220. private _currentLayer;
  141221. private _viewSpaceFrustumsZ;
  141222. private _viewMatrices;
  141223. private _projectionMatrices;
  141224. private _transformMatrices;
  141225. private _transformMatricesAsArray;
  141226. private _frustumLengths;
  141227. private _lightSizeUVCorrection;
  141228. private _depthCorrection;
  141229. private _frustumCornersWorldSpace;
  141230. private _frustumCenter;
  141231. private _shadowCameraPos;
  141232. private _shadowMaxZ;
  141233. /**
  141234. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  141235. * It defaults to camera.maxZ
  141236. */
  141237. get shadowMaxZ(): number;
  141238. /**
  141239. * Sets the shadow max z distance.
  141240. */
  141241. set shadowMaxZ(value: number);
  141242. protected _debug: boolean;
  141243. /**
  141244. * Gets or sets the debug flag.
  141245. * When enabled, the cascades are materialized by different colors on the screen.
  141246. */
  141247. get debug(): boolean;
  141248. set debug(dbg: boolean);
  141249. private _depthClamp;
  141250. /**
  141251. * Gets or sets the depth clamping value.
  141252. *
  141253. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  141254. * to account for the shadow casters far away.
  141255. *
  141256. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  141257. */
  141258. get depthClamp(): boolean;
  141259. set depthClamp(value: boolean);
  141260. private _cascadeBlendPercentage;
  141261. /**
  141262. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  141263. * It defaults to 0.1 (10% blending).
  141264. */
  141265. get cascadeBlendPercentage(): number;
  141266. set cascadeBlendPercentage(value: number);
  141267. private _lambda;
  141268. /**
  141269. * Gets or set the lambda parameter.
  141270. * This parameter is used to split the camera frustum and create the cascades.
  141271. * 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.
  141272. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  141273. */
  141274. get lambda(): number;
  141275. set lambda(value: number);
  141276. /**
  141277. * Gets the view matrix corresponding to a given cascade
  141278. * @param cascadeNum cascade to retrieve the view matrix from
  141279. * @returns the cascade view matrix
  141280. */
  141281. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  141282. /**
  141283. * Gets the projection matrix corresponding to a given cascade
  141284. * @param cascadeNum cascade to retrieve the projection matrix from
  141285. * @returns the cascade projection matrix
  141286. */
  141287. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  141288. /**
  141289. * Gets the transformation matrix corresponding to a given cascade
  141290. * @param cascadeNum cascade to retrieve the transformation matrix from
  141291. * @returns the cascade transformation matrix
  141292. */
  141293. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  141294. private _depthRenderer;
  141295. /**
  141296. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  141297. *
  141298. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  141299. *
  141300. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  141301. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  141302. * @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
  141303. */
  141304. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  141305. private _depthReducer;
  141306. private _autoCalcDepthBounds;
  141307. /**
  141308. * Gets or sets the autoCalcDepthBounds property.
  141309. *
  141310. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  141311. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  141312. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  141313. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  141314. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  141315. */
  141316. get autoCalcDepthBounds(): boolean;
  141317. set autoCalcDepthBounds(value: boolean);
  141318. /**
  141319. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  141320. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141321. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  141322. * for setting the refresh rate on the renderer yourself!
  141323. */
  141324. get autoCalcDepthBoundsRefreshRate(): number;
  141325. set autoCalcDepthBoundsRefreshRate(value: number);
  141326. /**
  141327. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  141328. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  141329. * you change the camera near/far planes!
  141330. */
  141331. splitFrustum(): void;
  141332. private _splitFrustum;
  141333. private _computeMatrices;
  141334. private _computeFrustumInWorldSpace;
  141335. private _computeCascadeFrustum;
  141336. /**
  141337. * Support test.
  141338. */
  141339. static get IsSupported(): boolean;
  141340. /** @hidden */
  141341. static _SceneComponentInitialization: (scene: Scene) => void;
  141342. /**
  141343. * Creates a Cascaded Shadow Generator object.
  141344. * A ShadowGenerator is the required tool to use the shadows.
  141345. * Each directional light casting shadows needs to use its own ShadowGenerator.
  141346. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141347. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  141348. * @param light The directional light object generating the shadows.
  141349. * @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.
  141350. */
  141351. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  141352. protected _initializeGenerator(): void;
  141353. protected _createTargetRenderTexture(): void;
  141354. protected _initializeShadowMap(): void;
  141355. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  141356. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  141357. /**
  141358. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  141359. * @param defines Defines of the material we want to update
  141360. * @param lightIndex Index of the light in the enabled light list of the material
  141361. */
  141362. prepareDefines(defines: any, lightIndex: number): void;
  141363. /**
  141364. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  141365. * defined in the generator but impacting the effect).
  141366. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  141367. * @param effect The effect we are binfing the information for
  141368. */
  141369. bindShadowLight(lightIndex: string, effect: Effect): void;
  141370. /**
  141371. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  141372. * (eq to view projection * shadow projection matrices)
  141373. * @returns The transform matrix used to create the shadow map
  141374. */
  141375. getTransformMatrix(): Matrix;
  141376. /**
  141377. * Disposes the ShadowGenerator.
  141378. * Returns nothing.
  141379. */
  141380. dispose(): void;
  141381. /**
  141382. * Serializes the shadow generator setup to a json object.
  141383. * @returns The serialized JSON object
  141384. */
  141385. serialize(): any;
  141386. /**
  141387. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  141388. * @param parsedShadowGenerator The JSON object to parse
  141389. * @param scene The scene to create the shadow map for
  141390. * @returns The parsed shadow generator
  141391. */
  141392. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  141393. }
  141394. }
  141395. declare module BABYLON {
  141396. /**
  141397. * Defines the shadow generator component responsible to manage any shadow generators
  141398. * in a given scene.
  141399. */
  141400. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  141401. /**
  141402. * The component name helpfull to identify the component in the list of scene components.
  141403. */
  141404. readonly name: string;
  141405. /**
  141406. * The scene the component belongs to.
  141407. */
  141408. scene: Scene;
  141409. /**
  141410. * Creates a new instance of the component for the given scene
  141411. * @param scene Defines the scene to register the component in
  141412. */
  141413. constructor(scene: Scene);
  141414. /**
  141415. * Registers the component in a given scene
  141416. */
  141417. register(): void;
  141418. /**
  141419. * Rebuilds the elements related to this component in case of
  141420. * context lost for instance.
  141421. */
  141422. rebuild(): void;
  141423. /**
  141424. * Serializes the component data to the specified json object
  141425. * @param serializationObject The object to serialize to
  141426. */
  141427. serialize(serializationObject: any): void;
  141428. /**
  141429. * Adds all the elements from the container to the scene
  141430. * @param container the container holding the elements
  141431. */
  141432. addFromContainer(container: AbstractScene): void;
  141433. /**
  141434. * Removes all the elements in the container from the scene
  141435. * @param container contains the elements to remove
  141436. * @param dispose if the removed element should be disposed (default: false)
  141437. */
  141438. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141439. /**
  141440. * Rebuilds the elements related to this component in case of
  141441. * context lost for instance.
  141442. */
  141443. dispose(): void;
  141444. private _gatherRenderTargets;
  141445. }
  141446. }
  141447. declare module BABYLON {
  141448. /**
  141449. * A point light is a light defined by an unique point in world space.
  141450. * The light is emitted in every direction from this point.
  141451. * A good example of a point light is a standard light bulb.
  141452. * Documentation: https://doc.babylonjs.com/babylon101/lights
  141453. */
  141454. export class PointLight extends ShadowLight {
  141455. private _shadowAngle;
  141456. /**
  141457. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141458. * This specifies what angle the shadow will use to be created.
  141459. *
  141460. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141461. */
  141462. get shadowAngle(): number;
  141463. /**
  141464. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141465. * This specifies what angle the shadow will use to be created.
  141466. *
  141467. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141468. */
  141469. set shadowAngle(value: number);
  141470. /**
  141471. * Gets the direction if it has been set.
  141472. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141473. */
  141474. get direction(): Vector3;
  141475. /**
  141476. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141477. */
  141478. set direction(value: Vector3);
  141479. /**
  141480. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  141481. * A PointLight emits the light in every direction.
  141482. * It can cast shadows.
  141483. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  141484. * ```javascript
  141485. * var pointLight = new PointLight("pl", camera.position, scene);
  141486. * ```
  141487. * Documentation : https://doc.babylonjs.com/babylon101/lights
  141488. * @param name The light friendly name
  141489. * @param position The position of the point light in the scene
  141490. * @param scene The scene the lights belongs to
  141491. */
  141492. constructor(name: string, position: Vector3, scene: Scene);
  141493. /**
  141494. * Returns the string "PointLight"
  141495. * @returns the class name
  141496. */
  141497. getClassName(): string;
  141498. /**
  141499. * Returns the integer 0.
  141500. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  141501. */
  141502. getTypeID(): number;
  141503. /**
  141504. * Specifies wether or not the shadowmap should be a cube texture.
  141505. * @returns true if the shadowmap needs to be a cube texture.
  141506. */
  141507. needCube(): boolean;
  141508. /**
  141509. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  141510. * @param faceIndex The index of the face we are computed the direction to generate shadow
  141511. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  141512. */
  141513. getShadowDirection(faceIndex?: number): Vector3;
  141514. /**
  141515. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  141516. * - fov = PI / 2
  141517. * - aspect ratio : 1.0
  141518. * - z-near and far equal to the active camera minZ and maxZ.
  141519. * Returns the PointLight.
  141520. */
  141521. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  141522. protected _buildUniformLayout(): void;
  141523. /**
  141524. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  141525. * @param effect The effect to update
  141526. * @param lightIndex The index of the light in the effect to update
  141527. * @returns The point light
  141528. */
  141529. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  141530. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  141531. /**
  141532. * Prepares the list of defines specific to the light type.
  141533. * @param defines the list of defines
  141534. * @param lightIndex defines the index of the light for the effect
  141535. */
  141536. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  141537. }
  141538. }
  141539. declare module BABYLON {
  141540. /**
  141541. * Header information of HDR texture files.
  141542. */
  141543. export interface HDRInfo {
  141544. /**
  141545. * The height of the texture in pixels.
  141546. */
  141547. height: number;
  141548. /**
  141549. * The width of the texture in pixels.
  141550. */
  141551. width: number;
  141552. /**
  141553. * The index of the beginning of the data in the binary file.
  141554. */
  141555. dataPosition: number;
  141556. }
  141557. /**
  141558. * This groups tools to convert HDR texture to native colors array.
  141559. */
  141560. export class HDRTools {
  141561. private static Ldexp;
  141562. private static Rgbe2float;
  141563. private static readStringLine;
  141564. /**
  141565. * Reads header information from an RGBE texture stored in a native array.
  141566. * More information on this format are available here:
  141567. * https://en.wikipedia.org/wiki/RGBE_image_format
  141568. *
  141569. * @param uint8array The binary file stored in native array.
  141570. * @return The header information.
  141571. */
  141572. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  141573. /**
  141574. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  141575. * This RGBE texture needs to store the information as a panorama.
  141576. *
  141577. * More information on this format are available here:
  141578. * https://en.wikipedia.org/wiki/RGBE_image_format
  141579. *
  141580. * @param buffer The binary file stored in an array buffer.
  141581. * @param size The expected size of the extracted cubemap.
  141582. * @return The Cube Map information.
  141583. */
  141584. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  141585. /**
  141586. * Returns the pixels data extracted from an RGBE texture.
  141587. * This pixels will be stored left to right up to down in the R G B order in one array.
  141588. *
  141589. * More information on this format are available here:
  141590. * https://en.wikipedia.org/wiki/RGBE_image_format
  141591. *
  141592. * @param uint8array The binary file stored in an array buffer.
  141593. * @param hdrInfo The header information of the file.
  141594. * @return The pixels data in RGB right to left up to down order.
  141595. */
  141596. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  141597. private static RGBE_ReadPixels_RLE;
  141598. private static RGBE_ReadPixels_NOT_RLE;
  141599. }
  141600. }
  141601. declare module BABYLON {
  141602. /**
  141603. * Effect Render Options
  141604. */
  141605. export interface IEffectRendererOptions {
  141606. /**
  141607. * Defines the vertices positions.
  141608. */
  141609. positions?: number[];
  141610. /**
  141611. * Defines the indices.
  141612. */
  141613. indices?: number[];
  141614. }
  141615. /**
  141616. * Helper class to render one or more effects.
  141617. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  141618. */
  141619. export class EffectRenderer {
  141620. private engine;
  141621. private static _DefaultOptions;
  141622. private _vertexBuffers;
  141623. private _indexBuffer;
  141624. private _fullscreenViewport;
  141625. /**
  141626. * Creates an effect renderer
  141627. * @param engine the engine to use for rendering
  141628. * @param options defines the options of the effect renderer
  141629. */
  141630. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  141631. /**
  141632. * Sets the current viewport in normalized coordinates 0-1
  141633. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  141634. */
  141635. setViewport(viewport?: Viewport): void;
  141636. /**
  141637. * Binds the embedded attributes buffer to the effect.
  141638. * @param effect Defines the effect to bind the attributes for
  141639. */
  141640. bindBuffers(effect: Effect): void;
  141641. /**
  141642. * Sets the current effect wrapper to use during draw.
  141643. * The effect needs to be ready before calling this api.
  141644. * This also sets the default full screen position attribute.
  141645. * @param effectWrapper Defines the effect to draw with
  141646. */
  141647. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  141648. /**
  141649. * Restores engine states
  141650. */
  141651. restoreStates(): void;
  141652. /**
  141653. * Draws a full screen quad.
  141654. */
  141655. draw(): void;
  141656. private isRenderTargetTexture;
  141657. /**
  141658. * renders one or more effects to a specified texture
  141659. * @param effectWrapper the effect to renderer
  141660. * @param outputTexture texture to draw to, if null it will render to the screen.
  141661. */
  141662. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  141663. /**
  141664. * Disposes of the effect renderer
  141665. */
  141666. dispose(): void;
  141667. }
  141668. /**
  141669. * Options to create an EffectWrapper
  141670. */
  141671. interface EffectWrapperCreationOptions {
  141672. /**
  141673. * Engine to use to create the effect
  141674. */
  141675. engine: ThinEngine;
  141676. /**
  141677. * Fragment shader for the effect
  141678. */
  141679. fragmentShader: string;
  141680. /**
  141681. * Use the shader store instead of direct source code
  141682. */
  141683. useShaderStore?: boolean;
  141684. /**
  141685. * Vertex shader for the effect
  141686. */
  141687. vertexShader?: string;
  141688. /**
  141689. * Attributes to use in the shader
  141690. */
  141691. attributeNames?: Array<string>;
  141692. /**
  141693. * Uniforms to use in the shader
  141694. */
  141695. uniformNames?: Array<string>;
  141696. /**
  141697. * Texture sampler names to use in the shader
  141698. */
  141699. samplerNames?: Array<string>;
  141700. /**
  141701. * Defines to use in the shader
  141702. */
  141703. defines?: Array<string>;
  141704. /**
  141705. * Callback when effect is compiled
  141706. */
  141707. onCompiled?: Nullable<(effect: Effect) => void>;
  141708. /**
  141709. * The friendly name of the effect displayed in Spector.
  141710. */
  141711. name?: string;
  141712. }
  141713. /**
  141714. * Wraps an effect to be used for rendering
  141715. */
  141716. export class EffectWrapper {
  141717. /**
  141718. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  141719. */
  141720. onApplyObservable: Observable<{}>;
  141721. /**
  141722. * The underlying effect
  141723. */
  141724. effect: Effect;
  141725. /**
  141726. * Creates an effect to be renderer
  141727. * @param creationOptions options to create the effect
  141728. */
  141729. constructor(creationOptions: EffectWrapperCreationOptions);
  141730. /**
  141731. * Disposes of the effect wrapper
  141732. */
  141733. dispose(): void;
  141734. }
  141735. }
  141736. declare module BABYLON {
  141737. /** @hidden */
  141738. export var hdrFilteringVertexShader: {
  141739. name: string;
  141740. shader: string;
  141741. };
  141742. }
  141743. declare module BABYLON {
  141744. /** @hidden */
  141745. export var hdrFilteringPixelShader: {
  141746. name: string;
  141747. shader: string;
  141748. };
  141749. }
  141750. declare module BABYLON {
  141751. /**
  141752. * Options for texture filtering
  141753. */
  141754. interface IHDRFilteringOptions {
  141755. /**
  141756. * Scales pixel intensity for the input HDR map.
  141757. */
  141758. hdrScale?: number;
  141759. /**
  141760. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  141761. */
  141762. quality?: number;
  141763. }
  141764. /**
  141765. * Filters HDR maps to get correct renderings of PBR reflections
  141766. */
  141767. export class HDRFiltering {
  141768. private _engine;
  141769. private _effectRenderer;
  141770. private _effectWrapper;
  141771. private _lodGenerationOffset;
  141772. private _lodGenerationScale;
  141773. /**
  141774. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  141775. * you care about baking speed.
  141776. */
  141777. quality: number;
  141778. /**
  141779. * Scales pixel intensity for the input HDR map.
  141780. */
  141781. hdrScale: number;
  141782. /**
  141783. * Instantiates HDR filter for reflection maps
  141784. *
  141785. * @param engine Thin engine
  141786. * @param options Options
  141787. */
  141788. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  141789. private _createRenderTarget;
  141790. private _prefilterInternal;
  141791. private _createEffect;
  141792. /**
  141793. * Get a value indicating if the filter is ready to be used
  141794. * @param texture Texture to filter
  141795. * @returns true if the filter is ready
  141796. */
  141797. isReady(texture: BaseTexture): boolean;
  141798. /**
  141799. * Prefilters a cube texture to have mipmap levels representing roughness values.
  141800. * Prefiltering will be invoked at the end of next rendering pass.
  141801. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  141802. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  141803. * @param texture Texture to filter
  141804. * @param onFinished Callback when filtering is done
  141805. * @return Promise called when prefiltering is done
  141806. */
  141807. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  141808. }
  141809. }
  141810. declare module BABYLON {
  141811. /**
  141812. * This represents a texture coming from an HDR input.
  141813. *
  141814. * The only supported format is currently panorama picture stored in RGBE format.
  141815. * Example of such files can be found on HDRLib: http://hdrlib.com/
  141816. */
  141817. export class HDRCubeTexture extends BaseTexture {
  141818. private static _facesMapping;
  141819. private _generateHarmonics;
  141820. private _noMipmap;
  141821. private _prefilterOnLoad;
  141822. private _textureMatrix;
  141823. private _size;
  141824. private _onLoad;
  141825. private _onError;
  141826. /**
  141827. * The texture URL.
  141828. */
  141829. url: string;
  141830. protected _isBlocking: boolean;
  141831. /**
  141832. * Sets wether or not the texture is blocking during loading.
  141833. */
  141834. set isBlocking(value: boolean);
  141835. /**
  141836. * Gets wether or not the texture is blocking during loading.
  141837. */
  141838. get isBlocking(): boolean;
  141839. protected _rotationY: number;
  141840. /**
  141841. * Sets texture matrix rotation angle around Y axis in radians.
  141842. */
  141843. set rotationY(value: number);
  141844. /**
  141845. * Gets texture matrix rotation angle around Y axis radians.
  141846. */
  141847. get rotationY(): number;
  141848. /**
  141849. * Gets or sets the center of the bounding box associated with the cube texture
  141850. * It must define where the camera used to render the texture was set
  141851. */
  141852. boundingBoxPosition: Vector3;
  141853. private _boundingBoxSize;
  141854. /**
  141855. * Gets or sets the size of the bounding box associated with the cube texture
  141856. * When defined, the cubemap will switch to local mode
  141857. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  141858. * @example https://www.babylonjs-playground.com/#RNASML
  141859. */
  141860. set boundingBoxSize(value: Vector3);
  141861. get boundingBoxSize(): Vector3;
  141862. /**
  141863. * Instantiates an HDRTexture from the following parameters.
  141864. *
  141865. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  141866. * @param sceneOrEngine The scene or engine the texture will be used in
  141867. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141868. * @param noMipmap Forces to not generate the mipmap if true
  141869. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  141870. * @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)
  141871. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  141872. */
  141873. 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>);
  141874. /**
  141875. * Get the current class name of the texture useful for serialization or dynamic coding.
  141876. * @returns "HDRCubeTexture"
  141877. */
  141878. getClassName(): string;
  141879. /**
  141880. * Occurs when the file is raw .hdr file.
  141881. */
  141882. private loadTexture;
  141883. clone(): HDRCubeTexture;
  141884. delayLoad(): void;
  141885. /**
  141886. * Get the texture reflection matrix used to rotate/transform the reflection.
  141887. * @returns the reflection matrix
  141888. */
  141889. getReflectionTextureMatrix(): Matrix;
  141890. /**
  141891. * Set the texture reflection matrix used to rotate/transform the reflection.
  141892. * @param value Define the reflection matrix to set
  141893. */
  141894. setReflectionTextureMatrix(value: Matrix): void;
  141895. /**
  141896. * Parses a JSON representation of an HDR Texture in order to create the texture
  141897. * @param parsedTexture Define the JSON representation
  141898. * @param scene Define the scene the texture should be created in
  141899. * @param rootUrl Define the root url in case we need to load relative dependencies
  141900. * @returns the newly created texture after parsing
  141901. */
  141902. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  141903. serialize(): any;
  141904. }
  141905. }
  141906. declare module BABYLON {
  141907. /**
  141908. * Class used to control physics engine
  141909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141910. */
  141911. export class PhysicsEngine implements IPhysicsEngine {
  141912. private _physicsPlugin;
  141913. /**
  141914. * Global value used to control the smallest number supported by the simulation
  141915. */
  141916. static Epsilon: number;
  141917. private _impostors;
  141918. private _joints;
  141919. private _subTimeStep;
  141920. /**
  141921. * Gets the gravity vector used by the simulation
  141922. */
  141923. gravity: Vector3;
  141924. /**
  141925. * Factory used to create the default physics plugin.
  141926. * @returns The default physics plugin
  141927. */
  141928. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  141929. /**
  141930. * Creates a new Physics Engine
  141931. * @param gravity defines the gravity vector used by the simulation
  141932. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  141933. */
  141934. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  141935. /**
  141936. * Sets the gravity vector used by the simulation
  141937. * @param gravity defines the gravity vector to use
  141938. */
  141939. setGravity(gravity: Vector3): void;
  141940. /**
  141941. * Set the time step of the physics engine.
  141942. * Default is 1/60.
  141943. * To slow it down, enter 1/600 for example.
  141944. * To speed it up, 1/30
  141945. * @param newTimeStep defines the new timestep to apply to this world.
  141946. */
  141947. setTimeStep(newTimeStep?: number): void;
  141948. /**
  141949. * Get the time step of the physics engine.
  141950. * @returns the current time step
  141951. */
  141952. getTimeStep(): number;
  141953. /**
  141954. * Set the sub time step of the physics engine.
  141955. * Default is 0 meaning there is no sub steps
  141956. * To increase physics resolution precision, set a small value (like 1 ms)
  141957. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141958. */
  141959. setSubTimeStep(subTimeStep?: number): void;
  141960. /**
  141961. * Get the sub time step of the physics engine.
  141962. * @returns the current sub time step
  141963. */
  141964. getSubTimeStep(): number;
  141965. /**
  141966. * Release all resources
  141967. */
  141968. dispose(): void;
  141969. /**
  141970. * Gets the name of the current physics plugin
  141971. * @returns the name of the plugin
  141972. */
  141973. getPhysicsPluginName(): string;
  141974. /**
  141975. * Adding a new impostor for the impostor tracking.
  141976. * This will be done by the impostor itself.
  141977. * @param impostor the impostor to add
  141978. */
  141979. addImpostor(impostor: PhysicsImpostor): void;
  141980. /**
  141981. * Remove an impostor from the engine.
  141982. * This impostor and its mesh will not longer be updated by the physics engine.
  141983. * @param impostor the impostor to remove
  141984. */
  141985. removeImpostor(impostor: PhysicsImpostor): void;
  141986. /**
  141987. * Add a joint to the physics engine
  141988. * @param mainImpostor defines the main impostor to which the joint is added.
  141989. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141990. * @param joint defines the joint that will connect both impostors.
  141991. */
  141992. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141993. /**
  141994. * Removes a joint from the simulation
  141995. * @param mainImpostor defines the impostor used with the joint
  141996. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141997. * @param joint defines the joint to remove
  141998. */
  141999. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142000. /**
  142001. * Called by the scene. No need to call it.
  142002. * @param delta defines the timespam between frames
  142003. */
  142004. _step(delta: number): void;
  142005. /**
  142006. * Gets the current plugin used to run the simulation
  142007. * @returns current plugin
  142008. */
  142009. getPhysicsPlugin(): IPhysicsEnginePlugin;
  142010. /**
  142011. * Gets the list of physic impostors
  142012. * @returns an array of PhysicsImpostor
  142013. */
  142014. getImpostors(): Array<PhysicsImpostor>;
  142015. /**
  142016. * Gets the impostor for a physics enabled object
  142017. * @param object defines the object impersonated by the impostor
  142018. * @returns the PhysicsImpostor or null if not found
  142019. */
  142020. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  142021. /**
  142022. * Gets the impostor for a physics body object
  142023. * @param body defines physics body used by the impostor
  142024. * @returns the PhysicsImpostor or null if not found
  142025. */
  142026. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  142027. /**
  142028. * Does a raycast in the physics world
  142029. * @param from when should the ray start?
  142030. * @param to when should the ray end?
  142031. * @returns PhysicsRaycastResult
  142032. */
  142033. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142034. }
  142035. }
  142036. declare module BABYLON {
  142037. /** @hidden */
  142038. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  142039. private _useDeltaForWorldStep;
  142040. world: any;
  142041. name: string;
  142042. private _physicsMaterials;
  142043. private _fixedTimeStep;
  142044. private _cannonRaycastResult;
  142045. private _raycastResult;
  142046. private _physicsBodysToRemoveAfterStep;
  142047. private _firstFrame;
  142048. BJSCANNON: any;
  142049. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  142050. setGravity(gravity: Vector3): void;
  142051. setTimeStep(timeStep: number): void;
  142052. getTimeStep(): number;
  142053. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142054. private _removeMarkedPhysicsBodiesFromWorld;
  142055. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142056. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142057. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142058. private _processChildMeshes;
  142059. removePhysicsBody(impostor: PhysicsImpostor): void;
  142060. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142061. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142062. private _addMaterial;
  142063. private _checkWithEpsilon;
  142064. private _createShape;
  142065. private _createHeightmap;
  142066. private _minus90X;
  142067. private _plus90X;
  142068. private _tmpPosition;
  142069. private _tmpDeltaPosition;
  142070. private _tmpUnityRotation;
  142071. private _updatePhysicsBodyTransformation;
  142072. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142073. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142074. isSupported(): boolean;
  142075. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142076. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142077. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142078. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142079. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142080. getBodyMass(impostor: PhysicsImpostor): number;
  142081. getBodyFriction(impostor: PhysicsImpostor): number;
  142082. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142083. getBodyRestitution(impostor: PhysicsImpostor): number;
  142084. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142085. sleepBody(impostor: PhysicsImpostor): void;
  142086. wakeUpBody(impostor: PhysicsImpostor): void;
  142087. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  142088. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142089. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142090. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142091. getRadius(impostor: PhysicsImpostor): number;
  142092. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142093. dispose(): void;
  142094. private _extendNamespace;
  142095. /**
  142096. * Does a raycast in the physics world
  142097. * @param from when should the ray start?
  142098. * @param to when should the ray end?
  142099. * @returns PhysicsRaycastResult
  142100. */
  142101. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142102. }
  142103. }
  142104. declare module BABYLON {
  142105. /** @hidden */
  142106. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  142107. private _useDeltaForWorldStep;
  142108. world: any;
  142109. name: string;
  142110. BJSOIMO: any;
  142111. private _raycastResult;
  142112. private _fixedTimeStep;
  142113. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  142114. setGravity(gravity: Vector3): void;
  142115. setTimeStep(timeStep: number): void;
  142116. getTimeStep(): number;
  142117. private _tmpImpostorsArray;
  142118. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142119. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142120. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142121. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142122. private _tmpPositionVector;
  142123. removePhysicsBody(impostor: PhysicsImpostor): void;
  142124. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142125. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142126. isSupported(): boolean;
  142127. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142128. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142129. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142130. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142131. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142132. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142133. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142134. getBodyMass(impostor: PhysicsImpostor): number;
  142135. getBodyFriction(impostor: PhysicsImpostor): number;
  142136. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142137. getBodyRestitution(impostor: PhysicsImpostor): number;
  142138. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142139. sleepBody(impostor: PhysicsImpostor): void;
  142140. wakeUpBody(impostor: PhysicsImpostor): void;
  142141. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142142. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  142143. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  142144. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142145. getRadius(impostor: PhysicsImpostor): number;
  142146. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142147. dispose(): void;
  142148. /**
  142149. * Does a raycast in the physics world
  142150. * @param from when should the ray start?
  142151. * @param to when should the ray end?
  142152. * @returns PhysicsRaycastResult
  142153. */
  142154. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142155. }
  142156. }
  142157. declare module BABYLON {
  142158. /**
  142159. * AmmoJS Physics plugin
  142160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142161. * @see https://github.com/kripken/ammo.js/
  142162. */
  142163. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  142164. private _useDeltaForWorldStep;
  142165. /**
  142166. * Reference to the Ammo library
  142167. */
  142168. bjsAMMO: any;
  142169. /**
  142170. * Created ammoJS world which physics bodies are added to
  142171. */
  142172. world: any;
  142173. /**
  142174. * Name of the plugin
  142175. */
  142176. name: string;
  142177. private _timeStep;
  142178. private _fixedTimeStep;
  142179. private _maxSteps;
  142180. private _tmpQuaternion;
  142181. private _tmpAmmoTransform;
  142182. private _tmpAmmoQuaternion;
  142183. private _tmpAmmoConcreteContactResultCallback;
  142184. private _collisionConfiguration;
  142185. private _dispatcher;
  142186. private _overlappingPairCache;
  142187. private _solver;
  142188. private _softBodySolver;
  142189. private _tmpAmmoVectorA;
  142190. private _tmpAmmoVectorB;
  142191. private _tmpAmmoVectorC;
  142192. private _tmpAmmoVectorD;
  142193. private _tmpContactCallbackResult;
  142194. private _tmpAmmoVectorRCA;
  142195. private _tmpAmmoVectorRCB;
  142196. private _raycastResult;
  142197. private static readonly DISABLE_COLLISION_FLAG;
  142198. private static readonly KINEMATIC_FLAG;
  142199. private static readonly DISABLE_DEACTIVATION_FLAG;
  142200. /**
  142201. * Initializes the ammoJS plugin
  142202. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  142203. * @param ammoInjection can be used to inject your own ammo reference
  142204. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  142205. */
  142206. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  142207. /**
  142208. * Sets the gravity of the physics world (m/(s^2))
  142209. * @param gravity Gravity to set
  142210. */
  142211. setGravity(gravity: Vector3): void;
  142212. /**
  142213. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  142214. * @param timeStep timestep to use in seconds
  142215. */
  142216. setTimeStep(timeStep: number): void;
  142217. /**
  142218. * 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)
  142219. * @param fixedTimeStep fixedTimeStep to use in seconds
  142220. */
  142221. setFixedTimeStep(fixedTimeStep: number): void;
  142222. /**
  142223. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  142224. * @param maxSteps the maximum number of steps by the physics engine per frame
  142225. */
  142226. setMaxSteps(maxSteps: number): void;
  142227. /**
  142228. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  142229. * @returns the current timestep in seconds
  142230. */
  142231. getTimeStep(): number;
  142232. /**
  142233. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  142234. */
  142235. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  142236. private _isImpostorInContact;
  142237. private _isImpostorPairInContact;
  142238. private _stepSimulation;
  142239. /**
  142240. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  142241. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  142242. * After the step the babylon meshes are set to the position of the physics imposters
  142243. * @param delta amount of time to step forward
  142244. * @param impostors array of imposters to update before/after the step
  142245. */
  142246. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142247. /**
  142248. * Update babylon mesh to match physics world object
  142249. * @param impostor imposter to match
  142250. */
  142251. private _afterSoftStep;
  142252. /**
  142253. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142254. * @param impostor imposter to match
  142255. */
  142256. private _ropeStep;
  142257. /**
  142258. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142259. * @param impostor imposter to match
  142260. */
  142261. private _softbodyOrClothStep;
  142262. private _tmpMatrix;
  142263. /**
  142264. * Applies an impulse on the imposter
  142265. * @param impostor imposter to apply impulse to
  142266. * @param force amount of force to be applied to the imposter
  142267. * @param contactPoint the location to apply the impulse on the imposter
  142268. */
  142269. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142270. /**
  142271. * Applies a force on the imposter
  142272. * @param impostor imposter to apply force
  142273. * @param force amount of force to be applied to the imposter
  142274. * @param contactPoint the location to apply the force on the imposter
  142275. */
  142276. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142277. /**
  142278. * Creates a physics body using the plugin
  142279. * @param impostor the imposter to create the physics body on
  142280. */
  142281. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142282. /**
  142283. * Removes the physics body from the imposter and disposes of the body's memory
  142284. * @param impostor imposter to remove the physics body from
  142285. */
  142286. removePhysicsBody(impostor: PhysicsImpostor): void;
  142287. /**
  142288. * Generates a joint
  142289. * @param impostorJoint the imposter joint to create the joint with
  142290. */
  142291. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142292. /**
  142293. * Removes a joint
  142294. * @param impostorJoint the imposter joint to remove the joint from
  142295. */
  142296. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142297. private _addMeshVerts;
  142298. /**
  142299. * Initialise the soft body vertices to match its object's (mesh) vertices
  142300. * Softbody vertices (nodes) are in world space and to match this
  142301. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  142302. * @param impostor to create the softbody for
  142303. */
  142304. private _softVertexData;
  142305. /**
  142306. * Create an impostor's soft body
  142307. * @param impostor to create the softbody for
  142308. */
  142309. private _createSoftbody;
  142310. /**
  142311. * Create cloth for an impostor
  142312. * @param impostor to create the softbody for
  142313. */
  142314. private _createCloth;
  142315. /**
  142316. * Create rope for an impostor
  142317. * @param impostor to create the softbody for
  142318. */
  142319. private _createRope;
  142320. /**
  142321. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  142322. * @param impostor to create the custom physics shape for
  142323. */
  142324. private _createCustom;
  142325. private _addHullVerts;
  142326. private _createShape;
  142327. /**
  142328. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  142329. * @param impostor imposter containing the physics body and babylon object
  142330. */
  142331. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142332. /**
  142333. * Sets the babylon object's position/rotation from the physics body's position/rotation
  142334. * @param impostor imposter containing the physics body and babylon object
  142335. * @param newPosition new position
  142336. * @param newRotation new rotation
  142337. */
  142338. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142339. /**
  142340. * If this plugin is supported
  142341. * @returns true if its supported
  142342. */
  142343. isSupported(): boolean;
  142344. /**
  142345. * Sets the linear velocity of the physics body
  142346. * @param impostor imposter to set the velocity on
  142347. * @param velocity velocity to set
  142348. */
  142349. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142350. /**
  142351. * Sets the angular velocity of the physics body
  142352. * @param impostor imposter to set the velocity on
  142353. * @param velocity velocity to set
  142354. */
  142355. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142356. /**
  142357. * gets the linear velocity
  142358. * @param impostor imposter to get linear velocity from
  142359. * @returns linear velocity
  142360. */
  142361. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142362. /**
  142363. * gets the angular velocity
  142364. * @param impostor imposter to get angular velocity from
  142365. * @returns angular velocity
  142366. */
  142367. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142368. /**
  142369. * Sets the mass of physics body
  142370. * @param impostor imposter to set the mass on
  142371. * @param mass mass to set
  142372. */
  142373. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142374. /**
  142375. * Gets the mass of the physics body
  142376. * @param impostor imposter to get the mass from
  142377. * @returns mass
  142378. */
  142379. getBodyMass(impostor: PhysicsImpostor): number;
  142380. /**
  142381. * Gets friction of the impostor
  142382. * @param impostor impostor to get friction from
  142383. * @returns friction value
  142384. */
  142385. getBodyFriction(impostor: PhysicsImpostor): number;
  142386. /**
  142387. * Sets friction of the impostor
  142388. * @param impostor impostor to set friction on
  142389. * @param friction friction value
  142390. */
  142391. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142392. /**
  142393. * Gets restitution of the impostor
  142394. * @param impostor impostor to get restitution from
  142395. * @returns restitution value
  142396. */
  142397. getBodyRestitution(impostor: PhysicsImpostor): number;
  142398. /**
  142399. * Sets resitution of the impostor
  142400. * @param impostor impostor to set resitution on
  142401. * @param restitution resitution value
  142402. */
  142403. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142404. /**
  142405. * Gets pressure inside the impostor
  142406. * @param impostor impostor to get pressure from
  142407. * @returns pressure value
  142408. */
  142409. getBodyPressure(impostor: PhysicsImpostor): number;
  142410. /**
  142411. * Sets pressure inside a soft body impostor
  142412. * Cloth and rope must remain 0 pressure
  142413. * @param impostor impostor to set pressure on
  142414. * @param pressure pressure value
  142415. */
  142416. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  142417. /**
  142418. * Gets stiffness of the impostor
  142419. * @param impostor impostor to get stiffness from
  142420. * @returns pressure value
  142421. */
  142422. getBodyStiffness(impostor: PhysicsImpostor): number;
  142423. /**
  142424. * Sets stiffness of the impostor
  142425. * @param impostor impostor to set stiffness on
  142426. * @param stiffness stiffness value from 0 to 1
  142427. */
  142428. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  142429. /**
  142430. * Gets velocityIterations of the impostor
  142431. * @param impostor impostor to get velocity iterations from
  142432. * @returns velocityIterations value
  142433. */
  142434. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  142435. /**
  142436. * Sets velocityIterations of the impostor
  142437. * @param impostor impostor to set velocity iterations on
  142438. * @param velocityIterations velocityIterations value
  142439. */
  142440. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  142441. /**
  142442. * Gets positionIterations of the impostor
  142443. * @param impostor impostor to get position iterations from
  142444. * @returns positionIterations value
  142445. */
  142446. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  142447. /**
  142448. * Sets positionIterations of the impostor
  142449. * @param impostor impostor to set position on
  142450. * @param positionIterations positionIterations value
  142451. */
  142452. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  142453. /**
  142454. * Append an anchor to a cloth object
  142455. * @param impostor is the cloth impostor to add anchor to
  142456. * @param otherImpostor is the rigid impostor to anchor to
  142457. * @param width ratio across width from 0 to 1
  142458. * @param height ratio up height from 0 to 1
  142459. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  142460. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142461. */
  142462. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142463. /**
  142464. * Append an hook to a rope object
  142465. * @param impostor is the rope impostor to add hook to
  142466. * @param otherImpostor is the rigid impostor to hook to
  142467. * @param length ratio along the rope from 0 to 1
  142468. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  142469. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142470. */
  142471. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142472. /**
  142473. * Sleeps the physics body and stops it from being active
  142474. * @param impostor impostor to sleep
  142475. */
  142476. sleepBody(impostor: PhysicsImpostor): void;
  142477. /**
  142478. * Activates the physics body
  142479. * @param impostor impostor to activate
  142480. */
  142481. wakeUpBody(impostor: PhysicsImpostor): void;
  142482. /**
  142483. * Updates the distance parameters of the joint
  142484. * @param joint joint to update
  142485. * @param maxDistance maximum distance of the joint
  142486. * @param minDistance minimum distance of the joint
  142487. */
  142488. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142489. /**
  142490. * Sets a motor on the joint
  142491. * @param joint joint to set motor on
  142492. * @param speed speed of the motor
  142493. * @param maxForce maximum force of the motor
  142494. * @param motorIndex index of the motor
  142495. */
  142496. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142497. /**
  142498. * Sets the motors limit
  142499. * @param joint joint to set limit on
  142500. * @param upperLimit upper limit
  142501. * @param lowerLimit lower limit
  142502. */
  142503. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142504. /**
  142505. * Syncs the position and rotation of a mesh with the impostor
  142506. * @param mesh mesh to sync
  142507. * @param impostor impostor to update the mesh with
  142508. */
  142509. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142510. /**
  142511. * Gets the radius of the impostor
  142512. * @param impostor impostor to get radius from
  142513. * @returns the radius
  142514. */
  142515. getRadius(impostor: PhysicsImpostor): number;
  142516. /**
  142517. * Gets the box size of the impostor
  142518. * @param impostor impostor to get box size from
  142519. * @param result the resulting box size
  142520. */
  142521. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142522. /**
  142523. * Disposes of the impostor
  142524. */
  142525. dispose(): void;
  142526. /**
  142527. * Does a raycast in the physics world
  142528. * @param from when should the ray start?
  142529. * @param to when should the ray end?
  142530. * @returns PhysicsRaycastResult
  142531. */
  142532. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142533. }
  142534. }
  142535. declare module BABYLON {
  142536. interface AbstractScene {
  142537. /**
  142538. * The list of reflection probes added to the scene
  142539. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142540. */
  142541. reflectionProbes: Array<ReflectionProbe>;
  142542. /**
  142543. * Removes the given reflection probe from this scene.
  142544. * @param toRemove The reflection probe to remove
  142545. * @returns The index of the removed reflection probe
  142546. */
  142547. removeReflectionProbe(toRemove: ReflectionProbe): number;
  142548. /**
  142549. * Adds the given reflection probe to this scene.
  142550. * @param newReflectionProbe The reflection probe to add
  142551. */
  142552. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  142553. }
  142554. /**
  142555. * Class used to generate realtime reflection / refraction cube textures
  142556. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142557. */
  142558. export class ReflectionProbe {
  142559. /** defines the name of the probe */
  142560. name: string;
  142561. private _scene;
  142562. private _renderTargetTexture;
  142563. private _projectionMatrix;
  142564. private _viewMatrix;
  142565. private _target;
  142566. private _add;
  142567. private _attachedMesh;
  142568. private _invertYAxis;
  142569. /** Gets or sets probe position (center of the cube map) */
  142570. position: Vector3;
  142571. /**
  142572. * Creates a new reflection probe
  142573. * @param name defines the name of the probe
  142574. * @param size defines the texture resolution (for each face)
  142575. * @param scene defines the hosting scene
  142576. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  142577. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  142578. */
  142579. constructor(
  142580. /** defines the name of the probe */
  142581. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  142582. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  142583. get samples(): number;
  142584. set samples(value: number);
  142585. /** Gets or sets the refresh rate to use (on every frame by default) */
  142586. get refreshRate(): number;
  142587. set refreshRate(value: number);
  142588. /**
  142589. * Gets the hosting scene
  142590. * @returns a Scene
  142591. */
  142592. getScene(): Scene;
  142593. /** Gets the internal CubeTexture used to render to */
  142594. get cubeTexture(): RenderTargetTexture;
  142595. /** Gets the list of meshes to render */
  142596. get renderList(): Nullable<AbstractMesh[]>;
  142597. /**
  142598. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  142599. * @param mesh defines the mesh to attach to
  142600. */
  142601. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142602. /**
  142603. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  142604. * @param renderingGroupId The rendering group id corresponding to its index
  142605. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  142606. */
  142607. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  142608. /**
  142609. * Clean all associated resources
  142610. */
  142611. dispose(): void;
  142612. /**
  142613. * Converts the reflection probe information to a readable string for debug purpose.
  142614. * @param fullDetails Supports for multiple levels of logging within scene loading
  142615. * @returns the human readable reflection probe info
  142616. */
  142617. toString(fullDetails?: boolean): string;
  142618. /**
  142619. * Get the class name of the relfection probe.
  142620. * @returns "ReflectionProbe"
  142621. */
  142622. getClassName(): string;
  142623. /**
  142624. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  142625. * @returns The JSON representation of the texture
  142626. */
  142627. serialize(): any;
  142628. /**
  142629. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  142630. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  142631. * @param scene Define the scene the parsed reflection probe should be instantiated in
  142632. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  142633. * @returns The parsed reflection probe if successful
  142634. */
  142635. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  142636. }
  142637. }
  142638. declare module BABYLON {
  142639. /** @hidden */
  142640. export var _BabylonLoaderRegistered: boolean;
  142641. /**
  142642. * Helps setting up some configuration for the babylon file loader.
  142643. */
  142644. export class BabylonFileLoaderConfiguration {
  142645. /**
  142646. * The loader does not allow injecting custom physix engine into the plugins.
  142647. * Unfortunately in ES6, we need to manually inject them into the plugin.
  142648. * So you could set this variable to your engine import to make it work.
  142649. */
  142650. static LoaderInjectedPhysicsEngine: any;
  142651. }
  142652. }
  142653. declare module BABYLON {
  142654. /**
  142655. * The Physically based simple base material of BJS.
  142656. *
  142657. * This enables better naming and convention enforcements on top of the pbrMaterial.
  142658. * It is used as the base class for both the specGloss and metalRough conventions.
  142659. */
  142660. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  142661. /**
  142662. * Number of Simultaneous lights allowed on the material.
  142663. */
  142664. maxSimultaneousLights: number;
  142665. /**
  142666. * If sets to true, disables all the lights affecting the material.
  142667. */
  142668. disableLighting: boolean;
  142669. /**
  142670. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  142671. */
  142672. environmentTexture: BaseTexture;
  142673. /**
  142674. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  142675. */
  142676. invertNormalMapX: boolean;
  142677. /**
  142678. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  142679. */
  142680. invertNormalMapY: boolean;
  142681. /**
  142682. * Normal map used in the model.
  142683. */
  142684. normalTexture: BaseTexture;
  142685. /**
  142686. * Emissivie color used to self-illuminate the model.
  142687. */
  142688. emissiveColor: Color3;
  142689. /**
  142690. * Emissivie texture used to self-illuminate the model.
  142691. */
  142692. emissiveTexture: BaseTexture;
  142693. /**
  142694. * Occlusion Channel Strenght.
  142695. */
  142696. occlusionStrength: number;
  142697. /**
  142698. * Occlusion Texture of the material (adding extra occlusion effects).
  142699. */
  142700. occlusionTexture: BaseTexture;
  142701. /**
  142702. * Defines the alpha limits in alpha test mode.
  142703. */
  142704. alphaCutOff: number;
  142705. /**
  142706. * Gets the current double sided mode.
  142707. */
  142708. get doubleSided(): boolean;
  142709. /**
  142710. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  142711. */
  142712. set doubleSided(value: boolean);
  142713. /**
  142714. * Stores the pre-calculated light information of a mesh in a texture.
  142715. */
  142716. lightmapTexture: BaseTexture;
  142717. /**
  142718. * If true, the light map contains occlusion information instead of lighting info.
  142719. */
  142720. useLightmapAsShadowmap: boolean;
  142721. /**
  142722. * Instantiates a new PBRMaterial instance.
  142723. *
  142724. * @param name The material name
  142725. * @param scene The scene the material will be use in.
  142726. */
  142727. constructor(name: string, scene: Scene);
  142728. getClassName(): string;
  142729. }
  142730. }
  142731. declare module BABYLON {
  142732. /**
  142733. * The PBR material of BJS following the metal roughness convention.
  142734. *
  142735. * This fits to the PBR convention in the GLTF definition:
  142736. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  142737. */
  142738. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  142739. /**
  142740. * The base color has two different interpretations depending on the value of metalness.
  142741. * When the material is a metal, the base color is the specific measured reflectance value
  142742. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  142743. * of the material.
  142744. */
  142745. baseColor: Color3;
  142746. /**
  142747. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  142748. * well as opacity information in the alpha channel.
  142749. */
  142750. baseTexture: BaseTexture;
  142751. /**
  142752. * Specifies the metallic scalar value of the material.
  142753. * Can also be used to scale the metalness values of the metallic texture.
  142754. */
  142755. metallic: number;
  142756. /**
  142757. * Specifies the roughness scalar value of the material.
  142758. * Can also be used to scale the roughness values of the metallic texture.
  142759. */
  142760. roughness: number;
  142761. /**
  142762. * Texture containing both the metallic value in the B channel and the
  142763. * roughness value in the G channel to keep better precision.
  142764. */
  142765. metallicRoughnessTexture: BaseTexture;
  142766. /**
  142767. * Instantiates a new PBRMetalRoughnessMaterial instance.
  142768. *
  142769. * @param name The material name
  142770. * @param scene The scene the material will be use in.
  142771. */
  142772. constructor(name: string, scene: Scene);
  142773. /**
  142774. * Return the currrent class name of the material.
  142775. */
  142776. getClassName(): string;
  142777. /**
  142778. * Makes a duplicate of the current material.
  142779. * @param name - name to use for the new material.
  142780. */
  142781. clone(name: string): PBRMetallicRoughnessMaterial;
  142782. /**
  142783. * Serialize the material to a parsable JSON object.
  142784. */
  142785. serialize(): any;
  142786. /**
  142787. * Parses a JSON object correponding to the serialize function.
  142788. */
  142789. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  142790. }
  142791. }
  142792. declare module BABYLON {
  142793. /**
  142794. * The PBR material of BJS following the specular glossiness convention.
  142795. *
  142796. * This fits to the PBR convention in the GLTF definition:
  142797. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  142798. */
  142799. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  142800. /**
  142801. * Specifies the diffuse color of the material.
  142802. */
  142803. diffuseColor: Color3;
  142804. /**
  142805. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  142806. * channel.
  142807. */
  142808. diffuseTexture: BaseTexture;
  142809. /**
  142810. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  142811. */
  142812. specularColor: Color3;
  142813. /**
  142814. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  142815. */
  142816. glossiness: number;
  142817. /**
  142818. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  142819. */
  142820. specularGlossinessTexture: BaseTexture;
  142821. /**
  142822. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  142823. *
  142824. * @param name The material name
  142825. * @param scene The scene the material will be use in.
  142826. */
  142827. constructor(name: string, scene: Scene);
  142828. /**
  142829. * Return the currrent class name of the material.
  142830. */
  142831. getClassName(): string;
  142832. /**
  142833. * Makes a duplicate of the current material.
  142834. * @param name - name to use for the new material.
  142835. */
  142836. clone(name: string): PBRSpecularGlossinessMaterial;
  142837. /**
  142838. * Serialize the material to a parsable JSON object.
  142839. */
  142840. serialize(): any;
  142841. /**
  142842. * Parses a JSON object correponding to the serialize function.
  142843. */
  142844. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  142845. }
  142846. }
  142847. declare module BABYLON {
  142848. /**
  142849. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  142850. * It can help converting any input color in a desired output one. This can then be used to create effects
  142851. * from sepia, black and white to sixties or futuristic rendering...
  142852. *
  142853. * The only supported format is currently 3dl.
  142854. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  142855. */
  142856. export class ColorGradingTexture extends BaseTexture {
  142857. /**
  142858. * The texture URL.
  142859. */
  142860. url: string;
  142861. /**
  142862. * Empty line regex stored for GC.
  142863. */
  142864. private static _noneEmptyLineRegex;
  142865. private _textureMatrix;
  142866. private _onLoad;
  142867. /**
  142868. * Instantiates a ColorGradingTexture from the following parameters.
  142869. *
  142870. * @param url The location of the color gradind data (currently only supporting 3dl)
  142871. * @param sceneOrEngine The scene or engine the texture will be used in
  142872. * @param onLoad defines a callback triggered when the texture has been loaded
  142873. */
  142874. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  142875. /**
  142876. * Fires the onload event from the constructor if requested.
  142877. */
  142878. private _triggerOnLoad;
  142879. /**
  142880. * Returns the texture matrix used in most of the material.
  142881. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  142882. */
  142883. getTextureMatrix(): Matrix;
  142884. /**
  142885. * Occurs when the file being loaded is a .3dl LUT file.
  142886. */
  142887. private load3dlTexture;
  142888. /**
  142889. * Starts the loading process of the texture.
  142890. */
  142891. private loadTexture;
  142892. /**
  142893. * Clones the color gradind texture.
  142894. */
  142895. clone(): ColorGradingTexture;
  142896. /**
  142897. * Called during delayed load for textures.
  142898. */
  142899. delayLoad(): void;
  142900. /**
  142901. * Parses a color grading texture serialized by Babylon.
  142902. * @param parsedTexture The texture information being parsedTexture
  142903. * @param scene The scene to load the texture in
  142904. * @param rootUrl The root url of the data assets to load
  142905. * @return A color gradind texture
  142906. */
  142907. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  142908. /**
  142909. * Serializes the LUT texture to json format.
  142910. */
  142911. serialize(): any;
  142912. }
  142913. }
  142914. declare module BABYLON {
  142915. /**
  142916. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  142917. */
  142918. export class EquiRectangularCubeTexture extends BaseTexture {
  142919. /** The six faces of the cube. */
  142920. private static _FacesMapping;
  142921. private _noMipmap;
  142922. private _onLoad;
  142923. private _onError;
  142924. /** The size of the cubemap. */
  142925. private _size;
  142926. /** The buffer of the image. */
  142927. private _buffer;
  142928. /** The width of the input image. */
  142929. private _width;
  142930. /** The height of the input image. */
  142931. private _height;
  142932. /** The URL to the image. */
  142933. url: string;
  142934. /**
  142935. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  142936. * @param url The location of the image
  142937. * @param scene The scene the texture will be used in
  142938. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142939. * @param noMipmap Forces to not generate the mipmap if true
  142940. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142941. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142942. * @param onLoad — defines a callback called when texture is loaded
  142943. * @param onError — defines a callback called if there is an error
  142944. */
  142945. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  142946. /**
  142947. * Load the image data, by putting the image on a canvas and extracting its buffer.
  142948. */
  142949. private loadImage;
  142950. /**
  142951. * Convert the image buffer into a cubemap and create a CubeTexture.
  142952. */
  142953. private loadTexture;
  142954. /**
  142955. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142956. * @param buffer The ArrayBuffer that should be converted.
  142957. * @returns The buffer as Float32Array.
  142958. */
  142959. private getFloat32ArrayFromArrayBuffer;
  142960. /**
  142961. * Get the current class name of the texture useful for serialization or dynamic coding.
  142962. * @returns "EquiRectangularCubeTexture"
  142963. */
  142964. getClassName(): string;
  142965. /**
  142966. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142967. * @returns A clone of the current EquiRectangularCubeTexture.
  142968. */
  142969. clone(): EquiRectangularCubeTexture;
  142970. }
  142971. }
  142972. declare module BABYLON {
  142973. /**
  142974. * Defines the options related to the creation of an HtmlElementTexture
  142975. */
  142976. export interface IHtmlElementTextureOptions {
  142977. /**
  142978. * Defines wether mip maps should be created or not.
  142979. */
  142980. generateMipMaps?: boolean;
  142981. /**
  142982. * Defines the sampling mode of the texture.
  142983. */
  142984. samplingMode?: number;
  142985. /**
  142986. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142987. */
  142988. engine: Nullable<ThinEngine>;
  142989. /**
  142990. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142991. */
  142992. scene: Nullable<Scene>;
  142993. }
  142994. /**
  142995. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142996. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142997. * is automatically managed.
  142998. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142999. * in your application.
  143000. *
  143001. * As the update is not automatic, you need to call them manually.
  143002. */
  143003. export class HtmlElementTexture extends BaseTexture {
  143004. /**
  143005. * The texture URL.
  143006. */
  143007. element: HTMLVideoElement | HTMLCanvasElement;
  143008. private static readonly DefaultOptions;
  143009. private _textureMatrix;
  143010. private _isVideo;
  143011. private _generateMipMaps;
  143012. private _samplingMode;
  143013. /**
  143014. * Instantiates a HtmlElementTexture from the following parameters.
  143015. *
  143016. * @param name Defines the name of the texture
  143017. * @param element Defines the video or canvas the texture is filled with
  143018. * @param options Defines the other none mandatory texture creation options
  143019. */
  143020. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  143021. private _createInternalTexture;
  143022. /**
  143023. * Returns the texture matrix used in most of the material.
  143024. */
  143025. getTextureMatrix(): Matrix;
  143026. /**
  143027. * Updates the content of the texture.
  143028. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  143029. */
  143030. update(invertY?: Nullable<boolean>): void;
  143031. }
  143032. }
  143033. declare module BABYLON {
  143034. /**
  143035. * Based on jsTGALoader - Javascript loader for TGA file
  143036. * By Vincent Thibault
  143037. * @see http://blog.robrowser.com/javascript-tga-loader.html
  143038. */
  143039. export class TGATools {
  143040. private static _TYPE_INDEXED;
  143041. private static _TYPE_RGB;
  143042. private static _TYPE_GREY;
  143043. private static _TYPE_RLE_INDEXED;
  143044. private static _TYPE_RLE_RGB;
  143045. private static _TYPE_RLE_GREY;
  143046. private static _ORIGIN_MASK;
  143047. private static _ORIGIN_SHIFT;
  143048. private static _ORIGIN_BL;
  143049. private static _ORIGIN_BR;
  143050. private static _ORIGIN_UL;
  143051. private static _ORIGIN_UR;
  143052. /**
  143053. * Gets the header of a TGA file
  143054. * @param data defines the TGA data
  143055. * @returns the header
  143056. */
  143057. static GetTGAHeader(data: Uint8Array): any;
  143058. /**
  143059. * Uploads TGA content to a Babylon Texture
  143060. * @hidden
  143061. */
  143062. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  143063. /** @hidden */
  143064. 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;
  143065. /** @hidden */
  143066. 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;
  143067. /** @hidden */
  143068. 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;
  143069. /** @hidden */
  143070. 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;
  143071. /** @hidden */
  143072. 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;
  143073. /** @hidden */
  143074. 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;
  143075. }
  143076. }
  143077. declare module BABYLON {
  143078. /**
  143079. * Implementation of the TGA Texture Loader.
  143080. * @hidden
  143081. */
  143082. export class _TGATextureLoader implements IInternalTextureLoader {
  143083. /**
  143084. * Defines wether the loader supports cascade loading the different faces.
  143085. */
  143086. readonly supportCascades: boolean;
  143087. /**
  143088. * This returns if the loader support the current file information.
  143089. * @param extension defines the file extension of the file being loaded
  143090. * @returns true if the loader can load the specified file
  143091. */
  143092. canLoad(extension: string): boolean;
  143093. /**
  143094. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143095. * @param data contains the texture data
  143096. * @param texture defines the BabylonJS internal texture
  143097. * @param createPolynomials will be true if polynomials have been requested
  143098. * @param onLoad defines the callback to trigger once the texture is ready
  143099. * @param onError defines the callback to trigger in case of error
  143100. */
  143101. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143102. /**
  143103. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143104. * @param data contains the texture data
  143105. * @param texture defines the BabylonJS internal texture
  143106. * @param callback defines the method to call once ready to upload
  143107. */
  143108. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143109. }
  143110. }
  143111. declare module BABYLON {
  143112. /**
  143113. * Info about the .basis files
  143114. */
  143115. class BasisFileInfo {
  143116. /**
  143117. * If the file has alpha
  143118. */
  143119. hasAlpha: boolean;
  143120. /**
  143121. * Info about each image of the basis file
  143122. */
  143123. images: Array<{
  143124. levels: Array<{
  143125. width: number;
  143126. height: number;
  143127. transcodedPixels: ArrayBufferView;
  143128. }>;
  143129. }>;
  143130. }
  143131. /**
  143132. * Result of transcoding a basis file
  143133. */
  143134. class TranscodeResult {
  143135. /**
  143136. * Info about the .basis file
  143137. */
  143138. fileInfo: BasisFileInfo;
  143139. /**
  143140. * Format to use when loading the file
  143141. */
  143142. format: number;
  143143. }
  143144. /**
  143145. * Configuration options for the Basis transcoder
  143146. */
  143147. export class BasisTranscodeConfiguration {
  143148. /**
  143149. * Supported compression formats used to determine the supported output format of the transcoder
  143150. */
  143151. supportedCompressionFormats?: {
  143152. /**
  143153. * etc1 compression format
  143154. */
  143155. etc1?: boolean;
  143156. /**
  143157. * s3tc compression format
  143158. */
  143159. s3tc?: boolean;
  143160. /**
  143161. * pvrtc compression format
  143162. */
  143163. pvrtc?: boolean;
  143164. /**
  143165. * etc2 compression format
  143166. */
  143167. etc2?: boolean;
  143168. };
  143169. /**
  143170. * If mipmap levels should be loaded for transcoded images (Default: true)
  143171. */
  143172. loadMipmapLevels?: boolean;
  143173. /**
  143174. * Index of a single image to load (Default: all images)
  143175. */
  143176. loadSingleImage?: number;
  143177. }
  143178. /**
  143179. * Used to load .Basis files
  143180. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  143181. */
  143182. export class BasisTools {
  143183. private static _IgnoreSupportedFormats;
  143184. /**
  143185. * URL to use when loading the basis transcoder
  143186. */
  143187. static JSModuleURL: string;
  143188. /**
  143189. * URL to use when loading the wasm module for the transcoder
  143190. */
  143191. static WasmModuleURL: string;
  143192. /**
  143193. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  143194. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  143195. * @returns internal format corresponding to the Basis format
  143196. */
  143197. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  143198. private static _WorkerPromise;
  143199. private static _Worker;
  143200. private static _actionId;
  143201. private static _CreateWorkerAsync;
  143202. /**
  143203. * Transcodes a loaded image file to compressed pixel data
  143204. * @param data image data to transcode
  143205. * @param config configuration options for the transcoding
  143206. * @returns a promise resulting in the transcoded image
  143207. */
  143208. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  143209. /**
  143210. * Loads a texture from the transcode result
  143211. * @param texture texture load to
  143212. * @param transcodeResult the result of transcoding the basis file to load from
  143213. */
  143214. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  143215. }
  143216. }
  143217. declare module BABYLON {
  143218. /**
  143219. * Loader for .basis file format
  143220. */
  143221. export class _BasisTextureLoader implements IInternalTextureLoader {
  143222. /**
  143223. * Defines whether the loader supports cascade loading the different faces.
  143224. */
  143225. readonly supportCascades: boolean;
  143226. /**
  143227. * This returns if the loader support the current file information.
  143228. * @param extension defines the file extension of the file being loaded
  143229. * @returns true if the loader can load the specified file
  143230. */
  143231. canLoad(extension: string): boolean;
  143232. /**
  143233. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143234. * @param data contains the texture data
  143235. * @param texture defines the BabylonJS internal texture
  143236. * @param createPolynomials will be true if polynomials have been requested
  143237. * @param onLoad defines the callback to trigger once the texture is ready
  143238. * @param onError defines the callback to trigger in case of error
  143239. */
  143240. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143241. /**
  143242. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143243. * @param data contains the texture data
  143244. * @param texture defines the BabylonJS internal texture
  143245. * @param callback defines the method to call once ready to upload
  143246. */
  143247. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143248. }
  143249. }
  143250. declare module BABYLON {
  143251. /**
  143252. * Defines the basic options interface of a TexturePacker Frame
  143253. */
  143254. export interface ITexturePackerFrame {
  143255. /**
  143256. * The frame ID
  143257. */
  143258. id: number;
  143259. /**
  143260. * The frames Scale
  143261. */
  143262. scale: Vector2;
  143263. /**
  143264. * The Frames offset
  143265. */
  143266. offset: Vector2;
  143267. }
  143268. /**
  143269. * This is a support class for frame Data on texture packer sets.
  143270. */
  143271. export class TexturePackerFrame implements ITexturePackerFrame {
  143272. /**
  143273. * The frame ID
  143274. */
  143275. id: number;
  143276. /**
  143277. * The frames Scale
  143278. */
  143279. scale: Vector2;
  143280. /**
  143281. * The Frames offset
  143282. */
  143283. offset: Vector2;
  143284. /**
  143285. * Initializes a texture package frame.
  143286. * @param id The numerical frame identifier
  143287. * @param scale Scalar Vector2 for UV frame
  143288. * @param offset Vector2 for the frame position in UV units.
  143289. * @returns TexturePackerFrame
  143290. */
  143291. constructor(id: number, scale: Vector2, offset: Vector2);
  143292. }
  143293. }
  143294. declare module BABYLON {
  143295. /**
  143296. * Defines the basic options interface of a TexturePacker
  143297. */
  143298. export interface ITexturePackerOptions {
  143299. /**
  143300. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  143301. */
  143302. map?: string[];
  143303. /**
  143304. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143305. */
  143306. uvsIn?: string;
  143307. /**
  143308. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143309. */
  143310. uvsOut?: string;
  143311. /**
  143312. * number representing the layout style. Defaults to LAYOUT_STRIP
  143313. */
  143314. layout?: number;
  143315. /**
  143316. * number of columns if using custom column count layout(2). This defaults to 4.
  143317. */
  143318. colnum?: number;
  143319. /**
  143320. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  143321. */
  143322. updateInputMeshes?: boolean;
  143323. /**
  143324. * boolean flag to dispose all the source textures. Defaults to true.
  143325. */
  143326. disposeSources?: boolean;
  143327. /**
  143328. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  143329. */
  143330. fillBlanks?: boolean;
  143331. /**
  143332. * string value representing the context fill style color. Defaults to 'black'.
  143333. */
  143334. customFillColor?: string;
  143335. /**
  143336. * Width and Height Value of each Frame in the TexturePacker Sets
  143337. */
  143338. frameSize?: number;
  143339. /**
  143340. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  143341. */
  143342. paddingRatio?: number;
  143343. /**
  143344. * Number that declares the fill method for the padding gutter.
  143345. */
  143346. paddingMode?: number;
  143347. /**
  143348. * If in SUBUV_COLOR padding mode what color to use.
  143349. */
  143350. paddingColor?: Color3 | Color4;
  143351. }
  143352. /**
  143353. * Defines the basic interface of a TexturePacker JSON File
  143354. */
  143355. export interface ITexturePackerJSON {
  143356. /**
  143357. * The frame ID
  143358. */
  143359. name: string;
  143360. /**
  143361. * The base64 channel data
  143362. */
  143363. sets: any;
  143364. /**
  143365. * The options of the Packer
  143366. */
  143367. options: ITexturePackerOptions;
  143368. /**
  143369. * The frame data of the Packer
  143370. */
  143371. frames: Array<number>;
  143372. }
  143373. /**
  143374. * This is a support class that generates a series of packed texture sets.
  143375. * @see https://doc.babylonjs.com/babylon101/materials
  143376. */
  143377. export class TexturePacker {
  143378. /** Packer Layout Constant 0 */
  143379. static readonly LAYOUT_STRIP: number;
  143380. /** Packer Layout Constant 1 */
  143381. static readonly LAYOUT_POWER2: number;
  143382. /** Packer Layout Constant 2 */
  143383. static readonly LAYOUT_COLNUM: number;
  143384. /** Packer Layout Constant 0 */
  143385. static readonly SUBUV_WRAP: number;
  143386. /** Packer Layout Constant 1 */
  143387. static readonly SUBUV_EXTEND: number;
  143388. /** Packer Layout Constant 2 */
  143389. static readonly SUBUV_COLOR: number;
  143390. /** The Name of the Texture Package */
  143391. name: string;
  143392. /** The scene scope of the TexturePacker */
  143393. scene: Scene;
  143394. /** The Meshes to target */
  143395. meshes: AbstractMesh[];
  143396. /** Arguments passed with the Constructor */
  143397. options: ITexturePackerOptions;
  143398. /** The promise that is started upon initialization */
  143399. promise: Nullable<Promise<TexturePacker | string>>;
  143400. /** The Container object for the channel sets that are generated */
  143401. sets: object;
  143402. /** The Container array for the frames that are generated */
  143403. frames: TexturePackerFrame[];
  143404. /** The expected number of textures the system is parsing. */
  143405. private _expecting;
  143406. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  143407. private _paddingValue;
  143408. /**
  143409. * Initializes a texture package series from an array of meshes or a single mesh.
  143410. * @param name The name of the package
  143411. * @param meshes The target meshes to compose the package from
  143412. * @param options The arguments that texture packer should follow while building.
  143413. * @param scene The scene which the textures are scoped to.
  143414. * @returns TexturePacker
  143415. */
  143416. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  143417. /**
  143418. * Starts the package process
  143419. * @param resolve The promises resolution function
  143420. * @returns TexturePacker
  143421. */
  143422. private _createFrames;
  143423. /**
  143424. * Calculates the Size of the Channel Sets
  143425. * @returns Vector2
  143426. */
  143427. private _calculateSize;
  143428. /**
  143429. * Calculates the UV data for the frames.
  143430. * @param baseSize the base frameSize
  143431. * @param padding the base frame padding
  143432. * @param dtSize size of the Dynamic Texture for that channel
  143433. * @param dtUnits is 1/dtSize
  143434. * @param update flag to update the input meshes
  143435. */
  143436. private _calculateMeshUVFrames;
  143437. /**
  143438. * Calculates the frames Offset.
  143439. * @param index of the frame
  143440. * @returns Vector2
  143441. */
  143442. private _getFrameOffset;
  143443. /**
  143444. * Updates a Mesh to the frame data
  143445. * @param mesh that is the target
  143446. * @param frameID or the frame index
  143447. */
  143448. private _updateMeshUV;
  143449. /**
  143450. * Updates a Meshes materials to use the texture packer channels
  143451. * @param m is the mesh to target
  143452. * @param force all channels on the packer to be set.
  143453. */
  143454. private _updateTextureReferences;
  143455. /**
  143456. * Public method to set a Mesh to a frame
  143457. * @param m that is the target
  143458. * @param frameID or the frame index
  143459. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  143460. */
  143461. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  143462. /**
  143463. * Starts the async promise to compile the texture packer.
  143464. * @returns Promise<void>
  143465. */
  143466. processAsync(): Promise<void>;
  143467. /**
  143468. * Disposes all textures associated with this packer
  143469. */
  143470. dispose(): void;
  143471. /**
  143472. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  143473. * @param imageType is the image type to use.
  143474. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  143475. */
  143476. download(imageType?: string, quality?: number): void;
  143477. /**
  143478. * Public method to load a texturePacker JSON file.
  143479. * @param data of the JSON file in string format.
  143480. */
  143481. updateFromJSON(data: string): void;
  143482. }
  143483. }
  143484. declare module BABYLON {
  143485. /**
  143486. * 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.
  143487. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143488. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143489. */
  143490. export class CustomProceduralTexture extends ProceduralTexture {
  143491. private _animate;
  143492. private _time;
  143493. private _config;
  143494. private _texturePath;
  143495. /**
  143496. * Instantiates a new Custom Procedural Texture.
  143497. * 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.
  143498. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143499. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143500. * @param name Define the name of the texture
  143501. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  143502. * @param size Define the size of the texture to create
  143503. * @param scene Define the scene the texture belongs to
  143504. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  143505. * @param generateMipMaps Define if the texture should creates mip maps or not
  143506. */
  143507. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143508. private _loadJson;
  143509. /**
  143510. * Is the texture ready to be used ? (rendered at least once)
  143511. * @returns true if ready, otherwise, false.
  143512. */
  143513. isReady(): boolean;
  143514. /**
  143515. * Render the texture to its associated render target.
  143516. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  143517. */
  143518. render(useCameraPostProcess?: boolean): void;
  143519. /**
  143520. * Update the list of dependant textures samplers in the shader.
  143521. */
  143522. updateTextures(): void;
  143523. /**
  143524. * Update the uniform values of the procedural texture in the shader.
  143525. */
  143526. updateShaderUniforms(): void;
  143527. /**
  143528. * Define if the texture animates or not.
  143529. */
  143530. get animate(): boolean;
  143531. set animate(value: boolean);
  143532. }
  143533. }
  143534. declare module BABYLON {
  143535. /** @hidden */
  143536. export var noisePixelShader: {
  143537. name: string;
  143538. shader: string;
  143539. };
  143540. }
  143541. declare module BABYLON {
  143542. /**
  143543. * Class used to generate noise procedural textures
  143544. */
  143545. export class NoiseProceduralTexture extends ProceduralTexture {
  143546. /** Gets or sets the start time (default is 0) */
  143547. time: number;
  143548. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  143549. brightness: number;
  143550. /** Defines the number of octaves to process */
  143551. octaves: number;
  143552. /** Defines the level of persistence (0.8 by default) */
  143553. persistence: number;
  143554. /** Gets or sets animation speed factor (default is 1) */
  143555. animationSpeedFactor: number;
  143556. /**
  143557. * Creates a new NoiseProceduralTexture
  143558. * @param name defines the name fo the texture
  143559. * @param size defines the size of the texture (default is 256)
  143560. * @param scene defines the hosting scene
  143561. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  143562. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  143563. */
  143564. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143565. private _updateShaderUniforms;
  143566. protected _getDefines(): string;
  143567. /** Generate the current state of the procedural texture */
  143568. render(useCameraPostProcess?: boolean): void;
  143569. /**
  143570. * Serializes this noise procedural texture
  143571. * @returns a serialized noise procedural texture object
  143572. */
  143573. serialize(): any;
  143574. /**
  143575. * Clone the texture.
  143576. * @returns the cloned texture
  143577. */
  143578. clone(): NoiseProceduralTexture;
  143579. /**
  143580. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  143581. * @param parsedTexture defines parsed texture data
  143582. * @param scene defines the current scene
  143583. * @param rootUrl defines the root URL containing noise procedural texture information
  143584. * @returns a parsed NoiseProceduralTexture
  143585. */
  143586. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  143587. }
  143588. }
  143589. declare module BABYLON {
  143590. /**
  143591. * Raw cube texture where the raw buffers are passed in
  143592. */
  143593. export class RawCubeTexture extends CubeTexture {
  143594. /**
  143595. * Creates a cube texture where the raw buffers are passed in.
  143596. * @param scene defines the scene the texture is attached to
  143597. * @param data defines the array of data to use to create each face
  143598. * @param size defines the size of the textures
  143599. * @param format defines the format of the data
  143600. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  143601. * @param generateMipMaps defines if the engine should generate the mip levels
  143602. * @param invertY defines if data must be stored with Y axis inverted
  143603. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  143604. * @param compression defines the compression used (null by default)
  143605. */
  143606. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  143607. /**
  143608. * Updates the raw cube texture.
  143609. * @param data defines the data to store
  143610. * @param format defines the data format
  143611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143612. * @param invertY defines if data must be stored with Y axis inverted
  143613. * @param compression defines the compression used (null by default)
  143614. * @param level defines which level of the texture to update
  143615. */
  143616. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  143617. /**
  143618. * Updates a raw cube texture with RGBD encoded data.
  143619. * @param data defines the array of data [mipmap][face] to use to create each face
  143620. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  143621. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  143622. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  143623. * @returns a promsie that resolves when the operation is complete
  143624. */
  143625. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  143626. /**
  143627. * Clones the raw cube texture.
  143628. * @return a new cube texture
  143629. */
  143630. clone(): CubeTexture;
  143631. /** @hidden */
  143632. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  143633. }
  143634. }
  143635. declare module BABYLON {
  143636. /**
  143637. * Class used to store 2D array textures containing user data
  143638. */
  143639. export class RawTexture2DArray extends Texture {
  143640. /** Gets or sets the texture format to use */
  143641. format: number;
  143642. /**
  143643. * Create a new RawTexture2DArray
  143644. * @param data defines the data of the texture
  143645. * @param width defines the width of the texture
  143646. * @param height defines the height of the texture
  143647. * @param depth defines the number of layers of the texture
  143648. * @param format defines the texture format to use
  143649. * @param scene defines the hosting scene
  143650. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143651. * @param invertY defines if texture must be stored with Y axis inverted
  143652. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143653. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143654. */
  143655. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143656. /** Gets or sets the texture format to use */
  143657. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143658. /**
  143659. * Update the texture with new data
  143660. * @param data defines the data to store in the texture
  143661. */
  143662. update(data: ArrayBufferView): void;
  143663. }
  143664. }
  143665. declare module BABYLON {
  143666. /**
  143667. * Class used to store 3D textures containing user data
  143668. */
  143669. export class RawTexture3D extends Texture {
  143670. /** Gets or sets the texture format to use */
  143671. format: number;
  143672. /**
  143673. * Create a new RawTexture3D
  143674. * @param data defines the data of the texture
  143675. * @param width defines the width of the texture
  143676. * @param height defines the height of the texture
  143677. * @param depth defines the depth of the texture
  143678. * @param format defines the texture format to use
  143679. * @param scene defines the hosting scene
  143680. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143681. * @param invertY defines if texture must be stored with Y axis inverted
  143682. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143683. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143684. */
  143685. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143686. /** Gets or sets the texture format to use */
  143687. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143688. /**
  143689. * Update the texture with new data
  143690. * @param data defines the data to store in the texture
  143691. */
  143692. update(data: ArrayBufferView): void;
  143693. }
  143694. }
  143695. declare module BABYLON {
  143696. /**
  143697. * Creates a refraction texture used by refraction channel of the standard material.
  143698. * It is like a mirror but to see through a material.
  143699. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143700. */
  143701. export class RefractionTexture extends RenderTargetTexture {
  143702. /**
  143703. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  143704. * 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.
  143705. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143706. */
  143707. refractionPlane: Plane;
  143708. /**
  143709. * Define how deep under the surface we should see.
  143710. */
  143711. depth: number;
  143712. /**
  143713. * Creates a refraction texture used by refraction channel of the standard material.
  143714. * It is like a mirror but to see through a material.
  143715. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143716. * @param name Define the texture name
  143717. * @param size Define the size of the underlying texture
  143718. * @param scene Define the scene the refraction belongs to
  143719. * @param generateMipMaps Define if we need to generate mips level for the refraction
  143720. */
  143721. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  143722. /**
  143723. * Clone the refraction texture.
  143724. * @returns the cloned texture
  143725. */
  143726. clone(): RefractionTexture;
  143727. /**
  143728. * Serialize the texture to a JSON representation you could use in Parse later on
  143729. * @returns the serialized JSON representation
  143730. */
  143731. serialize(): any;
  143732. }
  143733. }
  143734. declare module BABYLON {
  143735. /**
  143736. * Block used to add support for vertex skinning (bones)
  143737. */
  143738. export class BonesBlock extends NodeMaterialBlock {
  143739. /**
  143740. * Creates a new BonesBlock
  143741. * @param name defines the block name
  143742. */
  143743. constructor(name: string);
  143744. /**
  143745. * Initialize the block and prepare the context for build
  143746. * @param state defines the state that will be used for the build
  143747. */
  143748. initialize(state: NodeMaterialBuildState): void;
  143749. /**
  143750. * Gets the current class name
  143751. * @returns the class name
  143752. */
  143753. getClassName(): string;
  143754. /**
  143755. * Gets the matrix indices input component
  143756. */
  143757. get matricesIndices(): NodeMaterialConnectionPoint;
  143758. /**
  143759. * Gets the matrix weights input component
  143760. */
  143761. get matricesWeights(): NodeMaterialConnectionPoint;
  143762. /**
  143763. * Gets the extra matrix indices input component
  143764. */
  143765. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  143766. /**
  143767. * Gets the extra matrix weights input component
  143768. */
  143769. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  143770. /**
  143771. * Gets the world input component
  143772. */
  143773. get world(): NodeMaterialConnectionPoint;
  143774. /**
  143775. * Gets the output component
  143776. */
  143777. get output(): NodeMaterialConnectionPoint;
  143778. autoConfigure(material: NodeMaterial): void;
  143779. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  143780. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143781. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143782. protected _buildBlock(state: NodeMaterialBuildState): this;
  143783. }
  143784. }
  143785. declare module BABYLON {
  143786. /**
  143787. * Block used to add support for instances
  143788. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  143789. */
  143790. export class InstancesBlock extends NodeMaterialBlock {
  143791. /**
  143792. * Creates a new InstancesBlock
  143793. * @param name defines the block name
  143794. */
  143795. constructor(name: string);
  143796. /**
  143797. * Gets the current class name
  143798. * @returns the class name
  143799. */
  143800. getClassName(): string;
  143801. /**
  143802. * Gets the first world row input component
  143803. */
  143804. get world0(): NodeMaterialConnectionPoint;
  143805. /**
  143806. * Gets the second world row input component
  143807. */
  143808. get world1(): NodeMaterialConnectionPoint;
  143809. /**
  143810. * Gets the third world row input component
  143811. */
  143812. get world2(): NodeMaterialConnectionPoint;
  143813. /**
  143814. * Gets the forth world row input component
  143815. */
  143816. get world3(): NodeMaterialConnectionPoint;
  143817. /**
  143818. * Gets the world input component
  143819. */
  143820. get world(): NodeMaterialConnectionPoint;
  143821. /**
  143822. * Gets the output component
  143823. */
  143824. get output(): NodeMaterialConnectionPoint;
  143825. /**
  143826. * Gets the isntanceID component
  143827. */
  143828. get instanceID(): NodeMaterialConnectionPoint;
  143829. autoConfigure(material: NodeMaterial): void;
  143830. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  143831. protected _buildBlock(state: NodeMaterialBuildState): this;
  143832. }
  143833. }
  143834. declare module BABYLON {
  143835. /**
  143836. * Block used to add morph targets support to vertex shader
  143837. */
  143838. export class MorphTargetsBlock extends NodeMaterialBlock {
  143839. private _repeatableContentAnchor;
  143840. /**
  143841. * Create a new MorphTargetsBlock
  143842. * @param name defines the block name
  143843. */
  143844. constructor(name: string);
  143845. /**
  143846. * Gets the current class name
  143847. * @returns the class name
  143848. */
  143849. getClassName(): string;
  143850. /**
  143851. * Gets the position input component
  143852. */
  143853. get position(): NodeMaterialConnectionPoint;
  143854. /**
  143855. * Gets the normal input component
  143856. */
  143857. get normal(): NodeMaterialConnectionPoint;
  143858. /**
  143859. * Gets the tangent input component
  143860. */
  143861. get tangent(): NodeMaterialConnectionPoint;
  143862. /**
  143863. * Gets the tangent input component
  143864. */
  143865. get uv(): NodeMaterialConnectionPoint;
  143866. /**
  143867. * Gets the position output component
  143868. */
  143869. get positionOutput(): NodeMaterialConnectionPoint;
  143870. /**
  143871. * Gets the normal output component
  143872. */
  143873. get normalOutput(): NodeMaterialConnectionPoint;
  143874. /**
  143875. * Gets the tangent output component
  143876. */
  143877. get tangentOutput(): NodeMaterialConnectionPoint;
  143878. /**
  143879. * Gets the tangent output component
  143880. */
  143881. get uvOutput(): NodeMaterialConnectionPoint;
  143882. initialize(state: NodeMaterialBuildState): void;
  143883. autoConfigure(material: NodeMaterial): void;
  143884. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143885. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143886. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  143887. protected _buildBlock(state: NodeMaterialBuildState): this;
  143888. }
  143889. }
  143890. declare module BABYLON {
  143891. /**
  143892. * Block used to get data information from a light
  143893. */
  143894. export class LightInformationBlock extends NodeMaterialBlock {
  143895. private _lightDataUniformName;
  143896. private _lightColorUniformName;
  143897. private _lightTypeDefineName;
  143898. /**
  143899. * Gets or sets the light associated with this block
  143900. */
  143901. light: Nullable<Light>;
  143902. /**
  143903. * Creates a new LightInformationBlock
  143904. * @param name defines the block name
  143905. */
  143906. constructor(name: string);
  143907. /**
  143908. * Gets the current class name
  143909. * @returns the class name
  143910. */
  143911. getClassName(): string;
  143912. /**
  143913. * Gets the world position input component
  143914. */
  143915. get worldPosition(): NodeMaterialConnectionPoint;
  143916. /**
  143917. * Gets the direction output component
  143918. */
  143919. get direction(): NodeMaterialConnectionPoint;
  143920. /**
  143921. * Gets the direction output component
  143922. */
  143923. get color(): NodeMaterialConnectionPoint;
  143924. /**
  143925. * Gets the direction output component
  143926. */
  143927. get intensity(): NodeMaterialConnectionPoint;
  143928. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143930. protected _buildBlock(state: NodeMaterialBuildState): this;
  143931. serialize(): any;
  143932. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143933. }
  143934. }
  143935. declare module BABYLON {
  143936. /**
  143937. * Block used to add image processing support to fragment shader
  143938. */
  143939. export class ImageProcessingBlock extends NodeMaterialBlock {
  143940. /**
  143941. * Create a new ImageProcessingBlock
  143942. * @param name defines the block name
  143943. */
  143944. constructor(name: string);
  143945. /**
  143946. * Gets the current class name
  143947. * @returns the class name
  143948. */
  143949. getClassName(): string;
  143950. /**
  143951. * Gets the color input component
  143952. */
  143953. get color(): NodeMaterialConnectionPoint;
  143954. /**
  143955. * Gets the output component
  143956. */
  143957. get output(): NodeMaterialConnectionPoint;
  143958. /**
  143959. * Initialize the block and prepare the context for build
  143960. * @param state defines the state that will be used for the build
  143961. */
  143962. initialize(state: NodeMaterialBuildState): void;
  143963. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143964. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143966. protected _buildBlock(state: NodeMaterialBuildState): this;
  143967. }
  143968. }
  143969. declare module BABYLON {
  143970. /**
  143971. * Block used to pertub normals based on a normal map
  143972. */
  143973. export class PerturbNormalBlock extends NodeMaterialBlock {
  143974. private _tangentSpaceParameterName;
  143975. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143976. invertX: boolean;
  143977. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143978. invertY: boolean;
  143979. /**
  143980. * Create a new PerturbNormalBlock
  143981. * @param name defines the block name
  143982. */
  143983. constructor(name: string);
  143984. /**
  143985. * Gets the current class name
  143986. * @returns the class name
  143987. */
  143988. getClassName(): string;
  143989. /**
  143990. * Gets the world position input component
  143991. */
  143992. get worldPosition(): NodeMaterialConnectionPoint;
  143993. /**
  143994. * Gets the world normal input component
  143995. */
  143996. get worldNormal(): NodeMaterialConnectionPoint;
  143997. /**
  143998. * Gets the world tangent input component
  143999. */
  144000. get worldTangent(): NodeMaterialConnectionPoint;
  144001. /**
  144002. * Gets the uv input component
  144003. */
  144004. get uv(): NodeMaterialConnectionPoint;
  144005. /**
  144006. * Gets the normal map color input component
  144007. */
  144008. get normalMapColor(): NodeMaterialConnectionPoint;
  144009. /**
  144010. * Gets the strength input component
  144011. */
  144012. get strength(): NodeMaterialConnectionPoint;
  144013. /**
  144014. * Gets the output component
  144015. */
  144016. get output(): NodeMaterialConnectionPoint;
  144017. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144018. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144019. autoConfigure(material: NodeMaterial): void;
  144020. protected _buildBlock(state: NodeMaterialBuildState): this;
  144021. protected _dumpPropertiesCode(): string;
  144022. serialize(): any;
  144023. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144024. }
  144025. }
  144026. declare module BABYLON {
  144027. /**
  144028. * Block used to discard a pixel if a value is smaller than a cutoff
  144029. */
  144030. export class DiscardBlock extends NodeMaterialBlock {
  144031. /**
  144032. * Create a new DiscardBlock
  144033. * @param name defines the block name
  144034. */
  144035. constructor(name: string);
  144036. /**
  144037. * Gets the current class name
  144038. * @returns the class name
  144039. */
  144040. getClassName(): string;
  144041. /**
  144042. * Gets the color input component
  144043. */
  144044. get value(): NodeMaterialConnectionPoint;
  144045. /**
  144046. * Gets the cutoff input component
  144047. */
  144048. get cutoff(): NodeMaterialConnectionPoint;
  144049. protected _buildBlock(state: NodeMaterialBuildState): this;
  144050. }
  144051. }
  144052. declare module BABYLON {
  144053. /**
  144054. * Block used to test if the fragment shader is front facing
  144055. */
  144056. export class FrontFacingBlock extends NodeMaterialBlock {
  144057. /**
  144058. * Creates a new FrontFacingBlock
  144059. * @param name defines the block name
  144060. */
  144061. constructor(name: string);
  144062. /**
  144063. * Gets the current class name
  144064. * @returns the class name
  144065. */
  144066. getClassName(): string;
  144067. /**
  144068. * Gets the output component
  144069. */
  144070. get output(): NodeMaterialConnectionPoint;
  144071. protected _buildBlock(state: NodeMaterialBuildState): this;
  144072. }
  144073. }
  144074. declare module BABYLON {
  144075. /**
  144076. * Block used to get the derivative value on x and y of a given input
  144077. */
  144078. export class DerivativeBlock extends NodeMaterialBlock {
  144079. /**
  144080. * Create a new DerivativeBlock
  144081. * @param name defines the block name
  144082. */
  144083. constructor(name: string);
  144084. /**
  144085. * Gets the current class name
  144086. * @returns the class name
  144087. */
  144088. getClassName(): string;
  144089. /**
  144090. * Gets the input component
  144091. */
  144092. get input(): NodeMaterialConnectionPoint;
  144093. /**
  144094. * Gets the derivative output on x
  144095. */
  144096. get dx(): NodeMaterialConnectionPoint;
  144097. /**
  144098. * Gets the derivative output on y
  144099. */
  144100. get dy(): NodeMaterialConnectionPoint;
  144101. protected _buildBlock(state: NodeMaterialBuildState): this;
  144102. }
  144103. }
  144104. declare module BABYLON {
  144105. /**
  144106. * Block used to make gl_FragCoord available
  144107. */
  144108. export class FragCoordBlock extends NodeMaterialBlock {
  144109. /**
  144110. * Creates a new FragCoordBlock
  144111. * @param name defines the block name
  144112. */
  144113. constructor(name: string);
  144114. /**
  144115. * Gets the current class name
  144116. * @returns the class name
  144117. */
  144118. getClassName(): string;
  144119. /**
  144120. * Gets the xy component
  144121. */
  144122. get xy(): NodeMaterialConnectionPoint;
  144123. /**
  144124. * Gets the xyz component
  144125. */
  144126. get xyz(): NodeMaterialConnectionPoint;
  144127. /**
  144128. * Gets the xyzw component
  144129. */
  144130. get xyzw(): NodeMaterialConnectionPoint;
  144131. /**
  144132. * Gets the x component
  144133. */
  144134. get x(): NodeMaterialConnectionPoint;
  144135. /**
  144136. * Gets the y component
  144137. */
  144138. get y(): NodeMaterialConnectionPoint;
  144139. /**
  144140. * Gets the z component
  144141. */
  144142. get z(): NodeMaterialConnectionPoint;
  144143. /**
  144144. * Gets the w component
  144145. */
  144146. get output(): NodeMaterialConnectionPoint;
  144147. protected writeOutputs(state: NodeMaterialBuildState): string;
  144148. protected _buildBlock(state: NodeMaterialBuildState): this;
  144149. }
  144150. }
  144151. declare module BABYLON {
  144152. /**
  144153. * Block used to get the screen sizes
  144154. */
  144155. export class ScreenSizeBlock extends NodeMaterialBlock {
  144156. private _varName;
  144157. private _scene;
  144158. /**
  144159. * Creates a new ScreenSizeBlock
  144160. * @param name defines the block name
  144161. */
  144162. constructor(name: string);
  144163. /**
  144164. * Gets the current class name
  144165. * @returns the class name
  144166. */
  144167. getClassName(): string;
  144168. /**
  144169. * Gets the xy component
  144170. */
  144171. get xy(): NodeMaterialConnectionPoint;
  144172. /**
  144173. * Gets the x component
  144174. */
  144175. get x(): NodeMaterialConnectionPoint;
  144176. /**
  144177. * Gets the y component
  144178. */
  144179. get y(): NodeMaterialConnectionPoint;
  144180. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144181. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  144182. protected _buildBlock(state: NodeMaterialBuildState): this;
  144183. }
  144184. }
  144185. declare module BABYLON {
  144186. /**
  144187. * Block used to add support for scene fog
  144188. */
  144189. export class FogBlock extends NodeMaterialBlock {
  144190. private _fogDistanceName;
  144191. private _fogParameters;
  144192. /**
  144193. * Create a new FogBlock
  144194. * @param name defines the block name
  144195. */
  144196. constructor(name: string);
  144197. /**
  144198. * Gets the current class name
  144199. * @returns the class name
  144200. */
  144201. getClassName(): string;
  144202. /**
  144203. * Gets the world position input component
  144204. */
  144205. get worldPosition(): NodeMaterialConnectionPoint;
  144206. /**
  144207. * Gets the view input component
  144208. */
  144209. get view(): NodeMaterialConnectionPoint;
  144210. /**
  144211. * Gets the color input component
  144212. */
  144213. get input(): NodeMaterialConnectionPoint;
  144214. /**
  144215. * Gets the fog color input component
  144216. */
  144217. get fogColor(): NodeMaterialConnectionPoint;
  144218. /**
  144219. * Gets the output component
  144220. */
  144221. get output(): NodeMaterialConnectionPoint;
  144222. autoConfigure(material: NodeMaterial): void;
  144223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144224. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144225. protected _buildBlock(state: NodeMaterialBuildState): this;
  144226. }
  144227. }
  144228. declare module BABYLON {
  144229. /**
  144230. * Block used to add light in the fragment shader
  144231. */
  144232. export class LightBlock extends NodeMaterialBlock {
  144233. private _lightId;
  144234. /**
  144235. * Gets or sets the light associated with this block
  144236. */
  144237. light: Nullable<Light>;
  144238. /**
  144239. * Create a new LightBlock
  144240. * @param name defines the block name
  144241. */
  144242. constructor(name: string);
  144243. /**
  144244. * Gets the current class name
  144245. * @returns the class name
  144246. */
  144247. getClassName(): string;
  144248. /**
  144249. * Gets the world position input component
  144250. */
  144251. get worldPosition(): NodeMaterialConnectionPoint;
  144252. /**
  144253. * Gets the world normal input component
  144254. */
  144255. get worldNormal(): NodeMaterialConnectionPoint;
  144256. /**
  144257. * Gets the camera (or eye) position component
  144258. */
  144259. get cameraPosition(): NodeMaterialConnectionPoint;
  144260. /**
  144261. * Gets the glossiness component
  144262. */
  144263. get glossiness(): NodeMaterialConnectionPoint;
  144264. /**
  144265. * Gets the glossinness power component
  144266. */
  144267. get glossPower(): NodeMaterialConnectionPoint;
  144268. /**
  144269. * Gets the diffuse color component
  144270. */
  144271. get diffuseColor(): NodeMaterialConnectionPoint;
  144272. /**
  144273. * Gets the specular color component
  144274. */
  144275. get specularColor(): NodeMaterialConnectionPoint;
  144276. /**
  144277. * Gets the diffuse output component
  144278. */
  144279. get diffuseOutput(): NodeMaterialConnectionPoint;
  144280. /**
  144281. * Gets the specular output component
  144282. */
  144283. get specularOutput(): NodeMaterialConnectionPoint;
  144284. /**
  144285. * Gets the shadow output component
  144286. */
  144287. get shadow(): NodeMaterialConnectionPoint;
  144288. autoConfigure(material: NodeMaterial): void;
  144289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144290. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144291. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144292. private _injectVertexCode;
  144293. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144294. serialize(): any;
  144295. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144296. }
  144297. }
  144298. declare module BABYLON {
  144299. /**
  144300. * Block used to read a reflection texture from a sampler
  144301. */
  144302. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  144303. /**
  144304. * Create a new ReflectionTextureBlock
  144305. * @param name defines the block name
  144306. */
  144307. constructor(name: string);
  144308. /**
  144309. * Gets the current class name
  144310. * @returns the class name
  144311. */
  144312. getClassName(): string;
  144313. /**
  144314. * Gets the world position input component
  144315. */
  144316. get position(): NodeMaterialConnectionPoint;
  144317. /**
  144318. * Gets the world position input component
  144319. */
  144320. get worldPosition(): NodeMaterialConnectionPoint;
  144321. /**
  144322. * Gets the world normal input component
  144323. */
  144324. get worldNormal(): NodeMaterialConnectionPoint;
  144325. /**
  144326. * Gets the world input component
  144327. */
  144328. get world(): NodeMaterialConnectionPoint;
  144329. /**
  144330. * Gets the camera (or eye) position component
  144331. */
  144332. get cameraPosition(): NodeMaterialConnectionPoint;
  144333. /**
  144334. * Gets the view input component
  144335. */
  144336. get view(): NodeMaterialConnectionPoint;
  144337. /**
  144338. * Gets the rgb output component
  144339. */
  144340. get rgb(): NodeMaterialConnectionPoint;
  144341. /**
  144342. * Gets the rgba output component
  144343. */
  144344. get rgba(): NodeMaterialConnectionPoint;
  144345. /**
  144346. * Gets the r output component
  144347. */
  144348. get r(): NodeMaterialConnectionPoint;
  144349. /**
  144350. * Gets the g output component
  144351. */
  144352. get g(): NodeMaterialConnectionPoint;
  144353. /**
  144354. * Gets the b output component
  144355. */
  144356. get b(): NodeMaterialConnectionPoint;
  144357. /**
  144358. * Gets the a output component
  144359. */
  144360. get a(): NodeMaterialConnectionPoint;
  144361. autoConfigure(material: NodeMaterial): void;
  144362. protected _buildBlock(state: NodeMaterialBuildState): this;
  144363. }
  144364. }
  144365. declare module BABYLON {
  144366. /**
  144367. * Block used to add 2 vectors
  144368. */
  144369. export class AddBlock extends NodeMaterialBlock {
  144370. /**
  144371. * Creates a new AddBlock
  144372. * @param name defines the block name
  144373. */
  144374. constructor(name: string);
  144375. /**
  144376. * Gets the current class name
  144377. * @returns the class name
  144378. */
  144379. getClassName(): string;
  144380. /**
  144381. * Gets the left operand input component
  144382. */
  144383. get left(): NodeMaterialConnectionPoint;
  144384. /**
  144385. * Gets the right operand input component
  144386. */
  144387. get right(): NodeMaterialConnectionPoint;
  144388. /**
  144389. * Gets the output component
  144390. */
  144391. get output(): NodeMaterialConnectionPoint;
  144392. protected _buildBlock(state: NodeMaterialBuildState): this;
  144393. }
  144394. }
  144395. declare module BABYLON {
  144396. /**
  144397. * Block used to scale a vector by a float
  144398. */
  144399. export class ScaleBlock extends NodeMaterialBlock {
  144400. /**
  144401. * Creates a new ScaleBlock
  144402. * @param name defines the block name
  144403. */
  144404. constructor(name: string);
  144405. /**
  144406. * Gets the current class name
  144407. * @returns the class name
  144408. */
  144409. getClassName(): string;
  144410. /**
  144411. * Gets the input component
  144412. */
  144413. get input(): NodeMaterialConnectionPoint;
  144414. /**
  144415. * Gets the factor input component
  144416. */
  144417. get factor(): NodeMaterialConnectionPoint;
  144418. /**
  144419. * Gets the output component
  144420. */
  144421. get output(): NodeMaterialConnectionPoint;
  144422. protected _buildBlock(state: NodeMaterialBuildState): this;
  144423. }
  144424. }
  144425. declare module BABYLON {
  144426. /**
  144427. * Block used to clamp a float
  144428. */
  144429. export class ClampBlock extends NodeMaterialBlock {
  144430. /** Gets or sets the minimum range */
  144431. minimum: number;
  144432. /** Gets or sets the maximum range */
  144433. maximum: number;
  144434. /**
  144435. * Creates a new ClampBlock
  144436. * @param name defines the block name
  144437. */
  144438. constructor(name: string);
  144439. /**
  144440. * Gets the current class name
  144441. * @returns the class name
  144442. */
  144443. getClassName(): string;
  144444. /**
  144445. * Gets the value input component
  144446. */
  144447. get value(): NodeMaterialConnectionPoint;
  144448. /**
  144449. * Gets the output component
  144450. */
  144451. get output(): NodeMaterialConnectionPoint;
  144452. protected _buildBlock(state: NodeMaterialBuildState): this;
  144453. protected _dumpPropertiesCode(): string;
  144454. serialize(): any;
  144455. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144456. }
  144457. }
  144458. declare module BABYLON {
  144459. /**
  144460. * Block used to apply a cross product between 2 vectors
  144461. */
  144462. export class CrossBlock extends NodeMaterialBlock {
  144463. /**
  144464. * Creates a new CrossBlock
  144465. * @param name defines the block name
  144466. */
  144467. constructor(name: string);
  144468. /**
  144469. * Gets the current class name
  144470. * @returns the class name
  144471. */
  144472. getClassName(): string;
  144473. /**
  144474. * Gets the left operand input component
  144475. */
  144476. get left(): NodeMaterialConnectionPoint;
  144477. /**
  144478. * Gets the right operand input component
  144479. */
  144480. get right(): NodeMaterialConnectionPoint;
  144481. /**
  144482. * Gets the output component
  144483. */
  144484. get output(): NodeMaterialConnectionPoint;
  144485. protected _buildBlock(state: NodeMaterialBuildState): this;
  144486. }
  144487. }
  144488. declare module BABYLON {
  144489. /**
  144490. * Block used to apply a dot product between 2 vectors
  144491. */
  144492. export class DotBlock extends NodeMaterialBlock {
  144493. /**
  144494. * Creates a new DotBlock
  144495. * @param name defines the block name
  144496. */
  144497. constructor(name: string);
  144498. /**
  144499. * Gets the current class name
  144500. * @returns the class name
  144501. */
  144502. getClassName(): string;
  144503. /**
  144504. * Gets the left operand input component
  144505. */
  144506. get left(): NodeMaterialConnectionPoint;
  144507. /**
  144508. * Gets the right operand input component
  144509. */
  144510. get right(): NodeMaterialConnectionPoint;
  144511. /**
  144512. * Gets the output component
  144513. */
  144514. get output(): NodeMaterialConnectionPoint;
  144515. protected _buildBlock(state: NodeMaterialBuildState): this;
  144516. }
  144517. }
  144518. declare module BABYLON {
  144519. /**
  144520. * Block used to normalize a vector
  144521. */
  144522. export class NormalizeBlock extends NodeMaterialBlock {
  144523. /**
  144524. * Creates a new NormalizeBlock
  144525. * @param name defines the block name
  144526. */
  144527. constructor(name: string);
  144528. /**
  144529. * Gets the current class name
  144530. * @returns the class name
  144531. */
  144532. getClassName(): string;
  144533. /**
  144534. * Gets the input component
  144535. */
  144536. get input(): NodeMaterialConnectionPoint;
  144537. /**
  144538. * Gets the output component
  144539. */
  144540. get output(): NodeMaterialConnectionPoint;
  144541. protected _buildBlock(state: NodeMaterialBuildState): this;
  144542. }
  144543. }
  144544. declare module BABYLON {
  144545. /**
  144546. * Block used to create a Color3/4 out of individual inputs (one for each component)
  144547. */
  144548. export class ColorMergerBlock extends NodeMaterialBlock {
  144549. /**
  144550. * Create a new ColorMergerBlock
  144551. * @param name defines the block name
  144552. */
  144553. constructor(name: string);
  144554. /**
  144555. * Gets the current class name
  144556. * @returns the class name
  144557. */
  144558. getClassName(): string;
  144559. /**
  144560. * Gets the rgb component (input)
  144561. */
  144562. get rgbIn(): NodeMaterialConnectionPoint;
  144563. /**
  144564. * Gets the r component (input)
  144565. */
  144566. get r(): NodeMaterialConnectionPoint;
  144567. /**
  144568. * Gets the g component (input)
  144569. */
  144570. get g(): NodeMaterialConnectionPoint;
  144571. /**
  144572. * Gets the b component (input)
  144573. */
  144574. get b(): NodeMaterialConnectionPoint;
  144575. /**
  144576. * Gets the a component (input)
  144577. */
  144578. get a(): NodeMaterialConnectionPoint;
  144579. /**
  144580. * Gets the rgba component (output)
  144581. */
  144582. get rgba(): NodeMaterialConnectionPoint;
  144583. /**
  144584. * Gets the rgb component (output)
  144585. */
  144586. get rgbOut(): NodeMaterialConnectionPoint;
  144587. /**
  144588. * Gets the rgb component (output)
  144589. * @deprecated Please use rgbOut instead.
  144590. */
  144591. get rgb(): NodeMaterialConnectionPoint;
  144592. protected _buildBlock(state: NodeMaterialBuildState): this;
  144593. }
  144594. }
  144595. declare module BABYLON {
  144596. /**
  144597. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  144598. */
  144599. export class VectorSplitterBlock extends NodeMaterialBlock {
  144600. /**
  144601. * Create a new VectorSplitterBlock
  144602. * @param name defines the block name
  144603. */
  144604. constructor(name: string);
  144605. /**
  144606. * Gets the current class name
  144607. * @returns the class name
  144608. */
  144609. getClassName(): string;
  144610. /**
  144611. * Gets the xyzw component (input)
  144612. */
  144613. get xyzw(): NodeMaterialConnectionPoint;
  144614. /**
  144615. * Gets the xyz component (input)
  144616. */
  144617. get xyzIn(): NodeMaterialConnectionPoint;
  144618. /**
  144619. * Gets the xy component (input)
  144620. */
  144621. get xyIn(): NodeMaterialConnectionPoint;
  144622. /**
  144623. * Gets the xyz component (output)
  144624. */
  144625. get xyzOut(): NodeMaterialConnectionPoint;
  144626. /**
  144627. * Gets the xy component (output)
  144628. */
  144629. get xyOut(): NodeMaterialConnectionPoint;
  144630. /**
  144631. * Gets the x component (output)
  144632. */
  144633. get x(): NodeMaterialConnectionPoint;
  144634. /**
  144635. * Gets the y component (output)
  144636. */
  144637. get y(): NodeMaterialConnectionPoint;
  144638. /**
  144639. * Gets the z component (output)
  144640. */
  144641. get z(): NodeMaterialConnectionPoint;
  144642. /**
  144643. * Gets the w component (output)
  144644. */
  144645. get w(): NodeMaterialConnectionPoint;
  144646. protected _inputRename(name: string): string;
  144647. protected _outputRename(name: string): string;
  144648. protected _buildBlock(state: NodeMaterialBuildState): this;
  144649. }
  144650. }
  144651. declare module BABYLON {
  144652. /**
  144653. * Block used to lerp between 2 values
  144654. */
  144655. export class LerpBlock extends NodeMaterialBlock {
  144656. /**
  144657. * Creates a new LerpBlock
  144658. * @param name defines the block name
  144659. */
  144660. constructor(name: string);
  144661. /**
  144662. * Gets the current class name
  144663. * @returns the class name
  144664. */
  144665. getClassName(): string;
  144666. /**
  144667. * Gets the left operand input component
  144668. */
  144669. get left(): NodeMaterialConnectionPoint;
  144670. /**
  144671. * Gets the right operand input component
  144672. */
  144673. get right(): NodeMaterialConnectionPoint;
  144674. /**
  144675. * Gets the gradient operand input component
  144676. */
  144677. get gradient(): NodeMaterialConnectionPoint;
  144678. /**
  144679. * Gets the output component
  144680. */
  144681. get output(): NodeMaterialConnectionPoint;
  144682. protected _buildBlock(state: NodeMaterialBuildState): this;
  144683. }
  144684. }
  144685. declare module BABYLON {
  144686. /**
  144687. * Block used to divide 2 vectors
  144688. */
  144689. export class DivideBlock extends NodeMaterialBlock {
  144690. /**
  144691. * Creates a new DivideBlock
  144692. * @param name defines the block name
  144693. */
  144694. constructor(name: string);
  144695. /**
  144696. * Gets the current class name
  144697. * @returns the class name
  144698. */
  144699. getClassName(): string;
  144700. /**
  144701. * Gets the left operand input component
  144702. */
  144703. get left(): NodeMaterialConnectionPoint;
  144704. /**
  144705. * Gets the right operand input component
  144706. */
  144707. get right(): NodeMaterialConnectionPoint;
  144708. /**
  144709. * Gets the output component
  144710. */
  144711. get output(): NodeMaterialConnectionPoint;
  144712. protected _buildBlock(state: NodeMaterialBuildState): this;
  144713. }
  144714. }
  144715. declare module BABYLON {
  144716. /**
  144717. * Block used to subtract 2 vectors
  144718. */
  144719. export class SubtractBlock extends NodeMaterialBlock {
  144720. /**
  144721. * Creates a new SubtractBlock
  144722. * @param name defines the block name
  144723. */
  144724. constructor(name: string);
  144725. /**
  144726. * Gets the current class name
  144727. * @returns the class name
  144728. */
  144729. getClassName(): string;
  144730. /**
  144731. * Gets the left operand input component
  144732. */
  144733. get left(): NodeMaterialConnectionPoint;
  144734. /**
  144735. * Gets the right operand input component
  144736. */
  144737. get right(): NodeMaterialConnectionPoint;
  144738. /**
  144739. * Gets the output component
  144740. */
  144741. get output(): NodeMaterialConnectionPoint;
  144742. protected _buildBlock(state: NodeMaterialBuildState): this;
  144743. }
  144744. }
  144745. declare module BABYLON {
  144746. /**
  144747. * Block used to step a value
  144748. */
  144749. export class StepBlock extends NodeMaterialBlock {
  144750. /**
  144751. * Creates a new StepBlock
  144752. * @param name defines the block name
  144753. */
  144754. constructor(name: string);
  144755. /**
  144756. * Gets the current class name
  144757. * @returns the class name
  144758. */
  144759. getClassName(): string;
  144760. /**
  144761. * Gets the value operand input component
  144762. */
  144763. get value(): NodeMaterialConnectionPoint;
  144764. /**
  144765. * Gets the edge operand input component
  144766. */
  144767. get edge(): NodeMaterialConnectionPoint;
  144768. /**
  144769. * Gets the output component
  144770. */
  144771. get output(): NodeMaterialConnectionPoint;
  144772. protected _buildBlock(state: NodeMaterialBuildState): this;
  144773. }
  144774. }
  144775. declare module BABYLON {
  144776. /**
  144777. * Block used to get the opposite (1 - x) of a value
  144778. */
  144779. export class OneMinusBlock extends NodeMaterialBlock {
  144780. /**
  144781. * Creates a new OneMinusBlock
  144782. * @param name defines the block name
  144783. */
  144784. constructor(name: string);
  144785. /**
  144786. * Gets the current class name
  144787. * @returns the class name
  144788. */
  144789. getClassName(): string;
  144790. /**
  144791. * Gets the input component
  144792. */
  144793. get input(): NodeMaterialConnectionPoint;
  144794. /**
  144795. * Gets the output component
  144796. */
  144797. get output(): NodeMaterialConnectionPoint;
  144798. protected _buildBlock(state: NodeMaterialBuildState): this;
  144799. }
  144800. }
  144801. declare module BABYLON {
  144802. /**
  144803. * Block used to get the view direction
  144804. */
  144805. export class ViewDirectionBlock extends NodeMaterialBlock {
  144806. /**
  144807. * Creates a new ViewDirectionBlock
  144808. * @param name defines the block name
  144809. */
  144810. constructor(name: string);
  144811. /**
  144812. * Gets the current class name
  144813. * @returns the class name
  144814. */
  144815. getClassName(): string;
  144816. /**
  144817. * Gets the world position component
  144818. */
  144819. get worldPosition(): NodeMaterialConnectionPoint;
  144820. /**
  144821. * Gets the camera position component
  144822. */
  144823. get cameraPosition(): NodeMaterialConnectionPoint;
  144824. /**
  144825. * Gets the output component
  144826. */
  144827. get output(): NodeMaterialConnectionPoint;
  144828. autoConfigure(material: NodeMaterial): void;
  144829. protected _buildBlock(state: NodeMaterialBuildState): this;
  144830. }
  144831. }
  144832. declare module BABYLON {
  144833. /**
  144834. * Block used to compute fresnel value
  144835. */
  144836. export class FresnelBlock extends NodeMaterialBlock {
  144837. /**
  144838. * Create a new FresnelBlock
  144839. * @param name defines the block name
  144840. */
  144841. constructor(name: string);
  144842. /**
  144843. * Gets the current class name
  144844. * @returns the class name
  144845. */
  144846. getClassName(): string;
  144847. /**
  144848. * Gets the world normal input component
  144849. */
  144850. get worldNormal(): NodeMaterialConnectionPoint;
  144851. /**
  144852. * Gets the view direction input component
  144853. */
  144854. get viewDirection(): NodeMaterialConnectionPoint;
  144855. /**
  144856. * Gets the bias input component
  144857. */
  144858. get bias(): NodeMaterialConnectionPoint;
  144859. /**
  144860. * Gets the camera (or eye) position component
  144861. */
  144862. get power(): NodeMaterialConnectionPoint;
  144863. /**
  144864. * Gets the fresnel output component
  144865. */
  144866. get fresnel(): NodeMaterialConnectionPoint;
  144867. autoConfigure(material: NodeMaterial): void;
  144868. protected _buildBlock(state: NodeMaterialBuildState): this;
  144869. }
  144870. }
  144871. declare module BABYLON {
  144872. /**
  144873. * Block used to get the max of 2 values
  144874. */
  144875. export class MaxBlock extends NodeMaterialBlock {
  144876. /**
  144877. * Creates a new MaxBlock
  144878. * @param name defines the block name
  144879. */
  144880. constructor(name: string);
  144881. /**
  144882. * Gets the current class name
  144883. * @returns the class name
  144884. */
  144885. getClassName(): string;
  144886. /**
  144887. * Gets the left operand input component
  144888. */
  144889. get left(): NodeMaterialConnectionPoint;
  144890. /**
  144891. * Gets the right operand input component
  144892. */
  144893. get right(): NodeMaterialConnectionPoint;
  144894. /**
  144895. * Gets the output component
  144896. */
  144897. get output(): NodeMaterialConnectionPoint;
  144898. protected _buildBlock(state: NodeMaterialBuildState): this;
  144899. }
  144900. }
  144901. declare module BABYLON {
  144902. /**
  144903. * Block used to get the min of 2 values
  144904. */
  144905. export class MinBlock extends NodeMaterialBlock {
  144906. /**
  144907. * Creates a new MinBlock
  144908. * @param name defines the block name
  144909. */
  144910. constructor(name: string);
  144911. /**
  144912. * Gets the current class name
  144913. * @returns the class name
  144914. */
  144915. getClassName(): string;
  144916. /**
  144917. * Gets the left operand input component
  144918. */
  144919. get left(): NodeMaterialConnectionPoint;
  144920. /**
  144921. * Gets the right operand input component
  144922. */
  144923. get right(): NodeMaterialConnectionPoint;
  144924. /**
  144925. * Gets the output component
  144926. */
  144927. get output(): NodeMaterialConnectionPoint;
  144928. protected _buildBlock(state: NodeMaterialBuildState): this;
  144929. }
  144930. }
  144931. declare module BABYLON {
  144932. /**
  144933. * Block used to get the distance between 2 values
  144934. */
  144935. export class DistanceBlock extends NodeMaterialBlock {
  144936. /**
  144937. * Creates a new DistanceBlock
  144938. * @param name defines the block name
  144939. */
  144940. constructor(name: string);
  144941. /**
  144942. * Gets the current class name
  144943. * @returns the class name
  144944. */
  144945. getClassName(): string;
  144946. /**
  144947. * Gets the left operand input component
  144948. */
  144949. get left(): NodeMaterialConnectionPoint;
  144950. /**
  144951. * Gets the right operand input component
  144952. */
  144953. get right(): NodeMaterialConnectionPoint;
  144954. /**
  144955. * Gets the output component
  144956. */
  144957. get output(): NodeMaterialConnectionPoint;
  144958. protected _buildBlock(state: NodeMaterialBuildState): this;
  144959. }
  144960. }
  144961. declare module BABYLON {
  144962. /**
  144963. * Block used to get the length of a vector
  144964. */
  144965. export class LengthBlock extends NodeMaterialBlock {
  144966. /**
  144967. * Creates a new LengthBlock
  144968. * @param name defines the block name
  144969. */
  144970. constructor(name: string);
  144971. /**
  144972. * Gets the current class name
  144973. * @returns the class name
  144974. */
  144975. getClassName(): string;
  144976. /**
  144977. * Gets the value input component
  144978. */
  144979. get value(): NodeMaterialConnectionPoint;
  144980. /**
  144981. * Gets the output component
  144982. */
  144983. get output(): NodeMaterialConnectionPoint;
  144984. protected _buildBlock(state: NodeMaterialBuildState): this;
  144985. }
  144986. }
  144987. declare module BABYLON {
  144988. /**
  144989. * Block used to get negative version of a value (i.e. x * -1)
  144990. */
  144991. export class NegateBlock extends NodeMaterialBlock {
  144992. /**
  144993. * Creates a new NegateBlock
  144994. * @param name defines the block name
  144995. */
  144996. constructor(name: string);
  144997. /**
  144998. * Gets the current class name
  144999. * @returns the class name
  145000. */
  145001. getClassName(): string;
  145002. /**
  145003. * Gets the value input component
  145004. */
  145005. get value(): NodeMaterialConnectionPoint;
  145006. /**
  145007. * Gets the output component
  145008. */
  145009. get output(): NodeMaterialConnectionPoint;
  145010. protected _buildBlock(state: NodeMaterialBuildState): this;
  145011. }
  145012. }
  145013. declare module BABYLON {
  145014. /**
  145015. * Block used to get the value of the first parameter raised to the power of the second
  145016. */
  145017. export class PowBlock extends NodeMaterialBlock {
  145018. /**
  145019. * Creates a new PowBlock
  145020. * @param name defines the block name
  145021. */
  145022. constructor(name: string);
  145023. /**
  145024. * Gets the current class name
  145025. * @returns the class name
  145026. */
  145027. getClassName(): string;
  145028. /**
  145029. * Gets the value operand input component
  145030. */
  145031. get value(): NodeMaterialConnectionPoint;
  145032. /**
  145033. * Gets the power operand input component
  145034. */
  145035. get power(): NodeMaterialConnectionPoint;
  145036. /**
  145037. * Gets the output component
  145038. */
  145039. get output(): NodeMaterialConnectionPoint;
  145040. protected _buildBlock(state: NodeMaterialBuildState): this;
  145041. }
  145042. }
  145043. declare module BABYLON {
  145044. /**
  145045. * Block used to get a random number
  145046. */
  145047. export class RandomNumberBlock extends NodeMaterialBlock {
  145048. /**
  145049. * Creates a new RandomNumberBlock
  145050. * @param name defines the block name
  145051. */
  145052. constructor(name: string);
  145053. /**
  145054. * Gets the current class name
  145055. * @returns the class name
  145056. */
  145057. getClassName(): string;
  145058. /**
  145059. * Gets the seed input component
  145060. */
  145061. get seed(): NodeMaterialConnectionPoint;
  145062. /**
  145063. * Gets the output component
  145064. */
  145065. get output(): NodeMaterialConnectionPoint;
  145066. protected _buildBlock(state: NodeMaterialBuildState): this;
  145067. }
  145068. }
  145069. declare module BABYLON {
  145070. /**
  145071. * Block used to compute arc tangent of 2 values
  145072. */
  145073. export class ArcTan2Block extends NodeMaterialBlock {
  145074. /**
  145075. * Creates a new ArcTan2Block
  145076. * @param name defines the block name
  145077. */
  145078. constructor(name: string);
  145079. /**
  145080. * Gets the current class name
  145081. * @returns the class name
  145082. */
  145083. getClassName(): string;
  145084. /**
  145085. * Gets the x operand input component
  145086. */
  145087. get x(): NodeMaterialConnectionPoint;
  145088. /**
  145089. * Gets the y operand input component
  145090. */
  145091. get y(): NodeMaterialConnectionPoint;
  145092. /**
  145093. * Gets the output component
  145094. */
  145095. get output(): NodeMaterialConnectionPoint;
  145096. protected _buildBlock(state: NodeMaterialBuildState): this;
  145097. }
  145098. }
  145099. declare module BABYLON {
  145100. /**
  145101. * Block used to smooth step a value
  145102. */
  145103. export class SmoothStepBlock extends NodeMaterialBlock {
  145104. /**
  145105. * Creates a new SmoothStepBlock
  145106. * @param name defines the block name
  145107. */
  145108. constructor(name: string);
  145109. /**
  145110. * Gets the current class name
  145111. * @returns the class name
  145112. */
  145113. getClassName(): string;
  145114. /**
  145115. * Gets the value operand input component
  145116. */
  145117. get value(): NodeMaterialConnectionPoint;
  145118. /**
  145119. * Gets the first edge operand input component
  145120. */
  145121. get edge0(): NodeMaterialConnectionPoint;
  145122. /**
  145123. * Gets the second edge operand input component
  145124. */
  145125. get edge1(): NodeMaterialConnectionPoint;
  145126. /**
  145127. * Gets the output component
  145128. */
  145129. get output(): NodeMaterialConnectionPoint;
  145130. protected _buildBlock(state: NodeMaterialBuildState): this;
  145131. }
  145132. }
  145133. declare module BABYLON {
  145134. /**
  145135. * Block used to get the reciprocal (1 / x) of a value
  145136. */
  145137. export class ReciprocalBlock extends NodeMaterialBlock {
  145138. /**
  145139. * Creates a new ReciprocalBlock
  145140. * @param name defines the block name
  145141. */
  145142. constructor(name: string);
  145143. /**
  145144. * Gets the current class name
  145145. * @returns the class name
  145146. */
  145147. getClassName(): string;
  145148. /**
  145149. * Gets the input component
  145150. */
  145151. get input(): NodeMaterialConnectionPoint;
  145152. /**
  145153. * Gets the output component
  145154. */
  145155. get output(): NodeMaterialConnectionPoint;
  145156. protected _buildBlock(state: NodeMaterialBuildState): this;
  145157. }
  145158. }
  145159. declare module BABYLON {
  145160. /**
  145161. * Block used to replace a color by another one
  145162. */
  145163. export class ReplaceColorBlock extends NodeMaterialBlock {
  145164. /**
  145165. * Creates a new ReplaceColorBlock
  145166. * @param name defines the block name
  145167. */
  145168. constructor(name: string);
  145169. /**
  145170. * Gets the current class name
  145171. * @returns the class name
  145172. */
  145173. getClassName(): string;
  145174. /**
  145175. * Gets the value input component
  145176. */
  145177. get value(): NodeMaterialConnectionPoint;
  145178. /**
  145179. * Gets the reference input component
  145180. */
  145181. get reference(): NodeMaterialConnectionPoint;
  145182. /**
  145183. * Gets the distance input component
  145184. */
  145185. get distance(): NodeMaterialConnectionPoint;
  145186. /**
  145187. * Gets the replacement input component
  145188. */
  145189. get replacement(): NodeMaterialConnectionPoint;
  145190. /**
  145191. * Gets the output component
  145192. */
  145193. get output(): NodeMaterialConnectionPoint;
  145194. protected _buildBlock(state: NodeMaterialBuildState): this;
  145195. }
  145196. }
  145197. declare module BABYLON {
  145198. /**
  145199. * Block used to posterize a value
  145200. * @see https://en.wikipedia.org/wiki/Posterization
  145201. */
  145202. export class PosterizeBlock extends NodeMaterialBlock {
  145203. /**
  145204. * Creates a new PosterizeBlock
  145205. * @param name defines the block name
  145206. */
  145207. constructor(name: string);
  145208. /**
  145209. * Gets the current class name
  145210. * @returns the class name
  145211. */
  145212. getClassName(): string;
  145213. /**
  145214. * Gets the value input component
  145215. */
  145216. get value(): NodeMaterialConnectionPoint;
  145217. /**
  145218. * Gets the steps input component
  145219. */
  145220. get steps(): NodeMaterialConnectionPoint;
  145221. /**
  145222. * Gets the output component
  145223. */
  145224. get output(): NodeMaterialConnectionPoint;
  145225. protected _buildBlock(state: NodeMaterialBuildState): this;
  145226. }
  145227. }
  145228. declare module BABYLON {
  145229. /**
  145230. * Operations supported by the Wave block
  145231. */
  145232. export enum WaveBlockKind {
  145233. /** SawTooth */
  145234. SawTooth = 0,
  145235. /** Square */
  145236. Square = 1,
  145237. /** Triangle */
  145238. Triangle = 2
  145239. }
  145240. /**
  145241. * Block used to apply wave operation to floats
  145242. */
  145243. export class WaveBlock extends NodeMaterialBlock {
  145244. /**
  145245. * Gets or sets the kibnd of wave to be applied by the block
  145246. */
  145247. kind: WaveBlockKind;
  145248. /**
  145249. * Creates a new WaveBlock
  145250. * @param name defines the block name
  145251. */
  145252. constructor(name: string);
  145253. /**
  145254. * Gets the current class name
  145255. * @returns the class name
  145256. */
  145257. getClassName(): string;
  145258. /**
  145259. * Gets the input component
  145260. */
  145261. get input(): NodeMaterialConnectionPoint;
  145262. /**
  145263. * Gets the output component
  145264. */
  145265. get output(): NodeMaterialConnectionPoint;
  145266. protected _buildBlock(state: NodeMaterialBuildState): this;
  145267. serialize(): any;
  145268. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145269. }
  145270. }
  145271. declare module BABYLON {
  145272. /**
  145273. * Class used to store a color step for the GradientBlock
  145274. */
  145275. export class GradientBlockColorStep {
  145276. private _step;
  145277. /**
  145278. * Gets value indicating which step this color is associated with (between 0 and 1)
  145279. */
  145280. get step(): number;
  145281. /**
  145282. * Sets a value indicating which step this color is associated with (between 0 and 1)
  145283. */
  145284. set step(val: number);
  145285. private _color;
  145286. /**
  145287. * Gets the color associated with this step
  145288. */
  145289. get color(): Color3;
  145290. /**
  145291. * Sets the color associated with this step
  145292. */
  145293. set color(val: Color3);
  145294. /**
  145295. * Creates a new GradientBlockColorStep
  145296. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  145297. * @param color defines the color associated with this step
  145298. */
  145299. constructor(step: number, color: Color3);
  145300. }
  145301. /**
  145302. * Block used to return a color from a gradient based on an input value between 0 and 1
  145303. */
  145304. export class GradientBlock extends NodeMaterialBlock {
  145305. /**
  145306. * Gets or sets the list of color steps
  145307. */
  145308. colorSteps: GradientBlockColorStep[];
  145309. /** Gets an observable raised when the value is changed */
  145310. onValueChangedObservable: Observable<GradientBlock>;
  145311. /** calls observable when the value is changed*/
  145312. colorStepsUpdated(): void;
  145313. /**
  145314. * Creates a new GradientBlock
  145315. * @param name defines the block name
  145316. */
  145317. constructor(name: string);
  145318. /**
  145319. * Gets the current class name
  145320. * @returns the class name
  145321. */
  145322. getClassName(): string;
  145323. /**
  145324. * Gets the gradient input component
  145325. */
  145326. get gradient(): NodeMaterialConnectionPoint;
  145327. /**
  145328. * Gets the output component
  145329. */
  145330. get output(): NodeMaterialConnectionPoint;
  145331. private _writeColorConstant;
  145332. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145333. serialize(): any;
  145334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145335. protected _dumpPropertiesCode(): string;
  145336. }
  145337. }
  145338. declare module BABYLON {
  145339. /**
  145340. * Block used to normalize lerp between 2 values
  145341. */
  145342. export class NLerpBlock extends NodeMaterialBlock {
  145343. /**
  145344. * Creates a new NLerpBlock
  145345. * @param name defines the block name
  145346. */
  145347. constructor(name: string);
  145348. /**
  145349. * Gets the current class name
  145350. * @returns the class name
  145351. */
  145352. getClassName(): string;
  145353. /**
  145354. * Gets the left operand input component
  145355. */
  145356. get left(): NodeMaterialConnectionPoint;
  145357. /**
  145358. * Gets the right operand input component
  145359. */
  145360. get right(): NodeMaterialConnectionPoint;
  145361. /**
  145362. * Gets the gradient operand input component
  145363. */
  145364. get gradient(): NodeMaterialConnectionPoint;
  145365. /**
  145366. * Gets the output component
  145367. */
  145368. get output(): NodeMaterialConnectionPoint;
  145369. protected _buildBlock(state: NodeMaterialBuildState): this;
  145370. }
  145371. }
  145372. declare module BABYLON {
  145373. /**
  145374. * block used to Generate a Worley Noise 3D Noise Pattern
  145375. */
  145376. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  145377. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145378. manhattanDistance: boolean;
  145379. /**
  145380. * Creates a new WorleyNoise3DBlock
  145381. * @param name defines the block name
  145382. */
  145383. constructor(name: string);
  145384. /**
  145385. * Gets the current class name
  145386. * @returns the class name
  145387. */
  145388. getClassName(): string;
  145389. /**
  145390. * Gets the seed input component
  145391. */
  145392. get seed(): NodeMaterialConnectionPoint;
  145393. /**
  145394. * Gets the jitter input component
  145395. */
  145396. get jitter(): NodeMaterialConnectionPoint;
  145397. /**
  145398. * Gets the output component
  145399. */
  145400. get output(): NodeMaterialConnectionPoint;
  145401. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145402. /**
  145403. * Exposes the properties to the UI?
  145404. */
  145405. protected _dumpPropertiesCode(): string;
  145406. /**
  145407. * Exposes the properties to the Seralize?
  145408. */
  145409. serialize(): any;
  145410. /**
  145411. * Exposes the properties to the deseralize?
  145412. */
  145413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145414. }
  145415. }
  145416. declare module BABYLON {
  145417. /**
  145418. * block used to Generate a Simplex Perlin 3d Noise Pattern
  145419. */
  145420. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  145421. /**
  145422. * Creates a new SimplexPerlin3DBlock
  145423. * @param name defines the block name
  145424. */
  145425. constructor(name: string);
  145426. /**
  145427. * Gets the current class name
  145428. * @returns the class name
  145429. */
  145430. getClassName(): string;
  145431. /**
  145432. * Gets the seed operand input component
  145433. */
  145434. get seed(): NodeMaterialConnectionPoint;
  145435. /**
  145436. * Gets the output component
  145437. */
  145438. get output(): NodeMaterialConnectionPoint;
  145439. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145440. }
  145441. }
  145442. declare module BABYLON {
  145443. /**
  145444. * Block used to blend normals
  145445. */
  145446. export class NormalBlendBlock extends NodeMaterialBlock {
  145447. /**
  145448. * Creates a new NormalBlendBlock
  145449. * @param name defines the block name
  145450. */
  145451. constructor(name: string);
  145452. /**
  145453. * Gets the current class name
  145454. * @returns the class name
  145455. */
  145456. getClassName(): string;
  145457. /**
  145458. * Gets the first input component
  145459. */
  145460. get normalMap0(): NodeMaterialConnectionPoint;
  145461. /**
  145462. * Gets the second input component
  145463. */
  145464. get normalMap1(): NodeMaterialConnectionPoint;
  145465. /**
  145466. * Gets the output component
  145467. */
  145468. get output(): NodeMaterialConnectionPoint;
  145469. protected _buildBlock(state: NodeMaterialBuildState): this;
  145470. }
  145471. }
  145472. declare module BABYLON {
  145473. /**
  145474. * Block used to rotate a 2d vector by a given angle
  145475. */
  145476. export class Rotate2dBlock extends NodeMaterialBlock {
  145477. /**
  145478. * Creates a new Rotate2dBlock
  145479. * @param name defines the block name
  145480. */
  145481. constructor(name: string);
  145482. /**
  145483. * Gets the current class name
  145484. * @returns the class name
  145485. */
  145486. getClassName(): string;
  145487. /**
  145488. * Gets the input vector
  145489. */
  145490. get input(): NodeMaterialConnectionPoint;
  145491. /**
  145492. * Gets the input angle
  145493. */
  145494. get angle(): NodeMaterialConnectionPoint;
  145495. /**
  145496. * Gets the output component
  145497. */
  145498. get output(): NodeMaterialConnectionPoint;
  145499. autoConfigure(material: NodeMaterial): void;
  145500. protected _buildBlock(state: NodeMaterialBuildState): this;
  145501. }
  145502. }
  145503. declare module BABYLON {
  145504. /**
  145505. * Block used to get the reflected vector from a direction and a normal
  145506. */
  145507. export class ReflectBlock extends NodeMaterialBlock {
  145508. /**
  145509. * Creates a new ReflectBlock
  145510. * @param name defines the block name
  145511. */
  145512. constructor(name: string);
  145513. /**
  145514. * Gets the current class name
  145515. * @returns the class name
  145516. */
  145517. getClassName(): string;
  145518. /**
  145519. * Gets the incident component
  145520. */
  145521. get incident(): NodeMaterialConnectionPoint;
  145522. /**
  145523. * Gets the normal component
  145524. */
  145525. get normal(): NodeMaterialConnectionPoint;
  145526. /**
  145527. * Gets the output component
  145528. */
  145529. get output(): NodeMaterialConnectionPoint;
  145530. protected _buildBlock(state: NodeMaterialBuildState): this;
  145531. }
  145532. }
  145533. declare module BABYLON {
  145534. /**
  145535. * Block used to get the refracted vector from a direction and a normal
  145536. */
  145537. export class RefractBlock extends NodeMaterialBlock {
  145538. /**
  145539. * Creates a new RefractBlock
  145540. * @param name defines the block name
  145541. */
  145542. constructor(name: string);
  145543. /**
  145544. * Gets the current class name
  145545. * @returns the class name
  145546. */
  145547. getClassName(): string;
  145548. /**
  145549. * Gets the incident component
  145550. */
  145551. get incident(): NodeMaterialConnectionPoint;
  145552. /**
  145553. * Gets the normal component
  145554. */
  145555. get normal(): NodeMaterialConnectionPoint;
  145556. /**
  145557. * Gets the index of refraction component
  145558. */
  145559. get ior(): NodeMaterialConnectionPoint;
  145560. /**
  145561. * Gets the output component
  145562. */
  145563. get output(): NodeMaterialConnectionPoint;
  145564. protected _buildBlock(state: NodeMaterialBuildState): this;
  145565. }
  145566. }
  145567. declare module BABYLON {
  145568. /**
  145569. * Block used to desaturate a color
  145570. */
  145571. export class DesaturateBlock extends NodeMaterialBlock {
  145572. /**
  145573. * Creates a new DesaturateBlock
  145574. * @param name defines the block name
  145575. */
  145576. constructor(name: string);
  145577. /**
  145578. * Gets the current class name
  145579. * @returns the class name
  145580. */
  145581. getClassName(): string;
  145582. /**
  145583. * Gets the color operand input component
  145584. */
  145585. get color(): NodeMaterialConnectionPoint;
  145586. /**
  145587. * Gets the level operand input component
  145588. */
  145589. get level(): NodeMaterialConnectionPoint;
  145590. /**
  145591. * Gets the output component
  145592. */
  145593. get output(): NodeMaterialConnectionPoint;
  145594. protected _buildBlock(state: NodeMaterialBuildState): this;
  145595. }
  145596. }
  145597. declare module BABYLON {
  145598. /**
  145599. * Block used to implement the ambient occlusion module of the PBR material
  145600. */
  145601. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  145602. /**
  145603. * Create a new AmbientOcclusionBlock
  145604. * @param name defines the block name
  145605. */
  145606. constructor(name: string);
  145607. /**
  145608. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  145609. */
  145610. useAmbientInGrayScale: boolean;
  145611. /**
  145612. * Initialize the block and prepare the context for build
  145613. * @param state defines the state that will be used for the build
  145614. */
  145615. initialize(state: NodeMaterialBuildState): void;
  145616. /**
  145617. * Gets the current class name
  145618. * @returns the class name
  145619. */
  145620. getClassName(): string;
  145621. /**
  145622. * Gets the texture input component
  145623. */
  145624. get texture(): NodeMaterialConnectionPoint;
  145625. /**
  145626. * Gets the texture intensity component
  145627. */
  145628. get intensity(): NodeMaterialConnectionPoint;
  145629. /**
  145630. * Gets the direct light intensity input component
  145631. */
  145632. get directLightIntensity(): NodeMaterialConnectionPoint;
  145633. /**
  145634. * Gets the ambient occlusion object output component
  145635. */
  145636. get ambientOcc(): NodeMaterialConnectionPoint;
  145637. /**
  145638. * Gets the main code of the block (fragment side)
  145639. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  145640. * @returns the shader code
  145641. */
  145642. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  145643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145644. protected _buildBlock(state: NodeMaterialBuildState): this;
  145645. protected _dumpPropertiesCode(): string;
  145646. serialize(): any;
  145647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145648. }
  145649. }
  145650. declare module BABYLON {
  145651. /**
  145652. * Block used to implement the reflection module of the PBR material
  145653. */
  145654. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  145655. /** @hidden */
  145656. _defineLODReflectionAlpha: string;
  145657. /** @hidden */
  145658. _defineLinearSpecularReflection: string;
  145659. private _vEnvironmentIrradianceName;
  145660. /** @hidden */
  145661. _vReflectionMicrosurfaceInfosName: string;
  145662. /** @hidden */
  145663. _vReflectionInfosName: string;
  145664. /** @hidden */
  145665. _vReflectionFilteringInfoName: string;
  145666. private _scene;
  145667. /**
  145668. * The three properties below are set by the main PBR block prior to calling methods of this class.
  145669. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145670. * It's less burden on the user side in the editor part.
  145671. */
  145672. /** @hidden */
  145673. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145674. /** @hidden */
  145675. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145676. /** @hidden */
  145677. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  145678. /**
  145679. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  145680. * diffuse part of the IBL.
  145681. */
  145682. useSphericalHarmonics: boolean;
  145683. /**
  145684. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  145685. */
  145686. forceIrradianceInFragment: boolean;
  145687. /**
  145688. * Create a new ReflectionBlock
  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 position input component
  145699. */
  145700. get position(): NodeMaterialConnectionPoint;
  145701. /**
  145702. * Gets the world position input component
  145703. */
  145704. get worldPosition(): NodeMaterialConnectionPoint;
  145705. /**
  145706. * Gets the world normal input component
  145707. */
  145708. get worldNormal(): NodeMaterialConnectionPoint;
  145709. /**
  145710. * Gets the world input component
  145711. */
  145712. get world(): NodeMaterialConnectionPoint;
  145713. /**
  145714. * Gets the camera (or eye) position component
  145715. */
  145716. get cameraPosition(): NodeMaterialConnectionPoint;
  145717. /**
  145718. * Gets the view input component
  145719. */
  145720. get view(): NodeMaterialConnectionPoint;
  145721. /**
  145722. * Gets the color input component
  145723. */
  145724. get color(): NodeMaterialConnectionPoint;
  145725. /**
  145726. * Gets the reflection object output component
  145727. */
  145728. get reflection(): NodeMaterialConnectionPoint;
  145729. /**
  145730. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  145731. */
  145732. get hasTexture(): boolean;
  145733. /**
  145734. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  145735. */
  145736. get reflectionColor(): string;
  145737. protected _getTexture(): Nullable<BaseTexture>;
  145738. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145739. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145740. /**
  145741. * Gets the code to inject in the vertex shader
  145742. * @param state current state of the node material building
  145743. * @returns the shader code
  145744. */
  145745. handleVertexSide(state: NodeMaterialBuildState): string;
  145746. /**
  145747. * Gets the main code of the block (fragment side)
  145748. * @param state current state of the node material building
  145749. * @param normalVarName name of the existing variable corresponding to the normal
  145750. * @returns the shader code
  145751. */
  145752. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  145753. protected _buildBlock(state: NodeMaterialBuildState): this;
  145754. protected _dumpPropertiesCode(): string;
  145755. serialize(): any;
  145756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145757. }
  145758. }
  145759. declare module BABYLON {
  145760. /**
  145761. * Block used to implement the sheen module of the PBR material
  145762. */
  145763. export class SheenBlock extends NodeMaterialBlock {
  145764. /**
  145765. * Create a new SheenBlock
  145766. * @param name defines the block name
  145767. */
  145768. constructor(name: string);
  145769. /**
  145770. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  145771. * It allows the strength of the sheen effect to not depend on the base color of the material,
  145772. * making it easier to setup and tweak the effect
  145773. */
  145774. albedoScaling: boolean;
  145775. /**
  145776. * Defines if the sheen is linked to the sheen color.
  145777. */
  145778. linkSheenWithAlbedo: boolean;
  145779. /**
  145780. * Initialize the block and prepare the context for build
  145781. * @param state defines the state that will be used for the build
  145782. */
  145783. initialize(state: NodeMaterialBuildState): void;
  145784. /**
  145785. * Gets the current class name
  145786. * @returns the class name
  145787. */
  145788. getClassName(): string;
  145789. /**
  145790. * Gets the intensity input component
  145791. */
  145792. get intensity(): NodeMaterialConnectionPoint;
  145793. /**
  145794. * Gets the color input component
  145795. */
  145796. get color(): NodeMaterialConnectionPoint;
  145797. /**
  145798. * Gets the roughness input component
  145799. */
  145800. get roughness(): NodeMaterialConnectionPoint;
  145801. /**
  145802. * Gets the sheen object output component
  145803. */
  145804. get sheen(): NodeMaterialConnectionPoint;
  145805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145806. /**
  145807. * Gets the main code of the block (fragment side)
  145808. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145809. * @returns the shader code
  145810. */
  145811. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  145812. protected _buildBlock(state: NodeMaterialBuildState): this;
  145813. protected _dumpPropertiesCode(): string;
  145814. serialize(): any;
  145815. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145816. }
  145817. }
  145818. declare module BABYLON {
  145819. /**
  145820. * Block used to implement the reflectivity module of the PBR material
  145821. */
  145822. export class ReflectivityBlock extends NodeMaterialBlock {
  145823. private _metallicReflectanceColor;
  145824. private _metallicF0Factor;
  145825. /** @hidden */
  145826. _vMetallicReflectanceFactorsName: string;
  145827. /**
  145828. * The property below is set by the main PBR block prior to calling methods of this class.
  145829. */
  145830. /** @hidden */
  145831. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  145832. /**
  145833. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  145834. */
  145835. useAmbientOcclusionFromMetallicTextureRed: boolean;
  145836. /**
  145837. * Specifies if the metallic texture contains the metallness information in its blue channel.
  145838. */
  145839. useMetallnessFromMetallicTextureBlue: boolean;
  145840. /**
  145841. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  145842. */
  145843. useRoughnessFromMetallicTextureAlpha: boolean;
  145844. /**
  145845. * Specifies if the metallic texture contains the roughness information in its green channel.
  145846. */
  145847. useRoughnessFromMetallicTextureGreen: boolean;
  145848. /**
  145849. * Create a new ReflectivityBlock
  145850. * @param name defines the block name
  145851. */
  145852. constructor(name: string);
  145853. /**
  145854. * Initialize the block and prepare the context for build
  145855. * @param state defines the state that will be used for the build
  145856. */
  145857. initialize(state: NodeMaterialBuildState): void;
  145858. /**
  145859. * Gets the current class name
  145860. * @returns the class name
  145861. */
  145862. getClassName(): string;
  145863. /**
  145864. * Gets the metallic input component
  145865. */
  145866. get metallic(): NodeMaterialConnectionPoint;
  145867. /**
  145868. * Gets the roughness input component
  145869. */
  145870. get roughness(): NodeMaterialConnectionPoint;
  145871. /**
  145872. * Gets the texture input component
  145873. */
  145874. get texture(): NodeMaterialConnectionPoint;
  145875. /**
  145876. * Gets the reflectivity object output component
  145877. */
  145878. get reflectivity(): NodeMaterialConnectionPoint;
  145879. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145880. /**
  145881. * Gets the main code of the block (fragment side)
  145882. * @param state current state of the node material building
  145883. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  145884. * @returns the shader code
  145885. */
  145886. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  145887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145888. protected _buildBlock(state: NodeMaterialBuildState): this;
  145889. protected _dumpPropertiesCode(): string;
  145890. serialize(): any;
  145891. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145892. }
  145893. }
  145894. declare module BABYLON {
  145895. /**
  145896. * Block used to implement the anisotropy module of the PBR material
  145897. */
  145898. export class AnisotropyBlock extends NodeMaterialBlock {
  145899. /**
  145900. * The two properties below are set by the main PBR block prior to calling methods of this class.
  145901. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145902. * It's less burden on the user side in the editor part.
  145903. */
  145904. /** @hidden */
  145905. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145906. /** @hidden */
  145907. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145908. /**
  145909. * Create a new AnisotropyBlock
  145910. * @param name defines the block name
  145911. */
  145912. constructor(name: string);
  145913. /**
  145914. * Initialize the block and prepare the context for build
  145915. * @param state defines the state that will be used for the build
  145916. */
  145917. initialize(state: NodeMaterialBuildState): void;
  145918. /**
  145919. * Gets the current class name
  145920. * @returns the class name
  145921. */
  145922. getClassName(): string;
  145923. /**
  145924. * Gets the intensity input component
  145925. */
  145926. get intensity(): NodeMaterialConnectionPoint;
  145927. /**
  145928. * Gets the direction input component
  145929. */
  145930. get direction(): NodeMaterialConnectionPoint;
  145931. /**
  145932. * Gets the texture input component
  145933. */
  145934. get texture(): NodeMaterialConnectionPoint;
  145935. /**
  145936. * Gets the uv input component
  145937. */
  145938. get uv(): NodeMaterialConnectionPoint;
  145939. /**
  145940. * Gets the worldTangent input component
  145941. */
  145942. get worldTangent(): NodeMaterialConnectionPoint;
  145943. /**
  145944. * Gets the anisotropy object output component
  145945. */
  145946. get anisotropy(): NodeMaterialConnectionPoint;
  145947. private _generateTBNSpace;
  145948. /**
  145949. * Gets the main code of the block (fragment side)
  145950. * @param state current state of the node material building
  145951. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145952. * @returns the shader code
  145953. */
  145954. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145955. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145956. protected _buildBlock(state: NodeMaterialBuildState): this;
  145957. }
  145958. }
  145959. declare module BABYLON {
  145960. /**
  145961. * Block used to implement the clear coat module of the PBR material
  145962. */
  145963. export class ClearCoatBlock extends NodeMaterialBlock {
  145964. private _scene;
  145965. /**
  145966. * Create a new ClearCoatBlock
  145967. * @param name defines the block name
  145968. */
  145969. constructor(name: string);
  145970. /**
  145971. * Initialize the block and prepare the context for build
  145972. * @param state defines the state that will be used for the build
  145973. */
  145974. initialize(state: NodeMaterialBuildState): void;
  145975. /**
  145976. * Gets the current class name
  145977. * @returns the class name
  145978. */
  145979. getClassName(): string;
  145980. /**
  145981. * Gets the intensity input component
  145982. */
  145983. get intensity(): NodeMaterialConnectionPoint;
  145984. /**
  145985. * Gets the roughness input component
  145986. */
  145987. get roughness(): NodeMaterialConnectionPoint;
  145988. /**
  145989. * Gets the ior input component
  145990. */
  145991. get ior(): NodeMaterialConnectionPoint;
  145992. /**
  145993. * Gets the texture input component
  145994. */
  145995. get texture(): NodeMaterialConnectionPoint;
  145996. /**
  145997. * Gets the bump texture input component
  145998. */
  145999. get bumpTexture(): NodeMaterialConnectionPoint;
  146000. /**
  146001. * Gets the uv input component
  146002. */
  146003. get uv(): NodeMaterialConnectionPoint;
  146004. /**
  146005. * Gets the tint color input component
  146006. */
  146007. get tintColor(): NodeMaterialConnectionPoint;
  146008. /**
  146009. * Gets the tint "at distance" input component
  146010. */
  146011. get tintAtDistance(): NodeMaterialConnectionPoint;
  146012. /**
  146013. * Gets the tint thickness input component
  146014. */
  146015. get tintThickness(): NodeMaterialConnectionPoint;
  146016. /**
  146017. * Gets the world tangent input component
  146018. */
  146019. get worldTangent(): NodeMaterialConnectionPoint;
  146020. /**
  146021. * Gets the clear coat object output component
  146022. */
  146023. get clearcoat(): NodeMaterialConnectionPoint;
  146024. autoConfigure(material: NodeMaterial): void;
  146025. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146026. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146027. private _generateTBNSpace;
  146028. /**
  146029. * Gets the main code of the block (fragment side)
  146030. * @param state current state of the node material building
  146031. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  146032. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146033. * @param worldPosVarName name of the variable holding the world position
  146034. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146035. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  146036. * @param worldNormalVarName name of the variable holding the world normal
  146037. * @returns the shader code
  146038. */
  146039. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  146040. protected _buildBlock(state: NodeMaterialBuildState): this;
  146041. }
  146042. }
  146043. declare module BABYLON {
  146044. /**
  146045. * Block used to implement the sub surface module of the PBR material
  146046. */
  146047. export class SubSurfaceBlock extends NodeMaterialBlock {
  146048. /**
  146049. * Create a new SubSurfaceBlock
  146050. * @param name defines the block name
  146051. */
  146052. constructor(name: string);
  146053. /**
  146054. * Stores the intensity of the different subsurface effects in the thickness texture.
  146055. * * the green channel is the translucency intensity.
  146056. * * the blue channel is the scattering intensity.
  146057. * * the alpha channel is the refraction intensity.
  146058. */
  146059. useMaskFromThicknessTexture: boolean;
  146060. /**
  146061. * Initialize the block and prepare the context for build
  146062. * @param state defines the state that will be used for the build
  146063. */
  146064. initialize(state: NodeMaterialBuildState): void;
  146065. /**
  146066. * Gets the current class name
  146067. * @returns the class name
  146068. */
  146069. getClassName(): string;
  146070. /**
  146071. * Gets the min thickness input component
  146072. */
  146073. get minThickness(): NodeMaterialConnectionPoint;
  146074. /**
  146075. * Gets the max thickness input component
  146076. */
  146077. get maxThickness(): NodeMaterialConnectionPoint;
  146078. /**
  146079. * Gets the thickness texture component
  146080. */
  146081. get thicknessTexture(): NodeMaterialConnectionPoint;
  146082. /**
  146083. * Gets the tint color input component
  146084. */
  146085. get tintColor(): NodeMaterialConnectionPoint;
  146086. /**
  146087. * Gets the translucency intensity input component
  146088. */
  146089. get translucencyIntensity(): NodeMaterialConnectionPoint;
  146090. /**
  146091. * Gets the translucency diffusion distance input component
  146092. */
  146093. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  146094. /**
  146095. * Gets the refraction object parameters
  146096. */
  146097. get refraction(): NodeMaterialConnectionPoint;
  146098. /**
  146099. * Gets the sub surface object output component
  146100. */
  146101. get subsurface(): NodeMaterialConnectionPoint;
  146102. autoConfigure(material: NodeMaterial): void;
  146103. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146104. /**
  146105. * Gets the main code of the block (fragment side)
  146106. * @param state current state of the node material building
  146107. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  146108. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146109. * @param worldPosVarName name of the variable holding the world position
  146110. * @returns the shader code
  146111. */
  146112. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  146113. protected _buildBlock(state: NodeMaterialBuildState): this;
  146114. }
  146115. }
  146116. declare module BABYLON {
  146117. /**
  146118. * Block used to implement the PBR metallic/roughness model
  146119. */
  146120. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  146121. /**
  146122. * Gets or sets the light associated with this block
  146123. */
  146124. light: Nullable<Light>;
  146125. private _lightId;
  146126. private _scene;
  146127. private _environmentBRDFTexture;
  146128. private _environmentBrdfSamplerName;
  146129. private _vNormalWName;
  146130. private _invertNormalName;
  146131. /**
  146132. * Create a new ReflectionBlock
  146133. * @param name defines the block name
  146134. */
  146135. constructor(name: string);
  146136. /**
  146137. * Intensity of the direct lights e.g. the four lights available in your scene.
  146138. * This impacts both the direct diffuse and specular highlights.
  146139. */
  146140. directIntensity: number;
  146141. /**
  146142. * Intensity of the environment e.g. how much the environment will light the object
  146143. * either through harmonics for rough material or through the refelction for shiny ones.
  146144. */
  146145. environmentIntensity: number;
  146146. /**
  146147. * This is a special control allowing the reduction of the specular highlights coming from the
  146148. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  146149. */
  146150. specularIntensity: number;
  146151. /**
  146152. * Defines the falloff type used in this material.
  146153. * It by default is Physical.
  146154. */
  146155. lightFalloff: number;
  146156. /**
  146157. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  146158. */
  146159. useAlphaFromAlbedoTexture: boolean;
  146160. /**
  146161. * Specifies that alpha test should be used
  146162. */
  146163. useAlphaTest: boolean;
  146164. /**
  146165. * Defines the alpha limits in alpha test mode.
  146166. */
  146167. alphaTestCutoff: number;
  146168. /**
  146169. * Specifies that alpha blending should be used
  146170. */
  146171. useAlphaBlending: boolean;
  146172. /**
  146173. * Defines if the alpha value should be determined via the rgb values.
  146174. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  146175. */
  146176. opacityRGB: boolean;
  146177. /**
  146178. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  146179. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  146180. */
  146181. useRadianceOverAlpha: boolean;
  146182. /**
  146183. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  146184. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  146185. */
  146186. useSpecularOverAlpha: boolean;
  146187. /**
  146188. * Enables specular anti aliasing in the PBR shader.
  146189. * It will both interacts on the Geometry for analytical and IBL lighting.
  146190. * It also prefilter the roughness map based on the bump values.
  146191. */
  146192. enableSpecularAntiAliasing: boolean;
  146193. /**
  146194. * Enables realtime filtering on the texture.
  146195. */
  146196. realTimeFiltering: boolean;
  146197. /**
  146198. * Quality switch for realtime filtering
  146199. */
  146200. realTimeFilteringQuality: number;
  146201. /**
  146202. * Defines if the material uses energy conservation.
  146203. */
  146204. useEnergyConservation: boolean;
  146205. /**
  146206. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  146207. * too much the area relying on ambient texture to define their ambient occlusion.
  146208. */
  146209. useRadianceOcclusion: boolean;
  146210. /**
  146211. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  146212. * makes the reflect vector face the model (under horizon).
  146213. */
  146214. useHorizonOcclusion: boolean;
  146215. /**
  146216. * If set to true, no lighting calculations will be applied.
  146217. */
  146218. unlit: boolean;
  146219. /**
  146220. * Force normal to face away from face.
  146221. */
  146222. forceNormalForward: boolean;
  146223. /**
  146224. * Defines the material debug mode.
  146225. * It helps seeing only some components of the material while troubleshooting.
  146226. */
  146227. debugMode: number;
  146228. /**
  146229. * Specify from where on screen the debug mode should start.
  146230. * The value goes from -1 (full screen) to 1 (not visible)
  146231. * It helps with side by side comparison against the final render
  146232. * This defaults to 0
  146233. */
  146234. debugLimit: number;
  146235. /**
  146236. * As the default viewing range might not be enough (if the ambient is really small for instance)
  146237. * You can use the factor to better multiply the final value.
  146238. */
  146239. debugFactor: number;
  146240. /**
  146241. * Initialize the block and prepare the context for build
  146242. * @param state defines the state that will be used for the build
  146243. */
  146244. initialize(state: NodeMaterialBuildState): void;
  146245. /**
  146246. * Gets the current class name
  146247. * @returns the class name
  146248. */
  146249. getClassName(): string;
  146250. /**
  146251. * Gets the world position input component
  146252. */
  146253. get worldPosition(): NodeMaterialConnectionPoint;
  146254. /**
  146255. * Gets the world normal input component
  146256. */
  146257. get worldNormal(): NodeMaterialConnectionPoint;
  146258. /**
  146259. * Gets the perturbed normal input component
  146260. */
  146261. get perturbedNormal(): NodeMaterialConnectionPoint;
  146262. /**
  146263. * Gets the camera position input component
  146264. */
  146265. get cameraPosition(): NodeMaterialConnectionPoint;
  146266. /**
  146267. * Gets the base color input component
  146268. */
  146269. get baseColor(): NodeMaterialConnectionPoint;
  146270. /**
  146271. * Gets the opacity texture input component
  146272. */
  146273. get opacityTexture(): NodeMaterialConnectionPoint;
  146274. /**
  146275. * Gets the ambient color input component
  146276. */
  146277. get ambientColor(): NodeMaterialConnectionPoint;
  146278. /**
  146279. * Gets the reflectivity object parameters
  146280. */
  146281. get reflectivity(): NodeMaterialConnectionPoint;
  146282. /**
  146283. * Gets the ambient occlusion object parameters
  146284. */
  146285. get ambientOcc(): NodeMaterialConnectionPoint;
  146286. /**
  146287. * Gets the reflection object parameters
  146288. */
  146289. get reflection(): NodeMaterialConnectionPoint;
  146290. /**
  146291. * Gets the sheen object parameters
  146292. */
  146293. get sheen(): NodeMaterialConnectionPoint;
  146294. /**
  146295. * Gets the clear coat object parameters
  146296. */
  146297. get clearcoat(): NodeMaterialConnectionPoint;
  146298. /**
  146299. * Gets the sub surface object parameters
  146300. */
  146301. get subsurface(): NodeMaterialConnectionPoint;
  146302. /**
  146303. * Gets the anisotropy object parameters
  146304. */
  146305. get anisotropy(): NodeMaterialConnectionPoint;
  146306. /**
  146307. * Gets the ambient output component
  146308. */
  146309. get ambient(): NodeMaterialConnectionPoint;
  146310. /**
  146311. * Gets the diffuse output component
  146312. */
  146313. get diffuse(): NodeMaterialConnectionPoint;
  146314. /**
  146315. * Gets the specular output component
  146316. */
  146317. get specular(): NodeMaterialConnectionPoint;
  146318. /**
  146319. * Gets the sheen output component
  146320. */
  146321. get sheenDir(): NodeMaterialConnectionPoint;
  146322. /**
  146323. * Gets the clear coat output component
  146324. */
  146325. get clearcoatDir(): NodeMaterialConnectionPoint;
  146326. /**
  146327. * Gets the indirect diffuse output component
  146328. */
  146329. get diffuseIndirect(): NodeMaterialConnectionPoint;
  146330. /**
  146331. * Gets the indirect specular output component
  146332. */
  146333. get specularIndirect(): NodeMaterialConnectionPoint;
  146334. /**
  146335. * Gets the indirect sheen output component
  146336. */
  146337. get sheenIndirect(): NodeMaterialConnectionPoint;
  146338. /**
  146339. * Gets the indirect clear coat output component
  146340. */
  146341. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  146342. /**
  146343. * Gets the refraction output component
  146344. */
  146345. get refraction(): NodeMaterialConnectionPoint;
  146346. /**
  146347. * Gets the global lighting output component
  146348. */
  146349. get lighting(): NodeMaterialConnectionPoint;
  146350. /**
  146351. * Gets the shadow output component
  146352. */
  146353. get shadow(): NodeMaterialConnectionPoint;
  146354. /**
  146355. * Gets the alpha output component
  146356. */
  146357. get alpha(): NodeMaterialConnectionPoint;
  146358. autoConfigure(material: NodeMaterial): void;
  146359. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146360. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  146361. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146362. private _injectVertexCode;
  146363. /**
  146364. * Gets the code corresponding to the albedo/opacity module
  146365. * @returns the shader code
  146366. */
  146367. getAlbedoOpacityCode(): string;
  146368. protected _buildBlock(state: NodeMaterialBuildState): this;
  146369. protected _dumpPropertiesCode(): string;
  146370. serialize(): any;
  146371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146372. }
  146373. }
  146374. declare module BABYLON {
  146375. /**
  146376. * Block used to compute value of one parameter modulo another
  146377. */
  146378. export class ModBlock extends NodeMaterialBlock {
  146379. /**
  146380. * Creates a new ModBlock
  146381. * @param name defines the block name
  146382. */
  146383. constructor(name: string);
  146384. /**
  146385. * Gets the current class name
  146386. * @returns the class name
  146387. */
  146388. getClassName(): string;
  146389. /**
  146390. * Gets the left operand input component
  146391. */
  146392. get left(): NodeMaterialConnectionPoint;
  146393. /**
  146394. * Gets the right operand input component
  146395. */
  146396. get right(): NodeMaterialConnectionPoint;
  146397. /**
  146398. * Gets the output component
  146399. */
  146400. get output(): NodeMaterialConnectionPoint;
  146401. protected _buildBlock(state: NodeMaterialBuildState): this;
  146402. }
  146403. }
  146404. declare module BABYLON {
  146405. /**
  146406. * Configuration for Draco compression
  146407. */
  146408. export interface IDracoCompressionConfiguration {
  146409. /**
  146410. * Configuration for the decoder.
  146411. */
  146412. decoder: {
  146413. /**
  146414. * The url to the WebAssembly module.
  146415. */
  146416. wasmUrl?: string;
  146417. /**
  146418. * The url to the WebAssembly binary.
  146419. */
  146420. wasmBinaryUrl?: string;
  146421. /**
  146422. * The url to the fallback JavaScript module.
  146423. */
  146424. fallbackUrl?: string;
  146425. };
  146426. }
  146427. /**
  146428. * Draco compression (https://google.github.io/draco/)
  146429. *
  146430. * This class wraps the Draco module.
  146431. *
  146432. * **Encoder**
  146433. *
  146434. * The encoder is not currently implemented.
  146435. *
  146436. * **Decoder**
  146437. *
  146438. * 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.
  146439. *
  146440. * To update the configuration, use the following code:
  146441. * ```javascript
  146442. * DracoCompression.Configuration = {
  146443. * decoder: {
  146444. * wasmUrl: "<url to the WebAssembly library>",
  146445. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  146446. * fallbackUrl: "<url to the fallback JavaScript library>",
  146447. * }
  146448. * };
  146449. * ```
  146450. *
  146451. * 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.
  146452. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  146453. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  146454. *
  146455. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  146456. * ```javascript
  146457. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  146458. * ```
  146459. *
  146460. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  146461. */
  146462. export class DracoCompression implements IDisposable {
  146463. private _workerPoolPromise?;
  146464. private _decoderModulePromise?;
  146465. /**
  146466. * The configuration. Defaults to the following urls:
  146467. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  146468. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  146469. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  146470. */
  146471. static Configuration: IDracoCompressionConfiguration;
  146472. /**
  146473. * Returns true if the decoder configuration is available.
  146474. */
  146475. static get DecoderAvailable(): boolean;
  146476. /**
  146477. * Default number of workers to create when creating the draco compression object.
  146478. */
  146479. static DefaultNumWorkers: number;
  146480. private static GetDefaultNumWorkers;
  146481. private static _Default;
  146482. /**
  146483. * Default instance for the draco compression object.
  146484. */
  146485. static get Default(): DracoCompression;
  146486. /**
  146487. * Constructor
  146488. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  146489. */
  146490. constructor(numWorkers?: number);
  146491. /**
  146492. * Stop all async operations and release resources.
  146493. */
  146494. dispose(): void;
  146495. /**
  146496. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  146497. * @returns a promise that resolves when ready
  146498. */
  146499. whenReadyAsync(): Promise<void>;
  146500. /**
  146501. * Decode Draco compressed mesh data to vertex data.
  146502. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  146503. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  146504. * @returns A promise that resolves with the decoded vertex data
  146505. */
  146506. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  146507. [kind: string]: number;
  146508. }): Promise<VertexData>;
  146509. }
  146510. }
  146511. declare module BABYLON {
  146512. /**
  146513. * Class for building Constructive Solid Geometry
  146514. */
  146515. export class CSG {
  146516. private polygons;
  146517. /**
  146518. * The world matrix
  146519. */
  146520. matrix: Matrix;
  146521. /**
  146522. * Stores the position
  146523. */
  146524. position: Vector3;
  146525. /**
  146526. * Stores the rotation
  146527. */
  146528. rotation: Vector3;
  146529. /**
  146530. * Stores the rotation quaternion
  146531. */
  146532. rotationQuaternion: Nullable<Quaternion>;
  146533. /**
  146534. * Stores the scaling vector
  146535. */
  146536. scaling: Vector3;
  146537. /**
  146538. * Convert the Mesh to CSG
  146539. * @param mesh The Mesh to convert to CSG
  146540. * @returns A new CSG from the Mesh
  146541. */
  146542. static FromMesh(mesh: Mesh): CSG;
  146543. /**
  146544. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  146545. * @param polygons Polygons used to construct a CSG solid
  146546. */
  146547. private static FromPolygons;
  146548. /**
  146549. * Clones, or makes a deep copy, of the CSG
  146550. * @returns A new CSG
  146551. */
  146552. clone(): CSG;
  146553. /**
  146554. * Unions this CSG with another CSG
  146555. * @param csg The CSG to union against this CSG
  146556. * @returns The unioned CSG
  146557. */
  146558. union(csg: CSG): CSG;
  146559. /**
  146560. * Unions this CSG with another CSG in place
  146561. * @param csg The CSG to union against this CSG
  146562. */
  146563. unionInPlace(csg: CSG): void;
  146564. /**
  146565. * Subtracts this CSG with another CSG
  146566. * @param csg The CSG to subtract against this CSG
  146567. * @returns A new CSG
  146568. */
  146569. subtract(csg: CSG): CSG;
  146570. /**
  146571. * Subtracts this CSG with another CSG in place
  146572. * @param csg The CSG to subtact against this CSG
  146573. */
  146574. subtractInPlace(csg: CSG): void;
  146575. /**
  146576. * Intersect this CSG with another CSG
  146577. * @param csg The CSG to intersect against this CSG
  146578. * @returns A new CSG
  146579. */
  146580. intersect(csg: CSG): CSG;
  146581. /**
  146582. * Intersects this CSG with another CSG in place
  146583. * @param csg The CSG to intersect against this CSG
  146584. */
  146585. intersectInPlace(csg: CSG): void;
  146586. /**
  146587. * Return a new CSG solid with solid and empty space switched. This solid is
  146588. * not modified.
  146589. * @returns A new CSG solid with solid and empty space switched
  146590. */
  146591. inverse(): CSG;
  146592. /**
  146593. * Inverses the CSG in place
  146594. */
  146595. inverseInPlace(): void;
  146596. /**
  146597. * This is used to keep meshes transformations so they can be restored
  146598. * when we build back a Babylon Mesh
  146599. * NB : All CSG operations are performed in world coordinates
  146600. * @param csg The CSG to copy the transform attributes from
  146601. * @returns This CSG
  146602. */
  146603. copyTransformAttributes(csg: CSG): CSG;
  146604. /**
  146605. * Build Raw mesh from CSG
  146606. * Coordinates here are in world space
  146607. * @param name The name of the mesh geometry
  146608. * @param scene The Scene
  146609. * @param keepSubMeshes Specifies if the submeshes should be kept
  146610. * @returns A new Mesh
  146611. */
  146612. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146613. /**
  146614. * Build Mesh from CSG taking material and transforms into account
  146615. * @param name The name of the Mesh
  146616. * @param material The material of the Mesh
  146617. * @param scene The Scene
  146618. * @param keepSubMeshes Specifies if submeshes should be kept
  146619. * @returns The new Mesh
  146620. */
  146621. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146622. }
  146623. }
  146624. declare module BABYLON {
  146625. /**
  146626. * Class used to create a trail following a mesh
  146627. */
  146628. export class TrailMesh extends Mesh {
  146629. private _generator;
  146630. private _autoStart;
  146631. private _running;
  146632. private _diameter;
  146633. private _length;
  146634. private _sectionPolygonPointsCount;
  146635. private _sectionVectors;
  146636. private _sectionNormalVectors;
  146637. private _beforeRenderObserver;
  146638. /**
  146639. * @constructor
  146640. * @param name The value used by scene.getMeshByName() to do a lookup.
  146641. * @param generator The mesh or transform node to generate a trail.
  146642. * @param scene The scene to add this mesh to.
  146643. * @param diameter Diameter of trailing mesh. Default is 1.
  146644. * @param length Length of trailing mesh. Default is 60.
  146645. * @param autoStart Automatically start trailing mesh. Default true.
  146646. */
  146647. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  146648. /**
  146649. * "TrailMesh"
  146650. * @returns "TrailMesh"
  146651. */
  146652. getClassName(): string;
  146653. private _createMesh;
  146654. /**
  146655. * Start trailing mesh.
  146656. */
  146657. start(): void;
  146658. /**
  146659. * Stop trailing mesh.
  146660. */
  146661. stop(): void;
  146662. /**
  146663. * Update trailing mesh geometry.
  146664. */
  146665. update(): void;
  146666. /**
  146667. * Returns a new TrailMesh object.
  146668. * @param name is a string, the name given to the new mesh
  146669. * @param newGenerator use new generator object for cloned trail mesh
  146670. * @returns a new mesh
  146671. */
  146672. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  146673. /**
  146674. * Serializes this trail mesh
  146675. * @param serializationObject object to write serialization to
  146676. */
  146677. serialize(serializationObject: any): void;
  146678. /**
  146679. * Parses a serialized trail mesh
  146680. * @param parsedMesh the serialized mesh
  146681. * @param scene the scene to create the trail mesh in
  146682. * @returns the created trail mesh
  146683. */
  146684. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  146685. }
  146686. }
  146687. declare module BABYLON {
  146688. /**
  146689. * Class containing static functions to help procedurally build meshes
  146690. */
  146691. export class TiledBoxBuilder {
  146692. /**
  146693. * Creates a box mesh
  146694. * 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)
  146695. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146699. * @param name defines the name of the mesh
  146700. * @param options defines the options used to create the mesh
  146701. * @param scene defines the hosting scene
  146702. * @returns the box mesh
  146703. */
  146704. static CreateTiledBox(name: string, options: {
  146705. pattern?: number;
  146706. width?: number;
  146707. height?: number;
  146708. depth?: number;
  146709. tileSize?: number;
  146710. tileWidth?: number;
  146711. tileHeight?: number;
  146712. alignHorizontal?: number;
  146713. alignVertical?: number;
  146714. faceUV?: Vector4[];
  146715. faceColors?: Color4[];
  146716. sideOrientation?: number;
  146717. updatable?: boolean;
  146718. }, scene?: Nullable<Scene>): Mesh;
  146719. }
  146720. }
  146721. declare module BABYLON {
  146722. /**
  146723. * Class containing static functions to help procedurally build meshes
  146724. */
  146725. export class TorusKnotBuilder {
  146726. /**
  146727. * Creates a torus knot mesh
  146728. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146729. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146730. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146731. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146735. * @param name defines the name of the mesh
  146736. * @param options defines the options used to create the mesh
  146737. * @param scene defines the hosting scene
  146738. * @returns the torus knot mesh
  146739. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146740. */
  146741. static CreateTorusKnot(name: string, options: {
  146742. radius?: number;
  146743. tube?: number;
  146744. radialSegments?: number;
  146745. tubularSegments?: number;
  146746. p?: number;
  146747. q?: number;
  146748. updatable?: boolean;
  146749. sideOrientation?: number;
  146750. frontUVs?: Vector4;
  146751. backUVs?: Vector4;
  146752. }, scene: any): Mesh;
  146753. }
  146754. }
  146755. declare module BABYLON {
  146756. /**
  146757. * Polygon
  146758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  146759. */
  146760. export class Polygon {
  146761. /**
  146762. * Creates a rectangle
  146763. * @param xmin bottom X coord
  146764. * @param ymin bottom Y coord
  146765. * @param xmax top X coord
  146766. * @param ymax top Y coord
  146767. * @returns points that make the resulting rectation
  146768. */
  146769. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  146770. /**
  146771. * Creates a circle
  146772. * @param radius radius of circle
  146773. * @param cx scale in x
  146774. * @param cy scale in y
  146775. * @param numberOfSides number of sides that make up the circle
  146776. * @returns points that make the resulting circle
  146777. */
  146778. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  146779. /**
  146780. * Creates a polygon from input string
  146781. * @param input Input polygon data
  146782. * @returns the parsed points
  146783. */
  146784. static Parse(input: string): Vector2[];
  146785. /**
  146786. * Starts building a polygon from x and y coordinates
  146787. * @param x x coordinate
  146788. * @param y y coordinate
  146789. * @returns the started path2
  146790. */
  146791. static StartingAt(x: number, y: number): Path2;
  146792. }
  146793. /**
  146794. * Builds a polygon
  146795. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  146796. */
  146797. export class PolygonMeshBuilder {
  146798. private _points;
  146799. private _outlinepoints;
  146800. private _holes;
  146801. private _name;
  146802. private _scene;
  146803. private _epoints;
  146804. private _eholes;
  146805. private _addToepoint;
  146806. /**
  146807. * Babylon reference to the earcut plugin.
  146808. */
  146809. bjsEarcut: any;
  146810. /**
  146811. * Creates a PolygonMeshBuilder
  146812. * @param name name of the builder
  146813. * @param contours Path of the polygon
  146814. * @param scene scene to add to when creating the mesh
  146815. * @param earcutInjection can be used to inject your own earcut reference
  146816. */
  146817. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  146818. /**
  146819. * Adds a whole within the polygon
  146820. * @param hole Array of points defining the hole
  146821. * @returns this
  146822. */
  146823. addHole(hole: Vector2[]): PolygonMeshBuilder;
  146824. /**
  146825. * Creates the polygon
  146826. * @param updatable If the mesh should be updatable
  146827. * @param depth The depth of the mesh created
  146828. * @returns the created mesh
  146829. */
  146830. build(updatable?: boolean, depth?: number): Mesh;
  146831. /**
  146832. * Creates the polygon
  146833. * @param depth The depth of the mesh created
  146834. * @returns the created VertexData
  146835. */
  146836. buildVertexData(depth?: number): VertexData;
  146837. /**
  146838. * Adds a side to the polygon
  146839. * @param positions points that make the polygon
  146840. * @param normals normals of the polygon
  146841. * @param uvs uvs of the polygon
  146842. * @param indices indices of the polygon
  146843. * @param bounds bounds of the polygon
  146844. * @param points points of the polygon
  146845. * @param depth depth of the polygon
  146846. * @param flip flip of the polygon
  146847. */
  146848. private addSide;
  146849. }
  146850. }
  146851. declare module BABYLON {
  146852. /**
  146853. * Class containing static functions to help procedurally build meshes
  146854. */
  146855. export class PolygonBuilder {
  146856. /**
  146857. * Creates a polygon mesh
  146858. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146859. * * 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
  146860. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146863. * * Remember you can only change the shape positions, not their number when updating a polygon
  146864. * @param name defines the name of the mesh
  146865. * @param options defines the options used to create the mesh
  146866. * @param scene defines the hosting scene
  146867. * @param earcutInjection can be used to inject your own earcut reference
  146868. * @returns the polygon mesh
  146869. */
  146870. static CreatePolygon(name: string, options: {
  146871. shape: Vector3[];
  146872. holes?: Vector3[][];
  146873. depth?: number;
  146874. faceUV?: Vector4[];
  146875. faceColors?: Color4[];
  146876. updatable?: boolean;
  146877. sideOrientation?: number;
  146878. frontUVs?: Vector4;
  146879. backUVs?: Vector4;
  146880. wrap?: boolean;
  146881. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146882. /**
  146883. * Creates an extruded polygon mesh, with depth in the Y direction.
  146884. * * 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)
  146885. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146886. * @param name defines the name of the mesh
  146887. * @param options defines the options used to create the mesh
  146888. * @param scene defines the hosting scene
  146889. * @param earcutInjection can be used to inject your own earcut reference
  146890. * @returns the polygon mesh
  146891. */
  146892. static ExtrudePolygon(name: string, options: {
  146893. shape: Vector3[];
  146894. holes?: Vector3[][];
  146895. depth?: number;
  146896. faceUV?: Vector4[];
  146897. faceColors?: Color4[];
  146898. updatable?: boolean;
  146899. sideOrientation?: number;
  146900. frontUVs?: Vector4;
  146901. backUVs?: Vector4;
  146902. wrap?: boolean;
  146903. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146904. }
  146905. }
  146906. declare module BABYLON {
  146907. /**
  146908. * Class containing static functions to help procedurally build meshes
  146909. */
  146910. export class LatheBuilder {
  146911. /**
  146912. * Creates lathe mesh.
  146913. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146914. * * 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
  146915. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146916. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146917. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146918. * * 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
  146919. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146920. * * 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
  146921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146925. * @param name defines the name of the mesh
  146926. * @param options defines the options used to create the mesh
  146927. * @param scene defines the hosting scene
  146928. * @returns the lathe mesh
  146929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146930. */
  146931. static CreateLathe(name: string, options: {
  146932. shape: Vector3[];
  146933. radius?: number;
  146934. tessellation?: number;
  146935. clip?: number;
  146936. arc?: number;
  146937. closed?: boolean;
  146938. updatable?: boolean;
  146939. sideOrientation?: number;
  146940. frontUVs?: Vector4;
  146941. backUVs?: Vector4;
  146942. cap?: number;
  146943. invertUV?: boolean;
  146944. }, scene?: Nullable<Scene>): Mesh;
  146945. }
  146946. }
  146947. declare module BABYLON {
  146948. /**
  146949. * Class containing static functions to help procedurally build meshes
  146950. */
  146951. export class TiledPlaneBuilder {
  146952. /**
  146953. * Creates a tiled plane mesh
  146954. * * The parameter `pattern` will, depending on value, do nothing or
  146955. * * * flip (reflect about central vertical) alternate tiles across and up
  146956. * * * flip every tile on alternate rows
  146957. * * * rotate (180 degs) alternate tiles across and up
  146958. * * * rotate every tile on alternate rows
  146959. * * * flip and rotate alternate tiles across and up
  146960. * * * flip and rotate every tile on alternate rows
  146961. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146962. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146964. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146965. * * 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)
  146966. * * 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)
  146967. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146968. * @param name defines the name of the mesh
  146969. * @param options defines the options used to create the mesh
  146970. * @param scene defines the hosting scene
  146971. * @returns the box mesh
  146972. */
  146973. static CreateTiledPlane(name: string, options: {
  146974. pattern?: number;
  146975. tileSize?: number;
  146976. tileWidth?: number;
  146977. tileHeight?: number;
  146978. size?: number;
  146979. width?: number;
  146980. height?: number;
  146981. alignHorizontal?: number;
  146982. alignVertical?: number;
  146983. sideOrientation?: number;
  146984. frontUVs?: Vector4;
  146985. backUVs?: Vector4;
  146986. updatable?: boolean;
  146987. }, scene?: Nullable<Scene>): Mesh;
  146988. }
  146989. }
  146990. declare module BABYLON {
  146991. /**
  146992. * Class containing static functions to help procedurally build meshes
  146993. */
  146994. export class TubeBuilder {
  146995. /**
  146996. * Creates a tube mesh.
  146997. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146998. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146999. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147000. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147001. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147002. * * 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)
  147003. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147004. * * 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
  147005. * * 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
  147006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147008. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147010. * @param name defines the name of the mesh
  147011. * @param options defines the options used to create the mesh
  147012. * @param scene defines the hosting scene
  147013. * @returns the tube mesh
  147014. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147015. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147016. */
  147017. static CreateTube(name: string, options: {
  147018. path: Vector3[];
  147019. radius?: number;
  147020. tessellation?: number;
  147021. radiusFunction?: {
  147022. (i: number, distance: number): number;
  147023. };
  147024. cap?: number;
  147025. arc?: number;
  147026. updatable?: boolean;
  147027. sideOrientation?: number;
  147028. frontUVs?: Vector4;
  147029. backUVs?: Vector4;
  147030. instance?: Mesh;
  147031. invertUV?: boolean;
  147032. }, scene?: Nullable<Scene>): Mesh;
  147033. }
  147034. }
  147035. declare module BABYLON {
  147036. /**
  147037. * Class containing static functions to help procedurally build meshes
  147038. */
  147039. export class IcoSphereBuilder {
  147040. /**
  147041. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147042. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147043. * * 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`)
  147044. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147045. * * 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
  147046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147049. * @param name defines the name of the mesh
  147050. * @param options defines the options used to create the mesh
  147051. * @param scene defines the hosting scene
  147052. * @returns the icosahedron mesh
  147053. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147054. */
  147055. static CreateIcoSphere(name: string, options: {
  147056. radius?: number;
  147057. radiusX?: number;
  147058. radiusY?: number;
  147059. radiusZ?: number;
  147060. flat?: boolean;
  147061. subdivisions?: number;
  147062. sideOrientation?: number;
  147063. frontUVs?: Vector4;
  147064. backUVs?: Vector4;
  147065. updatable?: boolean;
  147066. }, scene?: Nullable<Scene>): Mesh;
  147067. }
  147068. }
  147069. declare module BABYLON {
  147070. /**
  147071. * Class containing static functions to help procedurally build meshes
  147072. */
  147073. export class DecalBuilder {
  147074. /**
  147075. * Creates a decal mesh.
  147076. * 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
  147077. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147078. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147079. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147080. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147081. * @param name defines the name of the mesh
  147082. * @param sourceMesh defines the mesh where the decal must be applied
  147083. * @param options defines the options used to create the mesh
  147084. * @param scene defines the hosting scene
  147085. * @returns the decal mesh
  147086. * @see https://doc.babylonjs.com/how_to/decals
  147087. */
  147088. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147089. position?: Vector3;
  147090. normal?: Vector3;
  147091. size?: Vector3;
  147092. angle?: number;
  147093. }): Mesh;
  147094. }
  147095. }
  147096. declare module BABYLON {
  147097. /**
  147098. * Class containing static functions to help procedurally build meshes
  147099. */
  147100. export class MeshBuilder {
  147101. /**
  147102. * Creates a box mesh
  147103. * * The parameter `size` sets the size (float) of each box side (default 1)
  147104. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  147105. * * 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)
  147106. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147110. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147111. * @param name defines the name of the mesh
  147112. * @param options defines the options used to create the mesh
  147113. * @param scene defines the hosting scene
  147114. * @returns the box mesh
  147115. */
  147116. static CreateBox(name: string, options: {
  147117. size?: number;
  147118. width?: number;
  147119. height?: number;
  147120. depth?: number;
  147121. faceUV?: Vector4[];
  147122. faceColors?: Color4[];
  147123. sideOrientation?: number;
  147124. frontUVs?: Vector4;
  147125. backUVs?: Vector4;
  147126. wrap?: boolean;
  147127. topBaseAt?: number;
  147128. bottomBaseAt?: number;
  147129. updatable?: boolean;
  147130. }, scene?: Nullable<Scene>): Mesh;
  147131. /**
  147132. * Creates a tiled box mesh
  147133. * * faceTiles sets the pattern, tile size and number of tiles for a face
  147134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147135. * @param name defines the name of the mesh
  147136. * @param options defines the options used to create the mesh
  147137. * @param scene defines the hosting scene
  147138. * @returns the tiled box mesh
  147139. */
  147140. static CreateTiledBox(name: string, options: {
  147141. pattern?: number;
  147142. size?: number;
  147143. width?: number;
  147144. height?: number;
  147145. depth: number;
  147146. tileSize?: number;
  147147. tileWidth?: number;
  147148. tileHeight?: number;
  147149. faceUV?: Vector4[];
  147150. faceColors?: Color4[];
  147151. alignHorizontal?: number;
  147152. alignVertical?: number;
  147153. sideOrientation?: number;
  147154. updatable?: boolean;
  147155. }, scene?: Nullable<Scene>): Mesh;
  147156. /**
  147157. * Creates a sphere mesh
  147158. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  147159. * * 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`)
  147160. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  147161. * * 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
  147162. * * 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)
  147163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147166. * @param name defines the name of the mesh
  147167. * @param options defines the options used to create the mesh
  147168. * @param scene defines the hosting scene
  147169. * @returns the sphere mesh
  147170. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  147171. */
  147172. static CreateSphere(name: string, options: {
  147173. segments?: number;
  147174. diameter?: number;
  147175. diameterX?: number;
  147176. diameterY?: number;
  147177. diameterZ?: number;
  147178. arc?: number;
  147179. slice?: number;
  147180. sideOrientation?: number;
  147181. frontUVs?: Vector4;
  147182. backUVs?: Vector4;
  147183. updatable?: boolean;
  147184. }, scene?: Nullable<Scene>): Mesh;
  147185. /**
  147186. * Creates a plane polygonal mesh. By default, this is a disc
  147187. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  147188. * * 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
  147189. * * 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
  147190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147193. * @param name defines the name of the mesh
  147194. * @param options defines the options used to create the mesh
  147195. * @param scene defines the hosting scene
  147196. * @returns the plane polygonal mesh
  147197. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  147198. */
  147199. static CreateDisc(name: string, options: {
  147200. radius?: number;
  147201. tessellation?: number;
  147202. arc?: number;
  147203. updatable?: boolean;
  147204. sideOrientation?: number;
  147205. frontUVs?: Vector4;
  147206. backUVs?: Vector4;
  147207. }, scene?: Nullable<Scene>): Mesh;
  147208. /**
  147209. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147210. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147211. * * 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`)
  147212. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147213. * * 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
  147214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147217. * @param name defines the name of the mesh
  147218. * @param options defines the options used to create the mesh
  147219. * @param scene defines the hosting scene
  147220. * @returns the icosahedron mesh
  147221. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147222. */
  147223. static CreateIcoSphere(name: string, options: {
  147224. radius?: number;
  147225. radiusX?: number;
  147226. radiusY?: number;
  147227. radiusZ?: number;
  147228. flat?: boolean;
  147229. subdivisions?: number;
  147230. sideOrientation?: number;
  147231. frontUVs?: Vector4;
  147232. backUVs?: Vector4;
  147233. updatable?: boolean;
  147234. }, scene?: Nullable<Scene>): Mesh;
  147235. /**
  147236. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147237. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  147238. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  147239. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  147240. * * 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
  147241. * * 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
  147242. * * 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
  147243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147245. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147246. * * 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
  147247. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  147248. * * 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
  147249. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  147250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147251. * @param name defines the name of the mesh
  147252. * @param options defines the options used to create the mesh
  147253. * @param scene defines the hosting scene
  147254. * @returns the ribbon mesh
  147255. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  147256. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147257. */
  147258. static CreateRibbon(name: string, options: {
  147259. pathArray: Vector3[][];
  147260. closeArray?: boolean;
  147261. closePath?: boolean;
  147262. offset?: number;
  147263. updatable?: boolean;
  147264. sideOrientation?: number;
  147265. frontUVs?: Vector4;
  147266. backUVs?: Vector4;
  147267. instance?: Mesh;
  147268. invertUV?: boolean;
  147269. uvs?: Vector2[];
  147270. colors?: Color4[];
  147271. }, scene?: Nullable<Scene>): Mesh;
  147272. /**
  147273. * Creates a cylinder or a cone mesh
  147274. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  147275. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  147276. * * 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.
  147277. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  147278. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  147279. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  147280. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  147281. * * 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).
  147282. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  147283. * * 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).
  147284. * * 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
  147285. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  147286. * * 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
  147287. * * 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.
  147288. * * If `enclose` is false, a ring surface is one element.
  147289. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  147290. * * 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
  147291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147294. * @param name defines the name of the mesh
  147295. * @param options defines the options used to create the mesh
  147296. * @param scene defines the hosting scene
  147297. * @returns the cylinder mesh
  147298. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  147299. */
  147300. static CreateCylinder(name: string, options: {
  147301. height?: number;
  147302. diameterTop?: number;
  147303. diameterBottom?: number;
  147304. diameter?: number;
  147305. tessellation?: number;
  147306. subdivisions?: number;
  147307. arc?: number;
  147308. faceColors?: Color4[];
  147309. faceUV?: Vector4[];
  147310. updatable?: boolean;
  147311. hasRings?: boolean;
  147312. enclose?: boolean;
  147313. cap?: number;
  147314. sideOrientation?: number;
  147315. frontUVs?: Vector4;
  147316. backUVs?: Vector4;
  147317. }, scene?: Nullable<Scene>): Mesh;
  147318. /**
  147319. * Creates a torus mesh
  147320. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  147321. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  147322. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  147323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147326. * @param name defines the name of the mesh
  147327. * @param options defines the options used to create the mesh
  147328. * @param scene defines the hosting scene
  147329. * @returns the torus mesh
  147330. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  147331. */
  147332. static CreateTorus(name: string, options: {
  147333. diameter?: number;
  147334. thickness?: number;
  147335. tessellation?: number;
  147336. updatable?: boolean;
  147337. sideOrientation?: number;
  147338. frontUVs?: Vector4;
  147339. backUVs?: Vector4;
  147340. }, scene?: Nullable<Scene>): Mesh;
  147341. /**
  147342. * Creates a torus knot mesh
  147343. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147344. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147345. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147346. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147350. * @param name defines the name of the mesh
  147351. * @param options defines the options used to create the mesh
  147352. * @param scene defines the hosting scene
  147353. * @returns the torus knot mesh
  147354. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147355. */
  147356. static CreateTorusKnot(name: string, options: {
  147357. radius?: number;
  147358. tube?: number;
  147359. radialSegments?: number;
  147360. tubularSegments?: number;
  147361. p?: number;
  147362. q?: number;
  147363. updatable?: boolean;
  147364. sideOrientation?: number;
  147365. frontUVs?: Vector4;
  147366. backUVs?: Vector4;
  147367. }, scene?: Nullable<Scene>): Mesh;
  147368. /**
  147369. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  147370. * * 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
  147371. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  147372. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  147373. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  147374. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  147375. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  147376. * * 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
  147377. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  147378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  147380. * @param name defines the name of the new line system
  147381. * @param options defines the options used to create the line system
  147382. * @param scene defines the hosting scene
  147383. * @returns a new line system mesh
  147384. */
  147385. static CreateLineSystem(name: string, options: {
  147386. lines: Vector3[][];
  147387. updatable?: boolean;
  147388. instance?: Nullable<LinesMesh>;
  147389. colors?: Nullable<Color4[][]>;
  147390. useVertexAlpha?: boolean;
  147391. }, scene: Nullable<Scene>): LinesMesh;
  147392. /**
  147393. * Creates a line mesh
  147394. * 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
  147395. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147396. * * The parameter `points` is an array successive Vector3
  147397. * * 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
  147398. * * The optional parameter `colors` is an array of successive Color4, one per line point
  147399. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  147400. * * When updating an instance, remember that only point positions can change, not the number of points
  147401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  147403. * @param name defines the name of the new line system
  147404. * @param options defines the options used to create the line system
  147405. * @param scene defines the hosting scene
  147406. * @returns a new line mesh
  147407. */
  147408. static CreateLines(name: string, options: {
  147409. points: Vector3[];
  147410. updatable?: boolean;
  147411. instance?: Nullable<LinesMesh>;
  147412. colors?: Color4[];
  147413. useVertexAlpha?: boolean;
  147414. }, scene?: Nullable<Scene>): LinesMesh;
  147415. /**
  147416. * Creates a dashed line mesh
  147417. * * 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
  147418. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147419. * * The parameter `points` is an array successive Vector3
  147420. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  147421. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  147422. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  147423. * * 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
  147424. * * When updating an instance, remember that only point positions can change, not the number of points
  147425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147426. * @param name defines the name of the mesh
  147427. * @param options defines the options used to create the mesh
  147428. * @param scene defines the hosting scene
  147429. * @returns the dashed line mesh
  147430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  147431. */
  147432. static CreateDashedLines(name: string, options: {
  147433. points: Vector3[];
  147434. dashSize?: number;
  147435. gapSize?: number;
  147436. dashNb?: number;
  147437. updatable?: boolean;
  147438. instance?: LinesMesh;
  147439. }, scene?: Nullable<Scene>): LinesMesh;
  147440. /**
  147441. * 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.
  147442. * * 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.
  147443. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147444. * * 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.
  147445. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  147446. * * 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
  147447. * * 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
  147448. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  147449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  147452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147453. * @param name defines the name of the mesh
  147454. * @param options defines the options used to create the mesh
  147455. * @param scene defines the hosting scene
  147456. * @returns the extruded shape mesh
  147457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147459. */
  147460. static ExtrudeShape(name: string, options: {
  147461. shape: Vector3[];
  147462. path: Vector3[];
  147463. scale?: number;
  147464. rotation?: number;
  147465. cap?: number;
  147466. updatable?: boolean;
  147467. sideOrientation?: number;
  147468. frontUVs?: Vector4;
  147469. backUVs?: Vector4;
  147470. instance?: Mesh;
  147471. invertUV?: boolean;
  147472. }, scene?: Nullable<Scene>): Mesh;
  147473. /**
  147474. * Creates an custom extruded shape mesh.
  147475. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  147476. * * 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.
  147477. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147478. * * 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
  147479. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  147480. * * 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
  147481. * * It must returns a float value that will be the scale value applied to the shape on each path point
  147482. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  147483. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  147484. * * 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
  147485. * * 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
  147486. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  147487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147489. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147491. * @param name defines the name of the mesh
  147492. * @param options defines the options used to create the mesh
  147493. * @param scene defines the hosting scene
  147494. * @returns the custom extruded shape mesh
  147495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  147496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147497. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147498. */
  147499. static ExtrudeShapeCustom(name: string, options: {
  147500. shape: Vector3[];
  147501. path: Vector3[];
  147502. scaleFunction?: any;
  147503. rotationFunction?: any;
  147504. ribbonCloseArray?: boolean;
  147505. ribbonClosePath?: boolean;
  147506. cap?: number;
  147507. updatable?: boolean;
  147508. sideOrientation?: number;
  147509. frontUVs?: Vector4;
  147510. backUVs?: Vector4;
  147511. instance?: Mesh;
  147512. invertUV?: boolean;
  147513. }, scene?: Nullable<Scene>): Mesh;
  147514. /**
  147515. * Creates lathe mesh.
  147516. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147517. * * 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
  147518. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147519. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147520. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147521. * * 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
  147522. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147523. * * 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
  147524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147526. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147528. * @param name defines the name of the mesh
  147529. * @param options defines the options used to create the mesh
  147530. * @param scene defines the hosting scene
  147531. * @returns the lathe mesh
  147532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147533. */
  147534. static CreateLathe(name: string, options: {
  147535. shape: Vector3[];
  147536. radius?: number;
  147537. tessellation?: number;
  147538. clip?: number;
  147539. arc?: number;
  147540. closed?: boolean;
  147541. updatable?: boolean;
  147542. sideOrientation?: number;
  147543. frontUVs?: Vector4;
  147544. backUVs?: Vector4;
  147545. cap?: number;
  147546. invertUV?: boolean;
  147547. }, scene?: Nullable<Scene>): Mesh;
  147548. /**
  147549. * Creates a tiled plane mesh
  147550. * * You can set a limited pattern arrangement with the tiles
  147551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147554. * @param name defines the name of the mesh
  147555. * @param options defines the options used to create the mesh
  147556. * @param scene defines the hosting scene
  147557. * @returns the plane mesh
  147558. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147559. */
  147560. static CreateTiledPlane(name: string, options: {
  147561. pattern?: number;
  147562. tileSize?: number;
  147563. tileWidth?: number;
  147564. tileHeight?: number;
  147565. size?: number;
  147566. width?: number;
  147567. height?: number;
  147568. alignHorizontal?: number;
  147569. alignVertical?: number;
  147570. sideOrientation?: number;
  147571. frontUVs?: Vector4;
  147572. backUVs?: Vector4;
  147573. updatable?: boolean;
  147574. }, scene?: Nullable<Scene>): Mesh;
  147575. /**
  147576. * Creates a plane mesh
  147577. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  147578. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  147579. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  147580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147581. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147583. * @param name defines the name of the mesh
  147584. * @param options defines the options used to create the mesh
  147585. * @param scene defines the hosting scene
  147586. * @returns the plane mesh
  147587. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147588. */
  147589. static CreatePlane(name: string, options: {
  147590. size?: number;
  147591. width?: number;
  147592. height?: number;
  147593. sideOrientation?: number;
  147594. frontUVs?: Vector4;
  147595. backUVs?: Vector4;
  147596. updatable?: boolean;
  147597. sourcePlane?: Plane;
  147598. }, scene?: Nullable<Scene>): Mesh;
  147599. /**
  147600. * Creates a ground mesh
  147601. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  147602. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  147603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147604. * @param name defines the name of the mesh
  147605. * @param options defines the options used to create the mesh
  147606. * @param scene defines the hosting scene
  147607. * @returns the ground mesh
  147608. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  147609. */
  147610. static CreateGround(name: string, options: {
  147611. width?: number;
  147612. height?: number;
  147613. subdivisions?: number;
  147614. subdivisionsX?: number;
  147615. subdivisionsY?: number;
  147616. updatable?: boolean;
  147617. }, scene?: Nullable<Scene>): Mesh;
  147618. /**
  147619. * Creates a tiled ground mesh
  147620. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  147621. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  147622. * * 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
  147623. * * 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
  147624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147625. * @param name defines the name of the mesh
  147626. * @param options defines the options used to create the mesh
  147627. * @param scene defines the hosting scene
  147628. * @returns the tiled ground mesh
  147629. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  147630. */
  147631. static CreateTiledGround(name: string, options: {
  147632. xmin: number;
  147633. zmin: number;
  147634. xmax: number;
  147635. zmax: number;
  147636. subdivisions?: {
  147637. w: number;
  147638. h: number;
  147639. };
  147640. precision?: {
  147641. w: number;
  147642. h: number;
  147643. };
  147644. updatable?: boolean;
  147645. }, scene?: Nullable<Scene>): Mesh;
  147646. /**
  147647. * Creates a ground mesh from a height map
  147648. * * The parameter `url` sets the URL of the height map image resource.
  147649. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  147650. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  147651. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  147652. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  147653. * * 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.
  147654. * * 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).
  147655. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  147656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147657. * @param name defines the name of the mesh
  147658. * @param url defines the url to the height map
  147659. * @param options defines the options used to create the mesh
  147660. * @param scene defines the hosting scene
  147661. * @returns the ground mesh
  147662. * @see https://doc.babylonjs.com/babylon101/height_map
  147663. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  147664. */
  147665. static CreateGroundFromHeightMap(name: string, url: string, options: {
  147666. width?: number;
  147667. height?: number;
  147668. subdivisions?: number;
  147669. minHeight?: number;
  147670. maxHeight?: number;
  147671. colorFilter?: Color3;
  147672. alphaFilter?: number;
  147673. updatable?: boolean;
  147674. onReady?: (mesh: GroundMesh) => void;
  147675. }, scene?: Nullable<Scene>): GroundMesh;
  147676. /**
  147677. * Creates a polygon mesh
  147678. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147679. * * 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
  147680. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147683. * * Remember you can only change the shape positions, not their number when updating a polygon
  147684. * @param name defines the name of the mesh
  147685. * @param options defines the options used to create the mesh
  147686. * @param scene defines the hosting scene
  147687. * @param earcutInjection can be used to inject your own earcut reference
  147688. * @returns the polygon mesh
  147689. */
  147690. static CreatePolygon(name: string, options: {
  147691. shape: Vector3[];
  147692. holes?: Vector3[][];
  147693. depth?: number;
  147694. faceUV?: Vector4[];
  147695. faceColors?: Color4[];
  147696. updatable?: boolean;
  147697. sideOrientation?: number;
  147698. frontUVs?: Vector4;
  147699. backUVs?: Vector4;
  147700. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147701. /**
  147702. * Creates an extruded polygon mesh, with depth in the Y direction.
  147703. * * 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)
  147704. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147705. * @param name defines the name of the mesh
  147706. * @param options defines the options used to create the mesh
  147707. * @param scene defines the hosting scene
  147708. * @param earcutInjection can be used to inject your own earcut reference
  147709. * @returns the polygon mesh
  147710. */
  147711. static ExtrudePolygon(name: string, options: {
  147712. shape: Vector3[];
  147713. holes?: Vector3[][];
  147714. depth?: number;
  147715. faceUV?: Vector4[];
  147716. faceColors?: Color4[];
  147717. updatable?: boolean;
  147718. sideOrientation?: number;
  147719. frontUVs?: Vector4;
  147720. backUVs?: Vector4;
  147721. wrap?: boolean;
  147722. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147723. /**
  147724. * Creates a tube mesh.
  147725. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147726. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147727. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147728. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147729. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147730. * * 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)
  147731. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147732. * * 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
  147733. * * 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
  147734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147735. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147736. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147738. * @param name defines the name of the mesh
  147739. * @param options defines the options used to create the mesh
  147740. * @param scene defines the hosting scene
  147741. * @returns the tube mesh
  147742. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147743. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147744. */
  147745. static CreateTube(name: string, options: {
  147746. path: Vector3[];
  147747. radius?: number;
  147748. tessellation?: number;
  147749. radiusFunction?: {
  147750. (i: number, distance: number): number;
  147751. };
  147752. cap?: number;
  147753. arc?: number;
  147754. updatable?: boolean;
  147755. sideOrientation?: number;
  147756. frontUVs?: Vector4;
  147757. backUVs?: Vector4;
  147758. instance?: Mesh;
  147759. invertUV?: boolean;
  147760. }, scene?: Nullable<Scene>): Mesh;
  147761. /**
  147762. * Creates a polyhedron mesh
  147763. * * 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
  147764. * * The parameter `size` (positive float, default 1) sets the polygon size
  147765. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  147766. * * 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`
  147767. * * 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
  147768. * * 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)`)
  147769. * * 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
  147770. * * 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
  147771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147774. * @param name defines the name of the mesh
  147775. * @param options defines the options used to create the mesh
  147776. * @param scene defines the hosting scene
  147777. * @returns the polyhedron mesh
  147778. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  147779. */
  147780. static CreatePolyhedron(name: string, options: {
  147781. type?: number;
  147782. size?: number;
  147783. sizeX?: number;
  147784. sizeY?: number;
  147785. sizeZ?: number;
  147786. custom?: any;
  147787. faceUV?: Vector4[];
  147788. faceColors?: Color4[];
  147789. flat?: boolean;
  147790. updatable?: boolean;
  147791. sideOrientation?: number;
  147792. frontUVs?: Vector4;
  147793. backUVs?: Vector4;
  147794. }, scene?: Nullable<Scene>): Mesh;
  147795. /**
  147796. * Creates a decal mesh.
  147797. * 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
  147798. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147799. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147800. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147801. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147802. * @param name defines the name of the mesh
  147803. * @param sourceMesh defines the mesh where the decal must be applied
  147804. * @param options defines the options used to create the mesh
  147805. * @param scene defines the hosting scene
  147806. * @returns the decal mesh
  147807. * @see https://doc.babylonjs.com/how_to/decals
  147808. */
  147809. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147810. position?: Vector3;
  147811. normal?: Vector3;
  147812. size?: Vector3;
  147813. angle?: number;
  147814. }): Mesh;
  147815. /**
  147816. * Creates a Capsule Mesh
  147817. * @param name defines the name of the mesh.
  147818. * @param options the constructors options used to shape the mesh.
  147819. * @param scene defines the scene the mesh is scoped to.
  147820. * @returns the capsule mesh
  147821. * @see https://doc.babylonjs.com/how_to/capsule_shape
  147822. */
  147823. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  147824. }
  147825. }
  147826. declare module BABYLON {
  147827. /**
  147828. * A simplifier interface for future simplification implementations
  147829. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147830. */
  147831. export interface ISimplifier {
  147832. /**
  147833. * Simplification of a given mesh according to the given settings.
  147834. * Since this requires computation, it is assumed that the function runs async.
  147835. * @param settings The settings of the simplification, including quality and distance
  147836. * @param successCallback A callback that will be called after the mesh was simplified.
  147837. * @param errorCallback in case of an error, this callback will be called. optional.
  147838. */
  147839. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  147840. }
  147841. /**
  147842. * Expected simplification settings.
  147843. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  147844. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147845. */
  147846. export interface ISimplificationSettings {
  147847. /**
  147848. * Gets or sets the expected quality
  147849. */
  147850. quality: number;
  147851. /**
  147852. * Gets or sets the distance when this optimized version should be used
  147853. */
  147854. distance: number;
  147855. /**
  147856. * Gets an already optimized mesh
  147857. */
  147858. optimizeMesh?: boolean;
  147859. }
  147860. /**
  147861. * Class used to specify simplification options
  147862. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147863. */
  147864. export class SimplificationSettings implements ISimplificationSettings {
  147865. /** expected quality */
  147866. quality: number;
  147867. /** distance when this optimized version should be used */
  147868. distance: number;
  147869. /** already optimized mesh */
  147870. optimizeMesh?: boolean | undefined;
  147871. /**
  147872. * Creates a SimplificationSettings
  147873. * @param quality expected quality
  147874. * @param distance distance when this optimized version should be used
  147875. * @param optimizeMesh already optimized mesh
  147876. */
  147877. constructor(
  147878. /** expected quality */
  147879. quality: number,
  147880. /** distance when this optimized version should be used */
  147881. distance: number,
  147882. /** already optimized mesh */
  147883. optimizeMesh?: boolean | undefined);
  147884. }
  147885. /**
  147886. * Interface used to define a simplification task
  147887. */
  147888. export interface ISimplificationTask {
  147889. /**
  147890. * Array of settings
  147891. */
  147892. settings: Array<ISimplificationSettings>;
  147893. /**
  147894. * Simplification type
  147895. */
  147896. simplificationType: SimplificationType;
  147897. /**
  147898. * Mesh to simplify
  147899. */
  147900. mesh: Mesh;
  147901. /**
  147902. * Callback called on success
  147903. */
  147904. successCallback?: () => void;
  147905. /**
  147906. * Defines if parallel processing can be used
  147907. */
  147908. parallelProcessing: boolean;
  147909. }
  147910. /**
  147911. * Queue used to order the simplification tasks
  147912. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147913. */
  147914. export class SimplificationQueue {
  147915. private _simplificationArray;
  147916. /**
  147917. * Gets a boolean indicating that the process is still running
  147918. */
  147919. running: boolean;
  147920. /**
  147921. * Creates a new queue
  147922. */
  147923. constructor();
  147924. /**
  147925. * Adds a new simplification task
  147926. * @param task defines a task to add
  147927. */
  147928. addTask(task: ISimplificationTask): void;
  147929. /**
  147930. * Execute next task
  147931. */
  147932. executeNext(): void;
  147933. /**
  147934. * Execute a simplification task
  147935. * @param task defines the task to run
  147936. */
  147937. runSimplification(task: ISimplificationTask): void;
  147938. private getSimplifier;
  147939. }
  147940. /**
  147941. * The implemented types of simplification
  147942. * At the moment only Quadratic Error Decimation is implemented
  147943. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147944. */
  147945. export enum SimplificationType {
  147946. /** Quadratic error decimation */
  147947. QUADRATIC = 0
  147948. }
  147949. /**
  147950. * An implementation of the Quadratic Error simplification algorithm.
  147951. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147952. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147953. * @author RaananW
  147954. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147955. */
  147956. export class QuadraticErrorSimplification implements ISimplifier {
  147957. private _mesh;
  147958. private triangles;
  147959. private vertices;
  147960. private references;
  147961. private _reconstructedMesh;
  147962. /** Gets or sets the number pf sync interations */
  147963. syncIterations: number;
  147964. /** Gets or sets the aggressiveness of the simplifier */
  147965. aggressiveness: number;
  147966. /** Gets or sets the number of allowed iterations for decimation */
  147967. decimationIterations: number;
  147968. /** Gets or sets the espilon to use for bounding box computation */
  147969. boundingBoxEpsilon: number;
  147970. /**
  147971. * Creates a new QuadraticErrorSimplification
  147972. * @param _mesh defines the target mesh
  147973. */
  147974. constructor(_mesh: Mesh);
  147975. /**
  147976. * Simplification of a given mesh according to the given settings.
  147977. * Since this requires computation, it is assumed that the function runs async.
  147978. * @param settings The settings of the simplification, including quality and distance
  147979. * @param successCallback A callback that will be called after the mesh was simplified.
  147980. */
  147981. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147982. private runDecimation;
  147983. private initWithMesh;
  147984. private init;
  147985. private reconstructMesh;
  147986. private initDecimatedMesh;
  147987. private isFlipped;
  147988. private updateTriangles;
  147989. private identifyBorder;
  147990. private updateMesh;
  147991. private vertexError;
  147992. private calculateError;
  147993. }
  147994. }
  147995. declare module BABYLON {
  147996. interface Scene {
  147997. /** @hidden (Backing field) */
  147998. _simplificationQueue: SimplificationQueue;
  147999. /**
  148000. * Gets or sets the simplification queue attached to the scene
  148001. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148002. */
  148003. simplificationQueue: SimplificationQueue;
  148004. }
  148005. interface Mesh {
  148006. /**
  148007. * Simplify the mesh according to the given array of settings.
  148008. * Function will return immediately and will simplify async
  148009. * @param settings a collection of simplification settings
  148010. * @param parallelProcessing should all levels calculate parallel or one after the other
  148011. * @param simplificationType the type of simplification to run
  148012. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  148013. * @returns the current mesh
  148014. */
  148015. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  148016. }
  148017. /**
  148018. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  148019. * created in a scene
  148020. */
  148021. export class SimplicationQueueSceneComponent implements ISceneComponent {
  148022. /**
  148023. * The component name helpfull to identify the component in the list of scene components.
  148024. */
  148025. readonly name: string;
  148026. /**
  148027. * The scene the component belongs to.
  148028. */
  148029. scene: Scene;
  148030. /**
  148031. * Creates a new instance of the component for the given scene
  148032. * @param scene Defines the scene to register the component in
  148033. */
  148034. constructor(scene: Scene);
  148035. /**
  148036. * Registers the component in a given scene
  148037. */
  148038. register(): void;
  148039. /**
  148040. * Rebuilds the elements related to this component in case of
  148041. * context lost for instance.
  148042. */
  148043. rebuild(): void;
  148044. /**
  148045. * Disposes the component and the associated ressources
  148046. */
  148047. dispose(): void;
  148048. private _beforeCameraUpdate;
  148049. }
  148050. }
  148051. declare module BABYLON {
  148052. interface Mesh {
  148053. /**
  148054. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  148055. */
  148056. thinInstanceEnablePicking: boolean;
  148057. /**
  148058. * Creates a new thin instance
  148059. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  148060. * @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
  148061. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  148062. */
  148063. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  148064. /**
  148065. * Adds the transformation (matrix) of the current mesh as a thin instance
  148066. * @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
  148067. * @returns the thin instance index number
  148068. */
  148069. thinInstanceAddSelf(refresh: boolean): number;
  148070. /**
  148071. * Registers a custom attribute to be used with thin instances
  148072. * @param kind name of the attribute
  148073. * @param stride size in floats of the attribute
  148074. */
  148075. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  148076. /**
  148077. * Sets the matrix of a thin instance
  148078. * @param index index of the thin instance
  148079. * @param matrix matrix to set
  148080. * @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
  148081. */
  148082. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  148083. /**
  148084. * Sets the value of a custom attribute for a thin instance
  148085. * @param kind name of the attribute
  148086. * @param index index of the thin instance
  148087. * @param value value to set
  148088. * @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
  148089. */
  148090. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  148091. /**
  148092. * 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.
  148093. */
  148094. thinInstanceCount: number;
  148095. /**
  148096. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  148097. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  148098. * @param buffer buffer to set
  148099. * @param stride size in floats of each value of the buffer
  148100. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  148101. */
  148102. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  148103. /**
  148104. * Gets the list of world matrices
  148105. * @return an array containing all the world matrices from the thin instances
  148106. */
  148107. thinInstanceGetWorldMatrices(): Matrix[];
  148108. /**
  148109. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  148110. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148111. */
  148112. thinInstanceBufferUpdated(kind: string): void;
  148113. /**
  148114. * Applies a partial update to a buffer directly on the GPU
  148115. * 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
  148116. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148117. * @param data the data to set in the GPU buffer
  148118. * @param offset the offset in the GPU buffer where to update the data
  148119. */
  148120. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  148121. /**
  148122. * Refreshes the bounding info, taking into account all the thin instances defined
  148123. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  148124. */
  148125. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  148126. /** @hidden */
  148127. _thinInstanceInitializeUserStorage(): void;
  148128. /** @hidden */
  148129. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  148130. /** @hidden */
  148131. _userThinInstanceBuffersStorage: {
  148132. data: {
  148133. [key: string]: Float32Array;
  148134. };
  148135. sizes: {
  148136. [key: string]: number;
  148137. };
  148138. vertexBuffers: {
  148139. [key: string]: Nullable<VertexBuffer>;
  148140. };
  148141. strides: {
  148142. [key: string]: number;
  148143. };
  148144. };
  148145. }
  148146. }
  148147. declare module BABYLON {
  148148. /**
  148149. * Navigation plugin interface to add navigation constrained by a navigation mesh
  148150. */
  148151. export interface INavigationEnginePlugin {
  148152. /**
  148153. * plugin name
  148154. */
  148155. name: string;
  148156. /**
  148157. * Creates a navigation mesh
  148158. * @param meshes array of all the geometry used to compute the navigatio mesh
  148159. * @param parameters bunch of parameters used to filter geometry
  148160. */
  148161. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148162. /**
  148163. * Create a navigation mesh debug mesh
  148164. * @param scene is where the mesh will be added
  148165. * @returns debug display mesh
  148166. */
  148167. createDebugNavMesh(scene: Scene): Mesh;
  148168. /**
  148169. * Get a navigation mesh constrained position, closest to the parameter position
  148170. * @param position world position
  148171. * @returns the closest point to position constrained by the navigation mesh
  148172. */
  148173. getClosestPoint(position: Vector3): Vector3;
  148174. /**
  148175. * Get a navigation mesh constrained position, closest to the parameter position
  148176. * @param position world position
  148177. * @param result output the closest point to position constrained by the navigation mesh
  148178. */
  148179. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148180. /**
  148181. * Get a navigation mesh constrained position, within a particular radius
  148182. * @param position world position
  148183. * @param maxRadius the maximum distance to the constrained world position
  148184. * @returns the closest point to position constrained by the navigation mesh
  148185. */
  148186. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148187. /**
  148188. * Get a navigation mesh constrained position, within a particular radius
  148189. * @param position world position
  148190. * @param maxRadius the maximum distance to the constrained world position
  148191. * @param result output the closest point to position constrained by the navigation mesh
  148192. */
  148193. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148194. /**
  148195. * Compute the final position from a segment made of destination-position
  148196. * @param position world position
  148197. * @param destination world position
  148198. * @returns the resulting point along the navmesh
  148199. */
  148200. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148201. /**
  148202. * Compute the final position from a segment made of destination-position
  148203. * @param position world position
  148204. * @param destination world position
  148205. * @param result output the resulting point along the navmesh
  148206. */
  148207. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148208. /**
  148209. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148210. * @param start world position
  148211. * @param end world position
  148212. * @returns array containing world position composing the path
  148213. */
  148214. computePath(start: Vector3, end: Vector3): Vector3[];
  148215. /**
  148216. * If this plugin is supported
  148217. * @returns true if plugin is supported
  148218. */
  148219. isSupported(): boolean;
  148220. /**
  148221. * Create a new Crowd so you can add agents
  148222. * @param maxAgents the maximum agent count in the crowd
  148223. * @param maxAgentRadius the maximum radius an agent can have
  148224. * @param scene to attach the crowd to
  148225. * @returns the crowd you can add agents to
  148226. */
  148227. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148228. /**
  148229. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148230. * The queries will try to find a solution within those bounds
  148231. * default is (1,1,1)
  148232. * @param extent x,y,z value that define the extent around the queries point of reference
  148233. */
  148234. setDefaultQueryExtent(extent: Vector3): void;
  148235. /**
  148236. * Get the Bounding box extent specified by setDefaultQueryExtent
  148237. * @returns the box extent values
  148238. */
  148239. getDefaultQueryExtent(): Vector3;
  148240. /**
  148241. * build the navmesh from a previously saved state using getNavmeshData
  148242. * @param data the Uint8Array returned by getNavmeshData
  148243. */
  148244. buildFromNavmeshData(data: Uint8Array): void;
  148245. /**
  148246. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148247. * @returns data the Uint8Array that can be saved and reused
  148248. */
  148249. getNavmeshData(): Uint8Array;
  148250. /**
  148251. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148252. * @param result output the box extent values
  148253. */
  148254. getDefaultQueryExtentToRef(result: Vector3): void;
  148255. /**
  148256. * Release all resources
  148257. */
  148258. dispose(): void;
  148259. }
  148260. /**
  148261. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  148262. */
  148263. export interface ICrowd {
  148264. /**
  148265. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148266. * You can attach anything to that node. The node position is updated in the scene update tick.
  148267. * @param pos world position that will be constrained by the navigation mesh
  148268. * @param parameters agent parameters
  148269. * @param transform hooked to the agent that will be update by the scene
  148270. * @returns agent index
  148271. */
  148272. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148273. /**
  148274. * Returns the agent position in world space
  148275. * @param index agent index returned by addAgent
  148276. * @returns world space position
  148277. */
  148278. getAgentPosition(index: number): Vector3;
  148279. /**
  148280. * Gets the agent position result in world space
  148281. * @param index agent index returned by addAgent
  148282. * @param result output world space position
  148283. */
  148284. getAgentPositionToRef(index: number, result: Vector3): void;
  148285. /**
  148286. * Gets the agent velocity in world space
  148287. * @param index agent index returned by addAgent
  148288. * @returns world space velocity
  148289. */
  148290. getAgentVelocity(index: number): Vector3;
  148291. /**
  148292. * Gets the agent velocity result in world space
  148293. * @param index agent index returned by addAgent
  148294. * @param result output world space velocity
  148295. */
  148296. getAgentVelocityToRef(index: number, result: Vector3): void;
  148297. /**
  148298. * remove a particular agent previously created
  148299. * @param index agent index returned by addAgent
  148300. */
  148301. removeAgent(index: number): void;
  148302. /**
  148303. * get the list of all agents attached to this crowd
  148304. * @returns list of agent indices
  148305. */
  148306. getAgents(): number[];
  148307. /**
  148308. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148309. * @param deltaTime in seconds
  148310. */
  148311. update(deltaTime: number): void;
  148312. /**
  148313. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148314. * @param index agent index returned by addAgent
  148315. * @param destination targeted world position
  148316. */
  148317. agentGoto(index: number, destination: Vector3): void;
  148318. /**
  148319. * Teleport the agent to a new position
  148320. * @param index agent index returned by addAgent
  148321. * @param destination targeted world position
  148322. */
  148323. agentTeleport(index: number, destination: Vector3): void;
  148324. /**
  148325. * Update agent parameters
  148326. * @param index agent index returned by addAgent
  148327. * @param parameters agent parameters
  148328. */
  148329. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148330. /**
  148331. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148332. * The queries will try to find a solution within those bounds
  148333. * default is (1,1,1)
  148334. * @param extent x,y,z value that define the extent around the queries point of reference
  148335. */
  148336. setDefaultQueryExtent(extent: Vector3): void;
  148337. /**
  148338. * Get the Bounding box extent specified by setDefaultQueryExtent
  148339. * @returns the box extent values
  148340. */
  148341. getDefaultQueryExtent(): Vector3;
  148342. /**
  148343. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148344. * @param result output the box extent values
  148345. */
  148346. getDefaultQueryExtentToRef(result: Vector3): void;
  148347. /**
  148348. * Release all resources
  148349. */
  148350. dispose(): void;
  148351. }
  148352. /**
  148353. * Configures an agent
  148354. */
  148355. export interface IAgentParameters {
  148356. /**
  148357. * Agent radius. [Limit: >= 0]
  148358. */
  148359. radius: number;
  148360. /**
  148361. * Agent height. [Limit: > 0]
  148362. */
  148363. height: number;
  148364. /**
  148365. * Maximum allowed acceleration. [Limit: >= 0]
  148366. */
  148367. maxAcceleration: number;
  148368. /**
  148369. * Maximum allowed speed. [Limit: >= 0]
  148370. */
  148371. maxSpeed: number;
  148372. /**
  148373. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  148374. */
  148375. collisionQueryRange: number;
  148376. /**
  148377. * The path visibility optimization range. [Limit: > 0]
  148378. */
  148379. pathOptimizationRange: number;
  148380. /**
  148381. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  148382. */
  148383. separationWeight: number;
  148384. }
  148385. /**
  148386. * Configures the navigation mesh creation
  148387. */
  148388. export interface INavMeshParameters {
  148389. /**
  148390. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  148391. */
  148392. cs: number;
  148393. /**
  148394. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  148395. */
  148396. ch: number;
  148397. /**
  148398. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  148399. */
  148400. walkableSlopeAngle: number;
  148401. /**
  148402. * Minimum floor to 'ceiling' height that will still allow the floor area to
  148403. * be considered walkable. [Limit: >= 3] [Units: vx]
  148404. */
  148405. walkableHeight: number;
  148406. /**
  148407. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  148408. */
  148409. walkableClimb: number;
  148410. /**
  148411. * The distance to erode/shrink the walkable area of the heightfield away from
  148412. * obstructions. [Limit: >=0] [Units: vx]
  148413. */
  148414. walkableRadius: number;
  148415. /**
  148416. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  148417. */
  148418. maxEdgeLen: number;
  148419. /**
  148420. * The maximum distance a simplfied contour's border edges should deviate
  148421. * the original raw contour. [Limit: >=0] [Units: vx]
  148422. */
  148423. maxSimplificationError: number;
  148424. /**
  148425. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  148426. */
  148427. minRegionArea: number;
  148428. /**
  148429. * Any regions with a span count smaller than this value will, if possible,
  148430. * be merged with larger regions. [Limit: >=0] [Units: vx]
  148431. */
  148432. mergeRegionArea: number;
  148433. /**
  148434. * The maximum number of vertices allowed for polygons generated during the
  148435. * contour to polygon conversion process. [Limit: >= 3]
  148436. */
  148437. maxVertsPerPoly: number;
  148438. /**
  148439. * Sets the sampling distance to use when generating the detail mesh.
  148440. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  148441. */
  148442. detailSampleDist: number;
  148443. /**
  148444. * The maximum distance the detail mesh surface should deviate from heightfield
  148445. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  148446. */
  148447. detailSampleMaxError: number;
  148448. }
  148449. }
  148450. declare module BABYLON {
  148451. /**
  148452. * RecastJS navigation plugin
  148453. */
  148454. export class RecastJSPlugin implements INavigationEnginePlugin {
  148455. /**
  148456. * Reference to the Recast library
  148457. */
  148458. bjsRECAST: any;
  148459. /**
  148460. * plugin name
  148461. */
  148462. name: string;
  148463. /**
  148464. * the first navmesh created. We might extend this to support multiple navmeshes
  148465. */
  148466. navMesh: any;
  148467. /**
  148468. * Initializes the recastJS plugin
  148469. * @param recastInjection can be used to inject your own recast reference
  148470. */
  148471. constructor(recastInjection?: any);
  148472. /**
  148473. * Creates a navigation mesh
  148474. * @param meshes array of all the geometry used to compute the navigatio mesh
  148475. * @param parameters bunch of parameters used to filter geometry
  148476. */
  148477. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148478. /**
  148479. * Create a navigation mesh debug mesh
  148480. * @param scene is where the mesh will be added
  148481. * @returns debug display mesh
  148482. */
  148483. createDebugNavMesh(scene: Scene): Mesh;
  148484. /**
  148485. * Get a navigation mesh constrained position, closest to the parameter position
  148486. * @param position world position
  148487. * @returns the closest point to position constrained by the navigation mesh
  148488. */
  148489. getClosestPoint(position: Vector3): Vector3;
  148490. /**
  148491. * Get a navigation mesh constrained position, closest to the parameter position
  148492. * @param position world position
  148493. * @param result output the closest point to position constrained by the navigation mesh
  148494. */
  148495. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148496. /**
  148497. * Get a navigation mesh constrained position, within a particular radius
  148498. * @param position world position
  148499. * @param maxRadius the maximum distance to the constrained world position
  148500. * @returns the closest point to position constrained by the navigation mesh
  148501. */
  148502. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148503. /**
  148504. * Get a navigation mesh constrained position, within a particular radius
  148505. * @param position world position
  148506. * @param maxRadius the maximum distance to the constrained world position
  148507. * @param result output the closest point to position constrained by the navigation mesh
  148508. */
  148509. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148510. /**
  148511. * Compute the final position from a segment made of destination-position
  148512. * @param position world position
  148513. * @param destination world position
  148514. * @returns the resulting point along the navmesh
  148515. */
  148516. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148517. /**
  148518. * Compute the final position from a segment made of destination-position
  148519. * @param position world position
  148520. * @param destination world position
  148521. * @param result output the resulting point along the navmesh
  148522. */
  148523. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148524. /**
  148525. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148526. * @param start world position
  148527. * @param end world position
  148528. * @returns array containing world position composing the path
  148529. */
  148530. computePath(start: Vector3, end: Vector3): Vector3[];
  148531. /**
  148532. * Create a new Crowd so you can add agents
  148533. * @param maxAgents the maximum agent count in the crowd
  148534. * @param maxAgentRadius the maximum radius an agent can have
  148535. * @param scene to attach the crowd to
  148536. * @returns the crowd you can add agents to
  148537. */
  148538. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148539. /**
  148540. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148541. * The queries will try to find a solution within those bounds
  148542. * default is (1,1,1)
  148543. * @param extent x,y,z value that define the extent around the queries point of reference
  148544. */
  148545. setDefaultQueryExtent(extent: Vector3): void;
  148546. /**
  148547. * Get the Bounding box extent specified by setDefaultQueryExtent
  148548. * @returns the box extent values
  148549. */
  148550. getDefaultQueryExtent(): Vector3;
  148551. /**
  148552. * build the navmesh from a previously saved state using getNavmeshData
  148553. * @param data the Uint8Array returned by getNavmeshData
  148554. */
  148555. buildFromNavmeshData(data: Uint8Array): void;
  148556. /**
  148557. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148558. * @returns data the Uint8Array that can be saved and reused
  148559. */
  148560. getNavmeshData(): Uint8Array;
  148561. /**
  148562. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148563. * @param result output the box extent values
  148564. */
  148565. getDefaultQueryExtentToRef(result: Vector3): void;
  148566. /**
  148567. * Disposes
  148568. */
  148569. dispose(): void;
  148570. /**
  148571. * If this plugin is supported
  148572. * @returns true if plugin is supported
  148573. */
  148574. isSupported(): boolean;
  148575. }
  148576. /**
  148577. * Recast detour crowd implementation
  148578. */
  148579. export class RecastJSCrowd implements ICrowd {
  148580. /**
  148581. * Recast/detour plugin
  148582. */
  148583. bjsRECASTPlugin: RecastJSPlugin;
  148584. /**
  148585. * Link to the detour crowd
  148586. */
  148587. recastCrowd: any;
  148588. /**
  148589. * One transform per agent
  148590. */
  148591. transforms: TransformNode[];
  148592. /**
  148593. * All agents created
  148594. */
  148595. agents: number[];
  148596. /**
  148597. * Link to the scene is kept to unregister the crowd from the scene
  148598. */
  148599. private _scene;
  148600. /**
  148601. * Observer for crowd updates
  148602. */
  148603. private _onBeforeAnimationsObserver;
  148604. /**
  148605. * Constructor
  148606. * @param plugin recastJS plugin
  148607. * @param maxAgents the maximum agent count in the crowd
  148608. * @param maxAgentRadius the maximum radius an agent can have
  148609. * @param scene to attach the crowd to
  148610. * @returns the crowd you can add agents to
  148611. */
  148612. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  148613. /**
  148614. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148615. * You can attach anything to that node. The node position is updated in the scene update tick.
  148616. * @param pos world position that will be constrained by the navigation mesh
  148617. * @param parameters agent parameters
  148618. * @param transform hooked to the agent that will be update by the scene
  148619. * @returns agent index
  148620. */
  148621. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148622. /**
  148623. * Returns the agent position in world space
  148624. * @param index agent index returned by addAgent
  148625. * @returns world space position
  148626. */
  148627. getAgentPosition(index: number): Vector3;
  148628. /**
  148629. * Returns the agent position result in world space
  148630. * @param index agent index returned by addAgent
  148631. * @param result output world space position
  148632. */
  148633. getAgentPositionToRef(index: number, result: Vector3): void;
  148634. /**
  148635. * Returns the agent velocity in world space
  148636. * @param index agent index returned by addAgent
  148637. * @returns world space velocity
  148638. */
  148639. getAgentVelocity(index: number): Vector3;
  148640. /**
  148641. * Returns the agent velocity result in world space
  148642. * @param index agent index returned by addAgent
  148643. * @param result output world space velocity
  148644. */
  148645. getAgentVelocityToRef(index: number, result: Vector3): void;
  148646. /**
  148647. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148648. * @param index agent index returned by addAgent
  148649. * @param destination targeted world position
  148650. */
  148651. agentGoto(index: number, destination: Vector3): void;
  148652. /**
  148653. * Teleport the agent to a new position
  148654. * @param index agent index returned by addAgent
  148655. * @param destination targeted world position
  148656. */
  148657. agentTeleport(index: number, destination: Vector3): void;
  148658. /**
  148659. * Update agent parameters
  148660. * @param index agent index returned by addAgent
  148661. * @param parameters agent parameters
  148662. */
  148663. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148664. /**
  148665. * remove a particular agent previously created
  148666. * @param index agent index returned by addAgent
  148667. */
  148668. removeAgent(index: number): void;
  148669. /**
  148670. * get the list of all agents attached to this crowd
  148671. * @returns list of agent indices
  148672. */
  148673. getAgents(): number[];
  148674. /**
  148675. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148676. * @param deltaTime in seconds
  148677. */
  148678. update(deltaTime: number): void;
  148679. /**
  148680. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148681. * The queries will try to find a solution within those bounds
  148682. * default is (1,1,1)
  148683. * @param extent x,y,z value that define the extent around the queries point of reference
  148684. */
  148685. setDefaultQueryExtent(extent: Vector3): void;
  148686. /**
  148687. * Get the Bounding box extent specified by setDefaultQueryExtent
  148688. * @returns the box extent values
  148689. */
  148690. getDefaultQueryExtent(): Vector3;
  148691. /**
  148692. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148693. * @param result output the box extent values
  148694. */
  148695. getDefaultQueryExtentToRef(result: Vector3): void;
  148696. /**
  148697. * Release all resources
  148698. */
  148699. dispose(): void;
  148700. }
  148701. }
  148702. declare module BABYLON {
  148703. /**
  148704. * Class used to enable access to IndexedDB
  148705. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  148706. */
  148707. export class Database implements IOfflineProvider {
  148708. private _callbackManifestChecked;
  148709. private _currentSceneUrl;
  148710. private _db;
  148711. private _enableSceneOffline;
  148712. private _enableTexturesOffline;
  148713. private _manifestVersionFound;
  148714. private _mustUpdateRessources;
  148715. private _hasReachedQuota;
  148716. private _isSupported;
  148717. private _idbFactory;
  148718. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  148719. private static IsUASupportingBlobStorage;
  148720. /**
  148721. * Gets a boolean indicating if Database storate is enabled (off by default)
  148722. */
  148723. static IDBStorageEnabled: boolean;
  148724. /**
  148725. * Gets a boolean indicating if scene must be saved in the database
  148726. */
  148727. get enableSceneOffline(): boolean;
  148728. /**
  148729. * Gets a boolean indicating if textures must be saved in the database
  148730. */
  148731. get enableTexturesOffline(): boolean;
  148732. /**
  148733. * Creates a new Database
  148734. * @param urlToScene defines the url to load the scene
  148735. * @param callbackManifestChecked defines the callback to use when manifest is checked
  148736. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  148737. */
  148738. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  148739. private static _ParseURL;
  148740. private static _ReturnFullUrlLocation;
  148741. private _checkManifestFile;
  148742. /**
  148743. * Open the database and make it available
  148744. * @param successCallback defines the callback to call on success
  148745. * @param errorCallback defines the callback to call on error
  148746. */
  148747. open(successCallback: () => void, errorCallback: () => void): void;
  148748. /**
  148749. * Loads an image from the database
  148750. * @param url defines the url to load from
  148751. * @param image defines the target DOM image
  148752. */
  148753. loadImage(url: string, image: HTMLImageElement): void;
  148754. private _loadImageFromDBAsync;
  148755. private _saveImageIntoDBAsync;
  148756. private _checkVersionFromDB;
  148757. private _loadVersionFromDBAsync;
  148758. private _saveVersionIntoDBAsync;
  148759. /**
  148760. * Loads a file from database
  148761. * @param url defines the URL to load from
  148762. * @param sceneLoaded defines a callback to call on success
  148763. * @param progressCallBack defines a callback to call when progress changed
  148764. * @param errorCallback defines a callback to call on error
  148765. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  148766. */
  148767. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  148768. private _loadFileAsync;
  148769. private _saveFileAsync;
  148770. /**
  148771. * Validates if xhr data is correct
  148772. * @param xhr defines the request to validate
  148773. * @param dataType defines the expected data type
  148774. * @returns true if data is correct
  148775. */
  148776. private static _ValidateXHRData;
  148777. }
  148778. }
  148779. declare module BABYLON {
  148780. /** @hidden */
  148781. export var gpuUpdateParticlesPixelShader: {
  148782. name: string;
  148783. shader: string;
  148784. };
  148785. }
  148786. declare module BABYLON {
  148787. /** @hidden */
  148788. export var gpuUpdateParticlesVertexShader: {
  148789. name: string;
  148790. shader: string;
  148791. };
  148792. }
  148793. declare module BABYLON {
  148794. /** @hidden */
  148795. export var clipPlaneFragmentDeclaration2: {
  148796. name: string;
  148797. shader: string;
  148798. };
  148799. }
  148800. declare module BABYLON {
  148801. /** @hidden */
  148802. export var gpuRenderParticlesPixelShader: {
  148803. name: string;
  148804. shader: string;
  148805. };
  148806. }
  148807. declare module BABYLON {
  148808. /** @hidden */
  148809. export var clipPlaneVertexDeclaration2: {
  148810. name: string;
  148811. shader: string;
  148812. };
  148813. }
  148814. declare module BABYLON {
  148815. /** @hidden */
  148816. export var gpuRenderParticlesVertexShader: {
  148817. name: string;
  148818. shader: string;
  148819. };
  148820. }
  148821. declare module BABYLON {
  148822. /**
  148823. * This represents a GPU particle system in Babylon
  148824. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  148825. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  148826. */
  148827. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  148828. /**
  148829. * The layer mask we are rendering the particles through.
  148830. */
  148831. layerMask: number;
  148832. private _capacity;
  148833. private _activeCount;
  148834. private _currentActiveCount;
  148835. private _accumulatedCount;
  148836. private _renderEffect;
  148837. private _updateEffect;
  148838. private _buffer0;
  148839. private _buffer1;
  148840. private _spriteBuffer;
  148841. private _updateVAO;
  148842. private _renderVAO;
  148843. private _targetIndex;
  148844. private _sourceBuffer;
  148845. private _targetBuffer;
  148846. private _currentRenderId;
  148847. private _started;
  148848. private _stopped;
  148849. private _timeDelta;
  148850. private _randomTexture;
  148851. private _randomTexture2;
  148852. private _attributesStrideSize;
  148853. private _updateEffectOptions;
  148854. private _randomTextureSize;
  148855. private _actualFrame;
  148856. private _customEffect;
  148857. private readonly _rawTextureWidth;
  148858. /**
  148859. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  148860. */
  148861. static get IsSupported(): boolean;
  148862. /**
  148863. * An event triggered when the system is disposed.
  148864. */
  148865. onDisposeObservable: Observable<IParticleSystem>;
  148866. /**
  148867. * An event triggered when the system is stopped
  148868. */
  148869. onStoppedObservable: Observable<IParticleSystem>;
  148870. /**
  148871. * Gets the maximum number of particles active at the same time.
  148872. * @returns The max number of active particles.
  148873. */
  148874. getCapacity(): number;
  148875. /**
  148876. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  148877. * to override the particles.
  148878. */
  148879. forceDepthWrite: boolean;
  148880. /**
  148881. * Gets or set the number of active particles
  148882. */
  148883. get activeParticleCount(): number;
  148884. set activeParticleCount(value: number);
  148885. private _preWarmDone;
  148886. /**
  148887. * Specifies if the particles are updated in emitter local space or world space.
  148888. */
  148889. isLocal: boolean;
  148890. /** Gets or sets a matrix to use to compute projection */
  148891. defaultProjectionMatrix: Matrix;
  148892. /**
  148893. * Is this system ready to be used/rendered
  148894. * @return true if the system is ready
  148895. */
  148896. isReady(): boolean;
  148897. /**
  148898. * Gets if the system has been started. (Note: this will still be true after stop is called)
  148899. * @returns True if it has been started, otherwise false.
  148900. */
  148901. isStarted(): boolean;
  148902. /**
  148903. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  148904. * @returns True if it has been stopped, otherwise false.
  148905. */
  148906. isStopped(): boolean;
  148907. /**
  148908. * Gets a boolean indicating that the system is stopping
  148909. * @returns true if the system is currently stopping
  148910. */
  148911. isStopping(): boolean;
  148912. /**
  148913. * Gets the number of particles active at the same time.
  148914. * @returns The number of active particles.
  148915. */
  148916. getActiveCount(): number;
  148917. /**
  148918. * Starts the particle system and begins to emit
  148919. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  148920. */
  148921. start(delay?: number): void;
  148922. /**
  148923. * Stops the particle system.
  148924. */
  148925. stop(): void;
  148926. /**
  148927. * Remove all active particles
  148928. */
  148929. reset(): void;
  148930. /**
  148931. * Returns the string "GPUParticleSystem"
  148932. * @returns a string containing the class name
  148933. */
  148934. getClassName(): string;
  148935. /**
  148936. * Gets the custom effect used to render the particles
  148937. * @param blendMode Blend mode for which the effect should be retrieved
  148938. * @returns The effect
  148939. */
  148940. getCustomEffect(blendMode?: number): Nullable<Effect>;
  148941. /**
  148942. * Sets the custom effect used to render the particles
  148943. * @param effect The effect to set
  148944. * @param blendMode Blend mode for which the effect should be set
  148945. */
  148946. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  148947. /** @hidden */
  148948. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  148949. /**
  148950. * Observable that will be called just before the particles are drawn
  148951. */
  148952. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  148953. /**
  148954. * Gets the name of the particle vertex shader
  148955. */
  148956. get vertexShaderName(): string;
  148957. private _colorGradientsTexture;
  148958. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148959. /**
  148960. * Adds a new color gradient
  148961. * @param gradient defines the gradient to use (between 0 and 1)
  148962. * @param color1 defines the color to affect to the specified gradient
  148963. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148964. * @returns the current particle system
  148965. */
  148966. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148967. private _refreshColorGradient;
  148968. /** Force the system to rebuild all gradients that need to be resync */
  148969. forceRefreshGradients(): void;
  148970. /**
  148971. * Remove a specific color gradient
  148972. * @param gradient defines the gradient to remove
  148973. * @returns the current particle system
  148974. */
  148975. removeColorGradient(gradient: number): GPUParticleSystem;
  148976. private _angularSpeedGradientsTexture;
  148977. private _sizeGradientsTexture;
  148978. private _velocityGradientsTexture;
  148979. private _limitVelocityGradientsTexture;
  148980. private _dragGradientsTexture;
  148981. private _addFactorGradient;
  148982. /**
  148983. * Adds a new size gradient
  148984. * @param gradient defines the gradient to use (between 0 and 1)
  148985. * @param factor defines the size factor to affect to the specified gradient
  148986. * @returns the current particle system
  148987. */
  148988. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148989. /**
  148990. * Remove a specific size gradient
  148991. * @param gradient defines the gradient to remove
  148992. * @returns the current particle system
  148993. */
  148994. removeSizeGradient(gradient: number): GPUParticleSystem;
  148995. private _refreshFactorGradient;
  148996. /**
  148997. * Adds a new angular speed gradient
  148998. * @param gradient defines the gradient to use (between 0 and 1)
  148999. * @param factor defines the angular speed to affect to the specified gradient
  149000. * @returns the current particle system
  149001. */
  149002. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  149003. /**
  149004. * Remove a specific angular speed gradient
  149005. * @param gradient defines the gradient to remove
  149006. * @returns the current particle system
  149007. */
  149008. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  149009. /**
  149010. * Adds a new velocity gradient
  149011. * @param gradient defines the gradient to use (between 0 and 1)
  149012. * @param factor defines the velocity to affect to the specified gradient
  149013. * @returns the current particle system
  149014. */
  149015. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149016. /**
  149017. * Remove a specific velocity gradient
  149018. * @param gradient defines the gradient to remove
  149019. * @returns the current particle system
  149020. */
  149021. removeVelocityGradient(gradient: number): GPUParticleSystem;
  149022. /**
  149023. * Adds a new limit velocity gradient
  149024. * @param gradient defines the gradient to use (between 0 and 1)
  149025. * @param factor defines the limit velocity value to affect to the specified gradient
  149026. * @returns the current particle system
  149027. */
  149028. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149029. /**
  149030. * Remove a specific limit velocity gradient
  149031. * @param gradient defines the gradient to remove
  149032. * @returns the current particle system
  149033. */
  149034. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  149035. /**
  149036. * Adds a new drag gradient
  149037. * @param gradient defines the gradient to use (between 0 and 1)
  149038. * @param factor defines the drag value to affect to the specified gradient
  149039. * @returns the current particle system
  149040. */
  149041. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  149042. /**
  149043. * Remove a specific drag gradient
  149044. * @param gradient defines the gradient to remove
  149045. * @returns the current particle system
  149046. */
  149047. removeDragGradient(gradient: number): GPUParticleSystem;
  149048. /**
  149049. * Not supported by GPUParticleSystem
  149050. * @param gradient defines the gradient to use (between 0 and 1)
  149051. * @param factor defines the emit rate value to affect to the specified gradient
  149052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149053. * @returns the current particle system
  149054. */
  149055. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149056. /**
  149057. * Not supported by GPUParticleSystem
  149058. * @param gradient defines the gradient to remove
  149059. * @returns the current particle system
  149060. */
  149061. removeEmitRateGradient(gradient: number): IParticleSystem;
  149062. /**
  149063. * Not supported by GPUParticleSystem
  149064. * @param gradient defines the gradient to use (between 0 and 1)
  149065. * @param factor defines the start size value to affect to the specified gradient
  149066. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149067. * @returns the current particle system
  149068. */
  149069. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149070. /**
  149071. * Not supported by GPUParticleSystem
  149072. * @param gradient defines the gradient to remove
  149073. * @returns the current particle system
  149074. */
  149075. removeStartSizeGradient(gradient: number): IParticleSystem;
  149076. /**
  149077. * Not supported by GPUParticleSystem
  149078. * @param gradient defines the gradient to use (between 0 and 1)
  149079. * @param min defines the color remap minimal range
  149080. * @param max defines the color remap maximal range
  149081. * @returns the current particle system
  149082. */
  149083. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149084. /**
  149085. * Not supported by GPUParticleSystem
  149086. * @param gradient defines the gradient to remove
  149087. * @returns the current particle system
  149088. */
  149089. removeColorRemapGradient(): IParticleSystem;
  149090. /**
  149091. * Not supported by GPUParticleSystem
  149092. * @param gradient defines the gradient to use (between 0 and 1)
  149093. * @param min defines the alpha remap minimal range
  149094. * @param max defines the alpha remap maximal range
  149095. * @returns the current particle system
  149096. */
  149097. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149098. /**
  149099. * Not supported by GPUParticleSystem
  149100. * @param gradient defines the gradient to remove
  149101. * @returns the current particle system
  149102. */
  149103. removeAlphaRemapGradient(): IParticleSystem;
  149104. /**
  149105. * Not supported by GPUParticleSystem
  149106. * @param gradient defines the gradient to use (between 0 and 1)
  149107. * @param color defines the color to affect to the specified gradient
  149108. * @returns the current particle system
  149109. */
  149110. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  149111. /**
  149112. * Not supported by GPUParticleSystem
  149113. * @param gradient defines the gradient to remove
  149114. * @returns the current particle system
  149115. */
  149116. removeRampGradient(): IParticleSystem;
  149117. /**
  149118. * Not supported by GPUParticleSystem
  149119. * @returns the list of ramp gradients
  149120. */
  149121. getRampGradients(): Nullable<Array<Color3Gradient>>;
  149122. /**
  149123. * Not supported by GPUParticleSystem
  149124. * Gets or sets a boolean indicating that ramp gradients must be used
  149125. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  149126. */
  149127. get useRampGradients(): boolean;
  149128. set useRampGradients(value: boolean);
  149129. /**
  149130. * Not supported by GPUParticleSystem
  149131. * @param gradient defines the gradient to use (between 0 and 1)
  149132. * @param factor defines the life time factor to affect to the specified gradient
  149133. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149134. * @returns the current particle system
  149135. */
  149136. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149137. /**
  149138. * Not supported by GPUParticleSystem
  149139. * @param gradient defines the gradient to remove
  149140. * @returns the current particle system
  149141. */
  149142. removeLifeTimeGradient(gradient: number): IParticleSystem;
  149143. /**
  149144. * Instantiates a GPU particle system.
  149145. * 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.
  149146. * @param name The name of the particle system
  149147. * @param options The options used to create the system
  149148. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  149149. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  149150. * @param customEffect a custom effect used to change the way particles are rendered by default
  149151. */
  149152. constructor(name: string, options: Partial<{
  149153. capacity: number;
  149154. randomTextureSize: number;
  149155. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  149156. protected _reset(): void;
  149157. private _createUpdateVAO;
  149158. private _createRenderVAO;
  149159. private _initialize;
  149160. /** @hidden */
  149161. _recreateUpdateEffect(): void;
  149162. private _getEffect;
  149163. /**
  149164. * Fill the defines array according to the current settings of the particle system
  149165. * @param defines Array to be updated
  149166. * @param blendMode blend mode to take into account when updating the array
  149167. */
  149168. fillDefines(defines: Array<string>, blendMode?: number): void;
  149169. /**
  149170. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  149171. * @param uniforms Uniforms array to fill
  149172. * @param attributes Attributes array to fill
  149173. * @param samplers Samplers array to fill
  149174. */
  149175. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  149176. /** @hidden */
  149177. _recreateRenderEffect(): Effect;
  149178. /**
  149179. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  149180. * @param preWarm defines if we are in the pre-warmimg phase
  149181. */
  149182. animate(preWarm?: boolean): void;
  149183. private _createFactorGradientTexture;
  149184. private _createSizeGradientTexture;
  149185. private _createAngularSpeedGradientTexture;
  149186. private _createVelocityGradientTexture;
  149187. private _createLimitVelocityGradientTexture;
  149188. private _createDragGradientTexture;
  149189. private _createColorGradientTexture;
  149190. /**
  149191. * Renders the particle system in its current state
  149192. * @param preWarm defines if the system should only update the particles but not render them
  149193. * @returns the current number of particles
  149194. */
  149195. render(preWarm?: boolean): number;
  149196. /**
  149197. * Rebuilds the particle system
  149198. */
  149199. rebuild(): void;
  149200. private _releaseBuffers;
  149201. private _releaseVAOs;
  149202. /**
  149203. * Disposes the particle system and free the associated resources
  149204. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  149205. */
  149206. dispose(disposeTexture?: boolean): void;
  149207. /**
  149208. * Clones the particle system.
  149209. * @param name The name of the cloned object
  149210. * @param newEmitter The new emitter to use
  149211. * @returns the cloned particle system
  149212. */
  149213. clone(name: string, newEmitter: any): GPUParticleSystem;
  149214. /**
  149215. * Serializes the particle system to a JSON object
  149216. * @param serializeTexture defines if the texture must be serialized as well
  149217. * @returns the JSON object
  149218. */
  149219. serialize(serializeTexture?: boolean): any;
  149220. /**
  149221. * Parses a JSON object to create a GPU particle system.
  149222. * @param parsedParticleSystem The JSON object to parse
  149223. * @param sceneOrEngine The scene or the engine to create the particle system in
  149224. * @param rootUrl The root url to use to load external dependencies like texture
  149225. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  149226. * @returns the parsed GPU particle system
  149227. */
  149228. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  149229. }
  149230. }
  149231. declare module BABYLON {
  149232. /**
  149233. * Represents a set of particle systems working together to create a specific effect
  149234. */
  149235. export class ParticleSystemSet implements IDisposable {
  149236. /**
  149237. * Gets or sets base Assets URL
  149238. */
  149239. static BaseAssetsUrl: string;
  149240. private _emitterCreationOptions;
  149241. private _emitterNode;
  149242. /**
  149243. * Gets the particle system list
  149244. */
  149245. systems: IParticleSystem[];
  149246. /**
  149247. * Gets the emitter node used with this set
  149248. */
  149249. get emitterNode(): Nullable<TransformNode>;
  149250. /**
  149251. * Creates a new emitter mesh as a sphere
  149252. * @param options defines the options used to create the sphere
  149253. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  149254. * @param scene defines the hosting scene
  149255. */
  149256. setEmitterAsSphere(options: {
  149257. diameter: number;
  149258. segments: number;
  149259. color: Color3;
  149260. }, renderingGroupId: number, scene: Scene): void;
  149261. /**
  149262. * Starts all particle systems of the set
  149263. * @param emitter defines an optional mesh to use as emitter for the particle systems
  149264. */
  149265. start(emitter?: AbstractMesh): void;
  149266. /**
  149267. * Release all associated resources
  149268. */
  149269. dispose(): void;
  149270. /**
  149271. * Serialize the set into a JSON compatible object
  149272. * @param serializeTexture defines if the texture must be serialized as well
  149273. * @returns a JSON compatible representation of the set
  149274. */
  149275. serialize(serializeTexture?: boolean): any;
  149276. /**
  149277. * Parse a new ParticleSystemSet from a serialized source
  149278. * @param data defines a JSON compatible representation of the set
  149279. * @param scene defines the hosting scene
  149280. * @param gpu defines if we want GPU particles or CPU particles
  149281. * @returns a new ParticleSystemSet
  149282. */
  149283. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  149284. }
  149285. }
  149286. declare module BABYLON {
  149287. /**
  149288. * This class is made for on one-liner static method to help creating particle system set.
  149289. */
  149290. export class ParticleHelper {
  149291. /**
  149292. * Gets or sets base Assets URL
  149293. */
  149294. static BaseAssetsUrl: string;
  149295. /** Define the Url to load snippets */
  149296. static SnippetUrl: string;
  149297. /**
  149298. * Create a default particle system that you can tweak
  149299. * @param emitter defines the emitter to use
  149300. * @param capacity defines the system capacity (default is 500 particles)
  149301. * @param scene defines the hosting scene
  149302. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  149303. * @returns the new Particle system
  149304. */
  149305. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  149306. /**
  149307. * This is the main static method (one-liner) of this helper to create different particle systems
  149308. * @param type This string represents the type to the particle system to create
  149309. * @param scene The scene where the particle system should live
  149310. * @param gpu If the system will use gpu
  149311. * @returns the ParticleSystemSet created
  149312. */
  149313. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  149314. /**
  149315. * Static function used to export a particle system to a ParticleSystemSet variable.
  149316. * Please note that the emitter shape is not exported
  149317. * @param systems defines the particle systems to export
  149318. * @returns the created particle system set
  149319. */
  149320. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  149321. /**
  149322. * Creates a particle system from a snippet saved in a remote file
  149323. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  149324. * @param url defines the url to load from
  149325. * @param scene defines the hosting scene
  149326. * @param gpu If the system will use gpu
  149327. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149328. * @returns a promise that will resolve to the new particle system
  149329. */
  149330. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149331. /**
  149332. * Creates a particle system from a snippet saved by the particle system editor
  149333. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  149334. * @param scene defines the hosting scene
  149335. * @param gpu If the system will use gpu
  149336. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149337. * @returns a promise that will resolve to the new particle system
  149338. */
  149339. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149340. }
  149341. }
  149342. declare module BABYLON {
  149343. interface Engine {
  149344. /**
  149345. * Create an effect to use with particle systems.
  149346. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  149347. * the particle system for which you want to create a custom effect in the last parameter
  149348. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  149349. * @param uniformsNames defines a list of attribute names
  149350. * @param samplers defines an array of string used to represent textures
  149351. * @param defines defines the string containing the defines to use to compile the shaders
  149352. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  149353. * @param onCompiled defines a function to call when the effect creation is successful
  149354. * @param onError defines a function to call when the effect creation has failed
  149355. * @param particleSystem the particle system you want to create the effect for
  149356. * @returns the new Effect
  149357. */
  149358. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  149359. }
  149360. interface Mesh {
  149361. /**
  149362. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  149363. * @returns an array of IParticleSystem
  149364. */
  149365. getEmittedParticleSystems(): IParticleSystem[];
  149366. /**
  149367. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  149368. * @returns an array of IParticleSystem
  149369. */
  149370. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  149371. }
  149372. }
  149373. declare module BABYLON {
  149374. /** Defines the 4 color options */
  149375. export enum PointColor {
  149376. /** color value */
  149377. Color = 2,
  149378. /** uv value */
  149379. UV = 1,
  149380. /** random value */
  149381. Random = 0,
  149382. /** stated value */
  149383. Stated = 3
  149384. }
  149385. /**
  149386. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  149387. * 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.
  149388. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  149389. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  149390. *
  149391. * Full documentation here : TO BE ENTERED
  149392. */
  149393. export class PointsCloudSystem implements IDisposable {
  149394. /**
  149395. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  149396. * Example : var p = SPS.particles[i];
  149397. */
  149398. particles: CloudPoint[];
  149399. /**
  149400. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  149401. */
  149402. nbParticles: number;
  149403. /**
  149404. * This a counter for your own usage. It's not set by any SPS functions.
  149405. */
  149406. counter: number;
  149407. /**
  149408. * The PCS name. This name is also given to the underlying mesh.
  149409. */
  149410. name: string;
  149411. /**
  149412. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  149413. */
  149414. mesh: Mesh;
  149415. /**
  149416. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  149417. * Please read :
  149418. */
  149419. vars: any;
  149420. /**
  149421. * @hidden
  149422. */
  149423. _size: number;
  149424. private _scene;
  149425. private _promises;
  149426. private _positions;
  149427. private _indices;
  149428. private _normals;
  149429. private _colors;
  149430. private _uvs;
  149431. private _indices32;
  149432. private _positions32;
  149433. private _colors32;
  149434. private _uvs32;
  149435. private _updatable;
  149436. private _isVisibilityBoxLocked;
  149437. private _alwaysVisible;
  149438. private _groups;
  149439. private _groupCounter;
  149440. private _computeParticleColor;
  149441. private _computeParticleTexture;
  149442. private _computeParticleRotation;
  149443. private _computeBoundingBox;
  149444. private _isReady;
  149445. /**
  149446. * Creates a PCS (Points Cloud System) object
  149447. * @param name (String) is the PCS name, this will be the underlying mesh name
  149448. * @param pointSize (number) is the size for each point
  149449. * @param scene (Scene) is the scene in which the PCS is added
  149450. * @param options defines the options of the PCS e.g.
  149451. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  149452. */
  149453. constructor(name: string, pointSize: number, scene: Scene, options?: {
  149454. updatable?: boolean;
  149455. });
  149456. /**
  149457. * Builds the PCS underlying mesh. Returns a standard Mesh.
  149458. * If no points were added to the PCS, the returned mesh is just a single point.
  149459. * @returns a promise for the created mesh
  149460. */
  149461. buildMeshAsync(): Promise<Mesh>;
  149462. /**
  149463. * @hidden
  149464. */
  149465. private _buildMesh;
  149466. private _addParticle;
  149467. private _randomUnitVector;
  149468. private _getColorIndicesForCoord;
  149469. private _setPointsColorOrUV;
  149470. private _colorFromTexture;
  149471. private _calculateDensity;
  149472. /**
  149473. * Adds points to the PCS in random positions within a unit sphere
  149474. * @param nb (positive integer) the number of particles to be created from this model
  149475. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  149476. * @returns the number of groups in the system
  149477. */
  149478. addPoints(nb: number, pointFunction?: any): number;
  149479. /**
  149480. * Adds points to the PCS from the surface of the model shape
  149481. * @param mesh is any Mesh object that will be used as a surface model for the points
  149482. * @param nb (positive integer) the number of particles to be created from this model
  149483. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149484. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149485. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149486. * @returns the number of groups in the system
  149487. */
  149488. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149489. /**
  149490. * Adds points to the PCS inside the model shape
  149491. * @param mesh is any Mesh object that will be used as a surface model for the points
  149492. * @param nb (positive integer) the number of particles to be created from this model
  149493. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149494. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149495. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149496. * @returns the number of groups in the system
  149497. */
  149498. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149499. /**
  149500. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  149501. * This method calls `updateParticle()` for each particle of the SPS.
  149502. * For an animated SPS, it is usually called within the render loop.
  149503. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  149504. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  149505. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  149506. * @returns the PCS.
  149507. */
  149508. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  149509. /**
  149510. * Disposes the PCS.
  149511. */
  149512. dispose(): void;
  149513. /**
  149514. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  149515. * doc :
  149516. * @returns the PCS.
  149517. */
  149518. refreshVisibleSize(): PointsCloudSystem;
  149519. /**
  149520. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  149521. * @param size the size (float) of the visibility box
  149522. * note : this doesn't lock the PCS mesh bounding box.
  149523. * doc :
  149524. */
  149525. setVisibilityBox(size: number): void;
  149526. /**
  149527. * Gets whether the PCS is always visible or not
  149528. * doc :
  149529. */
  149530. get isAlwaysVisible(): boolean;
  149531. /**
  149532. * Sets the PCS as always visible or not
  149533. * doc :
  149534. */
  149535. set isAlwaysVisible(val: boolean);
  149536. /**
  149537. * Tells to `setParticles()` to compute the particle rotations or not
  149538. * Default value : false. The PCS is faster when it's set to false
  149539. * Note : particle rotations are only applied to parent particles
  149540. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  149541. */
  149542. set computeParticleRotation(val: boolean);
  149543. /**
  149544. * Tells to `setParticles()` to compute the particle colors or not.
  149545. * Default value : true. The PCS is faster when it's set to false.
  149546. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149547. */
  149548. set computeParticleColor(val: boolean);
  149549. set computeParticleTexture(val: boolean);
  149550. /**
  149551. * Gets if `setParticles()` computes the particle colors or not.
  149552. * Default value : false. The PCS is faster when it's set to false.
  149553. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149554. */
  149555. get computeParticleColor(): boolean;
  149556. /**
  149557. * Gets if `setParticles()` computes the particle textures or not.
  149558. * Default value : false. The PCS is faster when it's set to false.
  149559. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  149560. */
  149561. get computeParticleTexture(): boolean;
  149562. /**
  149563. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  149564. */
  149565. set computeBoundingBox(val: boolean);
  149566. /**
  149567. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  149568. */
  149569. get computeBoundingBox(): boolean;
  149570. /**
  149571. * This function does nothing. It may be overwritten to set all the particle first values.
  149572. * The PCS doesn't call this function, you may have to call it by your own.
  149573. * doc :
  149574. */
  149575. initParticles(): void;
  149576. /**
  149577. * This function does nothing. It may be overwritten to recycle a particle
  149578. * The PCS doesn't call this function, you can to call it
  149579. * doc :
  149580. * @param particle The particle to recycle
  149581. * @returns the recycled particle
  149582. */
  149583. recycleParticle(particle: CloudPoint): CloudPoint;
  149584. /**
  149585. * Updates a particle : this function should be overwritten by the user.
  149586. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  149587. * doc :
  149588. * @example : just set a particle position or velocity and recycle conditions
  149589. * @param particle The particle to update
  149590. * @returns the updated particle
  149591. */
  149592. updateParticle(particle: CloudPoint): CloudPoint;
  149593. /**
  149594. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  149595. * This does nothing and may be overwritten by the user.
  149596. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149597. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149598. * @param update the boolean update value actually passed to setParticles()
  149599. */
  149600. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149601. /**
  149602. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  149603. * This will be passed three parameters.
  149604. * This does nothing and may be overwritten by the user.
  149605. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149606. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149607. * @param update the boolean update value actually passed to setParticles()
  149608. */
  149609. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149610. }
  149611. }
  149612. declare module BABYLON {
  149613. /**
  149614. * Represents one particle of a points cloud system.
  149615. */
  149616. export class CloudPoint {
  149617. /**
  149618. * particle global index
  149619. */
  149620. idx: number;
  149621. /**
  149622. * The color of the particle
  149623. */
  149624. color: Nullable<Color4>;
  149625. /**
  149626. * The world space position of the particle.
  149627. */
  149628. position: Vector3;
  149629. /**
  149630. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  149631. */
  149632. rotation: Vector3;
  149633. /**
  149634. * The world space rotation quaternion of the particle.
  149635. */
  149636. rotationQuaternion: Nullable<Quaternion>;
  149637. /**
  149638. * The uv of the particle.
  149639. */
  149640. uv: Nullable<Vector2>;
  149641. /**
  149642. * The current speed of the particle.
  149643. */
  149644. velocity: Vector3;
  149645. /**
  149646. * The pivot point in the particle local space.
  149647. */
  149648. pivot: Vector3;
  149649. /**
  149650. * Must the particle be translated from its pivot point in its local space ?
  149651. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  149652. * Default : false
  149653. */
  149654. translateFromPivot: boolean;
  149655. /**
  149656. * Index of this particle in the global "positions" array (Internal use)
  149657. * @hidden
  149658. */
  149659. _pos: number;
  149660. /**
  149661. * @hidden Index of this particle in the global "indices" array (Internal use)
  149662. */
  149663. _ind: number;
  149664. /**
  149665. * Group this particle belongs to
  149666. */
  149667. _group: PointsGroup;
  149668. /**
  149669. * Group id of this particle
  149670. */
  149671. groupId: number;
  149672. /**
  149673. * Index of the particle in its group id (Internal use)
  149674. */
  149675. idxInGroup: number;
  149676. /**
  149677. * @hidden Particle BoundingInfo object (Internal use)
  149678. */
  149679. _boundingInfo: BoundingInfo;
  149680. /**
  149681. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  149682. */
  149683. _pcs: PointsCloudSystem;
  149684. /**
  149685. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  149686. */
  149687. _stillInvisible: boolean;
  149688. /**
  149689. * @hidden Last computed particle rotation matrix
  149690. */
  149691. _rotationMatrix: number[];
  149692. /**
  149693. * Parent particle Id, if any.
  149694. * Default null.
  149695. */
  149696. parentId: Nullable<number>;
  149697. /**
  149698. * @hidden Internal global position in the PCS.
  149699. */
  149700. _globalPosition: Vector3;
  149701. /**
  149702. * Creates a Point Cloud object.
  149703. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  149704. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  149705. * @param group (PointsGroup) is the group the particle belongs to
  149706. * @param groupId (integer) is the group identifier in the PCS.
  149707. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  149708. * @param pcs defines the PCS it is associated to
  149709. */
  149710. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  149711. /**
  149712. * get point size
  149713. */
  149714. get size(): Vector3;
  149715. /**
  149716. * Set point size
  149717. */
  149718. set size(scale: Vector3);
  149719. /**
  149720. * Legacy support, changed quaternion to rotationQuaternion
  149721. */
  149722. get quaternion(): Nullable<Quaternion>;
  149723. /**
  149724. * Legacy support, changed quaternion to rotationQuaternion
  149725. */
  149726. set quaternion(q: Nullable<Quaternion>);
  149727. /**
  149728. * Returns a boolean. True if the particle intersects a mesh, else false
  149729. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  149730. * @param target is the object (point or mesh) what the intersection is computed against
  149731. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  149732. * @returns true if it intersects
  149733. */
  149734. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  149735. /**
  149736. * get the rotation matrix of the particle
  149737. * @hidden
  149738. */
  149739. getRotationMatrix(m: Matrix): void;
  149740. }
  149741. /**
  149742. * Represents a group of points in a points cloud system
  149743. * * PCS internal tool, don't use it manually.
  149744. */
  149745. export class PointsGroup {
  149746. /**
  149747. * The group id
  149748. * @hidden
  149749. */
  149750. groupID: number;
  149751. /**
  149752. * image data for group (internal use)
  149753. * @hidden
  149754. */
  149755. _groupImageData: Nullable<ArrayBufferView>;
  149756. /**
  149757. * Image Width (internal use)
  149758. * @hidden
  149759. */
  149760. _groupImgWidth: number;
  149761. /**
  149762. * Image Height (internal use)
  149763. * @hidden
  149764. */
  149765. _groupImgHeight: number;
  149766. /**
  149767. * Custom position function (internal use)
  149768. * @hidden
  149769. */
  149770. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  149771. /**
  149772. * density per facet for surface points
  149773. * @hidden
  149774. */
  149775. _groupDensity: number[];
  149776. /**
  149777. * Only when points are colored by texture carries pointer to texture list array
  149778. * @hidden
  149779. */
  149780. _textureNb: number;
  149781. /**
  149782. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  149783. * PCS internal tool, don't use it manually.
  149784. * @hidden
  149785. */
  149786. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  149787. }
  149788. }
  149789. declare module BABYLON {
  149790. interface Scene {
  149791. /** @hidden (Backing field) */
  149792. _physicsEngine: Nullable<IPhysicsEngine>;
  149793. /** @hidden */
  149794. _physicsTimeAccumulator: number;
  149795. /**
  149796. * Gets the current physics engine
  149797. * @returns a IPhysicsEngine or null if none attached
  149798. */
  149799. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  149800. /**
  149801. * Enables physics to the current scene
  149802. * @param gravity defines the scene's gravity for the physics engine
  149803. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  149804. * @return a boolean indicating if the physics engine was initialized
  149805. */
  149806. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  149807. /**
  149808. * Disables and disposes the physics engine associated with the scene
  149809. */
  149810. disablePhysicsEngine(): void;
  149811. /**
  149812. * Gets a boolean indicating if there is an active physics engine
  149813. * @returns a boolean indicating if there is an active physics engine
  149814. */
  149815. isPhysicsEnabled(): boolean;
  149816. /**
  149817. * Deletes a physics compound impostor
  149818. * @param compound defines the compound to delete
  149819. */
  149820. deleteCompoundImpostor(compound: any): void;
  149821. /**
  149822. * An event triggered when physic simulation is about to be run
  149823. */
  149824. onBeforePhysicsObservable: Observable<Scene>;
  149825. /**
  149826. * An event triggered when physic simulation has been done
  149827. */
  149828. onAfterPhysicsObservable: Observable<Scene>;
  149829. }
  149830. interface AbstractMesh {
  149831. /** @hidden */
  149832. _physicsImpostor: Nullable<PhysicsImpostor>;
  149833. /**
  149834. * Gets or sets impostor used for physic simulation
  149835. * @see https://doc.babylonjs.com/features/physics_engine
  149836. */
  149837. physicsImpostor: Nullable<PhysicsImpostor>;
  149838. /**
  149839. * Gets the current physics impostor
  149840. * @see https://doc.babylonjs.com/features/physics_engine
  149841. * @returns a physics impostor or null
  149842. */
  149843. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  149844. /** Apply a physic impulse to the mesh
  149845. * @param force defines the force to apply
  149846. * @param contactPoint defines where to apply the force
  149847. * @returns the current mesh
  149848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149849. */
  149850. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  149851. /**
  149852. * Creates a physic joint between two meshes
  149853. * @param otherMesh defines the other mesh to use
  149854. * @param pivot1 defines the pivot to use on this mesh
  149855. * @param pivot2 defines the pivot to use on the other mesh
  149856. * @param options defines additional options (can be plugin dependent)
  149857. * @returns the current mesh
  149858. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  149859. */
  149860. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  149861. /** @hidden */
  149862. _disposePhysicsObserver: Nullable<Observer<Node>>;
  149863. }
  149864. /**
  149865. * Defines the physics engine scene component responsible to manage a physics engine
  149866. */
  149867. export class PhysicsEngineSceneComponent implements ISceneComponent {
  149868. /**
  149869. * The component name helpful to identify the component in the list of scene components.
  149870. */
  149871. readonly name: string;
  149872. /**
  149873. * The scene the component belongs to.
  149874. */
  149875. scene: Scene;
  149876. /**
  149877. * Creates a new instance of the component for the given scene
  149878. * @param scene Defines the scene to register the component in
  149879. */
  149880. constructor(scene: Scene);
  149881. /**
  149882. * Registers the component in a given scene
  149883. */
  149884. register(): void;
  149885. /**
  149886. * Rebuilds the elements related to this component in case of
  149887. * context lost for instance.
  149888. */
  149889. rebuild(): void;
  149890. /**
  149891. * Disposes the component and the associated ressources
  149892. */
  149893. dispose(): void;
  149894. }
  149895. }
  149896. declare module BABYLON {
  149897. /**
  149898. * A helper for physics simulations
  149899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149900. */
  149901. export class PhysicsHelper {
  149902. private _scene;
  149903. private _physicsEngine;
  149904. /**
  149905. * Initializes the Physics helper
  149906. * @param scene Babylon.js scene
  149907. */
  149908. constructor(scene: Scene);
  149909. /**
  149910. * Applies a radial explosion impulse
  149911. * @param origin the origin of the explosion
  149912. * @param radiusOrEventOptions the radius or the options of radial explosion
  149913. * @param strength the explosion strength
  149914. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149915. * @returns A physics radial explosion event, or null
  149916. */
  149917. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149918. /**
  149919. * Applies a radial explosion force
  149920. * @param origin the origin of the explosion
  149921. * @param radiusOrEventOptions the radius or the options of radial explosion
  149922. * @param strength the explosion strength
  149923. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149924. * @returns A physics radial explosion event, or null
  149925. */
  149926. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149927. /**
  149928. * Creates a gravitational field
  149929. * @param origin the origin of the explosion
  149930. * @param radiusOrEventOptions the radius or the options of radial explosion
  149931. * @param strength the explosion strength
  149932. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149933. * @returns A physics gravitational field event, or null
  149934. */
  149935. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  149936. /**
  149937. * Creates a physics updraft event
  149938. * @param origin the origin of the updraft
  149939. * @param radiusOrEventOptions the radius or the options of the updraft
  149940. * @param strength the strength of the updraft
  149941. * @param height the height of the updraft
  149942. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  149943. * @returns A physics updraft event, or null
  149944. */
  149945. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  149946. /**
  149947. * Creates a physics vortex event
  149948. * @param origin the of the vortex
  149949. * @param radiusOrEventOptions the radius or the options of the vortex
  149950. * @param strength the strength of the vortex
  149951. * @param height the height of the vortex
  149952. * @returns a Physics vortex event, or null
  149953. * A physics vortex event or null
  149954. */
  149955. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149956. }
  149957. /**
  149958. * Represents a physics radial explosion event
  149959. */
  149960. class PhysicsRadialExplosionEvent {
  149961. private _scene;
  149962. private _options;
  149963. private _sphere;
  149964. private _dataFetched;
  149965. /**
  149966. * Initializes a radial explosioin event
  149967. * @param _scene BabylonJS scene
  149968. * @param _options The options for the vortex event
  149969. */
  149970. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149971. /**
  149972. * Returns the data related to the radial explosion event (sphere).
  149973. * @returns The radial explosion event data
  149974. */
  149975. getData(): PhysicsRadialExplosionEventData;
  149976. /**
  149977. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149978. * @param impostor A physics imposter
  149979. * @param origin the origin of the explosion
  149980. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149981. */
  149982. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149983. /**
  149984. * Triggers affecterd impostors callbacks
  149985. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149986. */
  149987. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149988. /**
  149989. * Disposes the sphere.
  149990. * @param force Specifies if the sphere should be disposed by force
  149991. */
  149992. dispose(force?: boolean): void;
  149993. /*** Helpers ***/
  149994. private _prepareSphere;
  149995. private _intersectsWithSphere;
  149996. }
  149997. /**
  149998. * Represents a gravitational field event
  149999. */
  150000. class PhysicsGravitationalFieldEvent {
  150001. private _physicsHelper;
  150002. private _scene;
  150003. private _origin;
  150004. private _options;
  150005. private _tickCallback;
  150006. private _sphere;
  150007. private _dataFetched;
  150008. /**
  150009. * Initializes the physics gravitational field event
  150010. * @param _physicsHelper A physics helper
  150011. * @param _scene BabylonJS scene
  150012. * @param _origin The origin position of the gravitational field event
  150013. * @param _options The options for the vortex event
  150014. */
  150015. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  150016. /**
  150017. * Returns the data related to the gravitational field event (sphere).
  150018. * @returns A gravitational field event
  150019. */
  150020. getData(): PhysicsGravitationalFieldEventData;
  150021. /**
  150022. * Enables the gravitational field.
  150023. */
  150024. enable(): void;
  150025. /**
  150026. * Disables the gravitational field.
  150027. */
  150028. disable(): void;
  150029. /**
  150030. * Disposes the sphere.
  150031. * @param force The force to dispose from the gravitational field event
  150032. */
  150033. dispose(force?: boolean): void;
  150034. private _tick;
  150035. }
  150036. /**
  150037. * Represents a physics updraft event
  150038. */
  150039. class PhysicsUpdraftEvent {
  150040. private _scene;
  150041. private _origin;
  150042. private _options;
  150043. private _physicsEngine;
  150044. private _originTop;
  150045. private _originDirection;
  150046. private _tickCallback;
  150047. private _cylinder;
  150048. private _cylinderPosition;
  150049. private _dataFetched;
  150050. /**
  150051. * Initializes the physics updraft event
  150052. * @param _scene BabylonJS scene
  150053. * @param _origin The origin position of the updraft
  150054. * @param _options The options for the updraft event
  150055. */
  150056. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  150057. /**
  150058. * Returns the data related to the updraft event (cylinder).
  150059. * @returns A physics updraft event
  150060. */
  150061. getData(): PhysicsUpdraftEventData;
  150062. /**
  150063. * Enables the updraft.
  150064. */
  150065. enable(): void;
  150066. /**
  150067. * Disables the updraft.
  150068. */
  150069. disable(): void;
  150070. /**
  150071. * Disposes the cylinder.
  150072. * @param force Specifies if the updraft should be disposed by force
  150073. */
  150074. dispose(force?: boolean): void;
  150075. private getImpostorHitData;
  150076. private _tick;
  150077. /*** Helpers ***/
  150078. private _prepareCylinder;
  150079. private _intersectsWithCylinder;
  150080. }
  150081. /**
  150082. * Represents a physics vortex event
  150083. */
  150084. class PhysicsVortexEvent {
  150085. private _scene;
  150086. private _origin;
  150087. private _options;
  150088. private _physicsEngine;
  150089. private _originTop;
  150090. private _tickCallback;
  150091. private _cylinder;
  150092. private _cylinderPosition;
  150093. private _dataFetched;
  150094. /**
  150095. * Initializes the physics vortex event
  150096. * @param _scene The BabylonJS scene
  150097. * @param _origin The origin position of the vortex
  150098. * @param _options The options for the vortex event
  150099. */
  150100. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  150101. /**
  150102. * Returns the data related to the vortex event (cylinder).
  150103. * @returns The physics vortex event data
  150104. */
  150105. getData(): PhysicsVortexEventData;
  150106. /**
  150107. * Enables the vortex.
  150108. */
  150109. enable(): void;
  150110. /**
  150111. * Disables the cortex.
  150112. */
  150113. disable(): void;
  150114. /**
  150115. * Disposes the sphere.
  150116. * @param force
  150117. */
  150118. dispose(force?: boolean): void;
  150119. private getImpostorHitData;
  150120. private _tick;
  150121. /*** Helpers ***/
  150122. private _prepareCylinder;
  150123. private _intersectsWithCylinder;
  150124. }
  150125. /**
  150126. * Options fot the radial explosion event
  150127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150128. */
  150129. export class PhysicsRadialExplosionEventOptions {
  150130. /**
  150131. * The radius of the sphere for the radial explosion.
  150132. */
  150133. radius: number;
  150134. /**
  150135. * The strenth of the explosion.
  150136. */
  150137. strength: number;
  150138. /**
  150139. * The strenght of the force in correspondence to the distance of the affected object
  150140. */
  150141. falloff: PhysicsRadialImpulseFalloff;
  150142. /**
  150143. * Sphere options for the radial explosion.
  150144. */
  150145. sphere: {
  150146. segments: number;
  150147. diameter: number;
  150148. };
  150149. /**
  150150. * Sphere options for the radial explosion.
  150151. */
  150152. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  150153. }
  150154. /**
  150155. * Options fot the updraft event
  150156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150157. */
  150158. export class PhysicsUpdraftEventOptions {
  150159. /**
  150160. * The radius of the cylinder for the vortex
  150161. */
  150162. radius: number;
  150163. /**
  150164. * The strenth of the updraft.
  150165. */
  150166. strength: number;
  150167. /**
  150168. * The height of the cylinder for the updraft.
  150169. */
  150170. height: number;
  150171. /**
  150172. * The mode for the the updraft.
  150173. */
  150174. updraftMode: PhysicsUpdraftMode;
  150175. }
  150176. /**
  150177. * Options fot the vortex event
  150178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150179. */
  150180. export class PhysicsVortexEventOptions {
  150181. /**
  150182. * The radius of the cylinder for the vortex
  150183. */
  150184. radius: number;
  150185. /**
  150186. * The strenth of the vortex.
  150187. */
  150188. strength: number;
  150189. /**
  150190. * The height of the cylinder for the vortex.
  150191. */
  150192. height: number;
  150193. /**
  150194. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  150195. */
  150196. centripetalForceThreshold: number;
  150197. /**
  150198. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  150199. */
  150200. centripetalForceMultiplier: number;
  150201. /**
  150202. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  150203. */
  150204. centrifugalForceMultiplier: number;
  150205. /**
  150206. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  150207. */
  150208. updraftForceMultiplier: number;
  150209. }
  150210. /**
  150211. * The strenght of the force in correspondence to the distance of the affected object
  150212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150213. */
  150214. export enum PhysicsRadialImpulseFalloff {
  150215. /** Defines that impulse is constant in strength across it's whole radius */
  150216. Constant = 0,
  150217. /** Defines that impulse gets weaker if it's further from the origin */
  150218. Linear = 1
  150219. }
  150220. /**
  150221. * The strength of the force in correspondence to the distance of the affected object
  150222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150223. */
  150224. export enum PhysicsUpdraftMode {
  150225. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  150226. Center = 0,
  150227. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  150228. Perpendicular = 1
  150229. }
  150230. /**
  150231. * Interface for a physics hit data
  150232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150233. */
  150234. export interface PhysicsHitData {
  150235. /**
  150236. * The force applied at the contact point
  150237. */
  150238. force: Vector3;
  150239. /**
  150240. * The contact point
  150241. */
  150242. contactPoint: Vector3;
  150243. /**
  150244. * The distance from the origin to the contact point
  150245. */
  150246. distanceFromOrigin: number;
  150247. }
  150248. /**
  150249. * Interface for radial explosion event data
  150250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150251. */
  150252. export interface PhysicsRadialExplosionEventData {
  150253. /**
  150254. * A sphere used for the radial explosion event
  150255. */
  150256. sphere: Mesh;
  150257. }
  150258. /**
  150259. * Interface for gravitational field event data
  150260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150261. */
  150262. export interface PhysicsGravitationalFieldEventData {
  150263. /**
  150264. * A sphere mesh used for the gravitational field event
  150265. */
  150266. sphere: Mesh;
  150267. }
  150268. /**
  150269. * Interface for updraft event data
  150270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150271. */
  150272. export interface PhysicsUpdraftEventData {
  150273. /**
  150274. * A cylinder used for the updraft event
  150275. */
  150276. cylinder: Mesh;
  150277. }
  150278. /**
  150279. * Interface for vortex event data
  150280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150281. */
  150282. export interface PhysicsVortexEventData {
  150283. /**
  150284. * A cylinder used for the vortex event
  150285. */
  150286. cylinder: Mesh;
  150287. }
  150288. /**
  150289. * Interface for an affected physics impostor
  150290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150291. */
  150292. export interface PhysicsAffectedImpostorWithData {
  150293. /**
  150294. * The impostor affected by the effect
  150295. */
  150296. impostor: PhysicsImpostor;
  150297. /**
  150298. * The data about the hit/horce from the explosion
  150299. */
  150300. hitData: PhysicsHitData;
  150301. }
  150302. }
  150303. declare module BABYLON {
  150304. /** @hidden */
  150305. export var blackAndWhitePixelShader: {
  150306. name: string;
  150307. shader: string;
  150308. };
  150309. }
  150310. declare module BABYLON {
  150311. /**
  150312. * Post process used to render in black and white
  150313. */
  150314. export class BlackAndWhitePostProcess extends PostProcess {
  150315. /**
  150316. * Linear about to convert he result to black and white (default: 1)
  150317. */
  150318. degree: number;
  150319. /**
  150320. * Gets a string identifying the name of the class
  150321. * @returns "BlackAndWhitePostProcess" string
  150322. */
  150323. getClassName(): string;
  150324. /**
  150325. * Creates a black and white post process
  150326. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  150327. * @param name The name of the effect.
  150328. * @param options The required width/height ratio to downsize to before computing the render pass.
  150329. * @param camera The camera to apply the render pass to.
  150330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150331. * @param engine The engine which the post process will be applied. (default: current engine)
  150332. * @param reusable If the post process can be reused on the same frame. (default: false)
  150333. */
  150334. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150335. /** @hidden */
  150336. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  150337. }
  150338. }
  150339. declare module BABYLON {
  150340. /**
  150341. * This represents a set of one or more post processes in Babylon.
  150342. * A post process can be used to apply a shader to a texture after it is rendered.
  150343. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150344. */
  150345. export class PostProcessRenderEffect {
  150346. private _postProcesses;
  150347. private _getPostProcesses;
  150348. private _singleInstance;
  150349. private _cameras;
  150350. private _indicesForCamera;
  150351. /**
  150352. * Name of the effect
  150353. * @hidden
  150354. */
  150355. _name: string;
  150356. /**
  150357. * Instantiates a post process render effect.
  150358. * A post process can be used to apply a shader to a texture after it is rendered.
  150359. * @param engine The engine the effect is tied to
  150360. * @param name The name of the effect
  150361. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  150362. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  150363. */
  150364. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  150365. /**
  150366. * Checks if all the post processes in the effect are supported.
  150367. */
  150368. get isSupported(): boolean;
  150369. /**
  150370. * Updates the current state of the effect
  150371. * @hidden
  150372. */
  150373. _update(): void;
  150374. /**
  150375. * Attaches the effect on cameras
  150376. * @param cameras The camera to attach to.
  150377. * @hidden
  150378. */
  150379. _attachCameras(cameras: Camera): void;
  150380. /**
  150381. * Attaches the effect on cameras
  150382. * @param cameras The camera to attach to.
  150383. * @hidden
  150384. */
  150385. _attachCameras(cameras: Camera[]): void;
  150386. /**
  150387. * Detaches the effect on cameras
  150388. * @param cameras The camera to detatch from.
  150389. * @hidden
  150390. */
  150391. _detachCameras(cameras: Camera): void;
  150392. /**
  150393. * Detatches the effect on cameras
  150394. * @param cameras The camera to detatch from.
  150395. * @hidden
  150396. */
  150397. _detachCameras(cameras: Camera[]): void;
  150398. /**
  150399. * Enables the effect on given cameras
  150400. * @param cameras The camera to enable.
  150401. * @hidden
  150402. */
  150403. _enable(cameras: Camera): void;
  150404. /**
  150405. * Enables the effect on given cameras
  150406. * @param cameras The camera to enable.
  150407. * @hidden
  150408. */
  150409. _enable(cameras: Nullable<Camera[]>): void;
  150410. /**
  150411. * Disables the effect on the given cameras
  150412. * @param cameras The camera to disable.
  150413. * @hidden
  150414. */
  150415. _disable(cameras: Camera): void;
  150416. /**
  150417. * Disables the effect on the given cameras
  150418. * @param cameras The camera to disable.
  150419. * @hidden
  150420. */
  150421. _disable(cameras: Nullable<Camera[]>): void;
  150422. /**
  150423. * Gets a list of the post processes contained in the effect.
  150424. * @param camera The camera to get the post processes on.
  150425. * @returns The list of the post processes in the effect.
  150426. */
  150427. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  150428. }
  150429. }
  150430. declare module BABYLON {
  150431. /** @hidden */
  150432. export var extractHighlightsPixelShader: {
  150433. name: string;
  150434. shader: string;
  150435. };
  150436. }
  150437. declare module BABYLON {
  150438. /**
  150439. * 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.
  150440. */
  150441. export class ExtractHighlightsPostProcess extends PostProcess {
  150442. /**
  150443. * The luminance threshold, pixels below this value will be set to black.
  150444. */
  150445. threshold: number;
  150446. /** @hidden */
  150447. _exposure: number;
  150448. /**
  150449. * Post process which has the input texture to be used when performing highlight extraction
  150450. * @hidden
  150451. */
  150452. _inputPostProcess: Nullable<PostProcess>;
  150453. /**
  150454. * Gets a string identifying the name of the class
  150455. * @returns "ExtractHighlightsPostProcess" string
  150456. */
  150457. getClassName(): string;
  150458. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150459. }
  150460. }
  150461. declare module BABYLON {
  150462. /** @hidden */
  150463. export var bloomMergePixelShader: {
  150464. name: string;
  150465. shader: string;
  150466. };
  150467. }
  150468. declare module BABYLON {
  150469. /**
  150470. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150471. */
  150472. export class BloomMergePostProcess extends PostProcess {
  150473. /** Weight of the bloom to be added to the original input. */
  150474. weight: number;
  150475. /**
  150476. * Gets a string identifying the name of the class
  150477. * @returns "BloomMergePostProcess" string
  150478. */
  150479. getClassName(): string;
  150480. /**
  150481. * Creates a new instance of @see BloomMergePostProcess
  150482. * @param name The name of the effect.
  150483. * @param originalFromInput Post process which's input will be used for the merge.
  150484. * @param blurred Blurred highlights post process which's output will be used.
  150485. * @param weight Weight of the bloom to be added to the original input.
  150486. * @param options The required width/height ratio to downsize to before computing the render pass.
  150487. * @param camera The camera to apply the render pass to.
  150488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150489. * @param engine The engine which the post process will be applied. (default: current engine)
  150490. * @param reusable If the post process can be reused on the same frame. (default: false)
  150491. * @param textureType Type of textures used when performing the post process. (default: 0)
  150492. * @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)
  150493. */
  150494. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  150495. /** Weight of the bloom to be added to the original input. */
  150496. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150497. }
  150498. }
  150499. declare module BABYLON {
  150500. /**
  150501. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  150502. */
  150503. export class BloomEffect extends PostProcessRenderEffect {
  150504. private bloomScale;
  150505. /**
  150506. * @hidden Internal
  150507. */
  150508. _effects: Array<PostProcess>;
  150509. /**
  150510. * @hidden Internal
  150511. */
  150512. _downscale: ExtractHighlightsPostProcess;
  150513. private _blurX;
  150514. private _blurY;
  150515. private _merge;
  150516. /**
  150517. * The luminance threshold to find bright areas of the image to bloom.
  150518. */
  150519. get threshold(): number;
  150520. set threshold(value: number);
  150521. /**
  150522. * The strength of the bloom.
  150523. */
  150524. get weight(): number;
  150525. set weight(value: number);
  150526. /**
  150527. * Specifies the size of the bloom blur kernel, relative to the final output size
  150528. */
  150529. get kernel(): number;
  150530. set kernel(value: number);
  150531. /**
  150532. * Creates a new instance of @see BloomEffect
  150533. * @param scene The scene the effect belongs to.
  150534. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  150535. * @param bloomKernel The size of the kernel to be used when applying the blur.
  150536. * @param bloomWeight The the strength of bloom.
  150537. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150538. * @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)
  150539. */
  150540. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  150541. /**
  150542. * Disposes each of the internal effects for a given camera.
  150543. * @param camera The camera to dispose the effect on.
  150544. */
  150545. disposeEffects(camera: Camera): void;
  150546. /**
  150547. * @hidden Internal
  150548. */
  150549. _updateEffects(): void;
  150550. /**
  150551. * Internal
  150552. * @returns if all the contained post processes are ready.
  150553. * @hidden
  150554. */
  150555. _isReady(): boolean;
  150556. }
  150557. }
  150558. declare module BABYLON {
  150559. /** @hidden */
  150560. export var chromaticAberrationPixelShader: {
  150561. name: string;
  150562. shader: string;
  150563. };
  150564. }
  150565. declare module BABYLON {
  150566. /**
  150567. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  150568. */
  150569. export class ChromaticAberrationPostProcess extends PostProcess {
  150570. /**
  150571. * The amount of seperation of rgb channels (default: 30)
  150572. */
  150573. aberrationAmount: number;
  150574. /**
  150575. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  150576. */
  150577. radialIntensity: number;
  150578. /**
  150579. * 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))
  150580. */
  150581. direction: Vector2;
  150582. /**
  150583. * 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))
  150584. */
  150585. centerPosition: Vector2;
  150586. /** The width of the screen to apply the effect on */
  150587. screenWidth: number;
  150588. /** The height of the screen to apply the effect on */
  150589. screenHeight: number;
  150590. /**
  150591. * Gets a string identifying the name of the class
  150592. * @returns "ChromaticAberrationPostProcess" string
  150593. */
  150594. getClassName(): string;
  150595. /**
  150596. * Creates a new instance ChromaticAberrationPostProcess
  150597. * @param name The name of the effect.
  150598. * @param screenWidth The width of the screen to apply the effect on.
  150599. * @param screenHeight The height of the screen to apply the effect on.
  150600. * @param options The required width/height ratio to downsize to before computing the render pass.
  150601. * @param camera The camera to apply the render pass to.
  150602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150603. * @param engine The engine which the post process will be applied. (default: current engine)
  150604. * @param reusable If the post process can be reused on the same frame. (default: false)
  150605. * @param textureType Type of textures used when performing the post process. (default: 0)
  150606. * @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)
  150607. */
  150608. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150609. /** @hidden */
  150610. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  150611. }
  150612. }
  150613. declare module BABYLON {
  150614. /** @hidden */
  150615. export var circleOfConfusionPixelShader: {
  150616. name: string;
  150617. shader: string;
  150618. };
  150619. }
  150620. declare module BABYLON {
  150621. /**
  150622. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  150623. */
  150624. export class CircleOfConfusionPostProcess extends PostProcess {
  150625. /**
  150626. * 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.
  150627. */
  150628. lensSize: number;
  150629. /**
  150630. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150631. */
  150632. fStop: number;
  150633. /**
  150634. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150635. */
  150636. focusDistance: number;
  150637. /**
  150638. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  150639. */
  150640. focalLength: number;
  150641. /**
  150642. * Gets a string identifying the name of the class
  150643. * @returns "CircleOfConfusionPostProcess" string
  150644. */
  150645. getClassName(): string;
  150646. private _depthTexture;
  150647. /**
  150648. * Creates a new instance CircleOfConfusionPostProcess
  150649. * @param name The name of the effect.
  150650. * @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.
  150651. * @param options The required width/height ratio to downsize to before computing the render pass.
  150652. * @param camera The camera to apply the render pass to.
  150653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150654. * @param engine The engine which the post process will be applied. (default: current engine)
  150655. * @param reusable If the post process can be reused on the same frame. (default: false)
  150656. * @param textureType Type of textures used when performing the post process. (default: 0)
  150657. * @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)
  150658. */
  150659. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150660. /**
  150661. * 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.
  150662. */
  150663. set depthTexture(value: RenderTargetTexture);
  150664. }
  150665. }
  150666. declare module BABYLON {
  150667. /** @hidden */
  150668. export var colorCorrectionPixelShader: {
  150669. name: string;
  150670. shader: string;
  150671. };
  150672. }
  150673. declare module BABYLON {
  150674. /**
  150675. *
  150676. * This post-process allows the modification of rendered colors by using
  150677. * a 'look-up table' (LUT). This effect is also called Color Grading.
  150678. *
  150679. * The object needs to be provided an url to a texture containing the color
  150680. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  150681. * Use an image editing software to tweak the LUT to match your needs.
  150682. *
  150683. * For an example of a color LUT, see here:
  150684. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  150685. * For explanations on color grading, see here:
  150686. * @see http://udn.epicgames.com/Three/ColorGrading.html
  150687. *
  150688. */
  150689. export class ColorCorrectionPostProcess extends PostProcess {
  150690. private _colorTableTexture;
  150691. /**
  150692. * Gets the color table url used to create the LUT texture
  150693. */
  150694. colorTableUrl: string;
  150695. /**
  150696. * Gets a string identifying the name of the class
  150697. * @returns "ColorCorrectionPostProcess" string
  150698. */
  150699. getClassName(): string;
  150700. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150701. /** @hidden */
  150702. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  150703. }
  150704. }
  150705. declare module BABYLON {
  150706. /** @hidden */
  150707. export var convolutionPixelShader: {
  150708. name: string;
  150709. shader: string;
  150710. };
  150711. }
  150712. declare module BABYLON {
  150713. /**
  150714. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  150715. * input texture to perform effects such as edge detection or sharpening
  150716. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150717. */
  150718. export class ConvolutionPostProcess extends PostProcess {
  150719. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  150720. kernel: number[];
  150721. /**
  150722. * Gets a string identifying the name of the class
  150723. * @returns "ConvolutionPostProcess" string
  150724. */
  150725. getClassName(): string;
  150726. /**
  150727. * Creates a new instance ConvolutionPostProcess
  150728. * @param name The name of the effect.
  150729. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  150730. * @param options The required width/height ratio to downsize to before computing the render pass.
  150731. * @param camera The camera to apply the render pass to.
  150732. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150733. * @param engine The engine which the post process will be applied. (default: current engine)
  150734. * @param reusable If the post process can be reused on the same frame. (default: false)
  150735. * @param textureType Type of textures used when performing the post process. (default: 0)
  150736. */
  150737. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150738. /** @hidden */
  150739. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  150740. /**
  150741. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150742. */
  150743. static EdgeDetect0Kernel: number[];
  150744. /**
  150745. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150746. */
  150747. static EdgeDetect1Kernel: number[];
  150748. /**
  150749. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150750. */
  150751. static EdgeDetect2Kernel: number[];
  150752. /**
  150753. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150754. */
  150755. static SharpenKernel: number[];
  150756. /**
  150757. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150758. */
  150759. static EmbossKernel: number[];
  150760. /**
  150761. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150762. */
  150763. static GaussianKernel: number[];
  150764. }
  150765. }
  150766. declare module BABYLON {
  150767. /**
  150768. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  150769. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  150770. * based on samples that have a large difference in distance than the center pixel.
  150771. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  150772. */
  150773. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  150774. /**
  150775. * The direction the blur should be applied
  150776. */
  150777. direction: Vector2;
  150778. /**
  150779. * Gets a string identifying the name of the class
  150780. * @returns "DepthOfFieldBlurPostProcess" string
  150781. */
  150782. getClassName(): string;
  150783. /**
  150784. * Creates a new instance CircleOfConfusionPostProcess
  150785. * @param name The name of the effect.
  150786. * @param scene The scene the effect belongs to.
  150787. * @param direction The direction the blur should be applied.
  150788. * @param kernel The size of the kernel used to blur.
  150789. * @param options The required width/height ratio to downsize to before computing the render pass.
  150790. * @param camera The camera to apply the render pass to.
  150791. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  150792. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  150793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150794. * @param engine The engine which the post process will be applied. (default: current engine)
  150795. * @param reusable If the post process can be reused on the same frame. (default: false)
  150796. * @param textureType Type of textures used when performing the post process. (default: 0)
  150797. * @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)
  150798. */
  150799. 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);
  150800. }
  150801. }
  150802. declare module BABYLON {
  150803. /** @hidden */
  150804. export var depthOfFieldMergePixelShader: {
  150805. name: string;
  150806. shader: string;
  150807. };
  150808. }
  150809. declare module BABYLON {
  150810. /**
  150811. * Options to be set when merging outputs from the default pipeline.
  150812. */
  150813. export class DepthOfFieldMergePostProcessOptions {
  150814. /**
  150815. * The original image to merge on top of
  150816. */
  150817. originalFromInput: PostProcess;
  150818. /**
  150819. * Parameters to perform the merge of the depth of field effect
  150820. */
  150821. depthOfField?: {
  150822. circleOfConfusion: PostProcess;
  150823. blurSteps: Array<PostProcess>;
  150824. };
  150825. /**
  150826. * Parameters to perform the merge of bloom effect
  150827. */
  150828. bloom?: {
  150829. blurred: PostProcess;
  150830. weight: number;
  150831. };
  150832. }
  150833. /**
  150834. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150835. */
  150836. export class DepthOfFieldMergePostProcess extends PostProcess {
  150837. private blurSteps;
  150838. /**
  150839. * Gets a string identifying the name of the class
  150840. * @returns "DepthOfFieldMergePostProcess" string
  150841. */
  150842. getClassName(): string;
  150843. /**
  150844. * Creates a new instance of DepthOfFieldMergePostProcess
  150845. * @param name The name of the effect.
  150846. * @param originalFromInput Post process which's input will be used for the merge.
  150847. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  150848. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  150849. * @param options The required width/height ratio to downsize to before computing the render pass.
  150850. * @param camera The camera to apply the render pass to.
  150851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150852. * @param engine The engine which the post process will be applied. (default: current engine)
  150853. * @param reusable If the post process can be reused on the same frame. (default: false)
  150854. * @param textureType Type of textures used when performing the post process. (default: 0)
  150855. * @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)
  150856. */
  150857. 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);
  150858. /**
  150859. * Updates the effect with the current post process compile time values and recompiles the shader.
  150860. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  150861. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  150862. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  150863. * @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
  150864. * @param onCompiled Called when the shader has been compiled.
  150865. * @param onError Called if there is an error when compiling a shader.
  150866. */
  150867. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  150868. }
  150869. }
  150870. declare module BABYLON {
  150871. /**
  150872. * Specifies the level of max blur that should be applied when using the depth of field effect
  150873. */
  150874. export enum DepthOfFieldEffectBlurLevel {
  150875. /**
  150876. * Subtle blur
  150877. */
  150878. Low = 0,
  150879. /**
  150880. * Medium blur
  150881. */
  150882. Medium = 1,
  150883. /**
  150884. * Large blur
  150885. */
  150886. High = 2
  150887. }
  150888. /**
  150889. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  150890. */
  150891. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  150892. private _circleOfConfusion;
  150893. /**
  150894. * @hidden Internal, blurs from high to low
  150895. */
  150896. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  150897. private _depthOfFieldBlurY;
  150898. private _dofMerge;
  150899. /**
  150900. * @hidden Internal post processes in depth of field effect
  150901. */
  150902. _effects: Array<PostProcess>;
  150903. /**
  150904. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  150905. */
  150906. set focalLength(value: number);
  150907. get focalLength(): number;
  150908. /**
  150909. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150910. */
  150911. set fStop(value: number);
  150912. get fStop(): number;
  150913. /**
  150914. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150915. */
  150916. set focusDistance(value: number);
  150917. get focusDistance(): number;
  150918. /**
  150919. * 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.
  150920. */
  150921. set lensSize(value: number);
  150922. get lensSize(): number;
  150923. /**
  150924. * Creates a new instance DepthOfFieldEffect
  150925. * @param scene The scene the effect belongs to.
  150926. * @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.
  150927. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150928. * @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)
  150929. */
  150930. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  150931. /**
  150932. * Get the current class name of the current effet
  150933. * @returns "DepthOfFieldEffect"
  150934. */
  150935. getClassName(): string;
  150936. /**
  150937. * 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.
  150938. */
  150939. set depthTexture(value: RenderTargetTexture);
  150940. /**
  150941. * Disposes each of the internal effects for a given camera.
  150942. * @param camera The camera to dispose the effect on.
  150943. */
  150944. disposeEffects(camera: Camera): void;
  150945. /**
  150946. * @hidden Internal
  150947. */
  150948. _updateEffects(): void;
  150949. /**
  150950. * Internal
  150951. * @returns if all the contained post processes are ready.
  150952. * @hidden
  150953. */
  150954. _isReady(): boolean;
  150955. }
  150956. }
  150957. declare module BABYLON {
  150958. /** @hidden */
  150959. export var displayPassPixelShader: {
  150960. name: string;
  150961. shader: string;
  150962. };
  150963. }
  150964. declare module BABYLON {
  150965. /**
  150966. * DisplayPassPostProcess which produces an output the same as it's input
  150967. */
  150968. export class DisplayPassPostProcess extends PostProcess {
  150969. /**
  150970. * Gets a string identifying the name of the class
  150971. * @returns "DisplayPassPostProcess" string
  150972. */
  150973. getClassName(): string;
  150974. /**
  150975. * Creates the DisplayPassPostProcess
  150976. * @param name The name of the effect.
  150977. * @param options The required width/height ratio to downsize to before computing the render pass.
  150978. * @param camera The camera to apply the render pass to.
  150979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150980. * @param engine The engine which the post process will be applied. (default: current engine)
  150981. * @param reusable If the post process can be reused on the same frame. (default: false)
  150982. */
  150983. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150984. /** @hidden */
  150985. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150986. }
  150987. }
  150988. declare module BABYLON {
  150989. /** @hidden */
  150990. export var filterPixelShader: {
  150991. name: string;
  150992. shader: string;
  150993. };
  150994. }
  150995. declare module BABYLON {
  150996. /**
  150997. * Applies a kernel filter to the image
  150998. */
  150999. export class FilterPostProcess extends PostProcess {
  151000. /** The matrix to be applied to the image */
  151001. kernelMatrix: Matrix;
  151002. /**
  151003. * Gets a string identifying the name of the class
  151004. * @returns "FilterPostProcess" string
  151005. */
  151006. getClassName(): string;
  151007. /**
  151008. *
  151009. * @param name The name of the effect.
  151010. * @param kernelMatrix The matrix to be applied to the image
  151011. * @param options The required width/height ratio to downsize to before computing the render pass.
  151012. * @param camera The camera to apply the render pass to.
  151013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151014. * @param engine The engine which the post process will be applied. (default: current engine)
  151015. * @param reusable If the post process can be reused on the same frame. (default: false)
  151016. */
  151017. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151018. /** @hidden */
  151019. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  151020. }
  151021. }
  151022. declare module BABYLON {
  151023. /** @hidden */
  151024. export var fxaaPixelShader: {
  151025. name: string;
  151026. shader: string;
  151027. };
  151028. }
  151029. declare module BABYLON {
  151030. /** @hidden */
  151031. export var fxaaVertexShader: {
  151032. name: string;
  151033. shader: string;
  151034. };
  151035. }
  151036. declare module BABYLON {
  151037. /**
  151038. * Fxaa post process
  151039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  151040. */
  151041. export class FxaaPostProcess extends PostProcess {
  151042. /**
  151043. * Gets a string identifying the name of the class
  151044. * @returns "FxaaPostProcess" string
  151045. */
  151046. getClassName(): string;
  151047. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151048. private _getDefines;
  151049. /** @hidden */
  151050. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  151051. }
  151052. }
  151053. declare module BABYLON {
  151054. /** @hidden */
  151055. export var grainPixelShader: {
  151056. name: string;
  151057. shader: string;
  151058. };
  151059. }
  151060. declare module BABYLON {
  151061. /**
  151062. * The GrainPostProcess adds noise to the image at mid luminance levels
  151063. */
  151064. export class GrainPostProcess extends PostProcess {
  151065. /**
  151066. * The intensity of the grain added (default: 30)
  151067. */
  151068. intensity: number;
  151069. /**
  151070. * If the grain should be randomized on every frame
  151071. */
  151072. animated: boolean;
  151073. /**
  151074. * Gets a string identifying the name of the class
  151075. * @returns "GrainPostProcess" string
  151076. */
  151077. getClassName(): string;
  151078. /**
  151079. * Creates a new instance of @see GrainPostProcess
  151080. * @param name The name of the effect.
  151081. * @param options The required width/height ratio to downsize to before computing the render pass.
  151082. * @param camera The camera to apply the render pass to.
  151083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151084. * @param engine The engine which the post process will be applied. (default: current engine)
  151085. * @param reusable If the post process can be reused on the same frame. (default: false)
  151086. * @param textureType Type of textures used when performing the post process. (default: 0)
  151087. * @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)
  151088. */
  151089. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151090. /** @hidden */
  151091. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  151092. }
  151093. }
  151094. declare module BABYLON {
  151095. /** @hidden */
  151096. export var highlightsPixelShader: {
  151097. name: string;
  151098. shader: string;
  151099. };
  151100. }
  151101. declare module BABYLON {
  151102. /**
  151103. * Extracts highlights from the image
  151104. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151105. */
  151106. export class HighlightsPostProcess extends PostProcess {
  151107. /**
  151108. * Gets a string identifying the name of the class
  151109. * @returns "HighlightsPostProcess" string
  151110. */
  151111. getClassName(): string;
  151112. /**
  151113. * Extracts highlights from the image
  151114. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151115. * @param name The name of the effect.
  151116. * @param options The required width/height ratio to downsize to before computing the render pass.
  151117. * @param camera The camera to apply the render pass to.
  151118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151119. * @param engine The engine which the post process will be applied. (default: current engine)
  151120. * @param reusable If the post process can be reused on the same frame. (default: false)
  151121. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  151122. */
  151123. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151124. }
  151125. }
  151126. declare module BABYLON {
  151127. /**
  151128. * Contains all parameters needed for the prepass to perform
  151129. * motion blur
  151130. */
  151131. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  151132. /**
  151133. * Is motion blur enabled
  151134. */
  151135. enabled: boolean;
  151136. /**
  151137. * Name of the configuration
  151138. */
  151139. name: string;
  151140. /**
  151141. * Textures that should be present in the MRT for this effect to work
  151142. */
  151143. readonly texturesRequired: number[];
  151144. }
  151145. }
  151146. declare module BABYLON {
  151147. interface Scene {
  151148. /** @hidden (Backing field) */
  151149. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151150. /**
  151151. * Gets or Sets the current geometry buffer associated to the scene.
  151152. */
  151153. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151154. /**
  151155. * Enables a GeometryBufferRender and associates it with the scene
  151156. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  151157. * @returns the GeometryBufferRenderer
  151158. */
  151159. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  151160. /**
  151161. * Disables the GeometryBufferRender associated with the scene
  151162. */
  151163. disableGeometryBufferRenderer(): void;
  151164. }
  151165. /**
  151166. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151167. * in several rendering techniques.
  151168. */
  151169. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  151170. /**
  151171. * The component name helpful to identify the component in the list of scene components.
  151172. */
  151173. readonly name: string;
  151174. /**
  151175. * The scene the component belongs to.
  151176. */
  151177. scene: Scene;
  151178. /**
  151179. * Creates a new instance of the component for the given scene
  151180. * @param scene Defines the scene to register the component in
  151181. */
  151182. constructor(scene: Scene);
  151183. /**
  151184. * Registers the component in a given scene
  151185. */
  151186. register(): void;
  151187. /**
  151188. * Rebuilds the elements related to this component in case of
  151189. * context lost for instance.
  151190. */
  151191. rebuild(): void;
  151192. /**
  151193. * Disposes the component and the associated ressources
  151194. */
  151195. dispose(): void;
  151196. private _gatherRenderTargets;
  151197. }
  151198. }
  151199. declare module BABYLON {
  151200. /** @hidden */
  151201. export var motionBlurPixelShader: {
  151202. name: string;
  151203. shader: string;
  151204. };
  151205. }
  151206. declare module BABYLON {
  151207. /**
  151208. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  151209. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  151210. * As an example, all you have to do is to create the post-process:
  151211. * var mb = new BABYLON.MotionBlurPostProcess(
  151212. * 'mb', // The name of the effect.
  151213. * scene, // The scene containing the objects to blur according to their velocity.
  151214. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  151215. * camera // The camera to apply the render pass to.
  151216. * );
  151217. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  151218. */
  151219. export class MotionBlurPostProcess extends PostProcess {
  151220. /**
  151221. * Defines how much the image is blurred by the movement. Default value is equal to 1
  151222. */
  151223. motionStrength: number;
  151224. /**
  151225. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  151226. */
  151227. get motionBlurSamples(): number;
  151228. /**
  151229. * Sets the number of iterations to be used for motion blur quality
  151230. */
  151231. set motionBlurSamples(samples: number);
  151232. private _motionBlurSamples;
  151233. private _forceGeometryBuffer;
  151234. private _geometryBufferRenderer;
  151235. private _prePassRenderer;
  151236. /**
  151237. * Gets a string identifying the name of the class
  151238. * @returns "MotionBlurPostProcess" string
  151239. */
  151240. getClassName(): string;
  151241. /**
  151242. * Creates a new instance MotionBlurPostProcess
  151243. * @param name The name of the effect.
  151244. * @param scene The scene containing the objects to blur according to their velocity.
  151245. * @param options The required width/height ratio to downsize to before computing the render pass.
  151246. * @param camera The camera to apply the render pass to.
  151247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151248. * @param engine The engine which the post process will be applied. (default: current engine)
  151249. * @param reusable If the post process can be reused on the same frame. (default: false)
  151250. * @param textureType Type of textures used when performing the post process. (default: 0)
  151251. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  151252. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  151253. */
  151254. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  151255. /**
  151256. * Excludes the given skinned mesh from computing bones velocities.
  151257. * 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.
  151258. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  151259. */
  151260. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151261. /**
  151262. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  151263. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  151264. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  151265. */
  151266. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151267. /**
  151268. * Disposes the post process.
  151269. * @param camera The camera to dispose the post process on.
  151270. */
  151271. dispose(camera?: Camera): void;
  151272. /** @hidden */
  151273. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  151274. }
  151275. }
  151276. declare module BABYLON {
  151277. /** @hidden */
  151278. export var refractionPixelShader: {
  151279. name: string;
  151280. shader: string;
  151281. };
  151282. }
  151283. declare module BABYLON {
  151284. /**
  151285. * Post process which applies a refractin texture
  151286. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151287. */
  151288. export class RefractionPostProcess extends PostProcess {
  151289. private _refTexture;
  151290. private _ownRefractionTexture;
  151291. /** the base color of the refraction (used to taint the rendering) */
  151292. color: Color3;
  151293. /** simulated refraction depth */
  151294. depth: number;
  151295. /** the coefficient of the base color (0 to remove base color tainting) */
  151296. colorLevel: number;
  151297. /** Gets the url used to load the refraction texture */
  151298. refractionTextureUrl: string;
  151299. /**
  151300. * Gets or sets the refraction texture
  151301. * Please note that you are responsible for disposing the texture if you set it manually
  151302. */
  151303. get refractionTexture(): Texture;
  151304. set refractionTexture(value: Texture);
  151305. /**
  151306. * Gets a string identifying the name of the class
  151307. * @returns "RefractionPostProcess" string
  151308. */
  151309. getClassName(): string;
  151310. /**
  151311. * Initializes the RefractionPostProcess
  151312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151313. * @param name The name of the effect.
  151314. * @param refractionTextureUrl Url of the refraction texture to use
  151315. * @param color the base color of the refraction (used to taint the rendering)
  151316. * @param depth simulated refraction depth
  151317. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  151318. * @param camera The camera to apply the render pass to.
  151319. * @param options The required width/height ratio to downsize to before computing the render pass.
  151320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151321. * @param engine The engine which the post process will be applied. (default: current engine)
  151322. * @param reusable If the post process can be reused on the same frame. (default: false)
  151323. */
  151324. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151325. /**
  151326. * Disposes of the post process
  151327. * @param camera Camera to dispose post process on
  151328. */
  151329. dispose(camera: Camera): void;
  151330. /** @hidden */
  151331. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  151332. }
  151333. }
  151334. declare module BABYLON {
  151335. /** @hidden */
  151336. export var sharpenPixelShader: {
  151337. name: string;
  151338. shader: string;
  151339. };
  151340. }
  151341. declare module BABYLON {
  151342. /**
  151343. * The SharpenPostProcess applies a sharpen kernel to every pixel
  151344. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151345. */
  151346. export class SharpenPostProcess extends PostProcess {
  151347. /**
  151348. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  151349. */
  151350. colorAmount: number;
  151351. /**
  151352. * How much sharpness should be applied (default: 0.3)
  151353. */
  151354. edgeAmount: number;
  151355. /**
  151356. * Gets a string identifying the name of the class
  151357. * @returns "SharpenPostProcess" string
  151358. */
  151359. getClassName(): string;
  151360. /**
  151361. * Creates a new instance ConvolutionPostProcess
  151362. * @param name The name of the effect.
  151363. * @param options The required width/height ratio to downsize to before computing the render pass.
  151364. * @param camera The camera to apply the render pass to.
  151365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151366. * @param engine The engine which the post process will be applied. (default: current engine)
  151367. * @param reusable If the post process can be reused on the same frame. (default: false)
  151368. * @param textureType Type of textures used when performing the post process. (default: 0)
  151369. * @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)
  151370. */
  151371. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151372. /** @hidden */
  151373. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  151374. }
  151375. }
  151376. declare module BABYLON {
  151377. /**
  151378. * PostProcessRenderPipeline
  151379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151380. */
  151381. export class PostProcessRenderPipeline {
  151382. private engine;
  151383. private _renderEffects;
  151384. private _renderEffectsForIsolatedPass;
  151385. /**
  151386. * List of inspectable custom properties (used by the Inspector)
  151387. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  151388. */
  151389. inspectableCustomProperties: IInspectable[];
  151390. /**
  151391. * @hidden
  151392. */
  151393. protected _cameras: Camera[];
  151394. /** @hidden */
  151395. _name: string;
  151396. /**
  151397. * Gets pipeline name
  151398. */
  151399. get name(): string;
  151400. /** Gets the list of attached cameras */
  151401. get cameras(): Camera[];
  151402. /**
  151403. * Initializes a PostProcessRenderPipeline
  151404. * @param engine engine to add the pipeline to
  151405. * @param name name of the pipeline
  151406. */
  151407. constructor(engine: Engine, name: string);
  151408. /**
  151409. * Gets the class name
  151410. * @returns "PostProcessRenderPipeline"
  151411. */
  151412. getClassName(): string;
  151413. /**
  151414. * If all the render effects in the pipeline are supported
  151415. */
  151416. get isSupported(): boolean;
  151417. /**
  151418. * Adds an effect to the pipeline
  151419. * @param renderEffect the effect to add
  151420. */
  151421. addEffect(renderEffect: PostProcessRenderEffect): void;
  151422. /** @hidden */
  151423. _rebuild(): void;
  151424. /** @hidden */
  151425. _enableEffect(renderEffectName: string, cameras: Camera): void;
  151426. /** @hidden */
  151427. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  151428. /** @hidden */
  151429. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151430. /** @hidden */
  151431. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151432. /** @hidden */
  151433. _attachCameras(cameras: Camera, unique: boolean): void;
  151434. /** @hidden */
  151435. _attachCameras(cameras: Camera[], unique: boolean): void;
  151436. /** @hidden */
  151437. _detachCameras(cameras: Camera): void;
  151438. /** @hidden */
  151439. _detachCameras(cameras: Nullable<Camera[]>): void;
  151440. /** @hidden */
  151441. _update(): void;
  151442. /** @hidden */
  151443. _reset(): void;
  151444. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  151445. /**
  151446. * Sets the required values to the prepass renderer.
  151447. * @param prePassRenderer defines the prepass renderer to setup.
  151448. * @returns true if the pre pass is needed.
  151449. */
  151450. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151451. /**
  151452. * Disposes of the pipeline
  151453. */
  151454. dispose(): void;
  151455. }
  151456. }
  151457. declare module BABYLON {
  151458. /**
  151459. * PostProcessRenderPipelineManager class
  151460. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151461. */
  151462. export class PostProcessRenderPipelineManager {
  151463. private _renderPipelines;
  151464. /**
  151465. * Initializes a PostProcessRenderPipelineManager
  151466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151467. */
  151468. constructor();
  151469. /**
  151470. * Gets the list of supported render pipelines
  151471. */
  151472. get supportedPipelines(): PostProcessRenderPipeline[];
  151473. /**
  151474. * Adds a pipeline to the manager
  151475. * @param renderPipeline The pipeline to add
  151476. */
  151477. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  151478. /**
  151479. * Attaches a camera to the pipeline
  151480. * @param renderPipelineName The name of the pipeline to attach to
  151481. * @param cameras the camera to attach
  151482. * @param unique if the camera can be attached multiple times to the pipeline
  151483. */
  151484. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  151485. /**
  151486. * Detaches a camera from the pipeline
  151487. * @param renderPipelineName The name of the pipeline to detach from
  151488. * @param cameras the camera to detach
  151489. */
  151490. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  151491. /**
  151492. * Enables an effect by name on a pipeline
  151493. * @param renderPipelineName the name of the pipeline to enable the effect in
  151494. * @param renderEffectName the name of the effect to enable
  151495. * @param cameras the cameras that the effect should be enabled on
  151496. */
  151497. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151498. /**
  151499. * Disables an effect by name on a pipeline
  151500. * @param renderPipelineName the name of the pipeline to disable the effect in
  151501. * @param renderEffectName the name of the effect to disable
  151502. * @param cameras the cameras that the effect should be disabled on
  151503. */
  151504. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151505. /**
  151506. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  151507. */
  151508. update(): void;
  151509. /** @hidden */
  151510. _rebuild(): void;
  151511. /**
  151512. * Disposes of the manager and pipelines
  151513. */
  151514. dispose(): void;
  151515. }
  151516. }
  151517. declare module BABYLON {
  151518. interface Scene {
  151519. /** @hidden (Backing field) */
  151520. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151521. /**
  151522. * Gets the postprocess render pipeline manager
  151523. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151524. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151525. */
  151526. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151527. }
  151528. /**
  151529. * Defines the Render Pipeline scene component responsible to rendering pipelines
  151530. */
  151531. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  151532. /**
  151533. * The component name helpfull to identify the component in the list of scene components.
  151534. */
  151535. readonly name: string;
  151536. /**
  151537. * The scene the component belongs to.
  151538. */
  151539. scene: Scene;
  151540. /**
  151541. * Creates a new instance of the component for the given scene
  151542. * @param scene Defines the scene to register the component in
  151543. */
  151544. constructor(scene: Scene);
  151545. /**
  151546. * Registers the component in a given scene
  151547. */
  151548. register(): void;
  151549. /**
  151550. * Rebuilds the elements related to this component in case of
  151551. * context lost for instance.
  151552. */
  151553. rebuild(): void;
  151554. /**
  151555. * Disposes the component and the associated ressources
  151556. */
  151557. dispose(): void;
  151558. private _gatherRenderTargets;
  151559. }
  151560. }
  151561. declare module BABYLON {
  151562. /**
  151563. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  151564. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151565. */
  151566. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151567. private _scene;
  151568. private _camerasToBeAttached;
  151569. /**
  151570. * ID of the sharpen post process,
  151571. */
  151572. private readonly SharpenPostProcessId;
  151573. /**
  151574. * @ignore
  151575. * ID of the image processing post process;
  151576. */
  151577. readonly ImageProcessingPostProcessId: string;
  151578. /**
  151579. * @ignore
  151580. * ID of the Fast Approximate Anti-Aliasing post process;
  151581. */
  151582. readonly FxaaPostProcessId: string;
  151583. /**
  151584. * ID of the chromatic aberration post process,
  151585. */
  151586. private readonly ChromaticAberrationPostProcessId;
  151587. /**
  151588. * ID of the grain post process
  151589. */
  151590. private readonly GrainPostProcessId;
  151591. /**
  151592. * Sharpen post process which will apply a sharpen convolution to enhance edges
  151593. */
  151594. sharpen: SharpenPostProcess;
  151595. private _sharpenEffect;
  151596. private bloom;
  151597. /**
  151598. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  151599. */
  151600. depthOfField: DepthOfFieldEffect;
  151601. /**
  151602. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151603. */
  151604. fxaa: FxaaPostProcess;
  151605. /**
  151606. * Image post processing pass used to perform operations such as tone mapping or color grading.
  151607. */
  151608. imageProcessing: ImageProcessingPostProcess;
  151609. /**
  151610. * Chromatic aberration post process which will shift rgb colors in the image
  151611. */
  151612. chromaticAberration: ChromaticAberrationPostProcess;
  151613. private _chromaticAberrationEffect;
  151614. /**
  151615. * Grain post process which add noise to the image
  151616. */
  151617. grain: GrainPostProcess;
  151618. private _grainEffect;
  151619. /**
  151620. * Glow post process which adds a glow to emissive areas of the image
  151621. */
  151622. private _glowLayer;
  151623. /**
  151624. * Animations which can be used to tweak settings over a period of time
  151625. */
  151626. animations: Animation[];
  151627. private _imageProcessingConfigurationObserver;
  151628. private _sharpenEnabled;
  151629. private _bloomEnabled;
  151630. private _depthOfFieldEnabled;
  151631. private _depthOfFieldBlurLevel;
  151632. private _fxaaEnabled;
  151633. private _imageProcessingEnabled;
  151634. private _defaultPipelineTextureType;
  151635. private _bloomScale;
  151636. private _chromaticAberrationEnabled;
  151637. private _grainEnabled;
  151638. private _buildAllowed;
  151639. /**
  151640. * Gets active scene
  151641. */
  151642. get scene(): Scene;
  151643. /**
  151644. * Enable or disable the sharpen process from the pipeline
  151645. */
  151646. set sharpenEnabled(enabled: boolean);
  151647. get sharpenEnabled(): boolean;
  151648. private _resizeObserver;
  151649. private _hardwareScaleLevel;
  151650. private _bloomKernel;
  151651. /**
  151652. * Specifies the size of the bloom blur kernel, relative to the final output size
  151653. */
  151654. get bloomKernel(): number;
  151655. set bloomKernel(value: number);
  151656. /**
  151657. * Specifies the weight of the bloom in the final rendering
  151658. */
  151659. private _bloomWeight;
  151660. /**
  151661. * Specifies the luma threshold for the area that will be blurred by the bloom
  151662. */
  151663. private _bloomThreshold;
  151664. private _hdr;
  151665. /**
  151666. * The strength of the bloom.
  151667. */
  151668. set bloomWeight(value: number);
  151669. get bloomWeight(): number;
  151670. /**
  151671. * The strength of the bloom.
  151672. */
  151673. set bloomThreshold(value: number);
  151674. get bloomThreshold(): number;
  151675. /**
  151676. * The scale of the bloom, lower value will provide better performance.
  151677. */
  151678. set bloomScale(value: number);
  151679. get bloomScale(): number;
  151680. /**
  151681. * Enable or disable the bloom from the pipeline
  151682. */
  151683. set bloomEnabled(enabled: boolean);
  151684. get bloomEnabled(): boolean;
  151685. private _rebuildBloom;
  151686. /**
  151687. * If the depth of field is enabled.
  151688. */
  151689. get depthOfFieldEnabled(): boolean;
  151690. set depthOfFieldEnabled(enabled: boolean);
  151691. /**
  151692. * Blur level of the depth of field effect. (Higher blur will effect performance)
  151693. */
  151694. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  151695. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  151696. /**
  151697. * If the anti aliasing is enabled.
  151698. */
  151699. set fxaaEnabled(enabled: boolean);
  151700. get fxaaEnabled(): boolean;
  151701. private _samples;
  151702. /**
  151703. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151704. */
  151705. set samples(sampleCount: number);
  151706. get samples(): number;
  151707. /**
  151708. * If image processing is enabled.
  151709. */
  151710. set imageProcessingEnabled(enabled: boolean);
  151711. get imageProcessingEnabled(): boolean;
  151712. /**
  151713. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  151714. */
  151715. set glowLayerEnabled(enabled: boolean);
  151716. get glowLayerEnabled(): boolean;
  151717. /**
  151718. * Gets the glow layer (or null if not defined)
  151719. */
  151720. get glowLayer(): Nullable<GlowLayer>;
  151721. /**
  151722. * Enable or disable the chromaticAberration process from the pipeline
  151723. */
  151724. set chromaticAberrationEnabled(enabled: boolean);
  151725. get chromaticAberrationEnabled(): boolean;
  151726. /**
  151727. * Enable or disable the grain process from the pipeline
  151728. */
  151729. set grainEnabled(enabled: boolean);
  151730. get grainEnabled(): boolean;
  151731. /**
  151732. * @constructor
  151733. * @param name - The rendering pipeline name (default: "")
  151734. * @param hdr - If high dynamic range textures should be used (default: true)
  151735. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151736. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151737. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151738. */
  151739. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151740. /**
  151741. * Get the class name
  151742. * @returns "DefaultRenderingPipeline"
  151743. */
  151744. getClassName(): string;
  151745. /**
  151746. * Force the compilation of the entire pipeline.
  151747. */
  151748. prepare(): void;
  151749. private _hasCleared;
  151750. private _prevPostProcess;
  151751. private _prevPrevPostProcess;
  151752. private _setAutoClearAndTextureSharing;
  151753. private _depthOfFieldSceneObserver;
  151754. private _buildPipeline;
  151755. private _disposePostProcesses;
  151756. /**
  151757. * Adds a camera to the pipeline
  151758. * @param camera the camera to be added
  151759. */
  151760. addCamera(camera: Camera): void;
  151761. /**
  151762. * Removes a camera from the pipeline
  151763. * @param camera the camera to remove
  151764. */
  151765. removeCamera(camera: Camera): void;
  151766. /**
  151767. * Dispose of the pipeline and stop all post processes
  151768. */
  151769. dispose(): void;
  151770. /**
  151771. * Serialize the rendering pipeline (Used when exporting)
  151772. * @returns the serialized object
  151773. */
  151774. serialize(): any;
  151775. /**
  151776. * Parse the serialized pipeline
  151777. * @param source Source pipeline.
  151778. * @param scene The scene to load the pipeline to.
  151779. * @param rootUrl The URL of the serialized pipeline.
  151780. * @returns An instantiated pipeline from the serialized object.
  151781. */
  151782. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  151783. }
  151784. }
  151785. declare module BABYLON {
  151786. /** @hidden */
  151787. export var lensHighlightsPixelShader: {
  151788. name: string;
  151789. shader: string;
  151790. };
  151791. }
  151792. declare module BABYLON {
  151793. /** @hidden */
  151794. export var depthOfFieldPixelShader: {
  151795. name: string;
  151796. shader: string;
  151797. };
  151798. }
  151799. declare module BABYLON {
  151800. /**
  151801. * BABYLON.JS Chromatic Aberration GLSL Shader
  151802. * Author: Olivier Guyot
  151803. * Separates very slightly R, G and B colors on the edges of the screen
  151804. * Inspired by Francois Tarlier & Martins Upitis
  151805. */
  151806. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151807. /**
  151808. * @ignore
  151809. * The chromatic aberration PostProcess id in the pipeline
  151810. */
  151811. LensChromaticAberrationEffect: string;
  151812. /**
  151813. * @ignore
  151814. * The highlights enhancing PostProcess id in the pipeline
  151815. */
  151816. HighlightsEnhancingEffect: string;
  151817. /**
  151818. * @ignore
  151819. * The depth-of-field PostProcess id in the pipeline
  151820. */
  151821. LensDepthOfFieldEffect: string;
  151822. private _scene;
  151823. private _depthTexture;
  151824. private _grainTexture;
  151825. private _chromaticAberrationPostProcess;
  151826. private _highlightsPostProcess;
  151827. private _depthOfFieldPostProcess;
  151828. private _edgeBlur;
  151829. private _grainAmount;
  151830. private _chromaticAberration;
  151831. private _distortion;
  151832. private _highlightsGain;
  151833. private _highlightsThreshold;
  151834. private _dofDistance;
  151835. private _dofAperture;
  151836. private _dofDarken;
  151837. private _dofPentagon;
  151838. private _blurNoise;
  151839. /**
  151840. * @constructor
  151841. *
  151842. * Effect parameters are as follow:
  151843. * {
  151844. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151845. * edge_blur: number; // from 0 to x (1 for realism)
  151846. * distortion: number; // from 0 to x (1 for realism)
  151847. * grain_amount: number; // from 0 to 1
  151848. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151849. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151850. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151851. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151852. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151853. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151854. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151855. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151856. * }
  151857. * Note: if an effect parameter is unset, effect is disabled
  151858. *
  151859. * @param name The rendering pipeline name
  151860. * @param parameters - An object containing all parameters (see above)
  151861. * @param scene The scene linked to this pipeline
  151862. * @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)
  151863. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151864. */
  151865. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151866. /**
  151867. * Get the class name
  151868. * @returns "LensRenderingPipeline"
  151869. */
  151870. getClassName(): string;
  151871. /**
  151872. * Gets associated scene
  151873. */
  151874. get scene(): Scene;
  151875. /**
  151876. * Gets or sets the edge blur
  151877. */
  151878. get edgeBlur(): number;
  151879. set edgeBlur(value: number);
  151880. /**
  151881. * Gets or sets the grain amount
  151882. */
  151883. get grainAmount(): number;
  151884. set grainAmount(value: number);
  151885. /**
  151886. * Gets or sets the chromatic aberration amount
  151887. */
  151888. get chromaticAberration(): number;
  151889. set chromaticAberration(value: number);
  151890. /**
  151891. * Gets or sets the depth of field aperture
  151892. */
  151893. get dofAperture(): number;
  151894. set dofAperture(value: number);
  151895. /**
  151896. * Gets or sets the edge distortion
  151897. */
  151898. get edgeDistortion(): number;
  151899. set edgeDistortion(value: number);
  151900. /**
  151901. * Gets or sets the depth of field distortion
  151902. */
  151903. get dofDistortion(): number;
  151904. set dofDistortion(value: number);
  151905. /**
  151906. * Gets or sets the darken out of focus amount
  151907. */
  151908. get darkenOutOfFocus(): number;
  151909. set darkenOutOfFocus(value: number);
  151910. /**
  151911. * Gets or sets a boolean indicating if blur noise is enabled
  151912. */
  151913. get blurNoise(): boolean;
  151914. set blurNoise(value: boolean);
  151915. /**
  151916. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151917. */
  151918. get pentagonBokeh(): boolean;
  151919. set pentagonBokeh(value: boolean);
  151920. /**
  151921. * Gets or sets the highlight grain amount
  151922. */
  151923. get highlightsGain(): number;
  151924. set highlightsGain(value: number);
  151925. /**
  151926. * Gets or sets the highlight threshold
  151927. */
  151928. get highlightsThreshold(): number;
  151929. set highlightsThreshold(value: number);
  151930. /**
  151931. * Sets the amount of blur at the edges
  151932. * @param amount blur amount
  151933. */
  151934. setEdgeBlur(amount: number): void;
  151935. /**
  151936. * Sets edge blur to 0
  151937. */
  151938. disableEdgeBlur(): void;
  151939. /**
  151940. * Sets the amout of grain
  151941. * @param amount Amount of grain
  151942. */
  151943. setGrainAmount(amount: number): void;
  151944. /**
  151945. * Set grain amount to 0
  151946. */
  151947. disableGrain(): void;
  151948. /**
  151949. * Sets the chromatic aberration amount
  151950. * @param amount amount of chromatic aberration
  151951. */
  151952. setChromaticAberration(amount: number): void;
  151953. /**
  151954. * Sets chromatic aberration amount to 0
  151955. */
  151956. disableChromaticAberration(): void;
  151957. /**
  151958. * Sets the EdgeDistortion amount
  151959. * @param amount amount of EdgeDistortion
  151960. */
  151961. setEdgeDistortion(amount: number): void;
  151962. /**
  151963. * Sets edge distortion to 0
  151964. */
  151965. disableEdgeDistortion(): void;
  151966. /**
  151967. * Sets the FocusDistance amount
  151968. * @param amount amount of FocusDistance
  151969. */
  151970. setFocusDistance(amount: number): void;
  151971. /**
  151972. * Disables depth of field
  151973. */
  151974. disableDepthOfField(): void;
  151975. /**
  151976. * Sets the Aperture amount
  151977. * @param amount amount of Aperture
  151978. */
  151979. setAperture(amount: number): void;
  151980. /**
  151981. * Sets the DarkenOutOfFocus amount
  151982. * @param amount amount of DarkenOutOfFocus
  151983. */
  151984. setDarkenOutOfFocus(amount: number): void;
  151985. private _pentagonBokehIsEnabled;
  151986. /**
  151987. * Creates a pentagon bokeh effect
  151988. */
  151989. enablePentagonBokeh(): void;
  151990. /**
  151991. * Disables the pentagon bokeh effect
  151992. */
  151993. disablePentagonBokeh(): void;
  151994. /**
  151995. * Enables noise blur
  151996. */
  151997. enableNoiseBlur(): void;
  151998. /**
  151999. * Disables noise blur
  152000. */
  152001. disableNoiseBlur(): void;
  152002. /**
  152003. * Sets the HighlightsGain amount
  152004. * @param amount amount of HighlightsGain
  152005. */
  152006. setHighlightsGain(amount: number): void;
  152007. /**
  152008. * Sets the HighlightsThreshold amount
  152009. * @param amount amount of HighlightsThreshold
  152010. */
  152011. setHighlightsThreshold(amount: number): void;
  152012. /**
  152013. * Disables highlights
  152014. */
  152015. disableHighlights(): void;
  152016. /**
  152017. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  152018. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  152019. */
  152020. dispose(disableDepthRender?: boolean): void;
  152021. private _createChromaticAberrationPostProcess;
  152022. private _createHighlightsPostProcess;
  152023. private _createDepthOfFieldPostProcess;
  152024. private _createGrainTexture;
  152025. }
  152026. }
  152027. declare module BABYLON {
  152028. /**
  152029. * Contains all parameters needed for the prepass to perform
  152030. * screen space subsurface scattering
  152031. */
  152032. export class SSAO2Configuration implements PrePassEffectConfiguration {
  152033. /**
  152034. * Is subsurface enabled
  152035. */
  152036. enabled: boolean;
  152037. /**
  152038. * Name of the configuration
  152039. */
  152040. name: string;
  152041. /**
  152042. * Textures that should be present in the MRT for this effect to work
  152043. */
  152044. readonly texturesRequired: number[];
  152045. }
  152046. }
  152047. declare module BABYLON {
  152048. /** @hidden */
  152049. export var ssao2PixelShader: {
  152050. name: string;
  152051. shader: string;
  152052. };
  152053. }
  152054. declare module BABYLON {
  152055. /** @hidden */
  152056. export var ssaoCombinePixelShader: {
  152057. name: string;
  152058. shader: string;
  152059. };
  152060. }
  152061. declare module BABYLON {
  152062. /**
  152063. * Render pipeline to produce ssao effect
  152064. */
  152065. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  152066. /**
  152067. * @ignore
  152068. * The PassPostProcess id in the pipeline that contains the original scene color
  152069. */
  152070. SSAOOriginalSceneColorEffect: string;
  152071. /**
  152072. * @ignore
  152073. * The SSAO PostProcess id in the pipeline
  152074. */
  152075. SSAORenderEffect: string;
  152076. /**
  152077. * @ignore
  152078. * The horizontal blur PostProcess id in the pipeline
  152079. */
  152080. SSAOBlurHRenderEffect: string;
  152081. /**
  152082. * @ignore
  152083. * The vertical blur PostProcess id in the pipeline
  152084. */
  152085. SSAOBlurVRenderEffect: string;
  152086. /**
  152087. * @ignore
  152088. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152089. */
  152090. SSAOCombineRenderEffect: string;
  152091. /**
  152092. * The output strength of the SSAO post-process. Default value is 1.0.
  152093. */
  152094. totalStrength: number;
  152095. /**
  152096. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  152097. */
  152098. maxZ: number;
  152099. /**
  152100. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  152101. */
  152102. minZAspect: number;
  152103. private _samples;
  152104. /**
  152105. * Number of samples used for the SSAO calculations. Default value is 8
  152106. */
  152107. set samples(n: number);
  152108. get samples(): number;
  152109. private _textureSamples;
  152110. /**
  152111. * Number of samples to use for antialiasing
  152112. */
  152113. set textureSamples(n: number);
  152114. get textureSamples(): number;
  152115. /**
  152116. * Force rendering the geometry through geometry buffer
  152117. */
  152118. private _forceGeometryBuffer;
  152119. /**
  152120. * Ratio object used for SSAO ratio and blur ratio
  152121. */
  152122. private _ratio;
  152123. /**
  152124. * Dynamically generated sphere sampler.
  152125. */
  152126. private _sampleSphere;
  152127. /**
  152128. * Blur filter offsets
  152129. */
  152130. private _samplerOffsets;
  152131. private _expensiveBlur;
  152132. /**
  152133. * If bilateral blur should be used
  152134. */
  152135. set expensiveBlur(b: boolean);
  152136. get expensiveBlur(): boolean;
  152137. /**
  152138. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  152139. */
  152140. radius: number;
  152141. /**
  152142. * The base color of the SSAO post-process
  152143. * The final result is "base + ssao" between [0, 1]
  152144. */
  152145. base: number;
  152146. /**
  152147. * Support test.
  152148. */
  152149. static get IsSupported(): boolean;
  152150. private _scene;
  152151. private _randomTexture;
  152152. private _originalColorPostProcess;
  152153. private _ssaoPostProcess;
  152154. private _blurHPostProcess;
  152155. private _blurVPostProcess;
  152156. private _ssaoCombinePostProcess;
  152157. private _prePassRenderer;
  152158. /**
  152159. * Gets active scene
  152160. */
  152161. get scene(): Scene;
  152162. /**
  152163. * @constructor
  152164. * @param name The rendering pipeline name
  152165. * @param scene The scene linked to this pipeline
  152166. * @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 }
  152167. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152168. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  152169. */
  152170. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  152171. /**
  152172. * Get the class name
  152173. * @returns "SSAO2RenderingPipeline"
  152174. */
  152175. getClassName(): string;
  152176. /**
  152177. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152178. */
  152179. dispose(disableGeometryBufferRenderer?: boolean): void;
  152180. private _createBlurPostProcess;
  152181. /** @hidden */
  152182. _rebuild(): void;
  152183. private _bits;
  152184. private _radicalInverse_VdC;
  152185. private _hammersley;
  152186. private _hemisphereSample_uniform;
  152187. private _generateHemisphere;
  152188. private _getDefinesForSSAO;
  152189. private _createSSAOPostProcess;
  152190. private _createSSAOCombinePostProcess;
  152191. private _createRandomTexture;
  152192. /**
  152193. * Serialize the rendering pipeline (Used when exporting)
  152194. * @returns the serialized object
  152195. */
  152196. serialize(): any;
  152197. /**
  152198. * Parse the serialized pipeline
  152199. * @param source Source pipeline.
  152200. * @param scene The scene to load the pipeline to.
  152201. * @param rootUrl The URL of the serialized pipeline.
  152202. * @returns An instantiated pipeline from the serialized object.
  152203. */
  152204. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  152205. }
  152206. }
  152207. declare module BABYLON {
  152208. /** @hidden */
  152209. export var ssaoPixelShader: {
  152210. name: string;
  152211. shader: string;
  152212. };
  152213. }
  152214. declare module BABYLON {
  152215. /**
  152216. * Render pipeline to produce ssao effect
  152217. */
  152218. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  152219. /**
  152220. * @ignore
  152221. * The PassPostProcess id in the pipeline that contains the original scene color
  152222. */
  152223. SSAOOriginalSceneColorEffect: string;
  152224. /**
  152225. * @ignore
  152226. * The SSAO PostProcess id in the pipeline
  152227. */
  152228. SSAORenderEffect: string;
  152229. /**
  152230. * @ignore
  152231. * The horizontal blur PostProcess id in the pipeline
  152232. */
  152233. SSAOBlurHRenderEffect: string;
  152234. /**
  152235. * @ignore
  152236. * The vertical blur PostProcess id in the pipeline
  152237. */
  152238. SSAOBlurVRenderEffect: string;
  152239. /**
  152240. * @ignore
  152241. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152242. */
  152243. SSAOCombineRenderEffect: string;
  152244. /**
  152245. * The output strength of the SSAO post-process. Default value is 1.0.
  152246. */
  152247. totalStrength: number;
  152248. /**
  152249. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  152250. */
  152251. radius: number;
  152252. /**
  152253. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  152254. * Must not be equal to fallOff and superior to fallOff.
  152255. * Default value is 0.0075
  152256. */
  152257. area: number;
  152258. /**
  152259. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  152260. * Must not be equal to area and inferior to area.
  152261. * Default value is 0.000001
  152262. */
  152263. fallOff: number;
  152264. /**
  152265. * The base color of the SSAO post-process
  152266. * The final result is "base + ssao" between [0, 1]
  152267. */
  152268. base: number;
  152269. private _scene;
  152270. private _depthTexture;
  152271. private _randomTexture;
  152272. private _originalColorPostProcess;
  152273. private _ssaoPostProcess;
  152274. private _blurHPostProcess;
  152275. private _blurVPostProcess;
  152276. private _ssaoCombinePostProcess;
  152277. private _firstUpdate;
  152278. /**
  152279. * Gets active scene
  152280. */
  152281. get scene(): Scene;
  152282. /**
  152283. * @constructor
  152284. * @param name - The rendering pipeline name
  152285. * @param scene - The scene linked to this pipeline
  152286. * @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 }
  152287. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  152288. */
  152289. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  152290. /**
  152291. * Get the class name
  152292. * @returns "SSAORenderingPipeline"
  152293. */
  152294. getClassName(): string;
  152295. /**
  152296. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152297. */
  152298. dispose(disableDepthRender?: boolean): void;
  152299. private _createBlurPostProcess;
  152300. /** @hidden */
  152301. _rebuild(): void;
  152302. private _createSSAOPostProcess;
  152303. private _createSSAOCombinePostProcess;
  152304. private _createRandomTexture;
  152305. }
  152306. }
  152307. declare module BABYLON {
  152308. /**
  152309. * Contains all parameters needed for the prepass to perform
  152310. * screen space reflections
  152311. */
  152312. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  152313. /**
  152314. * Is ssr enabled
  152315. */
  152316. enabled: boolean;
  152317. /**
  152318. * Name of the configuration
  152319. */
  152320. name: string;
  152321. /**
  152322. * Textures that should be present in the MRT for this effect to work
  152323. */
  152324. readonly texturesRequired: number[];
  152325. }
  152326. }
  152327. declare module BABYLON {
  152328. /** @hidden */
  152329. export var screenSpaceReflectionPixelShader: {
  152330. name: string;
  152331. shader: string;
  152332. };
  152333. }
  152334. declare module BABYLON {
  152335. /**
  152336. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  152337. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  152338. */
  152339. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  152340. /**
  152341. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  152342. */
  152343. threshold: number;
  152344. /**
  152345. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  152346. */
  152347. strength: number;
  152348. /**
  152349. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  152350. */
  152351. reflectionSpecularFalloffExponent: number;
  152352. /**
  152353. * 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]
  152354. */
  152355. step: number;
  152356. /**
  152357. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  152358. */
  152359. roughnessFactor: number;
  152360. private _forceGeometryBuffer;
  152361. private _geometryBufferRenderer;
  152362. private _prePassRenderer;
  152363. private _enableSmoothReflections;
  152364. private _reflectionSamples;
  152365. private _smoothSteps;
  152366. /**
  152367. * Gets a string identifying the name of the class
  152368. * @returns "ScreenSpaceReflectionPostProcess" string
  152369. */
  152370. getClassName(): string;
  152371. /**
  152372. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  152373. * @param name The name of the effect.
  152374. * @param scene The scene containing the objects to calculate reflections.
  152375. * @param options The required width/height ratio to downsize to before computing the render pass.
  152376. * @param camera The camera to apply the render pass to.
  152377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152378. * @param engine The engine which the post process will be applied. (default: current engine)
  152379. * @param reusable If the post process can be reused on the same frame. (default: false)
  152380. * @param textureType Type of textures used when performing the post process. (default: 0)
  152381. * @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)
  152382. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152383. */
  152384. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152385. /**
  152386. * Gets wether or not smoothing reflections is enabled.
  152387. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152388. */
  152389. get enableSmoothReflections(): boolean;
  152390. /**
  152391. * Sets wether or not smoothing reflections is enabled.
  152392. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152393. */
  152394. set enableSmoothReflections(enabled: boolean);
  152395. /**
  152396. * Gets the number of samples taken while computing reflections. More samples count is high,
  152397. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152398. */
  152399. get reflectionSamples(): number;
  152400. /**
  152401. * Sets the number of samples taken while computing reflections. More samples count is high,
  152402. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152403. */
  152404. set reflectionSamples(samples: number);
  152405. /**
  152406. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  152407. * more the post-process will require GPU power and can generate a drop in FPS.
  152408. * Default value (5.0) work pretty well in all cases but can be adjusted.
  152409. */
  152410. get smoothSteps(): number;
  152411. set smoothSteps(steps: number);
  152412. private _updateEffectDefines;
  152413. /** @hidden */
  152414. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  152415. }
  152416. }
  152417. declare module BABYLON {
  152418. /** @hidden */
  152419. export var standardPixelShader: {
  152420. name: string;
  152421. shader: string;
  152422. };
  152423. }
  152424. declare module BABYLON {
  152425. /**
  152426. * Standard rendering pipeline
  152427. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152428. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  152429. */
  152430. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152431. /**
  152432. * Public members
  152433. */
  152434. /**
  152435. * Post-process which contains the original scene color before the pipeline applies all the effects
  152436. */
  152437. originalPostProcess: Nullable<PostProcess>;
  152438. /**
  152439. * Post-process used to down scale an image x4
  152440. */
  152441. downSampleX4PostProcess: Nullable<PostProcess>;
  152442. /**
  152443. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  152444. */
  152445. brightPassPostProcess: Nullable<PostProcess>;
  152446. /**
  152447. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  152448. */
  152449. blurHPostProcesses: PostProcess[];
  152450. /**
  152451. * Post-process array storing all the vertical blur post-processes used by the pipeline
  152452. */
  152453. blurVPostProcesses: PostProcess[];
  152454. /**
  152455. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  152456. */
  152457. textureAdderPostProcess: Nullable<PostProcess>;
  152458. /**
  152459. * Post-process used to create volumetric lighting effect
  152460. */
  152461. volumetricLightPostProcess: Nullable<PostProcess>;
  152462. /**
  152463. * Post-process used to smooth the previous volumetric light post-process on the X axis
  152464. */
  152465. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  152466. /**
  152467. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  152468. */
  152469. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  152470. /**
  152471. * Post-process used to merge the volumetric light effect and the real scene color
  152472. */
  152473. volumetricLightMergePostProces: Nullable<PostProcess>;
  152474. /**
  152475. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  152476. */
  152477. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  152478. /**
  152479. * Base post-process used to calculate the average luminance of the final image for HDR
  152480. */
  152481. luminancePostProcess: Nullable<PostProcess>;
  152482. /**
  152483. * Post-processes used to create down sample post-processes in order to get
  152484. * the average luminance of the final image for HDR
  152485. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  152486. */
  152487. luminanceDownSamplePostProcesses: PostProcess[];
  152488. /**
  152489. * Post-process used to create a HDR effect (light adaptation)
  152490. */
  152491. hdrPostProcess: Nullable<PostProcess>;
  152492. /**
  152493. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  152494. */
  152495. textureAdderFinalPostProcess: Nullable<PostProcess>;
  152496. /**
  152497. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  152498. */
  152499. lensFlareFinalPostProcess: Nullable<PostProcess>;
  152500. /**
  152501. * Post-process used to merge the final HDR post-process and the real scene color
  152502. */
  152503. hdrFinalPostProcess: Nullable<PostProcess>;
  152504. /**
  152505. * Post-process used to create a lens flare effect
  152506. */
  152507. lensFlarePostProcess: Nullable<PostProcess>;
  152508. /**
  152509. * Post-process that merges the result of the lens flare post-process and the real scene color
  152510. */
  152511. lensFlareComposePostProcess: Nullable<PostProcess>;
  152512. /**
  152513. * Post-process used to create a motion blur effect
  152514. */
  152515. motionBlurPostProcess: Nullable<PostProcess>;
  152516. /**
  152517. * Post-process used to create a depth of field effect
  152518. */
  152519. depthOfFieldPostProcess: Nullable<PostProcess>;
  152520. /**
  152521. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152522. */
  152523. fxaaPostProcess: Nullable<FxaaPostProcess>;
  152524. /**
  152525. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  152526. */
  152527. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  152528. /**
  152529. * Represents the brightness threshold in order to configure the illuminated surfaces
  152530. */
  152531. brightThreshold: number;
  152532. /**
  152533. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  152534. */
  152535. blurWidth: number;
  152536. /**
  152537. * Sets if the blur for highlighted surfaces must be only horizontal
  152538. */
  152539. horizontalBlur: boolean;
  152540. /**
  152541. * Gets the overall exposure used by the pipeline
  152542. */
  152543. get exposure(): number;
  152544. /**
  152545. * Sets the overall exposure used by the pipeline
  152546. */
  152547. set exposure(value: number);
  152548. /**
  152549. * Texture used typically to simulate "dirty" on camera lens
  152550. */
  152551. lensTexture: Nullable<Texture>;
  152552. /**
  152553. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  152554. */
  152555. volumetricLightCoefficient: number;
  152556. /**
  152557. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  152558. */
  152559. volumetricLightPower: number;
  152560. /**
  152561. * Used the set the blur intensity to smooth the volumetric lights
  152562. */
  152563. volumetricLightBlurScale: number;
  152564. /**
  152565. * Light (spot or directional) used to generate the volumetric lights rays
  152566. * The source light must have a shadow generate so the pipeline can get its
  152567. * depth map
  152568. */
  152569. sourceLight: Nullable<SpotLight | DirectionalLight>;
  152570. /**
  152571. * For eye adaptation, represents the minimum luminance the eye can see
  152572. */
  152573. hdrMinimumLuminance: number;
  152574. /**
  152575. * For eye adaptation, represents the decrease luminance speed
  152576. */
  152577. hdrDecreaseRate: number;
  152578. /**
  152579. * For eye adaptation, represents the increase luminance speed
  152580. */
  152581. hdrIncreaseRate: number;
  152582. /**
  152583. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152584. */
  152585. get hdrAutoExposure(): boolean;
  152586. /**
  152587. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152588. */
  152589. set hdrAutoExposure(value: boolean);
  152590. /**
  152591. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  152592. */
  152593. lensColorTexture: Nullable<Texture>;
  152594. /**
  152595. * The overall strengh for the lens flare effect
  152596. */
  152597. lensFlareStrength: number;
  152598. /**
  152599. * Dispersion coefficient for lens flare ghosts
  152600. */
  152601. lensFlareGhostDispersal: number;
  152602. /**
  152603. * Main lens flare halo width
  152604. */
  152605. lensFlareHaloWidth: number;
  152606. /**
  152607. * Based on the lens distortion effect, defines how much the lens flare result
  152608. * is distorted
  152609. */
  152610. lensFlareDistortionStrength: number;
  152611. /**
  152612. * Configures the blur intensity used for for lens flare (halo)
  152613. */
  152614. lensFlareBlurWidth: number;
  152615. /**
  152616. * Lens star texture must be used to simulate rays on the flares and is available
  152617. * in the documentation
  152618. */
  152619. lensStarTexture: Nullable<Texture>;
  152620. /**
  152621. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  152622. * flare effect by taking account of the dirt texture
  152623. */
  152624. lensFlareDirtTexture: Nullable<Texture>;
  152625. /**
  152626. * Represents the focal length for the depth of field effect
  152627. */
  152628. depthOfFieldDistance: number;
  152629. /**
  152630. * Represents the blur intensity for the blurred part of the depth of field effect
  152631. */
  152632. depthOfFieldBlurWidth: number;
  152633. /**
  152634. * Gets how much the image is blurred by the movement while using the motion blur post-process
  152635. */
  152636. get motionStrength(): number;
  152637. /**
  152638. * Sets how much the image is blurred by the movement while using the motion blur post-process
  152639. */
  152640. set motionStrength(strength: number);
  152641. /**
  152642. * Gets wether or not the motion blur post-process is object based or screen based.
  152643. */
  152644. get objectBasedMotionBlur(): boolean;
  152645. /**
  152646. * Sets wether or not the motion blur post-process should be object based or screen based
  152647. */
  152648. set objectBasedMotionBlur(value: boolean);
  152649. /**
  152650. * List of animations for the pipeline (IAnimatable implementation)
  152651. */
  152652. animations: Animation[];
  152653. /**
  152654. * Private members
  152655. */
  152656. private _scene;
  152657. private _currentDepthOfFieldSource;
  152658. private _basePostProcess;
  152659. private _fixedExposure;
  152660. private _currentExposure;
  152661. private _hdrAutoExposure;
  152662. private _hdrCurrentLuminance;
  152663. private _motionStrength;
  152664. private _isObjectBasedMotionBlur;
  152665. private _floatTextureType;
  152666. private _camerasToBeAttached;
  152667. private _ratio;
  152668. private _bloomEnabled;
  152669. private _depthOfFieldEnabled;
  152670. private _vlsEnabled;
  152671. private _lensFlareEnabled;
  152672. private _hdrEnabled;
  152673. private _motionBlurEnabled;
  152674. private _fxaaEnabled;
  152675. private _screenSpaceReflectionsEnabled;
  152676. private _motionBlurSamples;
  152677. private _volumetricLightStepsCount;
  152678. private _samples;
  152679. /**
  152680. * @ignore
  152681. * Specifies if the bloom pipeline is enabled
  152682. */
  152683. get BloomEnabled(): boolean;
  152684. set BloomEnabled(enabled: boolean);
  152685. /**
  152686. * @ignore
  152687. * Specifies if the depth of field pipeline is enabed
  152688. */
  152689. get DepthOfFieldEnabled(): boolean;
  152690. set DepthOfFieldEnabled(enabled: boolean);
  152691. /**
  152692. * @ignore
  152693. * Specifies if the lens flare pipeline is enabed
  152694. */
  152695. get LensFlareEnabled(): boolean;
  152696. set LensFlareEnabled(enabled: boolean);
  152697. /**
  152698. * @ignore
  152699. * Specifies if the HDR pipeline is enabled
  152700. */
  152701. get HDREnabled(): boolean;
  152702. set HDREnabled(enabled: boolean);
  152703. /**
  152704. * @ignore
  152705. * Specifies if the volumetric lights scattering effect is enabled
  152706. */
  152707. get VLSEnabled(): boolean;
  152708. set VLSEnabled(enabled: boolean);
  152709. /**
  152710. * @ignore
  152711. * Specifies if the motion blur effect is enabled
  152712. */
  152713. get MotionBlurEnabled(): boolean;
  152714. set MotionBlurEnabled(enabled: boolean);
  152715. /**
  152716. * Specifies if anti-aliasing is enabled
  152717. */
  152718. get fxaaEnabled(): boolean;
  152719. set fxaaEnabled(enabled: boolean);
  152720. /**
  152721. * Specifies if screen space reflections are enabled.
  152722. */
  152723. get screenSpaceReflectionsEnabled(): boolean;
  152724. set screenSpaceReflectionsEnabled(enabled: boolean);
  152725. /**
  152726. * Specifies the number of steps used to calculate the volumetric lights
  152727. * Typically in interval [50, 200]
  152728. */
  152729. get volumetricLightStepsCount(): number;
  152730. set volumetricLightStepsCount(count: number);
  152731. /**
  152732. * Specifies the number of samples used for the motion blur effect
  152733. * Typically in interval [16, 64]
  152734. */
  152735. get motionBlurSamples(): number;
  152736. set motionBlurSamples(samples: number);
  152737. /**
  152738. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152739. */
  152740. get samples(): number;
  152741. set samples(sampleCount: number);
  152742. /**
  152743. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152744. * @constructor
  152745. * @param name The rendering pipeline name
  152746. * @param scene The scene linked to this pipeline
  152747. * @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)
  152748. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  152749. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152750. */
  152751. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  152752. private _buildPipeline;
  152753. private _createDownSampleX4PostProcess;
  152754. private _createBrightPassPostProcess;
  152755. private _createBlurPostProcesses;
  152756. private _createTextureAdderPostProcess;
  152757. private _createVolumetricLightPostProcess;
  152758. private _createLuminancePostProcesses;
  152759. private _createHdrPostProcess;
  152760. private _createLensFlarePostProcess;
  152761. private _createDepthOfFieldPostProcess;
  152762. private _createMotionBlurPostProcess;
  152763. private _getDepthTexture;
  152764. private _disposePostProcesses;
  152765. /**
  152766. * Dispose of the pipeline and stop all post processes
  152767. */
  152768. dispose(): void;
  152769. /**
  152770. * Serialize the rendering pipeline (Used when exporting)
  152771. * @returns the serialized object
  152772. */
  152773. serialize(): any;
  152774. /**
  152775. * Parse the serialized pipeline
  152776. * @param source Source pipeline.
  152777. * @param scene The scene to load the pipeline to.
  152778. * @param rootUrl The URL of the serialized pipeline.
  152779. * @returns An instantiated pipeline from the serialized object.
  152780. */
  152781. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  152782. /**
  152783. * Luminance steps
  152784. */
  152785. static LuminanceSteps: number;
  152786. }
  152787. }
  152788. declare module BABYLON {
  152789. /** @hidden */
  152790. export var stereoscopicInterlacePixelShader: {
  152791. name: string;
  152792. shader: string;
  152793. };
  152794. }
  152795. declare module BABYLON {
  152796. /**
  152797. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  152798. */
  152799. export class StereoscopicInterlacePostProcessI extends PostProcess {
  152800. private _stepSize;
  152801. private _passedProcess;
  152802. /**
  152803. * Gets a string identifying the name of the class
  152804. * @returns "StereoscopicInterlacePostProcessI" string
  152805. */
  152806. getClassName(): string;
  152807. /**
  152808. * Initializes a StereoscopicInterlacePostProcessI
  152809. * @param name The name of the effect.
  152810. * @param rigCameras The rig cameras to be appled to the post process
  152811. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152812. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152814. * @param engine The engine which the post process will be applied. (default: current engine)
  152815. * @param reusable If the post process can be reused on the same frame. (default: false)
  152816. */
  152817. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152818. }
  152819. /**
  152820. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152821. */
  152822. export class StereoscopicInterlacePostProcess extends PostProcess {
  152823. private _stepSize;
  152824. private _passedProcess;
  152825. /**
  152826. * Gets a string identifying the name of the class
  152827. * @returns "StereoscopicInterlacePostProcess" string
  152828. */
  152829. getClassName(): string;
  152830. /**
  152831. * Initializes a StereoscopicInterlacePostProcess
  152832. * @param name The name of the effect.
  152833. * @param rigCameras The rig cameras to be appled to the post process
  152834. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152835. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152836. * @param engine The engine which the post process will be applied. (default: current engine)
  152837. * @param reusable If the post process can be reused on the same frame. (default: false)
  152838. */
  152839. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152840. }
  152841. }
  152842. declare module BABYLON {
  152843. /** @hidden */
  152844. export var tonemapPixelShader: {
  152845. name: string;
  152846. shader: string;
  152847. };
  152848. }
  152849. declare module BABYLON {
  152850. /** Defines operator used for tonemapping */
  152851. export enum TonemappingOperator {
  152852. /** Hable */
  152853. Hable = 0,
  152854. /** Reinhard */
  152855. Reinhard = 1,
  152856. /** HejiDawson */
  152857. HejiDawson = 2,
  152858. /** Photographic */
  152859. Photographic = 3
  152860. }
  152861. /**
  152862. * Defines a post process to apply tone mapping
  152863. */
  152864. export class TonemapPostProcess extends PostProcess {
  152865. private _operator;
  152866. /** Defines the required exposure adjustement */
  152867. exposureAdjustment: number;
  152868. /**
  152869. * Gets a string identifying the name of the class
  152870. * @returns "TonemapPostProcess" string
  152871. */
  152872. getClassName(): string;
  152873. /**
  152874. * Creates a new TonemapPostProcess
  152875. * @param name defines the name of the postprocess
  152876. * @param _operator defines the operator to use
  152877. * @param exposureAdjustment defines the required exposure adjustement
  152878. * @param camera defines the camera to use (can be null)
  152879. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152880. * @param engine defines the hosting engine (can be ignore if camera is set)
  152881. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152882. */
  152883. constructor(name: string, _operator: TonemappingOperator,
  152884. /** Defines the required exposure adjustement */
  152885. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152886. }
  152887. }
  152888. declare module BABYLON {
  152889. /** @hidden */
  152890. export var volumetricLightScatteringPixelShader: {
  152891. name: string;
  152892. shader: string;
  152893. };
  152894. }
  152895. declare module BABYLON {
  152896. /** @hidden */
  152897. export var volumetricLightScatteringPassVertexShader: {
  152898. name: string;
  152899. shader: string;
  152900. };
  152901. }
  152902. declare module BABYLON {
  152903. /** @hidden */
  152904. export var volumetricLightScatteringPassPixelShader: {
  152905. name: string;
  152906. shader: string;
  152907. };
  152908. }
  152909. declare module BABYLON {
  152910. /**
  152911. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152912. */
  152913. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152914. private _volumetricLightScatteringPass;
  152915. private _volumetricLightScatteringRTT;
  152916. private _viewPort;
  152917. private _screenCoordinates;
  152918. private _cachedDefines;
  152919. /**
  152920. * If not undefined, the mesh position is computed from the attached node position
  152921. */
  152922. attachedNode: {
  152923. position: Vector3;
  152924. };
  152925. /**
  152926. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152927. */
  152928. customMeshPosition: Vector3;
  152929. /**
  152930. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152931. */
  152932. useCustomMeshPosition: boolean;
  152933. /**
  152934. * If the post-process should inverse the light scattering direction
  152935. */
  152936. invert: boolean;
  152937. /**
  152938. * The internal mesh used by the post-process
  152939. */
  152940. mesh: Mesh;
  152941. /**
  152942. * @hidden
  152943. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152944. */
  152945. get useDiffuseColor(): boolean;
  152946. set useDiffuseColor(useDiffuseColor: boolean);
  152947. /**
  152948. * Array containing the excluded meshes not rendered in the internal pass
  152949. */
  152950. excludedMeshes: AbstractMesh[];
  152951. /**
  152952. * Controls the overall intensity of the post-process
  152953. */
  152954. exposure: number;
  152955. /**
  152956. * Dissipates each sample's contribution in range [0, 1]
  152957. */
  152958. decay: number;
  152959. /**
  152960. * Controls the overall intensity of each sample
  152961. */
  152962. weight: number;
  152963. /**
  152964. * Controls the density of each sample
  152965. */
  152966. density: number;
  152967. /**
  152968. * @constructor
  152969. * @param name The post-process name
  152970. * @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)
  152971. * @param camera The camera that the post-process will be attached to
  152972. * @param mesh The mesh used to create the light scattering
  152973. * @param samples The post-process quality, default 100
  152974. * @param samplingModeThe post-process filtering mode
  152975. * @param engine The babylon engine
  152976. * @param reusable If the post-process is reusable
  152977. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152978. */
  152979. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152980. /**
  152981. * Returns the string "VolumetricLightScatteringPostProcess"
  152982. * @returns "VolumetricLightScatteringPostProcess"
  152983. */
  152984. getClassName(): string;
  152985. private _isReady;
  152986. /**
  152987. * Sets the new light position for light scattering effect
  152988. * @param position The new custom light position
  152989. */
  152990. setCustomMeshPosition(position: Vector3): void;
  152991. /**
  152992. * Returns the light position for light scattering effect
  152993. * @return Vector3 The custom light position
  152994. */
  152995. getCustomMeshPosition(): Vector3;
  152996. /**
  152997. * Disposes the internal assets and detaches the post-process from the camera
  152998. */
  152999. dispose(camera: Camera): void;
  153000. /**
  153001. * Returns the render target texture used by the post-process
  153002. * @return the render target texture used by the post-process
  153003. */
  153004. getPass(): RenderTargetTexture;
  153005. private _meshExcluded;
  153006. private _createPass;
  153007. private _updateMeshScreenCoordinates;
  153008. /**
  153009. * Creates a default mesh for the Volumeric Light Scattering post-process
  153010. * @param name The mesh name
  153011. * @param scene The scene where to create the mesh
  153012. * @return the default mesh
  153013. */
  153014. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  153015. }
  153016. }
  153017. declare module BABYLON {
  153018. /** @hidden */
  153019. export var screenSpaceCurvaturePixelShader: {
  153020. name: string;
  153021. shader: string;
  153022. };
  153023. }
  153024. declare module BABYLON {
  153025. /**
  153026. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  153027. */
  153028. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  153029. /**
  153030. * Defines how much ridge the curvature effect displays.
  153031. */
  153032. ridge: number;
  153033. /**
  153034. * Defines how much valley the curvature effect displays.
  153035. */
  153036. valley: number;
  153037. private _geometryBufferRenderer;
  153038. /**
  153039. * Gets a string identifying the name of the class
  153040. * @returns "ScreenSpaceCurvaturePostProcess" string
  153041. */
  153042. getClassName(): string;
  153043. /**
  153044. * Creates a new instance ScreenSpaceCurvaturePostProcess
  153045. * @param name The name of the effect.
  153046. * @param scene The scene containing the objects to blur according to their velocity.
  153047. * @param options The required width/height ratio to downsize to before computing the render pass.
  153048. * @param camera The camera to apply the render pass to.
  153049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153050. * @param engine The engine which the post process will be applied. (default: current engine)
  153051. * @param reusable If the post process can be reused on the same frame. (default: false)
  153052. * @param textureType Type of textures used when performing the post process. (default: 0)
  153053. * @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)
  153054. */
  153055. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  153056. /**
  153057. * Support test.
  153058. */
  153059. static get IsSupported(): boolean;
  153060. /** @hidden */
  153061. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  153062. }
  153063. }
  153064. declare module BABYLON {
  153065. interface Scene {
  153066. /** @hidden (Backing field) */
  153067. _boundingBoxRenderer: BoundingBoxRenderer;
  153068. /** @hidden (Backing field) */
  153069. _forceShowBoundingBoxes: boolean;
  153070. /**
  153071. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  153072. */
  153073. forceShowBoundingBoxes: boolean;
  153074. /**
  153075. * Gets the bounding box renderer associated with the scene
  153076. * @returns a BoundingBoxRenderer
  153077. */
  153078. getBoundingBoxRenderer(): BoundingBoxRenderer;
  153079. }
  153080. interface AbstractMesh {
  153081. /** @hidden (Backing field) */
  153082. _showBoundingBox: boolean;
  153083. /**
  153084. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  153085. */
  153086. showBoundingBox: boolean;
  153087. }
  153088. /**
  153089. * Component responsible of rendering the bounding box of the meshes in a scene.
  153090. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  153091. */
  153092. export class BoundingBoxRenderer implements ISceneComponent {
  153093. /**
  153094. * The component name helpfull to identify the component in the list of scene components.
  153095. */
  153096. readonly name: string;
  153097. /**
  153098. * The scene the component belongs to.
  153099. */
  153100. scene: Scene;
  153101. /**
  153102. * Color of the bounding box lines placed in front of an object
  153103. */
  153104. frontColor: Color3;
  153105. /**
  153106. * Color of the bounding box lines placed behind an object
  153107. */
  153108. backColor: Color3;
  153109. /**
  153110. * Defines if the renderer should show the back lines or not
  153111. */
  153112. showBackLines: boolean;
  153113. /**
  153114. * Observable raised before rendering a bounding box
  153115. */
  153116. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  153117. /**
  153118. * Observable raised after rendering a bounding box
  153119. */
  153120. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  153121. /**
  153122. * @hidden
  153123. */
  153124. renderList: SmartArray<BoundingBox>;
  153125. private _colorShader;
  153126. private _vertexBuffers;
  153127. private _indexBuffer;
  153128. private _fillIndexBuffer;
  153129. private _fillIndexData;
  153130. /**
  153131. * Instantiates a new bounding box renderer in a scene.
  153132. * @param scene the scene the renderer renders in
  153133. */
  153134. constructor(scene: Scene);
  153135. /**
  153136. * Registers the component in a given scene
  153137. */
  153138. register(): void;
  153139. private _evaluateSubMesh;
  153140. private _activeMesh;
  153141. private _prepareRessources;
  153142. private _createIndexBuffer;
  153143. /**
  153144. * Rebuilds the elements related to this component in case of
  153145. * context lost for instance.
  153146. */
  153147. rebuild(): void;
  153148. /**
  153149. * @hidden
  153150. */
  153151. reset(): void;
  153152. /**
  153153. * Render the bounding boxes of a specific rendering group
  153154. * @param renderingGroupId defines the rendering group to render
  153155. */
  153156. render(renderingGroupId: number): void;
  153157. /**
  153158. * In case of occlusion queries, we can render the occlusion bounding box through this method
  153159. * @param mesh Define the mesh to render the occlusion bounding box for
  153160. */
  153161. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  153162. /**
  153163. * Dispose and release the resources attached to this renderer.
  153164. */
  153165. dispose(): void;
  153166. }
  153167. }
  153168. declare module BABYLON {
  153169. interface Scene {
  153170. /** @hidden (Backing field) */
  153171. _depthRenderer: {
  153172. [id: string]: DepthRenderer;
  153173. };
  153174. /**
  153175. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  153176. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  153177. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  153178. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  153179. * @returns the created depth renderer
  153180. */
  153181. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  153182. /**
  153183. * Disables a depth renderer for a given camera
  153184. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  153185. */
  153186. disableDepthRenderer(camera?: Nullable<Camera>): void;
  153187. }
  153188. /**
  153189. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  153190. * in several rendering techniques.
  153191. */
  153192. export class DepthRendererSceneComponent implements ISceneComponent {
  153193. /**
  153194. * The component name helpfull to identify the component in the list of scene components.
  153195. */
  153196. readonly name: string;
  153197. /**
  153198. * The scene the component belongs to.
  153199. */
  153200. scene: Scene;
  153201. /**
  153202. * Creates a new instance of the component for the given scene
  153203. * @param scene Defines the scene to register the component in
  153204. */
  153205. constructor(scene: Scene);
  153206. /**
  153207. * Registers the component in a given scene
  153208. */
  153209. register(): void;
  153210. /**
  153211. * Rebuilds the elements related to this component in case of
  153212. * context lost for instance.
  153213. */
  153214. rebuild(): void;
  153215. /**
  153216. * Disposes the component and the associated ressources
  153217. */
  153218. dispose(): void;
  153219. private _gatherRenderTargets;
  153220. private _gatherActiveCameraRenderTargets;
  153221. }
  153222. }
  153223. declare module BABYLON {
  153224. interface AbstractScene {
  153225. /** @hidden (Backing field) */
  153226. _prePassRenderer: Nullable<PrePassRenderer>;
  153227. /**
  153228. * Gets or Sets the current prepass renderer associated to the scene.
  153229. */
  153230. prePassRenderer: Nullable<PrePassRenderer>;
  153231. /**
  153232. * Enables the prepass and associates it with the scene
  153233. * @returns the PrePassRenderer
  153234. */
  153235. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  153236. /**
  153237. * Disables the prepass associated with the scene
  153238. */
  153239. disablePrePassRenderer(): void;
  153240. }
  153241. /**
  153242. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153243. * in several rendering techniques.
  153244. */
  153245. export class PrePassRendererSceneComponent implements ISceneComponent {
  153246. /**
  153247. * The component name helpful to identify the component in the list of scene components.
  153248. */
  153249. readonly name: string;
  153250. /**
  153251. * The scene the component belongs to.
  153252. */
  153253. scene: Scene;
  153254. /**
  153255. * Creates a new instance of the component for the given scene
  153256. * @param scene Defines the scene to register the component in
  153257. */
  153258. constructor(scene: Scene);
  153259. /**
  153260. * Registers the component in a given scene
  153261. */
  153262. register(): void;
  153263. private _beforeCameraDraw;
  153264. private _afterCameraDraw;
  153265. private _beforeClearStage;
  153266. /**
  153267. * Rebuilds the elements related to this component in case of
  153268. * context lost for instance.
  153269. */
  153270. rebuild(): void;
  153271. /**
  153272. * Disposes the component and the associated ressources
  153273. */
  153274. dispose(): void;
  153275. }
  153276. }
  153277. declare module BABYLON {
  153278. /** @hidden */
  153279. export var fibonacci: {
  153280. name: string;
  153281. shader: string;
  153282. };
  153283. }
  153284. declare module BABYLON {
  153285. /** @hidden */
  153286. export var diffusionProfile: {
  153287. name: string;
  153288. shader: string;
  153289. };
  153290. }
  153291. declare module BABYLON {
  153292. /** @hidden */
  153293. export var subSurfaceScatteringPixelShader: {
  153294. name: string;
  153295. shader: string;
  153296. };
  153297. }
  153298. declare module BABYLON {
  153299. /**
  153300. * Sub surface scattering post process
  153301. */
  153302. export class SubSurfaceScatteringPostProcess extends PostProcess {
  153303. /**
  153304. * Gets a string identifying the name of the class
  153305. * @returns "SubSurfaceScatteringPostProcess" string
  153306. */
  153307. getClassName(): string;
  153308. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  153309. }
  153310. }
  153311. declare module BABYLON {
  153312. /**
  153313. * Contains all parameters needed for the prepass to perform
  153314. * screen space subsurface scattering
  153315. */
  153316. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  153317. /** @hidden */
  153318. static _SceneComponentInitialization: (scene: Scene) => void;
  153319. private _ssDiffusionS;
  153320. private _ssFilterRadii;
  153321. private _ssDiffusionD;
  153322. /**
  153323. * Post process to attach for screen space subsurface scattering
  153324. */
  153325. postProcess: SubSurfaceScatteringPostProcess;
  153326. /**
  153327. * Diffusion profile color for subsurface scattering
  153328. */
  153329. get ssDiffusionS(): number[];
  153330. /**
  153331. * Diffusion profile max color channel value for subsurface scattering
  153332. */
  153333. get ssDiffusionD(): number[];
  153334. /**
  153335. * Diffusion profile filter radius for subsurface scattering
  153336. */
  153337. get ssFilterRadii(): number[];
  153338. /**
  153339. * Is subsurface enabled
  153340. */
  153341. enabled: boolean;
  153342. /**
  153343. * Name of the configuration
  153344. */
  153345. name: string;
  153346. /**
  153347. * Diffusion profile colors for subsurface scattering
  153348. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  153349. * See ...
  153350. * Note that you can only store up to 5 of them
  153351. */
  153352. ssDiffusionProfileColors: Color3[];
  153353. /**
  153354. * Defines the ratio real world => scene units.
  153355. * Used for subsurface scattering
  153356. */
  153357. metersPerUnit: number;
  153358. /**
  153359. * Textures that should be present in the MRT for this effect to work
  153360. */
  153361. readonly texturesRequired: number[];
  153362. private _scene;
  153363. /**
  153364. * Builds a subsurface configuration object
  153365. * @param scene The scene
  153366. */
  153367. constructor(scene: Scene);
  153368. /**
  153369. * Adds a new diffusion profile.
  153370. * Useful for more realistic subsurface scattering on diverse materials.
  153371. * @param color The color of the diffusion profile. Should be the average color of the material.
  153372. * @return The index of the diffusion profile for the material subsurface configuration
  153373. */
  153374. addDiffusionProfile(color: Color3): number;
  153375. /**
  153376. * Creates the sss post process
  153377. * @return The created post process
  153378. */
  153379. createPostProcess(): SubSurfaceScatteringPostProcess;
  153380. /**
  153381. * Deletes all diffusion profiles.
  153382. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  153383. */
  153384. clearAllDiffusionProfiles(): void;
  153385. /**
  153386. * Disposes this object
  153387. */
  153388. dispose(): void;
  153389. /**
  153390. * @hidden
  153391. * https://zero-radiance.github.io/post/sampling-diffusion/
  153392. *
  153393. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  153394. * ------------------------------------------------------------------------------------
  153395. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  153396. * PDF[r, phi, s] = r * R[r, phi, s]
  153397. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  153398. * ------------------------------------------------------------------------------------
  153399. * We importance sample the color channel with the widest scattering distance.
  153400. */
  153401. getDiffusionProfileParameters(color: Color3): number;
  153402. /**
  153403. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  153404. * 'u' is the random number (the value of the CDF): [0, 1).
  153405. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  153406. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  153407. */
  153408. private _sampleBurleyDiffusionProfile;
  153409. }
  153410. }
  153411. declare module BABYLON {
  153412. interface AbstractScene {
  153413. /** @hidden (Backing field) */
  153414. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153415. /**
  153416. * Gets or Sets the current prepass renderer associated to the scene.
  153417. */
  153418. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153419. /**
  153420. * Enables the subsurface effect for prepass
  153421. * @returns the SubSurfaceConfiguration
  153422. */
  153423. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  153424. /**
  153425. * Disables the subsurface effect for prepass
  153426. */
  153427. disableSubSurfaceForPrePass(): void;
  153428. }
  153429. /**
  153430. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153431. * in several rendering techniques.
  153432. */
  153433. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  153434. /**
  153435. * The component name helpful to identify the component in the list of scene components.
  153436. */
  153437. readonly name: string;
  153438. /**
  153439. * The scene the component belongs to.
  153440. */
  153441. scene: Scene;
  153442. /**
  153443. * Creates a new instance of the component for the given scene
  153444. * @param scene Defines the scene to register the component in
  153445. */
  153446. constructor(scene: Scene);
  153447. /**
  153448. * Registers the component in a given scene
  153449. */
  153450. register(): void;
  153451. /**
  153452. * Serializes the component data to the specified json object
  153453. * @param serializationObject The object to serialize to
  153454. */
  153455. serialize(serializationObject: any): void;
  153456. /**
  153457. * Adds all the elements from the container to the scene
  153458. * @param container the container holding the elements
  153459. */
  153460. addFromContainer(container: AbstractScene): void;
  153461. /**
  153462. * Removes all the elements in the container from the scene
  153463. * @param container contains the elements to remove
  153464. * @param dispose if the removed element should be disposed (default: false)
  153465. */
  153466. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  153467. /**
  153468. * Rebuilds the elements related to this component in case of
  153469. * context lost for instance.
  153470. */
  153471. rebuild(): void;
  153472. /**
  153473. * Disposes the component and the associated ressources
  153474. */
  153475. dispose(): void;
  153476. }
  153477. }
  153478. declare module BABYLON {
  153479. /** @hidden */
  153480. export var outlinePixelShader: {
  153481. name: string;
  153482. shader: string;
  153483. };
  153484. }
  153485. declare module BABYLON {
  153486. /** @hidden */
  153487. export var outlineVertexShader: {
  153488. name: string;
  153489. shader: string;
  153490. };
  153491. }
  153492. declare module BABYLON {
  153493. interface Scene {
  153494. /** @hidden */
  153495. _outlineRenderer: OutlineRenderer;
  153496. /**
  153497. * Gets the outline renderer associated with the scene
  153498. * @returns a OutlineRenderer
  153499. */
  153500. getOutlineRenderer(): OutlineRenderer;
  153501. }
  153502. interface AbstractMesh {
  153503. /** @hidden (Backing field) */
  153504. _renderOutline: boolean;
  153505. /**
  153506. * Gets or sets a boolean indicating if the outline must be rendered as well
  153507. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  153508. */
  153509. renderOutline: boolean;
  153510. /** @hidden (Backing field) */
  153511. _renderOverlay: boolean;
  153512. /**
  153513. * Gets or sets a boolean indicating if the overlay must be rendered as well
  153514. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  153515. */
  153516. renderOverlay: boolean;
  153517. }
  153518. /**
  153519. * This class is responsible to draw bothe outline/overlay of meshes.
  153520. * It should not be used directly but through the available method on mesh.
  153521. */
  153522. export class OutlineRenderer implements ISceneComponent {
  153523. /**
  153524. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  153525. */
  153526. private static _StencilReference;
  153527. /**
  153528. * The name of the component. Each component must have a unique name.
  153529. */
  153530. name: string;
  153531. /**
  153532. * The scene the component belongs to.
  153533. */
  153534. scene: Scene;
  153535. /**
  153536. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  153537. */
  153538. zOffset: number;
  153539. private _engine;
  153540. private _effect;
  153541. private _cachedDefines;
  153542. private _savedDepthWrite;
  153543. /**
  153544. * Instantiates a new outline renderer. (There could be only one per scene).
  153545. * @param scene Defines the scene it belongs to
  153546. */
  153547. constructor(scene: Scene);
  153548. /**
  153549. * Register the component to one instance of a scene.
  153550. */
  153551. register(): void;
  153552. /**
  153553. * Rebuilds the elements related to this component in case of
  153554. * context lost for instance.
  153555. */
  153556. rebuild(): void;
  153557. /**
  153558. * Disposes the component and the associated ressources.
  153559. */
  153560. dispose(): void;
  153561. /**
  153562. * Renders the outline in the canvas.
  153563. * @param subMesh Defines the sumesh to render
  153564. * @param batch Defines the batch of meshes in case of instances
  153565. * @param useOverlay Defines if the rendering is for the overlay or the outline
  153566. */
  153567. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  153568. /**
  153569. * Returns whether or not the outline renderer is ready for a given submesh.
  153570. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  153571. * @param subMesh Defines the submesh to check readyness for
  153572. * @param useInstances Defines wheter wee are trying to render instances or not
  153573. * @returns true if ready otherwise false
  153574. */
  153575. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  153576. private _beforeRenderingMesh;
  153577. private _afterRenderingMesh;
  153578. }
  153579. }
  153580. declare module BABYLON {
  153581. /**
  153582. * Defines the basic options interface of a Sprite Frame Source Size.
  153583. */
  153584. export interface ISpriteJSONSpriteSourceSize {
  153585. /**
  153586. * number of the original width of the Frame
  153587. */
  153588. w: number;
  153589. /**
  153590. * number of the original height of the Frame
  153591. */
  153592. h: number;
  153593. }
  153594. /**
  153595. * Defines the basic options interface of a Sprite Frame Data.
  153596. */
  153597. export interface ISpriteJSONSpriteFrameData {
  153598. /**
  153599. * number of the x offset of the Frame
  153600. */
  153601. x: number;
  153602. /**
  153603. * number of the y offset of the Frame
  153604. */
  153605. y: number;
  153606. /**
  153607. * number of the width of the Frame
  153608. */
  153609. w: number;
  153610. /**
  153611. * number of the height of the Frame
  153612. */
  153613. h: number;
  153614. }
  153615. /**
  153616. * Defines the basic options interface of a JSON Sprite.
  153617. */
  153618. export interface ISpriteJSONSprite {
  153619. /**
  153620. * string name of the Frame
  153621. */
  153622. filename: string;
  153623. /**
  153624. * ISpriteJSONSpriteFrame basic object of the frame data
  153625. */
  153626. frame: ISpriteJSONSpriteFrameData;
  153627. /**
  153628. * boolean to flag is the frame was rotated.
  153629. */
  153630. rotated: boolean;
  153631. /**
  153632. * boolean to flag is the frame was trimmed.
  153633. */
  153634. trimmed: boolean;
  153635. /**
  153636. * ISpriteJSONSpriteFrame basic object of the source data
  153637. */
  153638. spriteSourceSize: ISpriteJSONSpriteFrameData;
  153639. /**
  153640. * ISpriteJSONSpriteFrame basic object of the source data
  153641. */
  153642. sourceSize: ISpriteJSONSpriteSourceSize;
  153643. }
  153644. /**
  153645. * Defines the basic options interface of a JSON atlas.
  153646. */
  153647. export interface ISpriteJSONAtlas {
  153648. /**
  153649. * Array of objects that contain the frame data.
  153650. */
  153651. frames: Array<ISpriteJSONSprite>;
  153652. /**
  153653. * object basic object containing the sprite meta data.
  153654. */
  153655. meta?: object;
  153656. }
  153657. }
  153658. declare module BABYLON {
  153659. /** @hidden */
  153660. export var spriteMapPixelShader: {
  153661. name: string;
  153662. shader: string;
  153663. };
  153664. }
  153665. declare module BABYLON {
  153666. /** @hidden */
  153667. export var spriteMapVertexShader: {
  153668. name: string;
  153669. shader: string;
  153670. };
  153671. }
  153672. declare module BABYLON {
  153673. /**
  153674. * Defines the basic options interface of a SpriteMap
  153675. */
  153676. export interface ISpriteMapOptions {
  153677. /**
  153678. * Vector2 of the number of cells in the grid.
  153679. */
  153680. stageSize?: Vector2;
  153681. /**
  153682. * Vector2 of the size of the output plane in World Units.
  153683. */
  153684. outputSize?: Vector2;
  153685. /**
  153686. * Vector3 of the position of the output plane in World Units.
  153687. */
  153688. outputPosition?: Vector3;
  153689. /**
  153690. * Vector3 of the rotation of the output plane.
  153691. */
  153692. outputRotation?: Vector3;
  153693. /**
  153694. * number of layers that the system will reserve in resources.
  153695. */
  153696. layerCount?: number;
  153697. /**
  153698. * number of max animation frames a single cell will reserve in resources.
  153699. */
  153700. maxAnimationFrames?: number;
  153701. /**
  153702. * number cell index of the base tile when the system compiles.
  153703. */
  153704. baseTile?: number;
  153705. /**
  153706. * boolean flip the sprite after its been repositioned by the framing data.
  153707. */
  153708. flipU?: boolean;
  153709. /**
  153710. * Vector3 scalar of the global RGB values of the SpriteMap.
  153711. */
  153712. colorMultiply?: Vector3;
  153713. }
  153714. /**
  153715. * Defines the IDisposable interface in order to be cleanable from resources.
  153716. */
  153717. export interface ISpriteMap extends IDisposable {
  153718. /**
  153719. * String name of the SpriteMap.
  153720. */
  153721. name: string;
  153722. /**
  153723. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153724. */
  153725. atlasJSON: ISpriteJSONAtlas;
  153726. /**
  153727. * Texture of the SpriteMap.
  153728. */
  153729. spriteSheet: Texture;
  153730. /**
  153731. * The parameters to initialize the SpriteMap with.
  153732. */
  153733. options: ISpriteMapOptions;
  153734. }
  153735. /**
  153736. * Class used to manage a grid restricted sprite deployment on an Output plane.
  153737. */
  153738. export class SpriteMap implements ISpriteMap {
  153739. /** The Name of the spriteMap */
  153740. name: string;
  153741. /** The JSON file with the frame and meta data */
  153742. atlasJSON: ISpriteJSONAtlas;
  153743. /** The systems Sprite Sheet Texture */
  153744. spriteSheet: Texture;
  153745. /** Arguments passed with the Constructor */
  153746. options: ISpriteMapOptions;
  153747. /** Public Sprite Storage array, parsed from atlasJSON */
  153748. sprites: Array<ISpriteJSONSprite>;
  153749. /** Returns the Number of Sprites in the System */
  153750. get spriteCount(): number;
  153751. /** Returns the Position of Output Plane*/
  153752. get position(): Vector3;
  153753. /** Returns the Position of Output Plane*/
  153754. set position(v: Vector3);
  153755. /** Returns the Rotation of Output Plane*/
  153756. get rotation(): Vector3;
  153757. /** Returns the Rotation of Output Plane*/
  153758. set rotation(v: Vector3);
  153759. /** Sets the AnimationMap*/
  153760. get animationMap(): RawTexture;
  153761. /** Sets the AnimationMap*/
  153762. set animationMap(v: RawTexture);
  153763. /** Scene that the SpriteMap was created in */
  153764. private _scene;
  153765. /** Texture Buffer of Float32 that holds tile frame data*/
  153766. private _frameMap;
  153767. /** Texture Buffers of Float32 that holds tileMap data*/
  153768. private _tileMaps;
  153769. /** Texture Buffer of Float32 that holds Animation Data*/
  153770. private _animationMap;
  153771. /** Custom ShaderMaterial Central to the System*/
  153772. private _material;
  153773. /** Custom ShaderMaterial Central to the System*/
  153774. private _output;
  153775. /** Systems Time Ticker*/
  153776. private _time;
  153777. /**
  153778. * Creates a new SpriteMap
  153779. * @param name defines the SpriteMaps Name
  153780. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  153781. * @param spriteSheet is the Texture that the Sprites are on.
  153782. * @param options a basic deployment configuration
  153783. * @param scene The Scene that the map is deployed on
  153784. */
  153785. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  153786. /**
  153787. * Returns tileID location
  153788. * @returns Vector2 the cell position ID
  153789. */
  153790. getTileID(): Vector2;
  153791. /**
  153792. * Gets the UV location of the mouse over the SpriteMap.
  153793. * @returns Vector2 the UV position of the mouse interaction
  153794. */
  153795. getMousePosition(): Vector2;
  153796. /**
  153797. * Creates the "frame" texture Buffer
  153798. * -------------------------------------
  153799. * Structure of frames
  153800. * "filename": "Falling-Water-2.png",
  153801. * "frame": {"x":69,"y":103,"w":24,"h":32},
  153802. * "rotated": true,
  153803. * "trimmed": true,
  153804. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  153805. * "sourceSize": {"w":32,"h":32}
  153806. * @returns RawTexture of the frameMap
  153807. */
  153808. private _createFrameBuffer;
  153809. /**
  153810. * Creates the tileMap texture Buffer
  153811. * @param buffer normally and array of numbers, or a false to generate from scratch
  153812. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153813. * @returns RawTexture of the tileMap
  153814. */
  153815. private _createTileBuffer;
  153816. /**
  153817. * Modifies the data of the tileMaps
  153818. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153819. * @param pos is the iVector2 Coordinates of the Tile
  153820. * @param tile The SpriteIndex of the new Tile
  153821. */
  153822. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153823. /**
  153824. * Creates the animationMap texture Buffer
  153825. * @param buffer normally and array of numbers, or a false to generate from scratch
  153826. * @returns RawTexture of the animationMap
  153827. */
  153828. private _createTileAnimationBuffer;
  153829. /**
  153830. * Modifies the data of the animationMap
  153831. * @param cellID is the Index of the Sprite
  153832. * @param _frame is the target Animation frame
  153833. * @param toCell is the Target Index of the next frame of the animation
  153834. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153835. * @param speed is a global scalar of the time variable on the map.
  153836. */
  153837. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153838. /**
  153839. * Exports the .tilemaps file
  153840. */
  153841. saveTileMaps(): void;
  153842. /**
  153843. * Imports the .tilemaps file
  153844. * @param url of the .tilemaps file
  153845. */
  153846. loadTileMaps(url: string): void;
  153847. /**
  153848. * Release associated resources
  153849. */
  153850. dispose(): void;
  153851. }
  153852. }
  153853. declare module BABYLON {
  153854. /**
  153855. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153856. * @see https://doc.babylonjs.com/babylon101/sprites
  153857. */
  153858. export class SpritePackedManager extends SpriteManager {
  153859. /** defines the packed manager's name */
  153860. name: string;
  153861. /**
  153862. * Creates a new sprite manager from a packed sprite sheet
  153863. * @param name defines the manager's name
  153864. * @param imgUrl defines the sprite sheet url
  153865. * @param capacity defines the maximum allowed number of sprites
  153866. * @param scene defines the hosting scene
  153867. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153868. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153869. * @param samplingMode defines the smapling mode to use with spritesheet
  153870. * @param fromPacked set to true; do not alter
  153871. */
  153872. constructor(
  153873. /** defines the packed manager's name */
  153874. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153875. }
  153876. }
  153877. declare module BABYLON {
  153878. /**
  153879. * Defines the list of states available for a task inside a AssetsManager
  153880. */
  153881. export enum AssetTaskState {
  153882. /**
  153883. * Initialization
  153884. */
  153885. INIT = 0,
  153886. /**
  153887. * Running
  153888. */
  153889. RUNNING = 1,
  153890. /**
  153891. * Done
  153892. */
  153893. DONE = 2,
  153894. /**
  153895. * Error
  153896. */
  153897. ERROR = 3
  153898. }
  153899. /**
  153900. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153901. */
  153902. export abstract class AbstractAssetTask {
  153903. /**
  153904. * Task name
  153905. */ name: string;
  153906. /**
  153907. * Callback called when the task is successful
  153908. */
  153909. onSuccess: (task: any) => void;
  153910. /**
  153911. * Callback called when the task is not successful
  153912. */
  153913. onError: (task: any, message?: string, exception?: any) => void;
  153914. /**
  153915. * Creates a new AssetsManager
  153916. * @param name defines the name of the task
  153917. */
  153918. constructor(
  153919. /**
  153920. * Task name
  153921. */ name: string);
  153922. private _isCompleted;
  153923. private _taskState;
  153924. private _errorObject;
  153925. /**
  153926. * Get if the task is completed
  153927. */
  153928. get isCompleted(): boolean;
  153929. /**
  153930. * Gets the current state of the task
  153931. */
  153932. get taskState(): AssetTaskState;
  153933. /**
  153934. * Gets the current error object (if task is in error)
  153935. */
  153936. get errorObject(): {
  153937. message?: string;
  153938. exception?: any;
  153939. };
  153940. /**
  153941. * Internal only
  153942. * @hidden
  153943. */
  153944. _setErrorObject(message?: string, exception?: any): void;
  153945. /**
  153946. * Execute the current task
  153947. * @param scene defines the scene where you want your assets to be loaded
  153948. * @param onSuccess is a callback called when the task is successfully executed
  153949. * @param onError is a callback called if an error occurs
  153950. */
  153951. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153952. /**
  153953. * Execute the current task
  153954. * @param scene defines the scene where you want your assets to be loaded
  153955. * @param onSuccess is a callback called when the task is successfully executed
  153956. * @param onError is a callback called if an error occurs
  153957. */
  153958. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153959. /**
  153960. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153961. * This can be used with failed tasks that have the reason for failure fixed.
  153962. */
  153963. reset(): void;
  153964. private onErrorCallback;
  153965. private onDoneCallback;
  153966. }
  153967. /**
  153968. * Define the interface used by progress events raised during assets loading
  153969. */
  153970. export interface IAssetsProgressEvent {
  153971. /**
  153972. * Defines the number of remaining tasks to process
  153973. */
  153974. remainingCount: number;
  153975. /**
  153976. * Defines the total number of tasks
  153977. */
  153978. totalCount: number;
  153979. /**
  153980. * Defines the task that was just processed
  153981. */
  153982. task: AbstractAssetTask;
  153983. }
  153984. /**
  153985. * Class used to share progress information about assets loading
  153986. */
  153987. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153988. /**
  153989. * Defines the number of remaining tasks to process
  153990. */
  153991. remainingCount: number;
  153992. /**
  153993. * Defines the total number of tasks
  153994. */
  153995. totalCount: number;
  153996. /**
  153997. * Defines the task that was just processed
  153998. */
  153999. task: AbstractAssetTask;
  154000. /**
  154001. * Creates a AssetsProgressEvent
  154002. * @param remainingCount defines the number of remaining tasks to process
  154003. * @param totalCount defines the total number of tasks
  154004. * @param task defines the task that was just processed
  154005. */
  154006. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  154007. }
  154008. /**
  154009. * Define a task used by AssetsManager to load assets into a container
  154010. */
  154011. export class ContainerAssetTask extends AbstractAssetTask {
  154012. /**
  154013. * Defines the name of the task
  154014. */
  154015. name: string;
  154016. /**
  154017. * Defines the list of mesh's names you want to load
  154018. */
  154019. meshesNames: any;
  154020. /**
  154021. * Defines the root url to use as a base to load your meshes and associated resources
  154022. */
  154023. rootUrl: string;
  154024. /**
  154025. * Defines the filename or File of the scene to load from
  154026. */
  154027. sceneFilename: string | File;
  154028. /**
  154029. * Get the loaded asset container
  154030. */
  154031. loadedContainer: AssetContainer;
  154032. /**
  154033. * Gets the list of loaded meshes
  154034. */
  154035. loadedMeshes: Array<AbstractMesh>;
  154036. /**
  154037. * Gets the list of loaded particle systems
  154038. */
  154039. loadedParticleSystems: Array<IParticleSystem>;
  154040. /**
  154041. * Gets the list of loaded skeletons
  154042. */
  154043. loadedSkeletons: Array<Skeleton>;
  154044. /**
  154045. * Gets the list of loaded animation groups
  154046. */
  154047. loadedAnimationGroups: Array<AnimationGroup>;
  154048. /**
  154049. * Callback called when the task is successful
  154050. */
  154051. onSuccess: (task: ContainerAssetTask) => void;
  154052. /**
  154053. * Callback called when the task is successful
  154054. */
  154055. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  154056. /**
  154057. * Creates a new ContainerAssetTask
  154058. * @param name defines the name of the task
  154059. * @param meshesNames defines the list of mesh's names you want to load
  154060. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154061. * @param sceneFilename defines the filename or File of the scene to load from
  154062. */
  154063. constructor(
  154064. /**
  154065. * Defines the name of the task
  154066. */
  154067. name: string,
  154068. /**
  154069. * Defines the list of mesh's names you want to load
  154070. */
  154071. meshesNames: any,
  154072. /**
  154073. * Defines the root url to use as a base to load your meshes and associated resources
  154074. */
  154075. rootUrl: string,
  154076. /**
  154077. * Defines the filename or File of the scene to load from
  154078. */
  154079. sceneFilename: string | File);
  154080. /**
  154081. * Execute the current task
  154082. * @param scene defines the scene where you want your assets to be loaded
  154083. * @param onSuccess is a callback called when the task is successfully executed
  154084. * @param onError is a callback called if an error occurs
  154085. */
  154086. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154087. }
  154088. /**
  154089. * Define a task used by AssetsManager to load meshes
  154090. */
  154091. export class MeshAssetTask extends AbstractAssetTask {
  154092. /**
  154093. * Defines the name of the task
  154094. */
  154095. name: string;
  154096. /**
  154097. * Defines the list of mesh's names you want to load
  154098. */
  154099. meshesNames: any;
  154100. /**
  154101. * Defines the root url to use as a base to load your meshes and associated resources
  154102. */
  154103. rootUrl: string;
  154104. /**
  154105. * Defines the filename or File of the scene to load from
  154106. */
  154107. sceneFilename: string | File;
  154108. /**
  154109. * Gets the list of loaded meshes
  154110. */
  154111. loadedMeshes: Array<AbstractMesh>;
  154112. /**
  154113. * Gets the list of loaded particle systems
  154114. */
  154115. loadedParticleSystems: Array<IParticleSystem>;
  154116. /**
  154117. * Gets the list of loaded skeletons
  154118. */
  154119. loadedSkeletons: Array<Skeleton>;
  154120. /**
  154121. * Gets the list of loaded animation groups
  154122. */
  154123. loadedAnimationGroups: Array<AnimationGroup>;
  154124. /**
  154125. * Callback called when the task is successful
  154126. */
  154127. onSuccess: (task: MeshAssetTask) => void;
  154128. /**
  154129. * Callback called when the task is successful
  154130. */
  154131. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  154132. /**
  154133. * Creates a new MeshAssetTask
  154134. * @param name defines the name of the task
  154135. * @param meshesNames defines the list of mesh's names you want to load
  154136. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154137. * @param sceneFilename defines the filename or File of the scene to load from
  154138. */
  154139. constructor(
  154140. /**
  154141. * Defines the name of the task
  154142. */
  154143. name: string,
  154144. /**
  154145. * Defines the list of mesh's names you want to load
  154146. */
  154147. meshesNames: any,
  154148. /**
  154149. * Defines the root url to use as a base to load your meshes and associated resources
  154150. */
  154151. rootUrl: string,
  154152. /**
  154153. * Defines the filename or File of the scene to load from
  154154. */
  154155. sceneFilename: string | File);
  154156. /**
  154157. * Execute the current task
  154158. * @param scene defines the scene where you want your assets to be loaded
  154159. * @param onSuccess is a callback called when the task is successfully executed
  154160. * @param onError is a callback called if an error occurs
  154161. */
  154162. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154163. }
  154164. /**
  154165. * Define a task used by AssetsManager to load text content
  154166. */
  154167. export class TextFileAssetTask extends AbstractAssetTask {
  154168. /**
  154169. * Defines the name of the task
  154170. */
  154171. name: string;
  154172. /**
  154173. * Defines the location of the file to load
  154174. */
  154175. url: string;
  154176. /**
  154177. * Gets the loaded text string
  154178. */
  154179. text: string;
  154180. /**
  154181. * Callback called when the task is successful
  154182. */
  154183. onSuccess: (task: TextFileAssetTask) => void;
  154184. /**
  154185. * Callback called when the task is successful
  154186. */
  154187. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  154188. /**
  154189. * Creates a new TextFileAssetTask object
  154190. * @param name defines the name of the task
  154191. * @param url defines the location of the file to load
  154192. */
  154193. constructor(
  154194. /**
  154195. * Defines the name of the task
  154196. */
  154197. name: string,
  154198. /**
  154199. * Defines the location of the file to load
  154200. */
  154201. url: string);
  154202. /**
  154203. * Execute the current task
  154204. * @param scene defines the scene where you want your assets to be loaded
  154205. * @param onSuccess is a callback called when the task is successfully executed
  154206. * @param onError is a callback called if an error occurs
  154207. */
  154208. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154209. }
  154210. /**
  154211. * Define a task used by AssetsManager to load binary data
  154212. */
  154213. export class BinaryFileAssetTask extends AbstractAssetTask {
  154214. /**
  154215. * Defines the name of the task
  154216. */
  154217. name: string;
  154218. /**
  154219. * Defines the location of the file to load
  154220. */
  154221. url: string;
  154222. /**
  154223. * Gets the lodaded data (as an array buffer)
  154224. */
  154225. data: ArrayBuffer;
  154226. /**
  154227. * Callback called when the task is successful
  154228. */
  154229. onSuccess: (task: BinaryFileAssetTask) => void;
  154230. /**
  154231. * Callback called when the task is successful
  154232. */
  154233. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  154234. /**
  154235. * Creates a new BinaryFileAssetTask object
  154236. * @param name defines the name of the new task
  154237. * @param url defines the location of the file to load
  154238. */
  154239. constructor(
  154240. /**
  154241. * Defines the name of the task
  154242. */
  154243. name: string,
  154244. /**
  154245. * Defines the location of the file to load
  154246. */
  154247. url: string);
  154248. /**
  154249. * Execute the current task
  154250. * @param scene defines the scene where you want your assets to be loaded
  154251. * @param onSuccess is a callback called when the task is successfully executed
  154252. * @param onError is a callback called if an error occurs
  154253. */
  154254. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154255. }
  154256. /**
  154257. * Define a task used by AssetsManager to load images
  154258. */
  154259. export class ImageAssetTask extends AbstractAssetTask {
  154260. /**
  154261. * Defines the name of the task
  154262. */
  154263. name: string;
  154264. /**
  154265. * Defines the location of the image to load
  154266. */
  154267. url: string;
  154268. /**
  154269. * Gets the loaded images
  154270. */
  154271. image: HTMLImageElement;
  154272. /**
  154273. * Callback called when the task is successful
  154274. */
  154275. onSuccess: (task: ImageAssetTask) => void;
  154276. /**
  154277. * Callback called when the task is successful
  154278. */
  154279. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  154280. /**
  154281. * Creates a new ImageAssetTask
  154282. * @param name defines the name of the task
  154283. * @param url defines the location of the image to load
  154284. */
  154285. constructor(
  154286. /**
  154287. * Defines the name of the task
  154288. */
  154289. name: string,
  154290. /**
  154291. * Defines the location of the image to load
  154292. */
  154293. url: string);
  154294. /**
  154295. * Execute the current task
  154296. * @param scene defines the scene where you want your assets to be loaded
  154297. * @param onSuccess is a callback called when the task is successfully executed
  154298. * @param onError is a callback called if an error occurs
  154299. */
  154300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154301. }
  154302. /**
  154303. * Defines the interface used by texture loading tasks
  154304. */
  154305. export interface ITextureAssetTask<TEX extends BaseTexture> {
  154306. /**
  154307. * Gets the loaded texture
  154308. */
  154309. texture: TEX;
  154310. }
  154311. /**
  154312. * Define a task used by AssetsManager to load 2D textures
  154313. */
  154314. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  154315. /**
  154316. * Defines the name of the task
  154317. */
  154318. name: string;
  154319. /**
  154320. * Defines the location of the file to load
  154321. */
  154322. url: string;
  154323. /**
  154324. * Defines if mipmap should not be generated (default is false)
  154325. */
  154326. noMipmap?: boolean | undefined;
  154327. /**
  154328. * Defines if texture must be inverted on Y axis (default is true)
  154329. */
  154330. invertY: boolean;
  154331. /**
  154332. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154333. */
  154334. samplingMode: number;
  154335. /**
  154336. * Gets the loaded texture
  154337. */
  154338. texture: Texture;
  154339. /**
  154340. * Callback called when the task is successful
  154341. */
  154342. onSuccess: (task: TextureAssetTask) => void;
  154343. /**
  154344. * Callback called when the task is successful
  154345. */
  154346. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  154347. /**
  154348. * Creates a new TextureAssetTask object
  154349. * @param name defines the name of the task
  154350. * @param url defines the location of the file to load
  154351. * @param noMipmap defines if mipmap should not be generated (default is false)
  154352. * @param invertY defines if texture must be inverted on Y axis (default is true)
  154353. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154354. */
  154355. constructor(
  154356. /**
  154357. * Defines the name of the task
  154358. */
  154359. name: string,
  154360. /**
  154361. * Defines the location of the file to load
  154362. */
  154363. url: string,
  154364. /**
  154365. * Defines if mipmap should not be generated (default is false)
  154366. */
  154367. noMipmap?: boolean | undefined,
  154368. /**
  154369. * Defines if texture must be inverted on Y axis (default is true)
  154370. */
  154371. invertY?: boolean,
  154372. /**
  154373. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154374. */
  154375. samplingMode?: number);
  154376. /**
  154377. * Execute the current task
  154378. * @param scene defines the scene where you want your assets to be loaded
  154379. * @param onSuccess is a callback called when the task is successfully executed
  154380. * @param onError is a callback called if an error occurs
  154381. */
  154382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154383. }
  154384. /**
  154385. * Define a task used by AssetsManager to load cube textures
  154386. */
  154387. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  154388. /**
  154389. * Defines the name of the task
  154390. */
  154391. name: string;
  154392. /**
  154393. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154394. */
  154395. url: string;
  154396. /**
  154397. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154398. */
  154399. extensions?: string[] | undefined;
  154400. /**
  154401. * Defines if mipmaps should not be generated (default is false)
  154402. */
  154403. noMipmap?: boolean | undefined;
  154404. /**
  154405. * Defines the explicit list of files (undefined by default)
  154406. */
  154407. files?: string[] | undefined;
  154408. /**
  154409. * Gets the loaded texture
  154410. */
  154411. texture: CubeTexture;
  154412. /**
  154413. * Callback called when the task is successful
  154414. */
  154415. onSuccess: (task: CubeTextureAssetTask) => void;
  154416. /**
  154417. * Callback called when the task is successful
  154418. */
  154419. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  154420. /**
  154421. * Creates a new CubeTextureAssetTask
  154422. * @param name defines the name of the task
  154423. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154424. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154425. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154426. * @param files defines the explicit list of files (undefined by default)
  154427. */
  154428. constructor(
  154429. /**
  154430. * Defines the name of the task
  154431. */
  154432. name: string,
  154433. /**
  154434. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154435. */
  154436. url: string,
  154437. /**
  154438. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154439. */
  154440. extensions?: string[] | undefined,
  154441. /**
  154442. * Defines if mipmaps should not be generated (default is false)
  154443. */
  154444. noMipmap?: boolean | undefined,
  154445. /**
  154446. * Defines the explicit list of files (undefined by default)
  154447. */
  154448. files?: string[] | undefined);
  154449. /**
  154450. * Execute the current task
  154451. * @param scene defines the scene where you want your assets to be loaded
  154452. * @param onSuccess is a callback called when the task is successfully executed
  154453. * @param onError is a callback called if an error occurs
  154454. */
  154455. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154456. }
  154457. /**
  154458. * Define a task used by AssetsManager to load HDR cube textures
  154459. */
  154460. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  154461. /**
  154462. * Defines the name of the task
  154463. */
  154464. name: string;
  154465. /**
  154466. * Defines the location of the file to load
  154467. */
  154468. url: string;
  154469. /**
  154470. * Defines the desired size (the more it increases the longer the generation will be)
  154471. */
  154472. size: number;
  154473. /**
  154474. * Defines if mipmaps should not be generated (default is false)
  154475. */
  154476. noMipmap: boolean;
  154477. /**
  154478. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154479. */
  154480. generateHarmonics: boolean;
  154481. /**
  154482. * 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)
  154483. */
  154484. gammaSpace: boolean;
  154485. /**
  154486. * Internal Use Only
  154487. */
  154488. reserved: boolean;
  154489. /**
  154490. * Gets the loaded texture
  154491. */
  154492. texture: HDRCubeTexture;
  154493. /**
  154494. * Callback called when the task is successful
  154495. */
  154496. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  154497. /**
  154498. * Callback called when the task is successful
  154499. */
  154500. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  154501. /**
  154502. * Creates a new HDRCubeTextureAssetTask object
  154503. * @param name defines the name of the task
  154504. * @param url defines the location of the file to load
  154505. * @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.
  154506. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154507. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154508. * @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)
  154509. * @param reserved Internal use only
  154510. */
  154511. constructor(
  154512. /**
  154513. * Defines the name of the task
  154514. */
  154515. name: string,
  154516. /**
  154517. * Defines the location of the file to load
  154518. */
  154519. url: string,
  154520. /**
  154521. * Defines the desired size (the more it increases the longer the generation will be)
  154522. */
  154523. size: number,
  154524. /**
  154525. * Defines if mipmaps should not be generated (default is false)
  154526. */
  154527. noMipmap?: boolean,
  154528. /**
  154529. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154530. */
  154531. generateHarmonics?: boolean,
  154532. /**
  154533. * 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)
  154534. */
  154535. gammaSpace?: boolean,
  154536. /**
  154537. * Internal Use Only
  154538. */
  154539. reserved?: boolean);
  154540. /**
  154541. * Execute the current task
  154542. * @param scene defines the scene where you want your assets to be loaded
  154543. * @param onSuccess is a callback called when the task is successfully executed
  154544. * @param onError is a callback called if an error occurs
  154545. */
  154546. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154547. }
  154548. /**
  154549. * Define a task used by AssetsManager to load Equirectangular cube textures
  154550. */
  154551. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  154552. /**
  154553. * Defines the name of the task
  154554. */
  154555. name: string;
  154556. /**
  154557. * Defines the location of the file to load
  154558. */
  154559. url: string;
  154560. /**
  154561. * Defines the desired size (the more it increases the longer the generation will be)
  154562. */
  154563. size: number;
  154564. /**
  154565. * Defines if mipmaps should not be generated (default is false)
  154566. */
  154567. noMipmap: boolean;
  154568. /**
  154569. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154570. * but the standard material would require them in Gamma space) (default is true)
  154571. */
  154572. gammaSpace: boolean;
  154573. /**
  154574. * Gets the loaded texture
  154575. */
  154576. texture: EquiRectangularCubeTexture;
  154577. /**
  154578. * Callback called when the task is successful
  154579. */
  154580. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  154581. /**
  154582. * Callback called when the task is successful
  154583. */
  154584. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  154585. /**
  154586. * Creates a new EquiRectangularCubeTextureAssetTask object
  154587. * @param name defines the name of the task
  154588. * @param url defines the location of the file to load
  154589. * @param size defines the desired size (the more it increases the longer the generation will be)
  154590. * If the size is omitted this implies you are using a preprocessed cubemap.
  154591. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154592. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  154593. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  154594. * (default is true)
  154595. */
  154596. constructor(
  154597. /**
  154598. * Defines the name of the task
  154599. */
  154600. name: string,
  154601. /**
  154602. * Defines the location of the file to load
  154603. */
  154604. url: string,
  154605. /**
  154606. * Defines the desired size (the more it increases the longer the generation will be)
  154607. */
  154608. size: number,
  154609. /**
  154610. * Defines if mipmaps should not be generated (default is false)
  154611. */
  154612. noMipmap?: boolean,
  154613. /**
  154614. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154615. * but the standard material would require them in Gamma space) (default is true)
  154616. */
  154617. gammaSpace?: boolean);
  154618. /**
  154619. * Execute the current task
  154620. * @param scene defines the scene where you want your assets to be loaded
  154621. * @param onSuccess is a callback called when the task is successfully executed
  154622. * @param onError is a callback called if an error occurs
  154623. */
  154624. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154625. }
  154626. /**
  154627. * This class can be used to easily import assets into a scene
  154628. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  154629. */
  154630. export class AssetsManager {
  154631. private _scene;
  154632. private _isLoading;
  154633. protected _tasks: AbstractAssetTask[];
  154634. protected _waitingTasksCount: number;
  154635. protected _totalTasksCount: number;
  154636. /**
  154637. * Callback called when all tasks are processed
  154638. */
  154639. onFinish: (tasks: AbstractAssetTask[]) => void;
  154640. /**
  154641. * Callback called when a task is successful
  154642. */
  154643. onTaskSuccess: (task: AbstractAssetTask) => void;
  154644. /**
  154645. * Callback called when a task had an error
  154646. */
  154647. onTaskError: (task: AbstractAssetTask) => void;
  154648. /**
  154649. * Callback called when a task is done (whatever the result is)
  154650. */
  154651. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  154652. /**
  154653. * Observable called when all tasks are processed
  154654. */
  154655. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  154656. /**
  154657. * Observable called when a task had an error
  154658. */
  154659. onTaskErrorObservable: Observable<AbstractAssetTask>;
  154660. /**
  154661. * Observable called when all tasks were executed
  154662. */
  154663. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  154664. /**
  154665. * Observable called when a task is done (whatever the result is)
  154666. */
  154667. onProgressObservable: Observable<IAssetsProgressEvent>;
  154668. /**
  154669. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  154670. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  154671. */
  154672. useDefaultLoadingScreen: boolean;
  154673. /**
  154674. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  154675. * when all assets have been downloaded.
  154676. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  154677. */
  154678. autoHideLoadingUI: boolean;
  154679. /**
  154680. * Creates a new AssetsManager
  154681. * @param scene defines the scene to work on
  154682. */
  154683. constructor(scene: Scene);
  154684. /**
  154685. * Add a ContainerAssetTask to the list of active tasks
  154686. * @param taskName defines the name of the new task
  154687. * @param meshesNames defines the name of meshes to load
  154688. * @param rootUrl defines the root url to use to locate files
  154689. * @param sceneFilename defines the filename of the scene file
  154690. * @returns a new ContainerAssetTask object
  154691. */
  154692. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  154693. /**
  154694. * Add a MeshAssetTask to the list of active tasks
  154695. * @param taskName defines the name of the new task
  154696. * @param meshesNames defines the name of meshes to load
  154697. * @param rootUrl defines the root url to use to locate files
  154698. * @param sceneFilename defines the filename of the scene file
  154699. * @returns a new MeshAssetTask object
  154700. */
  154701. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  154702. /**
  154703. * Add a TextFileAssetTask to the list of active tasks
  154704. * @param taskName defines the name of the new task
  154705. * @param url defines the url of the file to load
  154706. * @returns a new TextFileAssetTask object
  154707. */
  154708. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  154709. /**
  154710. * Add a BinaryFileAssetTask to the list of active tasks
  154711. * @param taskName defines the name of the new task
  154712. * @param url defines the url of the file to load
  154713. * @returns a new BinaryFileAssetTask object
  154714. */
  154715. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  154716. /**
  154717. * Add a ImageAssetTask to the list of active tasks
  154718. * @param taskName defines the name of the new task
  154719. * @param url defines the url of the file to load
  154720. * @returns a new ImageAssetTask object
  154721. */
  154722. addImageTask(taskName: string, url: string): ImageAssetTask;
  154723. /**
  154724. * Add a TextureAssetTask to the list of active tasks
  154725. * @param taskName defines the name of the new task
  154726. * @param url defines the url of the file to load
  154727. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154728. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154729. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154730. * @returns a new TextureAssetTask object
  154731. */
  154732. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154733. /**
  154734. * Add a CubeTextureAssetTask to the list of active tasks
  154735. * @param taskName defines the name of the new task
  154736. * @param url defines the url of the file to load
  154737. * @param extensions defines the extension to use to load the cube map (can be null)
  154738. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154739. * @param files defines the list of files to load (can be null)
  154740. * @returns a new CubeTextureAssetTask object
  154741. */
  154742. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  154743. /**
  154744. *
  154745. * Add a HDRCubeTextureAssetTask to the list of active tasks
  154746. * @param taskName defines the name of the new task
  154747. * @param url defines the url of the file to load
  154748. * @param size defines the size you want for the cubemap (can be null)
  154749. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154750. * @param generateHarmonics defines if you want to automatically generate (true by default)
  154751. * @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)
  154752. * @param reserved Internal use only
  154753. * @returns a new HDRCubeTextureAssetTask object
  154754. */
  154755. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  154756. /**
  154757. *
  154758. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  154759. * @param taskName defines the name of the new task
  154760. * @param url defines the url of the file to load
  154761. * @param size defines the size you want for the cubemap (can be null)
  154762. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154763. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  154764. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  154765. * @returns a new EquiRectangularCubeTextureAssetTask object
  154766. */
  154767. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  154768. /**
  154769. * Remove a task from the assets manager.
  154770. * @param task the task to remove
  154771. */
  154772. removeTask(task: AbstractAssetTask): void;
  154773. private _decreaseWaitingTasksCount;
  154774. private _runTask;
  154775. /**
  154776. * Reset the AssetsManager and remove all tasks
  154777. * @return the current instance of the AssetsManager
  154778. */
  154779. reset(): AssetsManager;
  154780. /**
  154781. * Start the loading process
  154782. * @return the current instance of the AssetsManager
  154783. */
  154784. load(): AssetsManager;
  154785. /**
  154786. * Start the loading process as an async operation
  154787. * @return a promise returning the list of failed tasks
  154788. */
  154789. loadAsync(): Promise<void>;
  154790. }
  154791. }
  154792. declare module BABYLON {
  154793. /**
  154794. * Wrapper class for promise with external resolve and reject.
  154795. */
  154796. export class Deferred<T> {
  154797. /**
  154798. * The promise associated with this deferred object.
  154799. */
  154800. readonly promise: Promise<T>;
  154801. private _resolve;
  154802. private _reject;
  154803. /**
  154804. * The resolve method of the promise associated with this deferred object.
  154805. */
  154806. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  154807. /**
  154808. * The reject method of the promise associated with this deferred object.
  154809. */
  154810. get reject(): (reason?: any) => void;
  154811. /**
  154812. * Constructor for this deferred object.
  154813. */
  154814. constructor();
  154815. }
  154816. }
  154817. declare module BABYLON {
  154818. /**
  154819. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154820. */
  154821. export class MeshExploder {
  154822. private _centerMesh;
  154823. private _meshes;
  154824. private _meshesOrigins;
  154825. private _toCenterVectors;
  154826. private _scaledDirection;
  154827. private _newPosition;
  154828. private _centerPosition;
  154829. /**
  154830. * Explodes meshes from a center mesh.
  154831. * @param meshes The meshes to explode.
  154832. * @param centerMesh The mesh to be center of explosion.
  154833. */
  154834. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154835. private _setCenterMesh;
  154836. /**
  154837. * Get class name
  154838. * @returns "MeshExploder"
  154839. */
  154840. getClassName(): string;
  154841. /**
  154842. * "Exploded meshes"
  154843. * @returns Array of meshes with the centerMesh at index 0.
  154844. */
  154845. getMeshes(): Array<Mesh>;
  154846. /**
  154847. * Explodes meshes giving a specific direction
  154848. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154849. */
  154850. explode(direction?: number): void;
  154851. }
  154852. }
  154853. declare module BABYLON {
  154854. /**
  154855. * Class used to help managing file picking and drag'n'drop
  154856. */
  154857. export class FilesInput {
  154858. /**
  154859. * List of files ready to be loaded
  154860. */
  154861. static get FilesToLoad(): {
  154862. [key: string]: File;
  154863. };
  154864. /**
  154865. * Callback called when a file is processed
  154866. */
  154867. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154868. private _engine;
  154869. private _currentScene;
  154870. private _sceneLoadedCallback;
  154871. private _progressCallback;
  154872. private _additionalRenderLoopLogicCallback;
  154873. private _textureLoadingCallback;
  154874. private _startingProcessingFilesCallback;
  154875. private _onReloadCallback;
  154876. private _errorCallback;
  154877. private _elementToMonitor;
  154878. private _sceneFileToLoad;
  154879. private _filesToLoad;
  154880. /**
  154881. * Creates a new FilesInput
  154882. * @param engine defines the rendering engine
  154883. * @param scene defines the hosting scene
  154884. * @param sceneLoadedCallback callback called when scene is loaded
  154885. * @param progressCallback callback called to track progress
  154886. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154887. * @param textureLoadingCallback callback called when a texture is loading
  154888. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154889. * @param onReloadCallback callback called when a reload is requested
  154890. * @param errorCallback callback call if an error occurs
  154891. */
  154892. 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>);
  154893. private _dragEnterHandler;
  154894. private _dragOverHandler;
  154895. private _dropHandler;
  154896. /**
  154897. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154898. * @param elementToMonitor defines the DOM element to track
  154899. */
  154900. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154901. /** Gets the current list of files to load */
  154902. get filesToLoad(): File[];
  154903. /**
  154904. * Release all associated resources
  154905. */
  154906. dispose(): void;
  154907. private renderFunction;
  154908. private drag;
  154909. private drop;
  154910. private _traverseFolder;
  154911. private _processFiles;
  154912. /**
  154913. * Load files from a drop event
  154914. * @param event defines the drop event to use as source
  154915. */
  154916. loadFiles(event: any): void;
  154917. private _processReload;
  154918. /**
  154919. * Reload the current scene from the loaded files
  154920. */
  154921. reload(): void;
  154922. }
  154923. }
  154924. declare module BABYLON {
  154925. /**
  154926. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154927. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154928. */
  154929. export class SceneOptimization {
  154930. /**
  154931. * Defines the priority of this optimization (0 by default which means first in the list)
  154932. */
  154933. priority: number;
  154934. /**
  154935. * Gets a string describing the action executed by the current optimization
  154936. * @returns description string
  154937. */
  154938. getDescription(): string;
  154939. /**
  154940. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154941. * @param scene defines the current scene where to apply this optimization
  154942. * @param optimizer defines the current optimizer
  154943. * @returns true if everything that can be done was applied
  154944. */
  154945. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154946. /**
  154947. * Creates the SceneOptimization object
  154948. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154949. * @param desc defines the description associated with the optimization
  154950. */
  154951. constructor(
  154952. /**
  154953. * Defines the priority of this optimization (0 by default which means first in the list)
  154954. */
  154955. priority?: number);
  154956. }
  154957. /**
  154958. * Defines an optimization used to reduce the size of render target textures
  154959. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154960. */
  154961. export class TextureOptimization extends SceneOptimization {
  154962. /**
  154963. * Defines the priority of this optimization (0 by default which means first in the list)
  154964. */
  154965. priority: number;
  154966. /**
  154967. * 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
  154968. */
  154969. maximumSize: number;
  154970. /**
  154971. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154972. */
  154973. step: number;
  154974. /**
  154975. * Gets a string describing the action executed by the current optimization
  154976. * @returns description string
  154977. */
  154978. getDescription(): string;
  154979. /**
  154980. * Creates the TextureOptimization object
  154981. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154982. * @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
  154983. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154984. */
  154985. constructor(
  154986. /**
  154987. * Defines the priority of this optimization (0 by default which means first in the list)
  154988. */
  154989. priority?: number,
  154990. /**
  154991. * 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
  154992. */
  154993. maximumSize?: number,
  154994. /**
  154995. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154996. */
  154997. step?: number);
  154998. /**
  154999. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155000. * @param scene defines the current scene where to apply this optimization
  155001. * @param optimizer defines the current optimizer
  155002. * @returns true if everything that can be done was applied
  155003. */
  155004. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155005. }
  155006. /**
  155007. * Defines an optimization used to increase or decrease the rendering resolution
  155008. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155009. */
  155010. export class HardwareScalingOptimization extends SceneOptimization {
  155011. /**
  155012. * Defines the priority of this optimization (0 by default which means first in the list)
  155013. */
  155014. priority: number;
  155015. /**
  155016. * Defines the maximum scale to use (2 by default)
  155017. */
  155018. maximumScale: number;
  155019. /**
  155020. * Defines the step to use between two passes (0.5 by default)
  155021. */
  155022. step: number;
  155023. private _currentScale;
  155024. private _directionOffset;
  155025. /**
  155026. * Gets a string describing the action executed by the current optimization
  155027. * @return description string
  155028. */
  155029. getDescription(): string;
  155030. /**
  155031. * Creates the HardwareScalingOptimization object
  155032. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155033. * @param maximumScale defines the maximum scale to use (2 by default)
  155034. * @param step defines the step to use between two passes (0.5 by default)
  155035. */
  155036. constructor(
  155037. /**
  155038. * Defines the priority of this optimization (0 by default which means first in the list)
  155039. */
  155040. priority?: number,
  155041. /**
  155042. * Defines the maximum scale to use (2 by default)
  155043. */
  155044. maximumScale?: number,
  155045. /**
  155046. * Defines the step to use between two passes (0.5 by default)
  155047. */
  155048. step?: number);
  155049. /**
  155050. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155051. * @param scene defines the current scene where to apply this optimization
  155052. * @param optimizer defines the current optimizer
  155053. * @returns true if everything that can be done was applied
  155054. */
  155055. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155056. }
  155057. /**
  155058. * Defines an optimization used to remove shadows
  155059. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155060. */
  155061. export class ShadowsOptimization extends SceneOptimization {
  155062. /**
  155063. * Gets a string describing the action executed by the current optimization
  155064. * @return description string
  155065. */
  155066. getDescription(): string;
  155067. /**
  155068. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155069. * @param scene defines the current scene where to apply this optimization
  155070. * @param optimizer defines the current optimizer
  155071. * @returns true if everything that can be done was applied
  155072. */
  155073. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155074. }
  155075. /**
  155076. * Defines an optimization used to turn post-processes off
  155077. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155078. */
  155079. export class PostProcessesOptimization extends SceneOptimization {
  155080. /**
  155081. * Gets a string describing the action executed by the current optimization
  155082. * @return description string
  155083. */
  155084. getDescription(): string;
  155085. /**
  155086. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155087. * @param scene defines the current scene where to apply this optimization
  155088. * @param optimizer defines the current optimizer
  155089. * @returns true if everything that can be done was applied
  155090. */
  155091. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155092. }
  155093. /**
  155094. * Defines an optimization used to turn lens flares off
  155095. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155096. */
  155097. export class LensFlaresOptimization extends SceneOptimization {
  155098. /**
  155099. * Gets a string describing the action executed by the current optimization
  155100. * @return description string
  155101. */
  155102. getDescription(): string;
  155103. /**
  155104. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155105. * @param scene defines the current scene where to apply this optimization
  155106. * @param optimizer defines the current optimizer
  155107. * @returns true if everything that can be done was applied
  155108. */
  155109. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155110. }
  155111. /**
  155112. * Defines an optimization based on user defined callback.
  155113. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155114. */
  155115. export class CustomOptimization extends SceneOptimization {
  155116. /**
  155117. * Callback called to apply the custom optimization.
  155118. */
  155119. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  155120. /**
  155121. * Callback called to get custom description
  155122. */
  155123. onGetDescription: () => string;
  155124. /**
  155125. * Gets a string describing the action executed by the current optimization
  155126. * @returns description string
  155127. */
  155128. getDescription(): string;
  155129. /**
  155130. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155131. * @param scene defines the current scene where to apply this optimization
  155132. * @param optimizer defines the current optimizer
  155133. * @returns true if everything that can be done was applied
  155134. */
  155135. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155136. }
  155137. /**
  155138. * Defines an optimization used to turn particles off
  155139. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155140. */
  155141. export class ParticlesOptimization extends SceneOptimization {
  155142. /**
  155143. * Gets a string describing the action executed by the current optimization
  155144. * @return description string
  155145. */
  155146. getDescription(): string;
  155147. /**
  155148. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155149. * @param scene defines the current scene where to apply this optimization
  155150. * @param optimizer defines the current optimizer
  155151. * @returns true if everything that can be done was applied
  155152. */
  155153. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155154. }
  155155. /**
  155156. * Defines an optimization used to turn render targets off
  155157. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155158. */
  155159. export class RenderTargetsOptimization extends SceneOptimization {
  155160. /**
  155161. * Gets a string describing the action executed by the current optimization
  155162. * @return description string
  155163. */
  155164. getDescription(): string;
  155165. /**
  155166. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155167. * @param scene defines the current scene where to apply this optimization
  155168. * @param optimizer defines the current optimizer
  155169. * @returns true if everything that can be done was applied
  155170. */
  155171. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155172. }
  155173. /**
  155174. * Defines an optimization used to merge meshes with compatible materials
  155175. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155176. */
  155177. export class MergeMeshesOptimization extends SceneOptimization {
  155178. private static _UpdateSelectionTree;
  155179. /**
  155180. * Gets or sets a boolean which defines if optimization octree has to be updated
  155181. */
  155182. static get UpdateSelectionTree(): boolean;
  155183. /**
  155184. * Gets or sets a boolean which defines if optimization octree has to be updated
  155185. */
  155186. static set UpdateSelectionTree(value: boolean);
  155187. /**
  155188. * Gets a string describing the action executed by the current optimization
  155189. * @return description string
  155190. */
  155191. getDescription(): string;
  155192. private _canBeMerged;
  155193. /**
  155194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155195. * @param scene defines the current scene where to apply this optimization
  155196. * @param optimizer defines the current optimizer
  155197. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  155198. * @returns true if everything that can be done was applied
  155199. */
  155200. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  155201. }
  155202. /**
  155203. * Defines a list of options used by SceneOptimizer
  155204. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155205. */
  155206. export class SceneOptimizerOptions {
  155207. /**
  155208. * Defines the target frame rate to reach (60 by default)
  155209. */
  155210. targetFrameRate: number;
  155211. /**
  155212. * Defines the interval between two checkes (2000ms by default)
  155213. */
  155214. trackerDuration: number;
  155215. /**
  155216. * Gets the list of optimizations to apply
  155217. */
  155218. optimizations: SceneOptimization[];
  155219. /**
  155220. * Creates a new list of options used by SceneOptimizer
  155221. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  155222. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  155223. */
  155224. constructor(
  155225. /**
  155226. * Defines the target frame rate to reach (60 by default)
  155227. */
  155228. targetFrameRate?: number,
  155229. /**
  155230. * Defines the interval between two checkes (2000ms by default)
  155231. */
  155232. trackerDuration?: number);
  155233. /**
  155234. * Add a new optimization
  155235. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  155236. * @returns the current SceneOptimizerOptions
  155237. */
  155238. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  155239. /**
  155240. * Add a new custom optimization
  155241. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  155242. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  155243. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155244. * @returns the current SceneOptimizerOptions
  155245. */
  155246. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  155247. /**
  155248. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  155249. * @param targetFrameRate defines the target frame rate (60 by default)
  155250. * @returns a SceneOptimizerOptions object
  155251. */
  155252. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155253. /**
  155254. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  155255. * @param targetFrameRate defines the target frame rate (60 by default)
  155256. * @returns a SceneOptimizerOptions object
  155257. */
  155258. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155259. /**
  155260. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  155261. * @param targetFrameRate defines the target frame rate (60 by default)
  155262. * @returns a SceneOptimizerOptions object
  155263. */
  155264. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155265. }
  155266. /**
  155267. * Class used to run optimizations in order to reach a target frame rate
  155268. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155269. */
  155270. export class SceneOptimizer implements IDisposable {
  155271. private _isRunning;
  155272. private _options;
  155273. private _scene;
  155274. private _currentPriorityLevel;
  155275. private _targetFrameRate;
  155276. private _trackerDuration;
  155277. private _currentFrameRate;
  155278. private _sceneDisposeObserver;
  155279. private _improvementMode;
  155280. /**
  155281. * Defines an observable called when the optimizer reaches the target frame rate
  155282. */
  155283. onSuccessObservable: Observable<SceneOptimizer>;
  155284. /**
  155285. * Defines an observable called when the optimizer enables an optimization
  155286. */
  155287. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  155288. /**
  155289. * Defines an observable called when the optimizer is not able to reach the target frame rate
  155290. */
  155291. onFailureObservable: Observable<SceneOptimizer>;
  155292. /**
  155293. * Gets a boolean indicating if the optimizer is in improvement mode
  155294. */
  155295. get isInImprovementMode(): boolean;
  155296. /**
  155297. * Gets the current priority level (0 at start)
  155298. */
  155299. get currentPriorityLevel(): number;
  155300. /**
  155301. * Gets the current frame rate checked by the SceneOptimizer
  155302. */
  155303. get currentFrameRate(): number;
  155304. /**
  155305. * Gets or sets the current target frame rate (60 by default)
  155306. */
  155307. get targetFrameRate(): number;
  155308. /**
  155309. * Gets or sets the current target frame rate (60 by default)
  155310. */
  155311. set targetFrameRate(value: number);
  155312. /**
  155313. * Gets or sets the current interval between two checks (every 2000ms by default)
  155314. */
  155315. get trackerDuration(): number;
  155316. /**
  155317. * Gets or sets the current interval between two checks (every 2000ms by default)
  155318. */
  155319. set trackerDuration(value: number);
  155320. /**
  155321. * Gets the list of active optimizations
  155322. */
  155323. get optimizations(): SceneOptimization[];
  155324. /**
  155325. * Creates a new SceneOptimizer
  155326. * @param scene defines the scene to work on
  155327. * @param options defines the options to use with the SceneOptimizer
  155328. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  155329. * @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)
  155330. */
  155331. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  155332. /**
  155333. * Stops the current optimizer
  155334. */
  155335. stop(): void;
  155336. /**
  155337. * Reset the optimizer to initial step (current priority level = 0)
  155338. */
  155339. reset(): void;
  155340. /**
  155341. * Start the optimizer. By default it will try to reach a specific framerate
  155342. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  155343. */
  155344. start(): void;
  155345. private _checkCurrentState;
  155346. /**
  155347. * Release all resources
  155348. */
  155349. dispose(): void;
  155350. /**
  155351. * Helper function to create a SceneOptimizer with one single line of code
  155352. * @param scene defines the scene to work on
  155353. * @param options defines the options to use with the SceneOptimizer
  155354. * @param onSuccess defines a callback to call on success
  155355. * @param onFailure defines a callback to call on failure
  155356. * @returns the new SceneOptimizer object
  155357. */
  155358. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  155359. }
  155360. }
  155361. declare module BABYLON {
  155362. /**
  155363. * Class used to serialize a scene into a string
  155364. */
  155365. export class SceneSerializer {
  155366. /**
  155367. * Clear cache used by a previous serialization
  155368. */
  155369. static ClearCache(): void;
  155370. /**
  155371. * Serialize a scene into a JSON compatible object
  155372. * @param scene defines the scene to serialize
  155373. * @returns a JSON compatible object
  155374. */
  155375. static Serialize(scene: Scene): any;
  155376. /**
  155377. * Serialize a mesh into a JSON compatible object
  155378. * @param toSerialize defines the mesh to serialize
  155379. * @param withParents defines if parents must be serialized as well
  155380. * @param withChildren defines if children must be serialized as well
  155381. * @returns a JSON compatible object
  155382. */
  155383. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  155384. }
  155385. }
  155386. declare module BABYLON {
  155387. /**
  155388. * Class used to host texture specific utilities
  155389. */
  155390. export class TextureTools {
  155391. /**
  155392. * Uses the GPU to create a copy texture rescaled at a given size
  155393. * @param texture Texture to copy from
  155394. * @param width defines the desired width
  155395. * @param height defines the desired height
  155396. * @param useBilinearMode defines if bilinear mode has to be used
  155397. * @return the generated texture
  155398. */
  155399. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  155400. }
  155401. }
  155402. declare module BABYLON {
  155403. /**
  155404. * This represents the different options available for the video capture.
  155405. */
  155406. export interface VideoRecorderOptions {
  155407. /** Defines the mime type of the video. */
  155408. mimeType: string;
  155409. /** Defines the FPS the video should be recorded at. */
  155410. fps: number;
  155411. /** Defines the chunk size for the recording data. */
  155412. recordChunckSize: number;
  155413. /** The audio tracks to attach to the recording. */
  155414. audioTracks?: MediaStreamTrack[];
  155415. }
  155416. /**
  155417. * This can help with recording videos from BabylonJS.
  155418. * This is based on the available WebRTC functionalities of the browser.
  155419. *
  155420. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  155421. */
  155422. export class VideoRecorder {
  155423. private static readonly _defaultOptions;
  155424. /**
  155425. * Returns whether or not the VideoRecorder is available in your browser.
  155426. * @param engine Defines the Babylon Engine.
  155427. * @returns true if supported otherwise false.
  155428. */
  155429. static IsSupported(engine: Engine): boolean;
  155430. private readonly _options;
  155431. private _canvas;
  155432. private _mediaRecorder;
  155433. private _recordedChunks;
  155434. private _fileName;
  155435. private _resolve;
  155436. private _reject;
  155437. /**
  155438. * True when a recording is already in progress.
  155439. */
  155440. get isRecording(): boolean;
  155441. /**
  155442. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  155443. * @param engine Defines the BabylonJS Engine you wish to record.
  155444. * @param options Defines options that can be used to customize the capture.
  155445. */
  155446. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  155447. /**
  155448. * Stops the current recording before the default capture timeout passed in the startRecording function.
  155449. */
  155450. stopRecording(): void;
  155451. /**
  155452. * Starts recording the canvas for a max duration specified in parameters.
  155453. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  155454. * If null no automatic download will start and you can rely on the promise to get the data back.
  155455. * @param maxDuration Defines the maximum recording time in seconds.
  155456. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  155457. * @return A promise callback at the end of the recording with the video data in Blob.
  155458. */
  155459. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  155460. /**
  155461. * Releases internal resources used during the recording.
  155462. */
  155463. dispose(): void;
  155464. private _handleDataAvailable;
  155465. private _handleError;
  155466. private _handleStop;
  155467. }
  155468. }
  155469. declare module BABYLON {
  155470. /**
  155471. * Class containing a set of static utilities functions for screenshots
  155472. */
  155473. export class ScreenshotTools {
  155474. /**
  155475. * Captures a screenshot of the current rendering
  155476. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155477. * @param engine defines the rendering engine
  155478. * @param camera defines the source camera
  155479. * @param size This parameter can be set to a single number or to an object with the
  155480. * following (optional) properties: precision, width, height. If a single number is passed,
  155481. * it will be used for both width and height. If an object is passed, the screenshot size
  155482. * will be derived from the parameters. The precision property is a multiplier allowing
  155483. * rendering at a higher or lower resolution
  155484. * @param successCallback defines the callback receives a single parameter which contains the
  155485. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155486. * src parameter of an <img> to display it
  155487. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155488. * Check your browser for supported MIME types
  155489. */
  155490. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  155491. /**
  155492. * Captures a screenshot of the current rendering
  155493. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155494. * @param engine defines the rendering engine
  155495. * @param camera defines the source camera
  155496. * @param size This parameter can be set to a single number or to an object with the
  155497. * following (optional) properties: precision, width, height. If a single number is passed,
  155498. * it will be used for both width and height. If an object is passed, the screenshot size
  155499. * will be derived from the parameters. The precision property is a multiplier allowing
  155500. * rendering at a higher or lower resolution
  155501. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155502. * Check your browser for supported MIME types
  155503. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155504. * to the src parameter of an <img> to display it
  155505. */
  155506. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  155507. /**
  155508. * Generates an image screenshot from the specified camera.
  155509. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155510. * @param engine The engine to use for rendering
  155511. * @param camera The camera to use for rendering
  155512. * @param size This parameter can be set to a single number or to an object with the
  155513. * following (optional) properties: precision, width, height. If a single number is passed,
  155514. * it will be used for both width and height. If an object is passed, the screenshot size
  155515. * will be derived from the parameters. The precision property is a multiplier allowing
  155516. * rendering at a higher or lower resolution
  155517. * @param successCallback The callback receives a single parameter which contains the
  155518. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155519. * src parameter of an <img> to display it
  155520. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155521. * Check your browser for supported MIME types
  155522. * @param samples Texture samples (default: 1)
  155523. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155524. * @param fileName A name for for the downloaded file.
  155525. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155526. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  155527. */
  155528. 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;
  155529. /**
  155530. * Generates an image screenshot from the specified camera.
  155531. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155532. * @param engine The engine to use for rendering
  155533. * @param camera The camera to use for rendering
  155534. * @param size This parameter can be set to a single number or to an object with the
  155535. * following (optional) properties: precision, width, height. If a single number is passed,
  155536. * it will be used for both width and height. If an object is passed, the screenshot size
  155537. * will be derived from the parameters. The precision property is a multiplier allowing
  155538. * rendering at a higher or lower resolution
  155539. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155540. * Check your browser for supported MIME types
  155541. * @param samples Texture samples (default: 1)
  155542. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155543. * @param fileName A name for for the downloaded file.
  155544. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155545. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155546. * to the src parameter of an <img> to display it
  155547. */
  155548. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  155549. /**
  155550. * Gets height and width for screenshot size
  155551. * @private
  155552. */
  155553. private static _getScreenshotSize;
  155554. }
  155555. }
  155556. declare module BABYLON {
  155557. /**
  155558. * Interface for a data buffer
  155559. */
  155560. export interface IDataBuffer {
  155561. /**
  155562. * Reads bytes from the data buffer.
  155563. * @param byteOffset The byte offset to read
  155564. * @param byteLength The byte length to read
  155565. * @returns A promise that resolves when the bytes are read
  155566. */
  155567. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  155568. /**
  155569. * The byte length of the buffer.
  155570. */
  155571. readonly byteLength: number;
  155572. }
  155573. /**
  155574. * Utility class for reading from a data buffer
  155575. */
  155576. export class DataReader {
  155577. /**
  155578. * The data buffer associated with this data reader.
  155579. */
  155580. readonly buffer: IDataBuffer;
  155581. /**
  155582. * The current byte offset from the beginning of the data buffer.
  155583. */
  155584. byteOffset: number;
  155585. private _dataView;
  155586. private _dataByteOffset;
  155587. /**
  155588. * Constructor
  155589. * @param buffer The buffer to read
  155590. */
  155591. constructor(buffer: IDataBuffer);
  155592. /**
  155593. * Loads the given byte length.
  155594. * @param byteLength The byte length to load
  155595. * @returns A promise that resolves when the load is complete
  155596. */
  155597. loadAsync(byteLength: number): Promise<void>;
  155598. /**
  155599. * Read a unsigned 32-bit integer from the currently loaded data range.
  155600. * @returns The 32-bit integer read
  155601. */
  155602. readUint32(): number;
  155603. /**
  155604. * Read a byte array from the currently loaded data range.
  155605. * @param byteLength The byte length to read
  155606. * @returns The byte array read
  155607. */
  155608. readUint8Array(byteLength: number): Uint8Array;
  155609. /**
  155610. * Read a string from the currently loaded data range.
  155611. * @param byteLength The byte length to read
  155612. * @returns The string read
  155613. */
  155614. readString(byteLength: number): string;
  155615. /**
  155616. * Skips the given byte length the currently loaded data range.
  155617. * @param byteLength The byte length to skip
  155618. */
  155619. skipBytes(byteLength: number): void;
  155620. }
  155621. }
  155622. declare module BABYLON {
  155623. /**
  155624. * Class for storing data to local storage if available or in-memory storage otherwise
  155625. */
  155626. export class DataStorage {
  155627. private static _Storage;
  155628. private static _GetStorage;
  155629. /**
  155630. * Reads a string from the data storage
  155631. * @param key The key to read
  155632. * @param defaultValue The value if the key doesn't exist
  155633. * @returns The string value
  155634. */
  155635. static ReadString(key: string, defaultValue: string): string;
  155636. /**
  155637. * Writes a string to the data storage
  155638. * @param key The key to write
  155639. * @param value The value to write
  155640. */
  155641. static WriteString(key: string, value: string): void;
  155642. /**
  155643. * Reads a boolean from the data storage
  155644. * @param key The key to read
  155645. * @param defaultValue The value if the key doesn't exist
  155646. * @returns The boolean value
  155647. */
  155648. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  155649. /**
  155650. * Writes a boolean to the data storage
  155651. * @param key The key to write
  155652. * @param value The value to write
  155653. */
  155654. static WriteBoolean(key: string, value: boolean): void;
  155655. /**
  155656. * Reads a number from the data storage
  155657. * @param key The key to read
  155658. * @param defaultValue The value if the key doesn't exist
  155659. * @returns The number value
  155660. */
  155661. static ReadNumber(key: string, defaultValue: number): number;
  155662. /**
  155663. * Writes a number to the data storage
  155664. * @param key The key to write
  155665. * @param value The value to write
  155666. */
  155667. static WriteNumber(key: string, value: number): void;
  155668. }
  155669. }
  155670. declare module BABYLON {
  155671. /**
  155672. * Class used to record delta files between 2 scene states
  155673. */
  155674. export class SceneRecorder {
  155675. private _trackedScene;
  155676. private _savedJSON;
  155677. /**
  155678. * Track a given scene. This means the current scene state will be considered the original state
  155679. * @param scene defines the scene to track
  155680. */
  155681. track(scene: Scene): void;
  155682. /**
  155683. * Get the delta between current state and original state
  155684. * @returns a string containing the delta
  155685. */
  155686. getDelta(): any;
  155687. private _compareArray;
  155688. private _compareObjects;
  155689. private _compareCollections;
  155690. private static GetShadowGeneratorById;
  155691. /**
  155692. * Apply a given delta to a given scene
  155693. * @param deltaJSON defines the JSON containing the delta
  155694. * @param scene defines the scene to apply the delta to
  155695. */
  155696. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  155697. private static _ApplyPropertiesToEntity;
  155698. private static _ApplyDeltaForEntity;
  155699. }
  155700. }
  155701. declare module BABYLON {
  155702. /**
  155703. * A 3D trajectory consisting of an order list of vectors describing a
  155704. * path of motion through 3D space.
  155705. */
  155706. export class Trajectory {
  155707. private _points;
  155708. private readonly _segmentLength;
  155709. /**
  155710. * Serialize to JSON.
  155711. * @returns serialized JSON string
  155712. */
  155713. serialize(): string;
  155714. /**
  155715. * Deserialize from JSON.
  155716. * @param json serialized JSON string
  155717. * @returns deserialized Trajectory
  155718. */
  155719. static Deserialize(json: string): Trajectory;
  155720. /**
  155721. * Create a new empty Trajectory.
  155722. * @param segmentLength radius of discretization for Trajectory points
  155723. */
  155724. constructor(segmentLength?: number);
  155725. /**
  155726. * Get the length of the Trajectory.
  155727. * @returns length of the Trajectory
  155728. */
  155729. getLength(): number;
  155730. /**
  155731. * Append a new point to the Trajectory.
  155732. * NOTE: This implementation has many allocations.
  155733. * @param point point to append to the Trajectory
  155734. */
  155735. add(point: DeepImmutable<Vector3>): void;
  155736. /**
  155737. * Create a new Trajectory with a segment length chosen to make it
  155738. * probable that the new Trajectory will have a specified number of
  155739. * segments. This operation is imprecise.
  155740. * @param targetResolution number of segments desired
  155741. * @returns new Trajectory with approximately the requested number of segments
  155742. */
  155743. resampleAtTargetResolution(targetResolution: number): Trajectory;
  155744. /**
  155745. * Convert Trajectory segments into tokenized representation. This
  155746. * representation is an array of numbers where each nth number is the
  155747. * index of the token which is most similar to the nth segment of the
  155748. * Trajectory.
  155749. * @param tokens list of vectors which serve as discrete tokens
  155750. * @returns list of indices of most similar token per segment
  155751. */
  155752. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  155753. private static _forwardDir;
  155754. private static _inverseFromVec;
  155755. private static _upDir;
  155756. private static _fromToVec;
  155757. private static _lookMatrix;
  155758. /**
  155759. * Transform the rotation (i.e., direction) of a segment to isolate
  155760. * the relative transformation represented by the segment. This operation
  155761. * may or may not succeed due to singularities in the equations that define
  155762. * motion relativity in this context.
  155763. * @param priorVec the origin of the prior segment
  155764. * @param fromVec the origin of the current segment
  155765. * @param toVec the destination of the current segment
  155766. * @param result reference to output variable
  155767. * @returns whether or not transformation was successful
  155768. */
  155769. private static _transformSegmentDirToRef;
  155770. private static _bestMatch;
  155771. private static _score;
  155772. private static _bestScore;
  155773. /**
  155774. * Determine which token vector is most similar to the
  155775. * segment vector.
  155776. * @param segment segment vector
  155777. * @param tokens token vector list
  155778. * @returns index of the most similar token to the segment
  155779. */
  155780. private static _tokenizeSegment;
  155781. }
  155782. /**
  155783. * Class representing a set of known, named trajectories to which Trajectories can be
  155784. * added and using which Trajectories can be recognized.
  155785. */
  155786. export class TrajectoryClassifier {
  155787. private _maximumAllowableMatchCost;
  155788. private _vector3Alphabet;
  155789. private _levenshteinAlphabet;
  155790. private _nameToDescribedTrajectory;
  155791. /**
  155792. * Serialize to JSON.
  155793. * @returns JSON serialization
  155794. */
  155795. serialize(): string;
  155796. /**
  155797. * Deserialize from JSON.
  155798. * @param json JSON serialization
  155799. * @returns deserialized TrajectorySet
  155800. */
  155801. static Deserialize(json: string): TrajectoryClassifier;
  155802. /**
  155803. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  155804. * VERY naive, need to be generating these things from known
  155805. * sets. Better version later, probably eliminating this one.
  155806. * @returns auto-generated TrajectorySet
  155807. */
  155808. static Generate(): TrajectoryClassifier;
  155809. private constructor();
  155810. /**
  155811. * Add a new Trajectory to the set with a given name.
  155812. * @param trajectory new Trajectory to be added
  155813. * @param classification name to which to add the Trajectory
  155814. */
  155815. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155816. /**
  155817. * Remove a known named trajectory and all Trajectories associated with it.
  155818. * @param classification name to remove
  155819. * @returns whether anything was removed
  155820. */
  155821. deleteClassification(classification: string): boolean;
  155822. /**
  155823. * Attempt to recognize a Trajectory from among all the classifications
  155824. * already known to the classifier.
  155825. * @param trajectory Trajectory to be recognized
  155826. * @returns classification of Trajectory if recognized, null otherwise
  155827. */
  155828. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155829. }
  155830. }
  155831. declare module BABYLON {
  155832. /**
  155833. * An interface for all Hit test features
  155834. */
  155835. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155836. /**
  155837. * Triggered when new babylon (transformed) hit test results are available
  155838. */
  155839. onHitTestResultObservable: Observable<T[]>;
  155840. }
  155841. /**
  155842. * Options used for hit testing
  155843. */
  155844. export interface IWebXRLegacyHitTestOptions {
  155845. /**
  155846. * Only test when user interacted with the scene. Default - hit test every frame
  155847. */
  155848. testOnPointerDownOnly?: boolean;
  155849. /**
  155850. * The node to use to transform the local results to world coordinates
  155851. */
  155852. worldParentNode?: TransformNode;
  155853. }
  155854. /**
  155855. * Interface defining the babylon result of raycasting/hit-test
  155856. */
  155857. export interface IWebXRLegacyHitResult {
  155858. /**
  155859. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155860. */
  155861. transformationMatrix: Matrix;
  155862. /**
  155863. * The native hit test result
  155864. */
  155865. xrHitResult: XRHitResult | XRHitTestResult;
  155866. }
  155867. /**
  155868. * The currently-working hit-test module.
  155869. * Hit test (or Ray-casting) is used to interact with the real world.
  155870. * For further information read here - https://github.com/immersive-web/hit-test
  155871. */
  155872. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155873. /**
  155874. * options to use when constructing this feature
  155875. */
  155876. readonly options: IWebXRLegacyHitTestOptions;
  155877. private _direction;
  155878. private _mat;
  155879. private _onSelectEnabled;
  155880. private _origin;
  155881. /**
  155882. * The module's name
  155883. */
  155884. static readonly Name: string;
  155885. /**
  155886. * The (Babylon) version of this module.
  155887. * This is an integer representing the implementation version.
  155888. * This number does not correspond to the WebXR specs version
  155889. */
  155890. static readonly Version: number;
  155891. /**
  155892. * Populated with the last native XR Hit Results
  155893. */
  155894. lastNativeXRHitResults: XRHitResult[];
  155895. /**
  155896. * Triggered when new babylon (transformed) hit test results are available
  155897. */
  155898. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155899. /**
  155900. * Creates a new instance of the (legacy version) hit test feature
  155901. * @param _xrSessionManager an instance of WebXRSessionManager
  155902. * @param options options to use when constructing this feature
  155903. */
  155904. constructor(_xrSessionManager: WebXRSessionManager,
  155905. /**
  155906. * options to use when constructing this feature
  155907. */
  155908. options?: IWebXRLegacyHitTestOptions);
  155909. /**
  155910. * execute a hit test with an XR Ray
  155911. *
  155912. * @param xrSession a native xrSession that will execute this hit test
  155913. * @param xrRay the ray (position and direction) to use for ray-casting
  155914. * @param referenceSpace native XR reference space to use for the hit-test
  155915. * @param filter filter function that will filter the results
  155916. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155917. */
  155918. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155919. /**
  155920. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155921. * @param event the (select) event to use to select with
  155922. * @param referenceSpace the reference space to use for this hit test
  155923. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155924. */
  155925. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155926. /**
  155927. * attach this feature
  155928. * Will usually be called by the features manager
  155929. *
  155930. * @returns true if successful.
  155931. */
  155932. attach(): boolean;
  155933. /**
  155934. * detach this feature.
  155935. * Will usually be called by the features manager
  155936. *
  155937. * @returns true if successful.
  155938. */
  155939. detach(): boolean;
  155940. /**
  155941. * Dispose this feature and all of the resources attached
  155942. */
  155943. dispose(): void;
  155944. protected _onXRFrame(frame: XRFrame): void;
  155945. private _onHitTestResults;
  155946. private _onSelect;
  155947. }
  155948. }
  155949. declare module BABYLON {
  155950. /**
  155951. * Options used for hit testing (version 2)
  155952. */
  155953. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155954. /**
  155955. * Do not create a permanent hit test. Will usually be used when only
  155956. * transient inputs are needed.
  155957. */
  155958. disablePermanentHitTest?: boolean;
  155959. /**
  155960. * Enable transient (for example touch-based) hit test inspections
  155961. */
  155962. enableTransientHitTest?: boolean;
  155963. /**
  155964. * Offset ray for the permanent hit test
  155965. */
  155966. offsetRay?: Vector3;
  155967. /**
  155968. * Offset ray for the transient hit test
  155969. */
  155970. transientOffsetRay?: Vector3;
  155971. /**
  155972. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155973. */
  155974. useReferenceSpace?: boolean;
  155975. /**
  155976. * Override the default entity type(s) of the hit-test result
  155977. */
  155978. entityTypes?: XRHitTestTrackableType[];
  155979. }
  155980. /**
  155981. * Interface defining the babylon result of hit-test
  155982. */
  155983. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155984. /**
  155985. * The input source that generated this hit test (if transient)
  155986. */
  155987. inputSource?: XRInputSource;
  155988. /**
  155989. * Is this a transient hit test
  155990. */
  155991. isTransient?: boolean;
  155992. /**
  155993. * Position of the hit test result
  155994. */
  155995. position: Vector3;
  155996. /**
  155997. * Rotation of the hit test result
  155998. */
  155999. rotationQuaternion: Quaternion;
  156000. /**
  156001. * The native hit test result
  156002. */
  156003. xrHitResult: XRHitTestResult;
  156004. }
  156005. /**
  156006. * The currently-working hit-test module.
  156007. * Hit test (or Ray-casting) is used to interact with the real world.
  156008. * For further information read here - https://github.com/immersive-web/hit-test
  156009. *
  156010. * Tested on chrome (mobile) 80.
  156011. */
  156012. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  156013. /**
  156014. * options to use when constructing this feature
  156015. */
  156016. readonly options: IWebXRHitTestOptions;
  156017. private _tmpMat;
  156018. private _tmpPos;
  156019. private _tmpQuat;
  156020. private _transientXrHitTestSource;
  156021. private _xrHitTestSource;
  156022. private initHitTestSource;
  156023. /**
  156024. * The module's name
  156025. */
  156026. static readonly Name: string;
  156027. /**
  156028. * The (Babylon) version of this module.
  156029. * This is an integer representing the implementation version.
  156030. * This number does not correspond to the WebXR specs version
  156031. */
  156032. static readonly Version: number;
  156033. /**
  156034. * When set to true, each hit test will have its own position/rotation objects
  156035. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  156036. * the developers will clone them or copy them as they see fit.
  156037. */
  156038. autoCloneTransformation: boolean;
  156039. /**
  156040. * Triggered when new babylon (transformed) hit test results are available
  156041. * Note - this will be called when results come back from the device. It can be an empty array!!
  156042. */
  156043. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  156044. /**
  156045. * Use this to temporarily pause hit test checks.
  156046. */
  156047. paused: boolean;
  156048. /**
  156049. * Creates a new instance of the hit test feature
  156050. * @param _xrSessionManager an instance of WebXRSessionManager
  156051. * @param options options to use when constructing this feature
  156052. */
  156053. constructor(_xrSessionManager: WebXRSessionManager,
  156054. /**
  156055. * options to use when constructing this feature
  156056. */
  156057. options?: IWebXRHitTestOptions);
  156058. /**
  156059. * attach this feature
  156060. * Will usually be called by the features manager
  156061. *
  156062. * @returns true if successful.
  156063. */
  156064. attach(): boolean;
  156065. /**
  156066. * detach this feature.
  156067. * Will usually be called by the features manager
  156068. *
  156069. * @returns true if successful.
  156070. */
  156071. detach(): boolean;
  156072. /**
  156073. * Dispose this feature and all of the resources attached
  156074. */
  156075. dispose(): void;
  156076. protected _onXRFrame(frame: XRFrame): void;
  156077. private _processWebXRHitTestResult;
  156078. }
  156079. }
  156080. declare module BABYLON {
  156081. /**
  156082. * Configuration options of the anchor system
  156083. */
  156084. export interface IWebXRAnchorSystemOptions {
  156085. /**
  156086. * a node that will be used to convert local to world coordinates
  156087. */
  156088. worldParentNode?: TransformNode;
  156089. /**
  156090. * If set to true a reference of the created anchors will be kept until the next session starts
  156091. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  156092. */
  156093. doNotRemoveAnchorsOnSessionEnded?: boolean;
  156094. }
  156095. /**
  156096. * A babylon container for an XR Anchor
  156097. */
  156098. export interface IWebXRAnchor {
  156099. /**
  156100. * A babylon-assigned ID for this anchor
  156101. */
  156102. id: number;
  156103. /**
  156104. * Transformation matrix to apply to an object attached to this anchor
  156105. */
  156106. transformationMatrix: Matrix;
  156107. /**
  156108. * The native anchor object
  156109. */
  156110. xrAnchor: XRAnchor;
  156111. /**
  156112. * if defined, this object will be constantly updated by the anchor's position and rotation
  156113. */
  156114. attachedNode?: TransformNode;
  156115. }
  156116. /**
  156117. * An implementation of the anchor system for WebXR.
  156118. * For further information see https://github.com/immersive-web/anchors/
  156119. */
  156120. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  156121. private _options;
  156122. private _lastFrameDetected;
  156123. private _trackedAnchors;
  156124. private _referenceSpaceForFrameAnchors;
  156125. private _futureAnchors;
  156126. /**
  156127. * The module's name
  156128. */
  156129. static readonly Name: string;
  156130. /**
  156131. * The (Babylon) version of this module.
  156132. * This is an integer representing the implementation version.
  156133. * This number does not correspond to the WebXR specs version
  156134. */
  156135. static readonly Version: number;
  156136. /**
  156137. * Observers registered here will be executed when a new anchor was added to the session
  156138. */
  156139. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  156140. /**
  156141. * Observers registered here will be executed when an anchor was removed from the session
  156142. */
  156143. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  156144. /**
  156145. * Observers registered here will be executed when an existing anchor updates
  156146. * This can execute N times every frame
  156147. */
  156148. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  156149. /**
  156150. * Set the reference space to use for anchor creation, when not using a hit test.
  156151. * Will default to the session's reference space if not defined
  156152. */
  156153. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  156154. /**
  156155. * constructs a new anchor system
  156156. * @param _xrSessionManager an instance of WebXRSessionManager
  156157. * @param _options configuration object for this feature
  156158. */
  156159. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  156160. private _tmpVector;
  156161. private _tmpQuaternion;
  156162. private _populateTmpTransformation;
  156163. /**
  156164. * Create a new anchor point using a hit test result at a specific point in the scene
  156165. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156166. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156167. *
  156168. * @param hitTestResult The hit test result to use for this anchor creation
  156169. * @param position an optional position offset for this anchor
  156170. * @param rotationQuaternion an optional rotation offset for this anchor
  156171. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156172. */
  156173. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  156174. /**
  156175. * Add a new anchor at a specific position and rotation
  156176. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  156177. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  156178. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156179. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156180. *
  156181. * @param position the position in which to add an anchor
  156182. * @param rotationQuaternion an optional rotation for the anchor transformation
  156183. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  156184. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156185. */
  156186. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  156187. /**
  156188. * detach this feature.
  156189. * Will usually be called by the features manager
  156190. *
  156191. * @returns true if successful.
  156192. */
  156193. detach(): boolean;
  156194. /**
  156195. * Dispose this feature and all of the resources attached
  156196. */
  156197. dispose(): void;
  156198. protected _onXRFrame(frame: XRFrame): void;
  156199. /**
  156200. * avoiding using Array.find for global support.
  156201. * @param xrAnchor the plane to find in the array
  156202. */
  156203. private _findIndexInAnchorArray;
  156204. private _updateAnchorWithXRFrame;
  156205. private _createAnchorAtTransformation;
  156206. }
  156207. }
  156208. declare module BABYLON {
  156209. /**
  156210. * Options used in the plane detector module
  156211. */
  156212. export interface IWebXRPlaneDetectorOptions {
  156213. /**
  156214. * The node to use to transform the local results to world coordinates
  156215. */
  156216. worldParentNode?: TransformNode;
  156217. /**
  156218. * If set to true a reference of the created planes will be kept until the next session starts
  156219. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  156220. */
  156221. doNotRemovePlanesOnSessionEnded?: boolean;
  156222. }
  156223. /**
  156224. * A babylon interface for a WebXR plane.
  156225. * A Plane is actually a polygon, built from N points in space
  156226. *
  156227. * Supported in chrome 79, not supported in canary 81 ATM
  156228. */
  156229. export interface IWebXRPlane {
  156230. /**
  156231. * a babylon-assigned ID for this polygon
  156232. */
  156233. id: number;
  156234. /**
  156235. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  156236. */
  156237. polygonDefinition: Array<Vector3>;
  156238. /**
  156239. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  156240. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  156241. */
  156242. transformationMatrix: Matrix;
  156243. /**
  156244. * the native xr-plane object
  156245. */
  156246. xrPlane: XRPlane;
  156247. }
  156248. /**
  156249. * The plane detector is used to detect planes in the real world when in AR
  156250. * For more information see https://github.com/immersive-web/real-world-geometry/
  156251. */
  156252. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  156253. private _options;
  156254. private _detectedPlanes;
  156255. private _enabled;
  156256. private _lastFrameDetected;
  156257. /**
  156258. * The module's name
  156259. */
  156260. static readonly Name: string;
  156261. /**
  156262. * The (Babylon) version of this module.
  156263. * This is an integer representing the implementation version.
  156264. * This number does not correspond to the WebXR specs version
  156265. */
  156266. static readonly Version: number;
  156267. /**
  156268. * Observers registered here will be executed when a new plane was added to the session
  156269. */
  156270. onPlaneAddedObservable: Observable<IWebXRPlane>;
  156271. /**
  156272. * Observers registered here will be executed when a plane is no longer detected in the session
  156273. */
  156274. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  156275. /**
  156276. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  156277. * This can execute N times every frame
  156278. */
  156279. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  156280. /**
  156281. * construct a new Plane Detector
  156282. * @param _xrSessionManager an instance of xr Session manager
  156283. * @param _options configuration to use when constructing this feature
  156284. */
  156285. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  156286. /**
  156287. * detach this feature.
  156288. * Will usually be called by the features manager
  156289. *
  156290. * @returns true if successful.
  156291. */
  156292. detach(): boolean;
  156293. /**
  156294. * Dispose this feature and all of the resources attached
  156295. */
  156296. dispose(): void;
  156297. protected _onXRFrame(frame: XRFrame): void;
  156298. private _init;
  156299. private _updatePlaneWithXRPlane;
  156300. /**
  156301. * avoiding using Array.find for global support.
  156302. * @param xrPlane the plane to find in the array
  156303. */
  156304. private findIndexInPlaneArray;
  156305. }
  156306. }
  156307. declare module BABYLON {
  156308. /**
  156309. * Options interface for the background remover plugin
  156310. */
  156311. export interface IWebXRBackgroundRemoverOptions {
  156312. /**
  156313. * Further background meshes to disable when entering AR
  156314. */
  156315. backgroundMeshes?: AbstractMesh[];
  156316. /**
  156317. * flags to configure the removal of the environment helper.
  156318. * If not set, the entire background will be removed. If set, flags should be set as well.
  156319. */
  156320. environmentHelperRemovalFlags?: {
  156321. /**
  156322. * Should the skybox be removed (default false)
  156323. */
  156324. skyBox?: boolean;
  156325. /**
  156326. * Should the ground be removed (default false)
  156327. */
  156328. ground?: boolean;
  156329. };
  156330. /**
  156331. * don't disable the environment helper
  156332. */
  156333. ignoreEnvironmentHelper?: boolean;
  156334. }
  156335. /**
  156336. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  156337. */
  156338. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  156339. /**
  156340. * read-only options to be used in this module
  156341. */
  156342. readonly options: IWebXRBackgroundRemoverOptions;
  156343. /**
  156344. * The module's name
  156345. */
  156346. static readonly Name: string;
  156347. /**
  156348. * The (Babylon) version of this module.
  156349. * This is an integer representing the implementation version.
  156350. * This number does not correspond to the WebXR specs version
  156351. */
  156352. static readonly Version: number;
  156353. /**
  156354. * registered observers will be triggered when the background state changes
  156355. */
  156356. onBackgroundStateChangedObservable: Observable<boolean>;
  156357. /**
  156358. * constructs a new background remover module
  156359. * @param _xrSessionManager the session manager for this module
  156360. * @param options read-only options to be used in this module
  156361. */
  156362. constructor(_xrSessionManager: WebXRSessionManager,
  156363. /**
  156364. * read-only options to be used in this module
  156365. */
  156366. options?: IWebXRBackgroundRemoverOptions);
  156367. /**
  156368. * attach this feature
  156369. * Will usually be called by the features manager
  156370. *
  156371. * @returns true if successful.
  156372. */
  156373. attach(): boolean;
  156374. /**
  156375. * detach this feature.
  156376. * Will usually be called by the features manager
  156377. *
  156378. * @returns true if successful.
  156379. */
  156380. detach(): boolean;
  156381. /**
  156382. * Dispose this feature and all of the resources attached
  156383. */
  156384. dispose(): void;
  156385. protected _onXRFrame(_xrFrame: XRFrame): void;
  156386. private _setBackgroundState;
  156387. }
  156388. }
  156389. declare module BABYLON {
  156390. /**
  156391. * Options for the controller physics feature
  156392. */
  156393. export class IWebXRControllerPhysicsOptions {
  156394. /**
  156395. * Should the headset get its own impostor
  156396. */
  156397. enableHeadsetImpostor?: boolean;
  156398. /**
  156399. * Optional parameters for the headset impostor
  156400. */
  156401. headsetImpostorParams?: {
  156402. /**
  156403. * The type of impostor to create. Default is sphere
  156404. */
  156405. impostorType: number;
  156406. /**
  156407. * the size of the impostor. Defaults to 10cm
  156408. */
  156409. impostorSize?: number | {
  156410. width: number;
  156411. height: number;
  156412. depth: number;
  156413. };
  156414. /**
  156415. * Friction definitions
  156416. */
  156417. friction?: number;
  156418. /**
  156419. * Restitution
  156420. */
  156421. restitution?: number;
  156422. };
  156423. /**
  156424. * The physics properties of the future impostors
  156425. */
  156426. physicsProperties?: {
  156427. /**
  156428. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  156429. * Note that this requires a physics engine that supports mesh impostors!
  156430. */
  156431. useControllerMesh?: boolean;
  156432. /**
  156433. * The type of impostor to create. Default is sphere
  156434. */
  156435. impostorType?: number;
  156436. /**
  156437. * the size of the impostor. Defaults to 10cm
  156438. */
  156439. impostorSize?: number | {
  156440. width: number;
  156441. height: number;
  156442. depth: number;
  156443. };
  156444. /**
  156445. * Friction definitions
  156446. */
  156447. friction?: number;
  156448. /**
  156449. * Restitution
  156450. */
  156451. restitution?: number;
  156452. };
  156453. /**
  156454. * the xr input to use with this pointer selection
  156455. */
  156456. xrInput: WebXRInput;
  156457. }
  156458. /**
  156459. * Add physics impostor to your webxr controllers,
  156460. * including naive calculation of their linear and angular velocity
  156461. */
  156462. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  156463. private readonly _options;
  156464. private _attachController;
  156465. private _controllers;
  156466. private _debugMode;
  156467. private _delta;
  156468. private _headsetImpostor?;
  156469. private _headsetMesh?;
  156470. private _lastTimestamp;
  156471. private _tmpQuaternion;
  156472. private _tmpVector;
  156473. /**
  156474. * The module's name
  156475. */
  156476. static readonly Name: string;
  156477. /**
  156478. * The (Babylon) version of this module.
  156479. * This is an integer representing the implementation version.
  156480. * This number does not correspond to the webxr specs version
  156481. */
  156482. static readonly Version: number;
  156483. /**
  156484. * Construct a new Controller Physics Feature
  156485. * @param _xrSessionManager the corresponding xr session manager
  156486. * @param _options options to create this feature with
  156487. */
  156488. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  156489. /**
  156490. * @hidden
  156491. * enable debugging - will show console outputs and the impostor mesh
  156492. */
  156493. _enablePhysicsDebug(): void;
  156494. /**
  156495. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  156496. * @param xrController the controller to add
  156497. */
  156498. addController(xrController: WebXRInputSource): void;
  156499. /**
  156500. * attach this feature
  156501. * Will usually be called by the features manager
  156502. *
  156503. * @returns true if successful.
  156504. */
  156505. attach(): boolean;
  156506. /**
  156507. * detach this feature.
  156508. * Will usually be called by the features manager
  156509. *
  156510. * @returns true if successful.
  156511. */
  156512. detach(): boolean;
  156513. /**
  156514. * Get the headset impostor, if enabled
  156515. * @returns the impostor
  156516. */
  156517. getHeadsetImpostor(): PhysicsImpostor | undefined;
  156518. /**
  156519. * Get the physics impostor of a specific controller.
  156520. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  156521. * @param controller the controller or the controller id of which to get the impostor
  156522. * @returns the impostor or null
  156523. */
  156524. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  156525. /**
  156526. * Update the physics properties provided in the constructor
  156527. * @param newProperties the new properties object
  156528. */
  156529. setPhysicsProperties(newProperties: {
  156530. impostorType?: number;
  156531. impostorSize?: number | {
  156532. width: number;
  156533. height: number;
  156534. depth: number;
  156535. };
  156536. friction?: number;
  156537. restitution?: number;
  156538. }): void;
  156539. protected _onXRFrame(_xrFrame: any): void;
  156540. private _detachController;
  156541. }
  156542. }
  156543. declare module BABYLON {
  156544. /**
  156545. * A babylon interface for a "WebXR" feature point.
  156546. * Represents the position and confidence value of a given feature point.
  156547. */
  156548. export interface IWebXRFeaturePoint {
  156549. /**
  156550. * Represents the position of the feature point in world space.
  156551. */
  156552. position: Vector3;
  156553. /**
  156554. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  156555. */
  156556. confidenceValue: number;
  156557. }
  156558. /**
  156559. * The feature point system is used to detect feature points from real world geometry.
  156560. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  156561. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  156562. */
  156563. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  156564. private _enabled;
  156565. private _featurePointCloud;
  156566. /**
  156567. * The module's name
  156568. */
  156569. static readonly Name: string;
  156570. /**
  156571. * The (Babylon) version of this module.
  156572. * This is an integer representing the implementation version.
  156573. * This number does not correspond to the WebXR specs version
  156574. */
  156575. static readonly Version: number;
  156576. /**
  156577. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  156578. * Will notify the observers about which feature points have been added.
  156579. */
  156580. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  156581. /**
  156582. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  156583. * Will notify the observers about which feature points have been updated.
  156584. */
  156585. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  156586. /**
  156587. * The current feature point cloud maintained across frames.
  156588. */
  156589. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  156590. /**
  156591. * construct the feature point system
  156592. * @param _xrSessionManager an instance of xr Session manager
  156593. */
  156594. constructor(_xrSessionManager: WebXRSessionManager);
  156595. /**
  156596. * Detach this feature.
  156597. * Will usually be called by the features manager
  156598. *
  156599. * @returns true if successful.
  156600. */
  156601. detach(): boolean;
  156602. /**
  156603. * Dispose this feature and all of the resources attached
  156604. */
  156605. dispose(): void;
  156606. /**
  156607. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  156608. */
  156609. protected _onXRFrame(frame: XRFrame): void;
  156610. /**
  156611. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  156612. */
  156613. private _init;
  156614. }
  156615. }
  156616. declare module BABYLON {
  156617. /**
  156618. * Configuration interface for the hand tracking feature
  156619. */
  156620. export interface IWebXRHandTrackingOptions {
  156621. /**
  156622. * The xrInput that will be used as source for new hands
  156623. */
  156624. xrInput: WebXRInput;
  156625. /**
  156626. * Configuration object for the joint meshes
  156627. */
  156628. jointMeshes?: {
  156629. /**
  156630. * Should the meshes created be invisible (defaults to false)
  156631. */
  156632. invisible?: boolean;
  156633. /**
  156634. * A source mesh to be used to create instances. Defaults to a sphere.
  156635. * This mesh will be the source for all other (25) meshes.
  156636. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  156637. */
  156638. sourceMesh?: Mesh;
  156639. /**
  156640. * This function will be called after a mesh was created for a specific joint.
  156641. * Using this function you can either manipulate the instance or return a new mesh.
  156642. * When returning a new mesh the instance created before will be disposed
  156643. */
  156644. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  156645. /**
  156646. * Should the source mesh stay visible. Defaults to false
  156647. */
  156648. keepOriginalVisible?: boolean;
  156649. /**
  156650. * Scale factor for all instances (defaults to 2)
  156651. */
  156652. scaleFactor?: number;
  156653. /**
  156654. * Should each instance have its own physics impostor
  156655. */
  156656. enablePhysics?: boolean;
  156657. /**
  156658. * If enabled, override default physics properties
  156659. */
  156660. physicsProps?: {
  156661. friction?: number;
  156662. restitution?: number;
  156663. impostorType?: number;
  156664. };
  156665. /**
  156666. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  156667. */
  156668. handMesh?: AbstractMesh;
  156669. };
  156670. }
  156671. /**
  156672. * Parts of the hands divided to writs and finger names
  156673. */
  156674. export const enum HandPart {
  156675. /**
  156676. * HandPart - Wrist
  156677. */
  156678. WRIST = "wrist",
  156679. /**
  156680. * HandPart - The THumb
  156681. */
  156682. THUMB = "thumb",
  156683. /**
  156684. * HandPart - Index finger
  156685. */
  156686. INDEX = "index",
  156687. /**
  156688. * HandPart - Middle finger
  156689. */
  156690. MIDDLE = "middle",
  156691. /**
  156692. * HandPart - Ring finger
  156693. */
  156694. RING = "ring",
  156695. /**
  156696. * HandPart - Little finger
  156697. */
  156698. LITTLE = "little"
  156699. }
  156700. /**
  156701. * Representing a single hand (with its corresponding native XRHand object)
  156702. */
  156703. export class WebXRHand implements IDisposable {
  156704. /** the controller to which the hand correlates */
  156705. readonly xrController: WebXRInputSource;
  156706. /** the meshes to be used to track the hand joints */
  156707. readonly trackedMeshes: AbstractMesh[];
  156708. /**
  156709. * Hand-parts definition (key is HandPart)
  156710. */
  156711. handPartsDefinition: {
  156712. [key: string]: number[];
  156713. };
  156714. /**
  156715. * Populate the HandPartsDefinition object.
  156716. * This is called as a side effect since certain browsers don't have XRHand defined.
  156717. */
  156718. private generateHandPartsDefinition;
  156719. /**
  156720. * Construct a new hand object
  156721. * @param xrController the controller to which the hand correlates
  156722. * @param trackedMeshes the meshes to be used to track the hand joints
  156723. */
  156724. constructor(
  156725. /** the controller to which the hand correlates */
  156726. xrController: WebXRInputSource,
  156727. /** the meshes to be used to track the hand joints */
  156728. trackedMeshes: AbstractMesh[]);
  156729. /**
  156730. * Update this hand from the latest xr frame
  156731. * @param xrFrame xrFrame to update from
  156732. * @param referenceSpace The current viewer reference space
  156733. * @param scaleFactor optional scale factor for the meshes
  156734. */
  156735. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156736. /**
  156737. * Get meshes of part of the hand
  156738. * @param part the part of hand to get
  156739. * @returns An array of meshes that correlate to the hand part requested
  156740. */
  156741. getHandPartMeshes(part: HandPart): AbstractMesh[];
  156742. /**
  156743. * Dispose this Hand object
  156744. */
  156745. dispose(): void;
  156746. }
  156747. /**
  156748. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  156749. */
  156750. export class WebXRHandTracking extends WebXRAbstractFeature {
  156751. /**
  156752. * options to use when constructing this feature
  156753. */
  156754. readonly options: IWebXRHandTrackingOptions;
  156755. private static _idCounter;
  156756. /**
  156757. * The module's name
  156758. */
  156759. static readonly Name: string;
  156760. /**
  156761. * The (Babylon) version of this module.
  156762. * This is an integer representing the implementation version.
  156763. * This number does not correspond to the WebXR specs version
  156764. */
  156765. static readonly Version: number;
  156766. /**
  156767. * This observable will notify registered observers when a new hand object was added and initialized
  156768. */
  156769. onHandAddedObservable: Observable<WebXRHand>;
  156770. /**
  156771. * This observable will notify its observers right before the hand object is disposed
  156772. */
  156773. onHandRemovedObservable: Observable<WebXRHand>;
  156774. private _hands;
  156775. /**
  156776. * Creates a new instance of the hit test feature
  156777. * @param _xrSessionManager an instance of WebXRSessionManager
  156778. * @param options options to use when constructing this feature
  156779. */
  156780. constructor(_xrSessionManager: WebXRSessionManager,
  156781. /**
  156782. * options to use when constructing this feature
  156783. */
  156784. options: IWebXRHandTrackingOptions);
  156785. /**
  156786. * Check if the needed objects are defined.
  156787. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  156788. */
  156789. isCompatible(): boolean;
  156790. /**
  156791. * attach this feature
  156792. * Will usually be called by the features manager
  156793. *
  156794. * @returns true if successful.
  156795. */
  156796. attach(): boolean;
  156797. /**
  156798. * detach this feature.
  156799. * Will usually be called by the features manager
  156800. *
  156801. * @returns true if successful.
  156802. */
  156803. detach(): boolean;
  156804. /**
  156805. * Dispose this feature and all of the resources attached
  156806. */
  156807. dispose(): void;
  156808. /**
  156809. * Get the hand object according to the controller id
  156810. * @param controllerId the controller id to which we want to get the hand
  156811. * @returns null if not found or the WebXRHand object if found
  156812. */
  156813. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  156814. /**
  156815. * Get a hand object according to the requested handedness
  156816. * @param handedness the handedness to request
  156817. * @returns null if not found or the WebXRHand object if found
  156818. */
  156819. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156820. protected _onXRFrame(_xrFrame: XRFrame): void;
  156821. private _attachHand;
  156822. private _detachHand;
  156823. }
  156824. }
  156825. declare module BABYLON {
  156826. /**
  156827. * The motion controller class for all microsoft mixed reality controllers
  156828. */
  156829. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156830. protected readonly _mapping: {
  156831. defaultButton: {
  156832. valueNodeName: string;
  156833. unpressedNodeName: string;
  156834. pressedNodeName: string;
  156835. };
  156836. defaultAxis: {
  156837. valueNodeName: string;
  156838. minNodeName: string;
  156839. maxNodeName: string;
  156840. };
  156841. buttons: {
  156842. "xr-standard-trigger": {
  156843. rootNodeName: string;
  156844. componentProperty: string;
  156845. states: string[];
  156846. };
  156847. "xr-standard-squeeze": {
  156848. rootNodeName: string;
  156849. componentProperty: string;
  156850. states: string[];
  156851. };
  156852. "xr-standard-touchpad": {
  156853. rootNodeName: string;
  156854. labelAnchorNodeName: string;
  156855. touchPointNodeName: string;
  156856. };
  156857. "xr-standard-thumbstick": {
  156858. rootNodeName: string;
  156859. componentProperty: string;
  156860. states: string[];
  156861. };
  156862. };
  156863. axes: {
  156864. "xr-standard-touchpad": {
  156865. "x-axis": {
  156866. rootNodeName: string;
  156867. };
  156868. "y-axis": {
  156869. rootNodeName: string;
  156870. };
  156871. };
  156872. "xr-standard-thumbstick": {
  156873. "x-axis": {
  156874. rootNodeName: string;
  156875. };
  156876. "y-axis": {
  156877. rootNodeName: string;
  156878. };
  156879. };
  156880. };
  156881. };
  156882. /**
  156883. * The base url used to load the left and right controller models
  156884. */
  156885. static MODEL_BASE_URL: string;
  156886. /**
  156887. * The name of the left controller model file
  156888. */
  156889. static MODEL_LEFT_FILENAME: string;
  156890. /**
  156891. * The name of the right controller model file
  156892. */
  156893. static MODEL_RIGHT_FILENAME: string;
  156894. profileId: string;
  156895. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156896. protected _getFilenameAndPath(): {
  156897. filename: string;
  156898. path: string;
  156899. };
  156900. protected _getModelLoadingConstraints(): boolean;
  156901. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156902. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156903. protected _updateModel(): void;
  156904. }
  156905. }
  156906. declare module BABYLON {
  156907. /**
  156908. * The motion controller class for oculus touch (quest, rift).
  156909. * This class supports legacy mapping as well the standard xr mapping
  156910. */
  156911. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156912. private _forceLegacyControllers;
  156913. private _modelRootNode;
  156914. /**
  156915. * The base url used to load the left and right controller models
  156916. */
  156917. static MODEL_BASE_URL: string;
  156918. /**
  156919. * The name of the left controller model file
  156920. */
  156921. static MODEL_LEFT_FILENAME: string;
  156922. /**
  156923. * The name of the right controller model file
  156924. */
  156925. static MODEL_RIGHT_FILENAME: string;
  156926. /**
  156927. * Base Url for the Quest controller model.
  156928. */
  156929. static QUEST_MODEL_BASE_URL: string;
  156930. profileId: string;
  156931. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156932. protected _getFilenameAndPath(): {
  156933. filename: string;
  156934. path: string;
  156935. };
  156936. protected _getModelLoadingConstraints(): boolean;
  156937. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156938. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156939. protected _updateModel(): void;
  156940. /**
  156941. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156942. * between the touch and touch 2.
  156943. */
  156944. private _isQuest;
  156945. }
  156946. }
  156947. declare module BABYLON {
  156948. /**
  156949. * The motion controller class for the standard HTC-Vive controllers
  156950. */
  156951. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156952. private _modelRootNode;
  156953. /**
  156954. * The base url used to load the left and right controller models
  156955. */
  156956. static MODEL_BASE_URL: string;
  156957. /**
  156958. * File name for the controller model.
  156959. */
  156960. static MODEL_FILENAME: string;
  156961. profileId: string;
  156962. /**
  156963. * Create a new Vive motion controller object
  156964. * @param scene the scene to use to create this controller
  156965. * @param gamepadObject the corresponding gamepad object
  156966. * @param handedness the handedness of the controller
  156967. */
  156968. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156969. protected _getFilenameAndPath(): {
  156970. filename: string;
  156971. path: string;
  156972. };
  156973. protected _getModelLoadingConstraints(): boolean;
  156974. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156975. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156976. protected _updateModel(): void;
  156977. }
  156978. }
  156979. declare module BABYLON {
  156980. /**
  156981. * A cursor which tracks a point on a path
  156982. */
  156983. export class PathCursor {
  156984. private path;
  156985. /**
  156986. * Stores path cursor callbacks for when an onchange event is triggered
  156987. */
  156988. private _onchange;
  156989. /**
  156990. * The value of the path cursor
  156991. */
  156992. value: number;
  156993. /**
  156994. * The animation array of the path cursor
  156995. */
  156996. animations: Animation[];
  156997. /**
  156998. * Initializes the path cursor
  156999. * @param path The path to track
  157000. */
  157001. constructor(path: Path2);
  157002. /**
  157003. * Gets the cursor point on the path
  157004. * @returns A point on the path cursor at the cursor location
  157005. */
  157006. getPoint(): Vector3;
  157007. /**
  157008. * Moves the cursor ahead by the step amount
  157009. * @param step The amount to move the cursor forward
  157010. * @returns This path cursor
  157011. */
  157012. moveAhead(step?: number): PathCursor;
  157013. /**
  157014. * Moves the cursor behind by the step amount
  157015. * @param step The amount to move the cursor back
  157016. * @returns This path cursor
  157017. */
  157018. moveBack(step?: number): PathCursor;
  157019. /**
  157020. * Moves the cursor by the step amount
  157021. * If the step amount is greater than one, an exception is thrown
  157022. * @param step The amount to move the cursor
  157023. * @returns This path cursor
  157024. */
  157025. move(step: number): PathCursor;
  157026. /**
  157027. * Ensures that the value is limited between zero and one
  157028. * @returns This path cursor
  157029. */
  157030. private ensureLimits;
  157031. /**
  157032. * Runs onchange callbacks on change (used by the animation engine)
  157033. * @returns This path cursor
  157034. */
  157035. private raiseOnChange;
  157036. /**
  157037. * Executes a function on change
  157038. * @param f A path cursor onchange callback
  157039. * @returns This path cursor
  157040. */
  157041. onchange(f: (cursor: PathCursor) => void): PathCursor;
  157042. }
  157043. }
  157044. declare module BABYLON {
  157045. /** @hidden */
  157046. export var blurPixelShader: {
  157047. name: string;
  157048. shader: string;
  157049. };
  157050. }
  157051. declare module BABYLON {
  157052. /** @hidden */
  157053. export var pointCloudVertexDeclaration: {
  157054. name: string;
  157055. shader: string;
  157056. };
  157057. }
  157058. // Mixins
  157059. interface Window {
  157060. mozIndexedDB: IDBFactory;
  157061. webkitIndexedDB: IDBFactory;
  157062. msIndexedDB: IDBFactory;
  157063. webkitURL: typeof URL;
  157064. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  157065. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  157066. WebGLRenderingContext: WebGLRenderingContext;
  157067. MSGesture: MSGesture;
  157068. CANNON: any;
  157069. AudioContext: AudioContext;
  157070. webkitAudioContext: AudioContext;
  157071. PointerEvent: any;
  157072. Math: Math;
  157073. Uint8Array: Uint8ArrayConstructor;
  157074. Float32Array: Float32ArrayConstructor;
  157075. mozURL: typeof URL;
  157076. msURL: typeof URL;
  157077. VRFrameData: any; // WebVR, from specs 1.1
  157078. DracoDecoderModule: any;
  157079. setImmediate(handler: (...args: any[]) => void): number;
  157080. }
  157081. interface HTMLCanvasElement {
  157082. requestPointerLock(): void;
  157083. msRequestPointerLock?(): void;
  157084. mozRequestPointerLock?(): void;
  157085. webkitRequestPointerLock?(): void;
  157086. /** Track wether a record is in progress */
  157087. isRecording: boolean;
  157088. /** Capture Stream method defined by some browsers */
  157089. captureStream(fps?: number): MediaStream;
  157090. }
  157091. interface CanvasRenderingContext2D {
  157092. msImageSmoothingEnabled: boolean;
  157093. }
  157094. interface MouseEvent {
  157095. mozMovementX: number;
  157096. mozMovementY: number;
  157097. webkitMovementX: number;
  157098. webkitMovementY: number;
  157099. msMovementX: number;
  157100. msMovementY: number;
  157101. }
  157102. interface Navigator {
  157103. mozGetVRDevices: (any: any) => any;
  157104. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157105. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157106. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157107. webkitGetGamepads(): Gamepad[];
  157108. msGetGamepads(): Gamepad[];
  157109. webkitGamepads(): Gamepad[];
  157110. }
  157111. interface HTMLVideoElement {
  157112. mozSrcObject: any;
  157113. }
  157114. interface Math {
  157115. fround(x: number): number;
  157116. imul(a: number, b: number): number;
  157117. }
  157118. interface WebGLRenderingContext {
  157119. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  157120. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  157121. vertexAttribDivisor(index: number, divisor: number): void;
  157122. createVertexArray(): any;
  157123. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  157124. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  157125. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  157126. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  157127. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  157128. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  157129. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  157130. // Queries
  157131. createQuery(): WebGLQuery;
  157132. deleteQuery(query: WebGLQuery): void;
  157133. beginQuery(target: number, query: WebGLQuery): void;
  157134. endQuery(target: number): void;
  157135. getQueryParameter(query: WebGLQuery, pname: number): any;
  157136. getQuery(target: number, pname: number): any;
  157137. MAX_SAMPLES: number;
  157138. RGBA8: number;
  157139. READ_FRAMEBUFFER: number;
  157140. DRAW_FRAMEBUFFER: number;
  157141. UNIFORM_BUFFER: number;
  157142. HALF_FLOAT_OES: number;
  157143. RGBA16F: number;
  157144. RGBA32F: number;
  157145. R32F: number;
  157146. RG32F: number;
  157147. RGB32F: number;
  157148. R16F: number;
  157149. RG16F: number;
  157150. RGB16F: number;
  157151. RED: number;
  157152. RG: number;
  157153. R8: number;
  157154. RG8: number;
  157155. UNSIGNED_INT_24_8: number;
  157156. DEPTH24_STENCIL8: number;
  157157. MIN: number;
  157158. MAX: number;
  157159. /* Multiple Render Targets */
  157160. drawBuffers(buffers: number[]): void;
  157161. readBuffer(src: number): void;
  157162. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  157163. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  157164. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  157165. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  157166. // Occlusion Query
  157167. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  157168. ANY_SAMPLES_PASSED: number;
  157169. QUERY_RESULT_AVAILABLE: number;
  157170. QUERY_RESULT: number;
  157171. }
  157172. interface WebGLProgram {
  157173. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  157174. }
  157175. interface EXT_disjoint_timer_query {
  157176. QUERY_COUNTER_BITS_EXT: number;
  157177. TIME_ELAPSED_EXT: number;
  157178. TIMESTAMP_EXT: number;
  157179. GPU_DISJOINT_EXT: number;
  157180. QUERY_RESULT_EXT: number;
  157181. QUERY_RESULT_AVAILABLE_EXT: number;
  157182. queryCounterEXT(query: WebGLQuery, target: number): void;
  157183. createQueryEXT(): WebGLQuery;
  157184. beginQueryEXT(target: number, query: WebGLQuery): void;
  157185. endQueryEXT(target: number): void;
  157186. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  157187. deleteQueryEXT(query: WebGLQuery): void;
  157188. }
  157189. interface WebGLUniformLocation {
  157190. _currentState: any;
  157191. }
  157192. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  157193. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  157194. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  157195. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157196. interface WebGLRenderingContext {
  157197. readonly RASTERIZER_DISCARD: number;
  157198. readonly DEPTH_COMPONENT24: number;
  157199. readonly TEXTURE_3D: number;
  157200. readonly TEXTURE_2D_ARRAY: number;
  157201. readonly TEXTURE_COMPARE_FUNC: number;
  157202. readonly TEXTURE_COMPARE_MODE: number;
  157203. readonly COMPARE_REF_TO_TEXTURE: number;
  157204. readonly TEXTURE_WRAP_R: number;
  157205. readonly HALF_FLOAT: number;
  157206. readonly RGB8: number;
  157207. readonly RED_INTEGER: number;
  157208. readonly RG_INTEGER: number;
  157209. readonly RGB_INTEGER: number;
  157210. readonly RGBA_INTEGER: number;
  157211. readonly R8_SNORM: number;
  157212. readonly RG8_SNORM: number;
  157213. readonly RGB8_SNORM: number;
  157214. readonly RGBA8_SNORM: number;
  157215. readonly R8I: number;
  157216. readonly RG8I: number;
  157217. readonly RGB8I: number;
  157218. readonly RGBA8I: number;
  157219. readonly R8UI: number;
  157220. readonly RG8UI: number;
  157221. readonly RGB8UI: number;
  157222. readonly RGBA8UI: number;
  157223. readonly R16I: number;
  157224. readonly RG16I: number;
  157225. readonly RGB16I: number;
  157226. readonly RGBA16I: number;
  157227. readonly R16UI: number;
  157228. readonly RG16UI: number;
  157229. readonly RGB16UI: number;
  157230. readonly RGBA16UI: number;
  157231. readonly R32I: number;
  157232. readonly RG32I: number;
  157233. readonly RGB32I: number;
  157234. readonly RGBA32I: number;
  157235. readonly R32UI: number;
  157236. readonly RG32UI: number;
  157237. readonly RGB32UI: number;
  157238. readonly RGBA32UI: number;
  157239. readonly RGB10_A2UI: number;
  157240. readonly R11F_G11F_B10F: number;
  157241. readonly RGB9_E5: number;
  157242. readonly RGB10_A2: number;
  157243. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  157244. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  157245. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  157246. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  157247. readonly DEPTH_COMPONENT32F: number;
  157248. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  157249. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  157250. 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;
  157251. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  157252. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  157253. readonly TRANSFORM_FEEDBACK: number;
  157254. readonly INTERLEAVED_ATTRIBS: number;
  157255. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  157256. createTransformFeedback(): WebGLTransformFeedback;
  157257. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  157258. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  157259. beginTransformFeedback(primitiveMode: number): void;
  157260. endTransformFeedback(): void;
  157261. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  157262. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157263. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157264. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157265. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  157266. }
  157267. interface ImageBitmap {
  157268. readonly width: number;
  157269. readonly height: number;
  157270. close(): void;
  157271. }
  157272. interface WebGLQuery extends WebGLObject {
  157273. }
  157274. declare var WebGLQuery: {
  157275. prototype: WebGLQuery;
  157276. new(): WebGLQuery;
  157277. };
  157278. interface WebGLSampler extends WebGLObject {
  157279. }
  157280. declare var WebGLSampler: {
  157281. prototype: WebGLSampler;
  157282. new(): WebGLSampler;
  157283. };
  157284. interface WebGLSync extends WebGLObject {
  157285. }
  157286. declare var WebGLSync: {
  157287. prototype: WebGLSync;
  157288. new(): WebGLSync;
  157289. };
  157290. interface WebGLTransformFeedback extends WebGLObject {
  157291. }
  157292. declare var WebGLTransformFeedback: {
  157293. prototype: WebGLTransformFeedback;
  157294. new(): WebGLTransformFeedback;
  157295. };
  157296. interface WebGLVertexArrayObject extends WebGLObject {
  157297. }
  157298. declare var WebGLVertexArrayObject: {
  157299. prototype: WebGLVertexArrayObject;
  157300. new(): WebGLVertexArrayObject;
  157301. };
  157302. // Type definitions for WebVR API
  157303. // Project: https://w3c.github.io/webvr/
  157304. // Definitions by: six a <https://github.com/lostfictions>
  157305. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157306. interface VRDisplay extends EventTarget {
  157307. /**
  157308. * Dictionary of capabilities describing the VRDisplay.
  157309. */
  157310. readonly capabilities: VRDisplayCapabilities;
  157311. /**
  157312. * z-depth defining the far plane of the eye view frustum
  157313. * enables mapping of values in the render target depth
  157314. * attachment to scene coordinates. Initially set to 10000.0.
  157315. */
  157316. depthFar: number;
  157317. /**
  157318. * z-depth defining the near plane of the eye view frustum
  157319. * enables mapping of values in the render target depth
  157320. * attachment to scene coordinates. Initially set to 0.01.
  157321. */
  157322. depthNear: number;
  157323. /**
  157324. * An identifier for this distinct VRDisplay. Used as an
  157325. * association point in the Gamepad API.
  157326. */
  157327. readonly displayId: number;
  157328. /**
  157329. * A display name, a user-readable name identifying it.
  157330. */
  157331. readonly displayName: string;
  157332. readonly isConnected: boolean;
  157333. readonly isPresenting: boolean;
  157334. /**
  157335. * If this VRDisplay supports room-scale experiences, the optional
  157336. * stage attribute contains details on the room-scale parameters.
  157337. */
  157338. readonly stageParameters: VRStageParameters | null;
  157339. /**
  157340. * Passing the value returned by `requestAnimationFrame` to
  157341. * `cancelAnimationFrame` will unregister the callback.
  157342. * @param handle Define the hanle of the request to cancel
  157343. */
  157344. cancelAnimationFrame(handle: number): void;
  157345. /**
  157346. * Stops presenting to the VRDisplay.
  157347. * @returns a promise to know when it stopped
  157348. */
  157349. exitPresent(): Promise<void>;
  157350. /**
  157351. * Return the current VREyeParameters for the given eye.
  157352. * @param whichEye Define the eye we want the parameter for
  157353. * @returns the eye parameters
  157354. */
  157355. getEyeParameters(whichEye: string): VREyeParameters;
  157356. /**
  157357. * Populates the passed VRFrameData with the information required to render
  157358. * the current frame.
  157359. * @param frameData Define the data structure to populate
  157360. * @returns true if ok otherwise false
  157361. */
  157362. getFrameData(frameData: VRFrameData): boolean;
  157363. /**
  157364. * Get the layers currently being presented.
  157365. * @returns the list of VR layers
  157366. */
  157367. getLayers(): VRLayer[];
  157368. /**
  157369. * Return a VRPose containing the future predicted pose of the VRDisplay
  157370. * when the current frame will be presented. The value returned will not
  157371. * change until JavaScript has returned control to the browser.
  157372. *
  157373. * The VRPose will contain the position, orientation, velocity,
  157374. * and acceleration of each of these properties.
  157375. * @returns the pose object
  157376. */
  157377. getPose(): VRPose;
  157378. /**
  157379. * Return the current instantaneous pose of the VRDisplay, with no
  157380. * prediction applied.
  157381. * @returns the current instantaneous pose
  157382. */
  157383. getImmediatePose(): VRPose;
  157384. /**
  157385. * The callback passed to `requestAnimationFrame` will be called
  157386. * any time a new frame should be rendered. When the VRDisplay is
  157387. * presenting the callback will be called at the native refresh
  157388. * rate of the HMD. When not presenting this function acts
  157389. * identically to how window.requestAnimationFrame acts. Content should
  157390. * make no assumptions of frame rate or vsync behavior as the HMD runs
  157391. * asynchronously from other displays and at differing refresh rates.
  157392. * @param callback Define the eaction to run next frame
  157393. * @returns the request handle it
  157394. */
  157395. requestAnimationFrame(callback: FrameRequestCallback): number;
  157396. /**
  157397. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  157398. * Repeat calls while already presenting will update the VRLayers being displayed.
  157399. * @param layers Define the list of layer to present
  157400. * @returns a promise to know when the request has been fulfilled
  157401. */
  157402. requestPresent(layers: VRLayer[]): Promise<void>;
  157403. /**
  157404. * Reset the pose for this display, treating its current position and
  157405. * orientation as the "origin/zero" values. VRPose.position,
  157406. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  157407. * updated when calling resetPose(). This should be called in only
  157408. * sitting-space experiences.
  157409. */
  157410. resetPose(): void;
  157411. /**
  157412. * The VRLayer provided to the VRDisplay will be captured and presented
  157413. * in the HMD. Calling this function has the same effect on the source
  157414. * canvas as any other operation that uses its source image, and canvases
  157415. * created without preserveDrawingBuffer set to true will be cleared.
  157416. * @param pose Define the pose to submit
  157417. */
  157418. submitFrame(pose?: VRPose): void;
  157419. }
  157420. declare var VRDisplay: {
  157421. prototype: VRDisplay;
  157422. new(): VRDisplay;
  157423. };
  157424. interface VRLayer {
  157425. leftBounds?: number[] | Float32Array | null;
  157426. rightBounds?: number[] | Float32Array | null;
  157427. source?: HTMLCanvasElement | null;
  157428. }
  157429. interface VRDisplayCapabilities {
  157430. readonly canPresent: boolean;
  157431. readonly hasExternalDisplay: boolean;
  157432. readonly hasOrientation: boolean;
  157433. readonly hasPosition: boolean;
  157434. readonly maxLayers: number;
  157435. }
  157436. interface VREyeParameters {
  157437. /** @deprecated */
  157438. readonly fieldOfView: VRFieldOfView;
  157439. readonly offset: Float32Array;
  157440. readonly renderHeight: number;
  157441. readonly renderWidth: number;
  157442. }
  157443. interface VRFieldOfView {
  157444. readonly downDegrees: number;
  157445. readonly leftDegrees: number;
  157446. readonly rightDegrees: number;
  157447. readonly upDegrees: number;
  157448. }
  157449. interface VRFrameData {
  157450. readonly leftProjectionMatrix: Float32Array;
  157451. readonly leftViewMatrix: Float32Array;
  157452. readonly pose: VRPose;
  157453. readonly rightProjectionMatrix: Float32Array;
  157454. readonly rightViewMatrix: Float32Array;
  157455. readonly timestamp: number;
  157456. }
  157457. interface VRPose {
  157458. readonly angularAcceleration: Float32Array | null;
  157459. readonly angularVelocity: Float32Array | null;
  157460. readonly linearAcceleration: Float32Array | null;
  157461. readonly linearVelocity: Float32Array | null;
  157462. readonly orientation: Float32Array | null;
  157463. readonly position: Float32Array | null;
  157464. readonly timestamp: number;
  157465. }
  157466. interface VRStageParameters {
  157467. sittingToStandingTransform?: Float32Array;
  157468. sizeX?: number;
  157469. sizeY?: number;
  157470. }
  157471. interface Navigator {
  157472. getVRDisplays(): Promise<VRDisplay[]>;
  157473. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  157474. }
  157475. interface Window {
  157476. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  157477. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  157478. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  157479. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157480. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157481. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  157482. }
  157483. interface Gamepad {
  157484. readonly displayId: number;
  157485. }
  157486. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  157487. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  157488. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  157489. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  157490. type XRHandedness = "none" | "left" | "right";
  157491. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  157492. type XREye = "none" | "left" | "right";
  157493. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  157494. interface XRSpace extends EventTarget {}
  157495. interface XRRenderState {
  157496. depthNear?: number;
  157497. depthFar?: number;
  157498. inlineVerticalFieldOfView?: number;
  157499. baseLayer?: XRWebGLLayer;
  157500. }
  157501. interface XRInputSource {
  157502. handedness: XRHandedness;
  157503. targetRayMode: XRTargetRayMode;
  157504. targetRaySpace: XRSpace;
  157505. gripSpace: XRSpace | undefined;
  157506. gamepad: Gamepad | undefined;
  157507. profiles: Array<string>;
  157508. hand: XRHand | undefined;
  157509. }
  157510. interface XRSessionInit {
  157511. optionalFeatures?: string[];
  157512. requiredFeatures?: string[];
  157513. }
  157514. interface XRSession {
  157515. addEventListener: Function;
  157516. removeEventListener: Function;
  157517. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  157518. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  157519. requestAnimationFrame: Function;
  157520. end(): Promise<void>;
  157521. renderState: XRRenderState;
  157522. inputSources: Array<XRInputSource>;
  157523. // hit test
  157524. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  157525. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  157526. // legacy AR hit test
  157527. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157528. // legacy plane detection
  157529. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  157530. }
  157531. interface XRReferenceSpace extends XRSpace {
  157532. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  157533. onreset: any;
  157534. }
  157535. type XRPlaneSet = Set<XRPlane>;
  157536. type XRAnchorSet = Set<XRAnchor>;
  157537. interface XRFrame {
  157538. session: XRSession;
  157539. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  157540. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  157541. // AR
  157542. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  157543. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  157544. // Anchors
  157545. trackedAnchors?: XRAnchorSet;
  157546. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  157547. // Planes
  157548. worldInformation: {
  157549. detectedPlanes?: XRPlaneSet;
  157550. };
  157551. // Hand tracking
  157552. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  157553. }
  157554. interface XRViewerPose extends XRPose {
  157555. views: Array<XRView>;
  157556. }
  157557. interface XRPose {
  157558. transform: XRRigidTransform;
  157559. emulatedPosition: boolean;
  157560. }
  157561. interface XRWebGLLayerOptions {
  157562. antialias?: boolean;
  157563. depth?: boolean;
  157564. stencil?: boolean;
  157565. alpha?: boolean;
  157566. multiview?: boolean;
  157567. framebufferScaleFactor?: number;
  157568. }
  157569. declare var XRWebGLLayer: {
  157570. prototype: XRWebGLLayer;
  157571. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  157572. };
  157573. interface XRWebGLLayer {
  157574. framebuffer: WebGLFramebuffer;
  157575. framebufferWidth: number;
  157576. framebufferHeight: number;
  157577. getViewport: Function;
  157578. }
  157579. declare class XRRigidTransform {
  157580. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  157581. position: DOMPointReadOnly;
  157582. orientation: DOMPointReadOnly;
  157583. matrix: Float32Array;
  157584. inverse: XRRigidTransform;
  157585. }
  157586. interface XRView {
  157587. eye: XREye;
  157588. projectionMatrix: Float32Array;
  157589. transform: XRRigidTransform;
  157590. }
  157591. interface XRInputSourceChangeEvent {
  157592. session: XRSession;
  157593. removed: Array<XRInputSource>;
  157594. added: Array<XRInputSource>;
  157595. }
  157596. interface XRInputSourceEvent extends Event {
  157597. readonly frame: XRFrame;
  157598. readonly inputSource: XRInputSource;
  157599. }
  157600. // Experimental(er) features
  157601. declare class XRRay {
  157602. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  157603. origin: DOMPointReadOnly;
  157604. direction: DOMPointReadOnly;
  157605. matrix: Float32Array;
  157606. }
  157607. declare enum XRHitTestTrackableType {
  157608. "point",
  157609. "plane",
  157610. "mesh",
  157611. }
  157612. interface XRHitResult {
  157613. hitMatrix: Float32Array;
  157614. }
  157615. interface XRTransientInputHitTestResult {
  157616. readonly inputSource: XRInputSource;
  157617. readonly results: Array<XRHitTestResult>;
  157618. }
  157619. interface XRHitTestResult {
  157620. getPose(baseSpace: XRSpace): XRPose | undefined;
  157621. // When anchor system is enabled
  157622. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  157623. }
  157624. interface XRHitTestSource {
  157625. cancel(): void;
  157626. }
  157627. interface XRTransientInputHitTestSource {
  157628. cancel(): void;
  157629. }
  157630. interface XRHitTestOptionsInit {
  157631. space: XRSpace;
  157632. entityTypes?: Array<XRHitTestTrackableType>;
  157633. offsetRay?: XRRay;
  157634. }
  157635. interface XRTransientInputHitTestOptionsInit {
  157636. profile: string;
  157637. entityTypes?: Array<XRHitTestTrackableType>;
  157638. offsetRay?: XRRay;
  157639. }
  157640. interface XRAnchor {
  157641. anchorSpace: XRSpace;
  157642. delete(): void;
  157643. }
  157644. interface XRPlane {
  157645. orientation: "Horizontal" | "Vertical";
  157646. planeSpace: XRSpace;
  157647. polygon: Array<DOMPointReadOnly>;
  157648. lastChangedTime: number;
  157649. }
  157650. interface XRJointSpace extends XRSpace {}
  157651. interface XRJointPose extends XRPose {
  157652. radius: number | undefined;
  157653. }
  157654. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  157655. readonly length: number;
  157656. [index: number]: XRJointSpace;
  157657. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  157658. readonly WRIST: number;
  157659. readonly THUMB_METACARPAL: number;
  157660. readonly THUMB_PHALANX_PROXIMAL: number;
  157661. readonly THUMB_PHALANX_DISTAL: number;
  157662. readonly THUMB_PHALANX_TIP: number;
  157663. readonly INDEX_METACARPAL: number;
  157664. readonly INDEX_PHALANX_PROXIMAL: number;
  157665. readonly INDEX_PHALANX_INTERMEDIATE: number;
  157666. readonly INDEX_PHALANX_DISTAL: number;
  157667. readonly INDEX_PHALANX_TIP: number;
  157668. readonly MIDDLE_METACARPAL: number;
  157669. readonly MIDDLE_PHALANX_PROXIMAL: number;
  157670. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  157671. readonly MIDDLE_PHALANX_DISTAL: number;
  157672. readonly MIDDLE_PHALANX_TIP: number;
  157673. readonly RING_METACARPAL: number;
  157674. readonly RING_PHALANX_PROXIMAL: number;
  157675. readonly RING_PHALANX_INTERMEDIATE: number;
  157676. readonly RING_PHALANX_DISTAL: number;
  157677. readonly RING_PHALANX_TIP: number;
  157678. readonly LITTLE_METACARPAL: number;
  157679. readonly LITTLE_PHALANX_PROXIMAL: number;
  157680. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  157681. readonly LITTLE_PHALANX_DISTAL: number;
  157682. readonly LITTLE_PHALANX_TIP: number;
  157683. }
  157684. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  157685. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  157686. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  157687. interface XRSession {
  157688. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  157689. }
  157690. interface XRFrame {
  157691. featurePointCloud? : Array<number>;
  157692. }